Derive from QOpenGLWidget instead of QGLWidget.

Derive from QOpenGLWidget instead of QGLWidget.
More commits to follow.
This commit is contained in:
mfeemster 2015-01-01 07:17:05 -08:00
parent 9502ae57ab
commit 3cf6141e27
14 changed files with 88 additions and 73 deletions

View File

@ -6,7 +6,7 @@ CONFIG -= app_bundle
CONFIG -= qt
VERSION = 0.1.4.7
DESTDIR = ../../../Bin
DESTDIR = $$(HOME)/Dev/fractorium/Bin
LIBS += -L/usr/lib -ltbb
LIBS += -L/usr/lib/x86_64-linux-gnu -lxml2
@ -16,7 +16,6 @@ INCLUDEPATH += /usr/include/tbb
INCLUDEPATH += /usr/include/libxml2
INCLUDEPATH += ../../../Source/Ember
QMAKE_CXXFLAGS_RELEASE += -O2
QMAKE_CXXFLAGS_RELEASE += -DNDEBUG
QMAKE_CXXFLAGS += -march=k8

View File

@ -6,15 +6,15 @@ CONFIG -= app_bundle
CONFIG -= qt
VERSION = 0.1.4.7
DESTDIR = ../../../Bin
DESTDIR = $$(HOME)/Dev/fractorium/Bin
LIBS += -L/usr/lib -lOpenCL
LIBS += -L/usr/lib -lGL
LIBS += -L/usr/lib -ljpeg
LIBS += -L/usr/lib -lpng
LIBS += -L/usr/lib/x86_64-linux-gnu -lxml2
LIBS += -L../../../Bin -lEmber
LIBS += -L../../../Bin -lEmberCL
LIBS += -L$$DESTDIR -lEmber
LIBS += -L$$DESTDIR -lEmberCL
INCLUDEPATH += /usr/include/CL
INCLUDEPATH += /usr/include/GL

View File

@ -6,7 +6,7 @@ CONFIG -= app_bundle
CONFIG -= qt
VERSION = 0.1.4.7
DESTDIR = ../../../Bin
DESTDIR = $$(HOME)/Dev/fractorium/Bin
LIBS += -L/usr/lib -lOpenCL
LIBS += -L/usr/lib -lGL
@ -18,7 +18,6 @@ INCLUDEPATH += /usr/include/tbb
INCLUDEPATH += /usr/include/libxml2
INCLUDEPATH += ../../../Source/Ember
QMAKE_CXXFLAGS_RELEASE += -O2
QMAKE_CXXFLAGS_RELEASE += -DNDEBUG
QMAKE_CXXFLAGS += -march=k8

View File

@ -6,15 +6,15 @@ CONFIG -= app_bundle
CONFIG -= qt
VERSION = 0.1.4.7
DESTDIR = ../../../Bin
DESTDIR = $$(HOME)/Dev/fractorium/Bin
LIBS += -L/usr/lib -lOpenCL
LIBS += -L/usr/lib -lGL
LIBS += -L/usr/lib -ljpeg
LIBS += -L/usr/lib -lpng
LIBS += -L/usr/lib/x86_64-linux-gnu -lxml2
LIBS += -L../../../Bin -lEmber
LIBS += -L../../../Bin -lEmberCL
LIBS += -L$$DESTDIR -lEmber
LIBS += -L$$DESTDIR -lEmberCL
INCLUDEPATH += /usr/include/CL
INCLUDEPATH += /usr/include/GL

View File

@ -6,15 +6,15 @@ CONFIG -= app_bundle
CONFIG -= qt
VERSION = 0.1.4.7
DESTDIR = ../../../Bin
DESTDIR = $$(HOME)/Dev/fractorium/Bin
LIBS += -L/usr/lib -lOpenCL
LIBS += -L/usr/lib -lGL
LIBS += -L/usr/lib -ljpeg
LIBS += -L/usr/lib -lpng
LIBS += -L/usr/lib/x86_64-linux-gnu -lxml2
LIBS += -L../../../Bin -lEmber
LIBS += -L../../../Bin -lEmberCL
LIBS += -L$$DESTDIR -lEmber
LIBS += -L$$DESTDIR -lEmberCL
INCLUDEPATH += /usr/include/CL
INCLUDEPATH += /usr/include/GL

View File

@ -13,7 +13,7 @@ TEMPLATE = app
CONFIG += precompile_header
VERSION = 0.1.4.7
DESTDIR = ../../../Bin
DESTDIR = $$(HOME)/Dev/fractorium/Bin
LIBS += -L/usr/lib -lOpenCL
LIBS += -L/usr/lib -lGL
@ -21,8 +21,8 @@ LIBS += -L/usr/lib -ljpeg
LIBS += -L/usr/lib -lpng
LIBS += -L/usr/lib -ltbb
LIBS += -L/usr/lib/x86_64-linux-gnu -lxml2
LIBS += -L../../../Bin -lEmber
LIBS += -L../../../Bin -lEmberCL
LIBS += -L$$DESTDIR -lEmber
LIBS += -L$$DESTDIR -lEmberCL
INCLUDEPATH += /usr/include/CL
INCLUDEPATH += /usr/include/GL

View File

@ -193,8 +193,8 @@ private:
CriticalSection()
{
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
pthread_mutexattr_init(&attr);
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL);
pthread_mutex_init(&m_CriticalSection, &attr);
pthread_mutexattr_destroy(&attr);

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>488</width>
<height>617</height>
<height>565</height>
</rect>
</property>
<property name="sizePolicy">
@ -19,13 +19,13 @@
<property name="minimumSize">
<size>
<width>488</width>
<height>617</height>
<height>565</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>587</width>
<height>617</height>
<height>565</height>
</size>
</property>
<property name="windowTitle">
@ -77,6 +77,9 @@
<property name="topMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="text">
@ -105,6 +108,9 @@
<property name="topMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
@ -133,6 +139,9 @@
<property name="topMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
@ -154,6 +163,12 @@
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<property name="horizontalSpacing">
<number>6</number>
</property>
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QPushButton" name="okButton">
<property name="minimumSize">

View File

@ -119,6 +119,9 @@ Fractorium::Fractorium(QWidget* p)
m_ProgressBar->setMaximumWidth(progressBarWidth);
ui.statusBar->addPermanentWidget(m_ProgressBar);
//Setup pointer in the GL window to point back to here.
ui.GLDisplay->SetMainWindow(this);
showMaximized();
connect(ui.DockWidget, SIGNAL(dockLocationChanged(Qt::DockWidgetArea)), this, SLOT(dockLocationChanged(Qt::DockWidgetArea)));
@ -146,15 +149,11 @@ Fractorium::Fractorium(QWidget* p)
//setStyleSheet("QGroupBox { border: 2px solid gray; border-radius: 3px; } ");
m_PreviousPaletteRow = -1;//Force click handler the first time through.
//Setup pointer in the GL window to point back to here.
ui.GLDisplay->SetMainWindow(this);
//ui.GLDisplay->setParent(this);
SetCoordinateStatus(0, 0, 0, 0);
SetTabOrders();
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
//which executes whenever the program is idle. Upon starting the timer, the renderer
@ -263,7 +262,7 @@ bool Fractorium::eventFilter(QObject* o, QEvent* e)
{
m_WidthSpin->DoubleClickNonZero(ui.GLParentScrollArea->width());
m_HeightSpin->DoubleClickNonZero(ui.GLParentScrollArea->height());
//qDebug() << "scroll area resized";
//qDebug() << "scroll area resized";
}
return QMainWindow::eventFilter(o, e);

View File

@ -35,7 +35,7 @@
#include <QApplication>
#include <QSettings>
#include <QStandardPaths>
#include <QGLWidget>
#include <QOpenGLWidget>
#include <qopenglfunctions_2_0.h>
#include <QtWidgets/QMainWindow>
#include <QFuture>

View File

@ -434,10 +434,10 @@ bool FractoriumEmberController<T>::Render()
{
if (m_FinalImage.size() == m_Renderer->FinalBufferSize())//Make absolutely sure the correct amount of data is passed.
gl->repaint();
//gl->update();
//gl->update();
//m_Fractorium->update();
//m_Fractorium->ui.GLParentScrollArea->update();
//m_Fractorium->update();
//m_Fractorium->ui.GLParentScrollArea->update();
//Uncomment for debugging kernel build and execution errors.
//m_Fractorium->ui.InfoRenderingTextEdit->setText(QString::fromStdString(m_Fractorium->m_Wrapper.DumpInfo()));
//if (rendererCL)

View File

@ -30,15 +30,15 @@ void Fractorium::InitXformsUI()
connect(ui.XformWeightNameTable, SIGNAL(cellChanged(int, int)), this, SLOT(OnXformNameChanged(int, int)), Qt::QueuedConnection);
ui.CurrentXformCombo->setProperty("soloxform", -1);
#ifndef WIN32
//For some reason linux makes these 24x24, even though the designer explicitly says 16x16.
ui.AddXformButton->setIconSize(QSize(16, 16));
ui.DuplicateXformButton->setIconSize(QSize(16, 16));
ui.ClearXformButton->setIconSize(QSize(16, 16));
ui.DeleteXformButton->setIconSize(QSize(16, 16));
ui.AddFinalXformButton->setIconSize(QSize(16, 16));
ui.CurrentXformCombo->setIconSize(QSize(16, 16));
//For some reason linux makes these 24x24, even though the designer explicitly says 16x16.
ui.AddXformButton->setIconSize(QSize(16, 16));
ui.DuplicateXformButton->setIconSize(QSize(16, 16));
ui.ClearXformButton->setIconSize(QSize(16, 16));
ui.DeleteXformButton->setIconSize(QSize(16, 16));
ui.AddFinalXformButton->setIconSize(QSize(16, 16));
ui.CurrentXformCombo->setIconSize(QSize(16, 16));
#endif
}

View File

@ -10,9 +10,9 @@
/// </summary>
/// <param name="p">The parent widget</param>
GLWidget::GLWidget(QWidget* p)
: QGLWidget(QGLFormat(QGL::SampleBuffers), p)
: QOpenGLWidget(p)
{
QGLFormat qglFormat;
QSurfaceFormat qsf;
m_Init = false;
m_Drawing = false;
@ -20,14 +20,12 @@ GLWidget::GLWidget(QWidget* p)
m_TexHeight = 0;
m_OutputTexID = 0;
m_Fractorium = NULL;
qglFormat.setSwapInterval(1);//Vsync.
qglFormat.setDoubleBuffer(true);
qglFormat.setVersion(2, 0);
//qglFormat.setVersion(3, 2);
qglFormat.setProfile(QGLFormat::CompatibilityProfile);
//qglFormat.setProfile(QGLFormat::CoreProfile);
setFormat(qglFormat);
qsf.setSwapInterval(1);//Vsync.
qsf.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
qsf.setVersion(2, 0);
setFormat(qsf);
}
/// <summary>
@ -120,8 +118,10 @@ void GLEmberController<T>::ClearWindow()
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->swapBuffers();
//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);
@ -144,6 +144,7 @@ void GLEmberController<T>::SetSelectedXform(Xform<T>* xform)
m_SelectedXform = xform;
if (m_GL->m_Init)
//m_GL->update();
m_GL->repaint();//Force immediate redraw with repaint() instead of update().
}
}
@ -176,14 +177,14 @@ 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->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();
//int w = m_Fractorium->ui.GLParentScrollArea->width();
//int h = m_Fractorium->ui.GLParentScrollArea->height();
//show();
//m_Fractorium->ui.GLParentScrollArea->showMaximized();
//show();
//m_Fractorium->ui.GLParentScrollArea->showMaximized();
SetDimensions(w, h);
m_Fractorium->m_WidthSpin->setValue(w);
m_Fractorium->m_HeightSpin->setValue(h);
@ -198,7 +199,7 @@ void GLWidget::initializeGL()
//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->repaint();
m_Fractorium->m_Controller->DelayedStartRenderTimer();
m_Init = true;
}
@ -401,7 +402,7 @@ bool GLEmberControllerBase::KeyPress_(QKeyEvent* e)
void GLWidget::keyPressEvent(QKeyEvent* e)
{
if (!GLController() || !GLController()->KeyPress_(e))
QGLWidget::keyPressEvent(e);
QOpenGLWidget::keyPressEvent(e);
update();
}
@ -441,7 +442,7 @@ bool GLEmberControllerBase::KeyRelease_(QKeyEvent* e)
void GLWidget::keyReleaseEvent(QKeyEvent* e)
{
if (!GLController() || !GLController()->KeyRelease_(e))
QGLWidget::keyReleaseEvent(e);
QOpenGLWidget::keyReleaseEvent(e);
update();
}
@ -545,7 +546,7 @@ void GLWidget::mousePressEvent(QMouseEvent* e)
if (GLEmberControllerBase* controller = GLController())
controller->MousePress(e);
QGLWidget::mousePressEvent(e);
QOpenGLWidget::mousePressEvent(e);
}
/// <summary>
@ -583,7 +584,7 @@ void GLWidget::mouseReleaseEvent(QMouseEvent* e)
if (GLEmberControllerBase* controller = GLController())
controller->MouseRelease(e);
QGLWidget::mouseReleaseEvent(e);
QOpenGLWidget::mouseReleaseEvent(e);
}
/// <summary>
@ -692,7 +693,7 @@ void GLWidget::mouseMoveEvent(QMouseEvent* e)
if (GLEmberControllerBase* controller = GLController())
controller->MouseMove(e);
QGLWidget::mouseMoveEvent(e);
QOpenGLWidget::mouseMoveEvent(e);
}
/// <summary>
@ -720,7 +721,7 @@ void GLWidget::wheelEvent(QWheelEvent* e)
if (GLEmberControllerBase* controller = GLController())
controller->Wheel(e);
//Do not call QGLWidget::wheelEvent(e) because this should only affect the scale and not the position of the scroll bars.
//Do not call QOpenGLWidget::wheelEvent(e) because this should only affect the scale and not the position of the scroll bars.
}
/// <summary>
@ -730,12 +731,14 @@ void GLWidget::wheelEvent(QWheelEvent* e)
/// the OpenGL texture it's being drawn on.
/// </summary>
/// <param name="e">The event</param>
void GLWidget::resizeEvent(QResizeEvent* e)
{
if (m_Fractorium)
{
}
}
//void GLWidget::resizeEvent(QResizeEvent* e)
//{
// if (m_Fractorium)
// {
// }
//
// QOpenGLWidget::resizeEvent(e);
//}
/// <summary>
/// Set the dimensions of the drawing area.
@ -746,7 +749,7 @@ void GLWidget::resizeEvent(QResizeEvent* e)
void GLWidget::SetDimensions(int w, int h)
{
setFixedSize(w, h);
//resize(w, h);
//resize(w, h);
//m_Fractorium->ui.GLParentScrollAreaContents->setFixedSize(w, h);
}
@ -803,7 +806,7 @@ bool GLWidget::Deallocate()
if (m_OutputTexID != 0)
{
glBindTexture(GL_TEXTURE_2D, m_OutputTexID);
glBindTexture(GL_TEXTURE_2D, m_OutputTexID);
glDeleteTextures(1, &m_OutputTexID);
m_OutputTexID = 0;
deleted = true;

View File

@ -28,7 +28,7 @@ static const float GridStep = 1.0f / 8.0f;
/// the main window and several of its members.
/// This class uses a controller-based design similar to the main window.
/// </summary>
class GLWidget : public QGLWidget, protected QOpenGLFunctions_2_0//QOpenGLFunctions_3_2_Compatibility//QOpenGLFunctions_3_2_Core//, protected QOpenGLFunctions
class GLWidget : public QOpenGLWidget, protected QOpenGLFunctions_2_0//QOpenGLFunctions_3_2_Compatibility//QOpenGLFunctions_3_2_Core//, protected QOpenGLFunctions
{
Q_OBJECT
@ -61,7 +61,7 @@ protected:
virtual void mouseReleaseEvent(QMouseEvent* e) override;
virtual void mouseMoveEvent(QMouseEvent* e) override;
virtual void wheelEvent(QWheelEvent* e) override;
virtual void resizeEvent(QResizeEvent* e) override;
//virtual void resizeEvent(QResizeEvent* e) override;
private:
void SetDimensions(int w, int h);