diff --git a/Builds/MSVC/VS2013/Fractorium.sln b/Builds/MSVC/VS2013/Fractorium.sln index c4666f2..8daf31f 100644 --- a/Builds/MSVC/VS2013/Fractorium.sln +++ b/Builds/MSVC/VS2013/Fractorium.sln @@ -80,6 +80,11 @@ Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "FractoriumInstaller", "..\I {6547D5FA-64CE-44BA-9D3C-B6E217456445} = {6547D5FA-64CE-44BA-9D3C-B6E217456445} EndProjectSection EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5CD06D80-903E-45D6-90F3-3C3EB4FFE46F}" + ProjectSection(SolutionItems) = preProject + ..\..\..\Data\Version History.txt = ..\..\..\Data\Version History.txt + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug Library|Mixed Platforms = Debug Library|Mixed Platforms diff --git a/Data/Version History.txt b/Data/Version History.txt index e029d4e..e94ec47 100644 --- a/Data/Version History.txt +++ b/Data/Version History.txt @@ -1,16 +1,25 @@ +0.4.1.7 Beta 01/02/2015 --User changes Use actual strips count when computing memory requirements in the final render dialog. Output CL_DEVICE_ADDRESS_BITS when passing --openclinfo to command line programs. Warn if single/total allocations are greater than the max allowed for OpenCL in the final render dialog. - + Make about box properly sized for different fonts. + Dock widget is slightly resizable now. + Center scroll area when loading a new ember. + --Bug Fixes Fix bad values left in an ember when a render with strips > 1 fails in the final render dialog. Fix incorrect calculation in dc_cube variation when using OpenCL. --Code Changes + Major work to get it running on Linux. + Migrate from QGLWidget to QOpenGLWidget. + Delayed init due to QOpenGLWidget. Break RendererBase::MemoryRequired() into two functions, it and HistMemRequired() and return a tuple. Add GlobalMemSize() and MaxAllocSize() functions in OpenCLWrapper. Change CHOOSE_XFORM_GRAIN to be 16384, so we can & with 16383 instead of using modulo when selecting an xform. This results in a 9% speed increase on the CPU. + Save each newly loaded ember in a file called "last.flame" in the executable folder. This will help diagnose crashes that occur when switching embers. + Use nullptr instead of NULL in the Fractorium project. It had previously been done in all other places. 0.4.1.6 Beta 11/29/2014 --User Changes diff --git a/Source/Fractorium/AboutDialog.cpp b/Source/Fractorium/AboutDialog.cpp index b07dc88..1fdeeda 100644 --- a/Source/Fractorium/AboutDialog.cpp +++ b/Source/Fractorium/AboutDialog.cpp @@ -5,10 +5,15 @@ /// Constructor that takes a parent widget and passes it to the base, then /// sets up the GUI. /// -/// The parent widget. Default: NULL. +/// The parent widget. Default: nullptr. /// The window flags. Default: 0. FractoriumAboutDialog::FractoriumAboutDialog(QWidget* p, Qt::WindowFlags f) : QDialog(p, f) { ui.setupUi(this); + adjustSize();//Must do this to ensure all text is displayed when using different fonts. + setMinimumHeight(height());//Once properly sized, disallow resizing. + setMaximumHeight(height()); + setMinimumWidth(width()); + setMaximumWidth(width()); } diff --git a/Source/Fractorium/AboutDialog.ui b/Source/Fractorium/AboutDialog.ui index acf1074..4b10e3e 100644 --- a/Source/Fractorium/AboutDialog.ui +++ b/Source/Fractorium/AboutDialog.ui @@ -7,11 +7,11 @@ 0 0 488 - 565 + 567 - + 0 0 @@ -19,19 +19,19 @@ 488 - 565 + 546 - 587 - 565 + 16777215 + 16777215 About - + 6 @@ -45,7 +45,13 @@ 6 - + + + + 0 + 0 + + 12 @@ -70,10 +76,22 @@ + + + 0 + 0 + + + + + 0 + 0 + + Code Copied - + 4 @@ -81,7 +99,19 @@ 6 - + + + + 0 + 0 + + + + + 0 + 0 + + <html><head/><body><p><a href="http://code.google.com/p/flam3"><span style=" text-decoration: underline; color:#0000ff;">flam3</span></a>: Scott Draves, Erik Reckase (GPL v2)<br/><a href="http://github.com/stevenrobertson/cuburn"><span style=" text-decoration: underline; color:#0000ff;">cuburn</span></a>: Steven Robertson, Michael Semeniuk, Matthew Znoj, Nicolas Mejia (GPL v3)<br/><a href="http://fractron9000.sourceforge.net"><span style=" text-decoration: underline; color:#0000ff;">Fractron 9000</span></a>: Mike Thiesen (GPL)<br/><a href="http://sourceforge.net/projects/apophysis7x"><span style=" text-decoration: underline; color:#0000ff;">Apophysis</span></a>: Mark Townsend, Ronald Hordijk, Peter Sdobnov, Piotr Borys, Georg Kiehne (GPL)<br/><a href="http://jwildfire.org/"><span style=" text-decoration: underline; color:#0000ff;">JWildfire</span></a>: Andreas Maschke (LGPL)<br/>Numerous Apophysis plugin developers (GPL)</p></body></html> @@ -101,10 +131,22 @@ + + + 0 + 0 + + + + + 0 + 0 + + Libraries Linked - + 4 @@ -112,7 +154,13 @@ 6 - + + + + 0 + 0 + + <html><head/><body><p><a href="http://qt-project.org"><span style=" text-decoration: underline; color:#0000ff;">Qt</span></a>: Digia Plc (GPL v3, LGPL v2)<br/><a href="http://g-truc.net"><span style=" text-decoration: underline; color:#0000ff;">glm</span></a>: Christophe Riccio (MIT License)<br/><a href="http://threadingbuildingblocks.org"><span style=" text-decoration: underline; color:#0000ff;">Threading Building Blocks</span></a>: Intel Corporation (GPLv2)<br/><a href="http://libjpeg.sourceforge.net"><span style=" text-decoration: underline; color:#0000ff;">libjpeg</span></a>: Independent JPEG Group (Free Software License)<br/><a href="http://libpng.org"><span style=" text-decoration: underline; color:#0000ff;">libpng</span></a>: Glenn Randers-Pehrson et al (Libpng License)<br/><a href="http://xmlsoft.org"><span style=" text-decoration: underline; color:#0000ff;">libxml2</span></a>: Daniel Veillard (MIT License)<br/><a href="http://zlib.net"><span style=" text-decoration: underline; color:#0000ff;">zlib</span></a>: Jean-loup Gailly, Mark Adler (Zlib License)<br/><a href="http://burtleburtle.net/bob/rand/isaac.html"><span style=" text-decoration: underline; color:#0000ff;">QTIsaac</span></a>: Robert J. Jenkins, Quinn Tyler Jackson (Public Domain)<br/><a href="http://cas.ee.ic.ac.uk/people/dt10/index.html"><span style=" text-decoration: underline; color:#0000ff;">MWC64X Random Number Generator</span></a>: David Thomas (Public Domain)<br/><a href="http://code.jellycan.com/simpleopt/"><span style=" text-decoration: underline; color:#0000ff;">SimpleOpt</span></a>: Brodie Thiesfield (MIT License)</p></body></html> @@ -132,10 +180,16 @@ + + + 0 + 0 + + Icons Used - + 4 @@ -143,7 +197,13 @@ 6 - + + + + 0 + 0 + + <html><head/><body><p><a href="http://famfamfam.com"><span style=" text-decoration: underline; color:#0000ff;">Silk</span></a>: Mark James (Creative Commons Attribution 2.5 License)<br/><a href="http://momentumdesignlab.com"><span style=" text-decoration: underline; color:#0000ff;">Momentum</span></a>: Momentum Design Lab (Creative Commons Attribution-ShareAlike 3.5 License)<br/><a href="http://everaldo.com"><span style=" text-decoration: underline; color:#0000ff;">Crystal Clear</span></a>: Everaldo Coelho (LGPL)<br/><a href="http://openiconlibrary.sourceforge.net"><span style=" text-decoration: underline; color:#0000ff;">Open Icon Library</span></a>: Jeff Israel (GPL, LGPL, Creative Commons, Public Domain)<br/><a href="http://icons.mysitemyway.com/category/3d-transparent-glass-icons/"><span style=" text-decoration: underline; color:#0000ff;">3D Transparent Glass</span></a>: iconsETC (Public Domain)<br/><a href="http://p.yusukekamiyamane.com"><span style=" text-decoration: underline; color:#0000ff;">Fugue</span></a>: Yusuke Kamiyamane (Creative Commons Attribution 3.0 License)</p></body></html> @@ -162,12 +222,9 @@ - - - 6 - + - 0 + 6 diff --git a/Source/Fractorium/DoubleSpinBox.cpp b/Source/Fractorium/DoubleSpinBox.cpp index d857744..0bc1d20 100644 --- a/Source/Fractorium/DoubleSpinBox.cpp +++ b/Source/Fractorium/DoubleSpinBox.cpp @@ -7,7 +7,7 @@ /// and change its value using the mouse wheel without explicitly having to click /// inside of it. /// -/// The parent widget. Default: NULL. +/// The parent widget. Default: nullptr. /// The height of the spin box. Default: 16. /// The step used to increment/decrement the spin box when using the mouse wheel. Default: 0.05. DoubleSpinBox::DoubleSpinBox(QWidget* p, int h, double step) diff --git a/Source/Fractorium/FinalRenderDialog.cpp b/Source/Fractorium/FinalRenderDialog.cpp index 0758b1c..a08a4c0 100644 --- a/Source/Fractorium/FinalRenderDialog.cpp +++ b/Source/Fractorium/FinalRenderDialog.cpp @@ -19,7 +19,7 @@ FractoriumFinalRenderDialog::FractoriumFinalRenderDialog(FractoriumSettings* set uint i; double dmax = numeric_limits::max(); QTableWidget* table = ui.FinalRenderParamsTable; - QTableWidgetItem* item = NULL; + QTableWidgetItem* item = nullptr; m_Fractorium = dynamic_cast(p); m_Settings = settings; @@ -649,9 +649,9 @@ bool FractoriumFinalRenderDialog::CreateControllerFromGUI(bool createRenderer) #ifdef DO_DOUBLE size_t elementSize = Double() ? sizeof(double) : sizeof(float); #else - size_t elementSize = sizeof(float); + size_t elementSize = sizeof(float); #endif - + if (!m_Controller.get() || (m_Controller->SizeOfT() != elementSize)) { #ifdef DO_DOUBLE diff --git a/Source/Fractorium/FinalRenderDialog.h b/Source/Fractorium/FinalRenderDialog.h index 17e6d76..794d911 100644 --- a/Source/Fractorium/FinalRenderDialog.h +++ b/Source/Fractorium/FinalRenderDialog.h @@ -40,7 +40,7 @@ class FractoriumFinalRenderDialog : public QDialog friend Fractorium; friend FinalRenderEmberControllerBase; friend FinalRenderEmberController; - + #ifdef DO_DOUBLE friend FinalRenderEmberController; #endif diff --git a/Source/Fractorium/FinalRenderEmberController.cpp b/Source/Fractorium/FinalRenderEmberController.cpp index 725321e..85800c8 100644 --- a/Source/Fractorium/FinalRenderEmberController.cpp +++ b/Source/Fractorium/FinalRenderEmberController.cpp @@ -93,7 +93,7 @@ FinalRenderEmberController::FinalRenderEmberController(FractoriumFinalRenderD : FinalRenderEmberControllerBase(finalRender) { m_FinalPreviewRenderer = unique_ptr>(new EmberNs::Renderer()); - m_FinalPreviewRenderer->Callback(NULL); + m_FinalPreviewRenderer->Callback(nullptr); m_FinalPreviewRenderer->NumChannels(4); m_FinalPreviewRenderFunc = [&]() @@ -669,10 +669,10 @@ void FinalRenderEmberController::RenderComplete(Ember& ember) QString newPath = xmlFileInfo.absolutePath() + '/' + xmlFileInfo.completeBaseName() + ".flame"; xmlDocPtr tempEdit = ember.m_Edits; - ember.m_Edits = m_XmlWriter.CreateNewEditdoc(&ember, NULL, "edit", m_Settings->Nick().toStdString(), m_Settings->Url().toStdString(), m_Settings->Id().toStdString(), "", 0, 0); + ember.m_Edits = m_XmlWriter.CreateNewEditdoc(&ember, nullptr, "edit", m_Settings->Nick().toStdString(), m_Settings->Url().toStdString(), m_Settings->Id().toStdString(), "", 0, 0); m_XmlWriter.Save(newPath.toStdString().c_str(), ember, 0, true, false, true);//Note that the ember passed is used, rather than m_Ember because it's what was actually rendered. - if (tempEdit != NULL) + if (tempEdit != nullptr) xmlFreeDoc(tempEdit); } diff --git a/Source/Fractorium/Fractorium.cpp b/Source/Fractorium/Fractorium.cpp index f3df81c..7aacea1 100644 --- a/Source/Fractorium/Fractorium.cpp +++ b/Source/Fractorium/Fractorium.cpp @@ -24,8 +24,8 @@ Fractorium::Fractorium(QWidget* p) m_ColorDialog = new QColorDialog(this); m_Settings = new FractoriumSettings(this); - m_FileDialog = NULL;//Use lazy instantiation upon first use. - m_FolderDialog = NULL; + m_FileDialog = nullptr;//Use lazy instantiation upon first use. + m_FolderDialog = nullptr; m_FinalRenderDialog = new FractoriumFinalRenderDialog(m_Settings, this); m_OptionsDialog = new FractoriumOptionsDialog(m_Settings, this); m_AboutDialog = new FractoriumAboutDialog(this); @@ -122,8 +122,8 @@ Fractorium::Fractorium(QWidget* p) //Setup pointer in the GL window to point back to here. ui.GLDisplay->SetMainWindow(this); - showMaximized(); - + showMaximized();//This won't fully set things up and show them until after this constructor exits. + connect(ui.DockWidget, SIGNAL(dockLocationChanged(Qt::DockWidgetArea)), this, SLOT(dockLocationChanged(Qt::DockWidgetArea))); connect(ui.DockWidget, SIGNAL(topLevelChanged(bool)), this, SLOT(OnDockTopLevelChanged(bool))); @@ -155,9 +155,10 @@ Fractorium::Fractorium(QWidget* p) ui.GLParentScrollArea->installEventFilter(this); //At this point, everything has been setup except the renderer. Shortly after - //this constructor exits, GLWidget::initializeGL() will create the initial flock and start the rendering timer + //this constructor exits, GLWidget::InitGL() will create the initial flock and start the rendering timer //which executes whenever the program is idle. Upon starting the timer, the renderer //will be initialized. + QTimer::singleShot(500, [&]() { ui.GLDisplay->InitGL(); }); } /// @@ -183,6 +184,19 @@ void Fractorium::SetCoordinateStatus(int rasX, int rasY, float worldX, float wor m_CoordinateStatusLabel->setText(QString(m_CoordinateString)); } +/// +/// Center the scroll area. +/// Called in response to a resizing, or setting of new ember. +/// +void Fractorium::CenterScrollbars() +{ + QScrollBar* w = ui.GLParentScrollArea->horizontalScrollBar(); + QScrollBar* h = ui.GLParentScrollArea->verticalScrollBar(); + + w->setValue(w->maximum() / 2); + h->setValue(h->maximum() / 2); +} + /// /// Apply the settings for saving an ember to an Xml file to an ember (presumably about to be saved). /// diff --git a/Source/Fractorium/Fractorium.h b/Source/Fractorium/Fractorium.h index d03a6d6..d0aee0a 100644 --- a/Source/Fractorium/Fractorium.h +++ b/Source/Fractorium/Fractorium.h @@ -87,6 +87,7 @@ public: void SetRotation(double rot, bool stealth); void SetScale(double scale); void SetCoordinateStatus(int rasX, int rasY, float worldX, float worldY); + void CenterScrollbars(); //Xforms. void CurrentXform(uint i); diff --git a/Source/Fractorium/Fractorium.ui b/Source/Fractorium/Fractorium.ui index 9890712..32bf551 100644 --- a/Source/Fractorium/Fractorium.ui +++ b/Source/Fractorium/Fractorium.ui @@ -48,6 +48,9 @@ 0 + + true + true @@ -71,8 +74,8 @@ 0 0 - 926 - 941 + 923 + 942 @@ -87,6 +90,12 @@ 0 + + true + + + Qt::WheelFocus + @@ -95,7 +104,7 @@ 0 0 1214 - 20 + 21 @@ -388,8 +397,8 @@ 0 0 - 261 - 845 + 259 + 852 @@ -495,8 +504,8 @@ 0 0 - 261 - 845 + 259 + 852 @@ -2816,8 +2825,8 @@ SpinBox 0 0 - 141 - 610 + 118 + 597 @@ -5032,8 +5041,8 @@ SpinBox 0 0 - 98 - 470 + 259 + 853 diff --git a/Source/Fractorium/FractoriumEmberController.cpp b/Source/Fractorium/FractoriumEmberController.cpp index 10e79b7..5c01216 100644 --- a/Source/Fractorium/FractoriumEmberController.cpp +++ b/Source/Fractorium/FractoriumEmberController.cpp @@ -3,6 +3,8 @@ #include "Fractorium.h" #include "GLEmberController.h" +#define SAVE_EACH 1 + /// /// Constructor which initializes the non-templated members contained in this class. /// The renderer, other templated members and GUI setup will be done in the templated derived controller class. @@ -22,8 +24,8 @@ FractoriumEmberControllerBase::FractoriumEmberControllerBase(Fractorium* fractor m_OutputTexID = 0; m_SubBatchCount = 1;//Will be ovewritten by the options on first render. m_Fractorium = fractorium; - m_RenderTimer = NULL; - m_RenderRestartTimer = NULL; + m_RenderTimer = nullptr; + m_RenderRestartTimer = nullptr; m_Rand = QTIsaac(ISAAC_INT(t.Tic()), ISAAC_INT(t.Tic() * 2), ISAAC_INT(t.Tic() * 3));//Ensure a different rand seed on each instance. m_RenderTimer = new QTimer(m_Fractorium); @@ -46,14 +48,14 @@ FractoriumEmberControllerBase::~FractoriumEmberControllerBase() { m_RenderTimer->stop(); delete m_RenderTimer; - m_RenderTimer = NULL; + m_RenderTimer = nullptr; } if (m_RenderRestartTimer) { m_RenderRestartTimer->stop(); delete m_RenderRestartTimer; - m_RenderRestartTimer = NULL; + m_RenderRestartTimer = nullptr; } } @@ -77,7 +79,7 @@ FractoriumEmberController::FractoriumEmberController(Fractorium* fractorium) BackgroundChanged(QColor(0, 0, 0));//Default to black. ClearUndo(); - m_PreviewRenderer->Callback(NULL); + m_PreviewRenderer->Callback(nullptr); m_PreviewRenderer->NumChannels(4); m_PreviewRenderer->EarlyClip(m_Fractorium->m_Settings->EarlyClip()); m_PreviewRenderer->YAxisUp(m_Fractorium->m_Settings->YAxisUp()); @@ -248,6 +250,9 @@ void FractoriumEmberController::SetEmberPrivate(const Ember& ember, bool v if (ember.m_Name != m_Ember.m_Name) m_LastSaveCurrent = ""; + size_t w = m_Ember.m_FinalRasW;//Cache values for use below. + size_t h = m_Ember.m_FinalRasH; + m_Ember = ember; if (!verbatim) @@ -258,8 +263,22 @@ void FractoriumEmberController::SetEmberPrivate(const Ember& ember, bool v m_Ember.m_Supersample = m_Fractorium->m_SupersampleSpin->value(); } +#ifdef SAVE_EACH + static EmberToXml writer; + string filename = "last.flame"; + + writer.Save(filename.c_str(), m_Ember, 0, true, false, true); +#endif + + m_GLController->ResetMouseState(); m_Fractorium->FillXforms();//Must do this first because the palette setup in FillParamTablesAndPalette() uses the xforms combo. FillParamTablesAndPalette(); + + //If a resize happened, this won't do anything because the new size is not reflected in the scroll area yet. + //However, it will have been taken care of in SyncSizes() in that case, so it's ok. + //This is for when a new ember with the same size was loaded. If it was larger than the scroll area, and was scrolled, re-center it. + if (m_Ember.m_FinalRasW == w && m_Ember.m_FinalRasH == h) + m_Fractorium->CenterScrollbars(); } template class FractoriumEmberController; diff --git a/Source/Fractorium/FractoriumEmberController.h b/Source/Fractorium/FractoriumEmberController.h index 35f50cf..bcdd22c 100644 --- a/Source/Fractorium/FractoriumEmberController.h +++ b/Source/Fractorium/FractoriumEmberController.h @@ -192,7 +192,7 @@ public: virtual bool CreateRenderer(eRendererType renderType, uint platform, uint device, bool shared = true) { return false; } virtual uint SizeOfT() const { return 0; } virtual void ClearUndo() { } - virtual GLEmberControllerBase* GLController() { return NULL; } + virtual GLEmberControllerBase* GLController() { return nullptr; } bool RenderTimerRunning(); void StartRenderTimer(); void DelayedStartRenderTimer(); diff --git a/Source/Fractorium/FractoriumMenus.cpp b/Source/Fractorium/FractoriumMenus.cpp index 91cda4d..b8dcad4 100644 --- a/Source/Fractorium/FractoriumMenus.cpp +++ b/Source/Fractorium/FractoriumMenus.cpp @@ -273,9 +273,9 @@ void FractoriumEmberController::SaveCurrentAsXml() SaveCurrentToOpenedFile();//Save the current ember back to the opened file before writing to disk. ApplyXmlSavingTemplate(ember); - ember.m_Edits = writer.CreateNewEditdoc(&ember, NULL, "edit", s->Nick().toStdString(), s->Url().toStdString(), s->Id().toStdString(), "", 0, 0); + ember.m_Edits = writer.CreateNewEditdoc(&ember, nullptr, "edit", s->Nick().toStdString(), s->Url().toStdString(), s->Id().toStdString(), "", 0, 0); - if (tempEdit != NULL) + if (tempEdit != nullptr) xmlFreeDoc(tempEdit); if (writer.Save(filename.toStdString().c_str(), ember, 0, true, false, true)) @@ -383,7 +383,7 @@ void Fractorium::OnActionSaveCurrentToOpenedFile(bool checked) { m_Controller->S /// Ignore. void Fractorium::OnActionExit(bool checked) { - closeEvent(NULL); + closeEvent(nullptr); QApplication::exit(); } diff --git a/Source/Fractorium/FractoriumRender.cpp b/Source/Fractorium/FractoriumRender.cpp index 5ed9c6c..5357d70 100644 --- a/Source/Fractorium/FractoriumRender.cpp +++ b/Source/Fractorium/FractoriumRender.cpp @@ -117,7 +117,7 @@ void FractoriumEmberControllerBase::SaveCurrentRender(const QString& filename, b uint i, j; uint width = m_Renderer->FinalRasW(); uint height = m_Renderer->FinalRasH(); - byte* data = NULL; + byte* data = nullptr; vector vecRgb; QFileInfo fileInfo(filename); QString suffix = fileInfo.suffix(); @@ -278,6 +278,7 @@ bool FractoriumEmberController::SyncSizes() if (m_Renderer->RendererType() == OPENCL_RENDERER && (rendererCL = dynamic_cast*>(m_Renderer.get()))) rendererCL->SetOutputTexture(gl->OutputTexID()); + m_Fractorium->CenterScrollbars(); changed = true; } @@ -433,8 +434,8 @@ bool FractoriumEmberController::Render() if (iterBegin || ProcessState() == ACCUM_DONE) { if (m_FinalImage.size() == m_Renderer->FinalBufferSize())//Make absolutely sure the correct amount of data is passed. - gl->repaint(); - //gl->update(); + //gl->repaint(); + gl->update(); //m_Fractorium->update(); //m_Fractorium->ui.GLParentScrollArea->update(); @@ -673,7 +674,7 @@ bool Fractorium::CreateControllerFromOptions() } } - return m_Controller.get() != NULL; + return m_Controller.get() != nullptr; } /// @@ -704,7 +705,7 @@ void Fractorium::IdleTimer() { m_Controller->Render(); } /// /// Thin wrapper to determine if the controllers have been properly initialized. /// -/// True if the ember controller and GL controllers are both not NULL, else false. +/// True if the ember controller and GL controllers are both not nullptr, else false. bool Fractorium::ControllersOk() { return m_Controller.get() && m_Controller->GLController(); } template class FractoriumEmberController; diff --git a/Source/Fractorium/FractoriumXforms.cpp b/Source/Fractorium/FractoriumXforms.cpp index c6c7d5f..aa66dae 100644 --- a/Source/Fractorium/FractoriumXforms.cpp +++ b/Source/Fractorium/FractoriumXforms.cpp @@ -45,7 +45,7 @@ void Fractorium::InitXformsUI() /// /// Get the current xform. /// -/// The current xform as specified by the current xform combo box index. NULL if out of range (should never happen). +/// The current xform as specified by the current xform combo box index. nullptr if out of range (should never happen). template Xform* FractoriumEmberController::CurrentXform() { diff --git a/Source/Fractorium/FractoriumXformsColor.cpp b/Source/Fractorium/FractoriumXformsColor.cpp index fb07581..fad8939 100644 --- a/Source/Fractorium/FractoriumXformsColor.cpp +++ b/Source/Fractorium/FractoriumXformsColor.cpp @@ -141,7 +141,7 @@ void Fractorium::OnSoloXformCheckBoxStateChanged(int state) /// Ignored void Fractorium::OnXformRefPaletteResized(int logicalIndex, int oldSize, int newSize) { - m_Controller->SetPaletteRefTable(NULL); + m_Controller->SetPaletteRefTable(nullptr); } /// diff --git a/Source/Fractorium/FractoriumXformsVariations.cpp b/Source/Fractorium/FractoriumXformsVariations.cpp index 018b928..03f1505 100644 --- a/Source/Fractorium/FractoriumXformsVariations.cpp +++ b/Source/Fractorium/FractoriumXformsVariations.cpp @@ -237,7 +237,7 @@ void FractoriumEmberController::FillVariationTreeWithXform(Xform* xform) for (uint j = 0; j < item->childCount(); j++)//Iterate through all of the children, which will be the params if it was a parametric variation. { - T* param = NULL; + T* param = nullptr; QTreeWidgetItem* childItem = item->child(j);//Get the child. QWidget* childItemWidget = tree->itemWidget(childItem, 1);//Get the widget for the child. diff --git a/Source/Fractorium/GLEmberController.cpp b/Source/Fractorium/GLEmberController.cpp index dda71ca..6b37b4b 100644 --- a/Source/Fractorium/GLEmberController.cpp +++ b/Source/Fractorium/GLEmberController.cpp @@ -38,8 +38,8 @@ GLEmberController::GLEmberController(Fractorium* fractorium, GLWidget* glWidg GridStep = T(1.0 / 8.0); m_FractoriumEmberController = controller; - m_HoverXform = NULL; - m_SelectedXform = NULL; + m_HoverXform = nullptr; + m_SelectedXform = nullptr; m_CenterDownX = 0; m_CenterDownY = 0; } @@ -62,6 +62,17 @@ bool GLEmberController::CheckForSizeMismatch(int w, int h) return (m_FractoriumEmberController->FinalRasW() != w || m_FractoriumEmberController->FinalRasH() != h); } +/// +/// Reset the drag and hover state. Called in response setting a new ember as the current one. +/// +template +void GLEmberController::ResetMouseState() +{ + m_HoverType = HoverNone; + m_HoverXform = nullptr; + m_SelectedXform = nullptr; +} + /// /// Calculate the scale. /// Used when dragging the right mouse button. diff --git a/Source/Fractorium/GLEmberController.h b/Source/Fractorium/GLEmberController.h index 87534f2..b499bbe 100644 --- a/Source/Fractorium/GLEmberController.h +++ b/Source/Fractorium/GLEmberController.h @@ -63,6 +63,7 @@ public: virtual bool SizesMatch() { return false; } virtual bool CheckForSizeMismatch(int w, int h) { return true; } virtual void QueryMatrices(bool print) { } + virtual void ResetMouseState() { } protected: uint m_DragModifier; @@ -96,6 +97,7 @@ public: virtual void QueryMatrices(bool print) override; virtual bool SizesMatch() override; virtual bool CheckForSizeMismatch(int w, int h) override; + virtual void ResetMouseState() override; T CalcScale(); T CalcRotation(); diff --git a/Source/Fractorium/GLWidget.cpp b/Source/Fractorium/GLWidget.cpp index ab053f4..1858ba1 100644 --- a/Source/Fractorium/GLWidget.cpp +++ b/Source/Fractorium/GLWidget.cpp @@ -19,7 +19,7 @@ GLWidget::GLWidget(QWidget* p) m_TexWidth = 0; m_TexHeight = 0; m_OutputTexID = 0; - m_Fractorium = NULL; + m_Fractorium = nullptr; qsf.setSwapInterval(1);//Vsync. qsf.setSwapBehavior(QSurfaceFormat::DoubleBuffer); @@ -35,6 +35,28 @@ GLWidget::~GLWidget() { } +/// +/// A manual initialization that must be called immediately after the main window is shown +/// and the virtual initializeGL() is called. +/// +void GLWidget::InitGL() +{ + if (!m_Init) + { + int w = m_Fractorium->ui.GLParentScrollArea->width(); + int h = m_Fractorium->ui.GLParentScrollArea->height(); + + SetDimensions(w, h); + m_Fractorium->m_WidthSpin->setValue(w); + m_Fractorium->m_HeightSpin->setValue(h); + + //Start with a flock of 10 random embers. Can't do this until now because the window wasn't maximized yet, so the sizes would have been off. + m_Fractorium->OnActionNewFlock(false); + m_Fractorium->m_Controller->DelayedStartRenderTimer(); + m_Init = true; + } +} + /// /// Draw the final rendered image as a texture on a quad that is the same size as the window. /// Different action is taken based on whether a CPU or OpenCL renderer is used. @@ -114,15 +136,8 @@ template void GLEmberController::ClearWindow() { Ember* ember = m_FractoriumEmberController->CurrentEmber(); - - m_GL->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - m_GL->glClearColor(ember->m_Background.r, ember->m_Background.g, ember->m_Background.b, 1.0); - - //m_GL->update(); + m_GL->makeCurrent(); - //m_GL->context()->swapBuffers(; - //m_GL->context()->swapBuffers(m_GL->context()->surface()); - m_GL->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); m_GL->glClearColor(ember->m_Background.r, ember->m_Background.g, ember->m_Background.b, 1.0); } @@ -177,31 +192,12 @@ void GLWidget::initializeGL() { glClearColor(0.0, 0.0, 0.0, 1.0); - int w = m_Fractorium->width() - m_Fractorium->ui.DockWidget->width(); - int h = m_Fractorium->ui.DockWidget->height(); - - //int w = m_Fractorium->ui.GLParentScrollArea->width(); - //int h = m_Fractorium->ui.GLParentScrollArea->height(); - - //show(); - //m_Fractorium->ui.GLParentScrollArea->showMaximized(); - SetDimensions(w, h); - m_Fractorium->m_WidthSpin->setValue(w); - m_Fractorium->m_HeightSpin->setValue(h); - //m_Fractorium->ui.GLParentScrollArea->setViewport(this); - glEnable(GL_TEXTURE_2D); glGetIntegerv(GL_MAX_TEXTURE_SIZE, &m_MaxTexSize); glDisable(GL_TEXTURE_2D); m_Fractorium->m_WidthSpin->setMaximum(m_MaxTexSize); m_Fractorium->m_HeightSpin->setMaximum(m_MaxTexSize); - - //Start with a flock of 10 random embers. Can't do this until now because the window wasn't maximized yet, so the sizes would have been off. - m_Fractorium->OnActionNewFlock(false); - //m_Fractorium->repaint(); - m_Fractorium->m_Controller->DelayedStartRenderTimer(); - m_Init = true; } } @@ -512,7 +508,7 @@ void GLEmberController::MousePress(QMouseEvent* e) } else//Nothing was selected. { - //m_SelectedXform = NULL; + //m_SelectedXform = nullptr; m_DragState = DragNone; } } @@ -783,7 +779,7 @@ bool GLWidget::Allocate(bool force) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_TexWidth, m_TexHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_TexWidth, m_TexHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); alloc = true; } @@ -1089,7 +1085,7 @@ int GLEmberController::UpdateHover(v3T& glCoords) m_HoverType = HoverNone; //If there's a selected/current xform, check it first so it gets precedence over the others. - if (m_SelectedXform != NULL) + if (m_SelectedXform != nullptr) { //These checks prevent highlighting the pre/post selected xform circle, when one is set to show all, and the other //is set to show current, and the user hovers over another xform, but doesn't select it, then moves the mouse @@ -1452,7 +1448,7 @@ GLEmberControllerBase* GLWidget::GLController() if (m_Fractorium && m_Fractorium->ControllersOk()) return m_Fractorium->m_Controller->GLController(); - return NULL; + return nullptr; } template class GLEmberController; diff --git a/Source/Fractorium/GLWidget.h b/Source/Fractorium/GLWidget.h index 7784c9e..a437163 100644 --- a/Source/Fractorium/GLWidget.h +++ b/Source/Fractorium/GLWidget.h @@ -45,6 +45,7 @@ class GLWidget : public QOpenGLWidget, protected QOpenGLFunctions_2_0//QOpenGLFu public: GLWidget(QWidget* p = nullptr); ~GLWidget(); + void InitGL(); void DrawQuad(); void SetMainWindow(Fractorium* f); bool Init(); @@ -62,7 +63,7 @@ protected: virtual void mouseMoveEvent(QMouseEvent* e) override; virtual void wheelEvent(QWheelEvent* e) override; //virtual void resizeEvent(QResizeEvent* e) override; - + private: void SetDimensions(int w, int h); bool Allocate(bool force = false); diff --git a/Source/Fractorium/OptionsDialog.cpp b/Source/Fractorium/OptionsDialog.cpp index d423fe9..76191a6 100644 --- a/Source/Fractorium/OptionsDialog.cpp +++ b/Source/Fractorium/OptionsDialog.cpp @@ -6,7 +6,7 @@ /// Constructor that takes a pointer to the settings object and the parent widget. /// /// A pointer to the settings object to use -/// The parent widget. Default: NULL. +/// The parent widget. Default: nullptr. /// The window flags. Default: 0. FractoriumOptionsDialog::FractoriumOptionsDialog(FractoriumSettings* settings, QWidget* p, Qt::WindowFlags f) : QDialog(p, f) diff --git a/Source/Fractorium/SpinBox.cpp b/Source/Fractorium/SpinBox.cpp index 6e8ca10..1931406 100644 --- a/Source/Fractorium/SpinBox.cpp +++ b/Source/Fractorium/SpinBox.cpp @@ -7,7 +7,7 @@ /// and change its value using the mouse wheel without explicitly having to click /// inside of it. /// -/// The parent widget. Default: NULL. +/// The parent widget. Default: nullptr. /// The height of the spin box. Default: 16. /// The step used to increment/decrement the spin box when using the mouse wheel. Default: 1. SpinBox::SpinBox(QWidget* p, int h, int step)