mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Refactored SnippetRunner to handle utilize cvfqt::OpenGLWidget
This commit is contained in:
@@ -81,12 +81,12 @@ if (CEE_BUILD_TEST_APPS)
|
||||
|
||||
if (CEE_BUILD_GUI_QT)
|
||||
add_subdirectory(TestApps/Qt/QtMinimal)
|
||||
add_subdirectory(TestApps/Qt/QtSnippetRunner)
|
||||
|
||||
if (CEE_USE_QT5)
|
||||
add_subdirectory(TestApps/Qt/QtMinimal_GLWidget)
|
||||
add_subdirectory(TestApps/Qt/QtMinimal_deprecated)
|
||||
add_subdirectory(TestApps/Qt/QtMultiView_deprecated)
|
||||
add_subdirectory(TestApps/Qt/QtSnippetRunner)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
@@ -60,10 +60,9 @@ CVF_GCC_DIAGNOSTIC_IGNORE("-Wmisleading-indentation")
|
||||
#endif
|
||||
|
||||
|
||||
// !!!
|
||||
// Big time hack since C++17 does not allow ‘register’ storage class specifier
|
||||
#if __cplusplus > 199711L
|
||||
#define register
|
||||
#endif
|
||||
|
||||
|
||||
// Doxygen conditional section to hide contents of the cvfu_jpgFreeImage namespace
|
||||
|
||||
@@ -98,6 +98,8 @@ int main(int argc, char *argv[])
|
||||
// Comment in this line to be able to read the glsl directly from file
|
||||
//cvf::ShaderSourceProvider::instance()->setSourceRepository(new cvf::ShaderSourceRepositoryFile("../../../LibRender/glsl/"));
|
||||
|
||||
cvf::LogManager* logManager = cvf::LogManager::instance();
|
||||
logManager->logger("cee.cvf.OpenGL")->setLevel(cvf::Logger::LL_DEBUG);
|
||||
|
||||
QSRMainWindow window;
|
||||
window.resize(1000, 800);;
|
||||
|
||||
@@ -302,8 +302,22 @@ void QSRMainWindow::createDockPanels()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void QSRMainWindow::executeTestSnippetInNewWidget(const cvf::String& snippetId, TestSnippet* snippet)
|
||||
{
|
||||
cvf::Trace::show("Executing snippet: %s", snippetId.toAscii().ptr());
|
||||
|
||||
closeCurrentSnippet();
|
||||
|
||||
QWidget* parentWidget = centralWidget();
|
||||
CVF_ASSERT(m_contextGroup.notNull());
|
||||
|
||||
#ifdef QSR_USE_OPENGLWIDGET
|
||||
|
||||
QSurfaceFormat surfFormat;
|
||||
surfFormat.setSamples(m_formatMultisampleAction->isChecked() ? 8 : 0);
|
||||
m_currentSnippetWidget = new QSRSnippetWidget(snippet, m_contextGroup.p(), parentWidget);
|
||||
m_currentSnippetWidget->setFormat(surfFormat);
|
||||
|
||||
#else
|
||||
|
||||
QGLFormat glFormat;
|
||||
|
||||
glFormat.setDirectRendering(!m_formatSoftwareAction->isChecked());
|
||||
@@ -320,9 +334,11 @@ void QSRMainWindow::executeTestSnippetInNewWidget(const cvf::String& snippetId,
|
||||
// For FSAA, use with glEnable(GL_MULTISAMPLE);
|
||||
//glFormat.setSampleBuffers(true);
|
||||
|
||||
QWidget* parentWidget = centralWidget();
|
||||
CVF_ASSERT(m_contextGroup.notNull());
|
||||
m_currentSnippetWidget = new QSRSnippetWidget(snippet, m_contextGroup.p(), glFormat, parentWidget);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
m_currentSnippetWidget->setFocus();
|
||||
|
||||
if (m_formatMultisampleAction->isChecked())
|
||||
@@ -537,6 +553,9 @@ void QSRMainWindow::slotViewMultipleRedrawMany()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void QSRMainWindow::slotSaveFrameBufferToFile()
|
||||
{
|
||||
#ifdef QSR_USE_OPENGLWIDGET
|
||||
cvf::Trace::show("NOT IMPLEMENTED!!");
|
||||
#else
|
||||
if (!m_currentSnippetWidget)
|
||||
{
|
||||
cvf::Trace::show("No current widget");
|
||||
@@ -556,7 +575,7 @@ void QSRMainWindow::slotSaveFrameBufferToFile()
|
||||
{
|
||||
cvf::Trace::show("FAILED to saved image: %s", (const char*)fileName.toLatin1());
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -740,32 +759,49 @@ void QSRMainWindow::slotShowHelp()
|
||||
}
|
||||
|
||||
// OpenGL info
|
||||
cvf::OpenGLContext* currentOglContext = m_currentSnippetWidget->cvfOpenGLContext();
|
||||
if (currentOglContext)
|
||||
{
|
||||
cvf::OpenGLInfo cvfOglInfo = currentOglContext->group()->info();
|
||||
oglInfo = QString("OpenGL info:");
|
||||
oglInfo += QString("\nversion:\t") + reinterpret_cast<const char*>(glGetString(GL_VERSION));
|
||||
oglInfo += QString("\nrenderer:\t") + reinterpret_cast<const char*>(glGetString(GL_RENDERER));
|
||||
oglInfo += QString("\nvendor:\t") + reinterpret_cast<const char*>(glGetString(GL_VENDOR));
|
||||
oglInfo += QString("\nglsl ver.:\t") + reinterpret_cast<const char*>(glGetString(GL_SHADING_LANGUAGE_VERSION));
|
||||
oglInfo += QString("\nversion: ") + cvfqt::Utils::toQString(cvfOglInfo.version());
|
||||
oglInfo += QString("\nrenderer: ") + cvfqt::Utils::toQString(cvfOglInfo.renderer());
|
||||
oglInfo += QString("\nvendor: ") + cvfqt::Utils::toQString(cvfOglInfo.vendor());
|
||||
}
|
||||
|
||||
#ifdef QSR_USE_OPENGLWIDGET
|
||||
{
|
||||
oglInfo += "\n\nReported by Qt:";
|
||||
|
||||
QGLFormat currrentFormat = m_currentSnippetWidget->format();
|
||||
oglInfo += "\n\nReported by Qt QSurfaceFormat:";
|
||||
|
||||
QSurfaceFormat currrentFormat = m_currentSnippetWidget->format();
|
||||
oglInfo += QString("\nOpenGL version:\t%1.%2").arg(currrentFormat.majorVersion()).arg(currrentFormat.minorVersion());
|
||||
|
||||
switch (currrentFormat.profile())
|
||||
{
|
||||
case QGLFormat::NoProfile: oglInfo += "\nProfile:\t\tNoProfile (GLver < 3.3)"; break;
|
||||
case QGLFormat::CoreProfile: oglInfo += "\nProfile:\t\tCoreProfile"; break;
|
||||
case QGLFormat::CompatibilityProfile: oglInfo += "\nProfile:\t\tCompatibilityProfile"; break;
|
||||
case QSurfaceFormat::NoProfile: oglInfo += "\nProfile:NoProfile (GLver < 3.3)"; break;
|
||||
case QSurfaceFormat::CoreProfile: oglInfo += "\nProfile:CoreProfile"; break;
|
||||
case QSurfaceFormat::CompatibilityProfile: oglInfo += "\nProfile:CompatibilityProfile"; break;
|
||||
}
|
||||
|
||||
oglInfo += QString("\nColor buffer size:\t<%1 %2 %3 %4>").arg(currrentFormat.redBufferSize()).arg(currrentFormat.greenBufferSize()).arg(currrentFormat.blueBufferSize()).arg(currrentFormat.alphaBufferSize());
|
||||
oglInfo += QString("\nDepth buffer size:\t%1").arg(currrentFormat.depthBufferSize());
|
||||
oglInfo += QString("\nColor buffer size:<%1 %2 %3 %4>").arg(currrentFormat.redBufferSize()).arg(currrentFormat.greenBufferSize()).arg(currrentFormat.blueBufferSize()).arg(currrentFormat.alphaBufferSize());
|
||||
oglInfo += QString("\nDepth buffer size:%1").arg(currrentFormat.depthBufferSize());
|
||||
}
|
||||
#else
|
||||
{
|
||||
oglInfo += "\n\nReported by Qt QGLFormat:";
|
||||
|
||||
QGLFormat currrentFormat = m_currentSnippetWidget->format();
|
||||
oglInfo += QString("\nOpenGL version:\t%1.%2").arg(currrentFormat.majorVersion()).arg(currrentFormat.minorVersion());
|
||||
switch (currrentFormat.profile())
|
||||
{
|
||||
case QGLFormat::NoProfile: oglInfo += "\nProfile:NoProfile (GLver < 3.3)"; break;
|
||||
case QGLFormat::CoreProfile: oglInfo += "\nProfile:CoreProfile"; break;
|
||||
case QGLFormat::CompatibilityProfile: oglInfo += "\nProfile:CompatibilityProfile"; break;
|
||||
}
|
||||
|
||||
oglInfo += QString("\nColor buffer size:<%1 %2 %3 %4>").arg(currrentFormat.redBufferSize()).arg(currrentFormat.greenBufferSize()).arg(currrentFormat.blueBufferSize()).arg(currrentFormat.alphaBufferSize());
|
||||
oglInfo += QString("\nDepth buffer size:%1").arg(currrentFormat.depthBufferSize());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
QMessageBox dlg(this);
|
||||
|
||||
@@ -52,8 +52,13 @@ using cvfu::TestSnippet;
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#ifdef QSR_USE_OPENGLWIDGET
|
||||
QSRSnippetWidget::QSRSnippetWidget(TestSnippet* snippet, cvf::OpenGLContextGroup* contextGroup, QWidget* parent)
|
||||
: OglWidgetBaseClass(contextGroup, parent),
|
||||
#else
|
||||
QSRSnippetWidget::QSRSnippetWidget(TestSnippet* snippet, cvf::OpenGLContextGroup* contextGroup, const QGLFormat& format, QWidget* parent)
|
||||
: cvfqt::GLWidget_deprecated(contextGroup, format, parent),
|
||||
: OglWidgetBaseClass(contextGroup, format, parent),
|
||||
#endif
|
||||
m_drawHUD(false),
|
||||
m_lastSetRenderMode(DrawableGeo::VERTEX_ARRAY),
|
||||
m_enableMultisampleWhenDrawing(false)
|
||||
@@ -87,8 +92,6 @@ QSRSnippetWidget::~QSRSnippetWidget()
|
||||
m_snippet->destroySnippet();
|
||||
m_snippet = NULL;
|
||||
}
|
||||
|
||||
cvfShutdownOpenGLContext();
|
||||
}
|
||||
|
||||
|
||||
@@ -525,6 +528,8 @@ void QSRSnippetWidget::showModelStatistics()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void QSRSnippetWidget::initializeGL()
|
||||
{
|
||||
OglWidgetBaseClass::initializeGL();
|
||||
|
||||
CVF_ASSERT(m_snippet.notNull());
|
||||
|
||||
cvf::OpenGLContext* currentOglContext = cvfOpenGLContext();
|
||||
@@ -533,6 +538,7 @@ void QSRSnippetWidget::initializeGL()
|
||||
|
||||
bool bInitOK = m_snippet->initializeSnippet(currentOglContext);
|
||||
CVF_ASSERT(bInitOK);
|
||||
CVF_UNUSED(bInitOK);
|
||||
|
||||
CVF_CHECK_OGL(currentOglContext);
|
||||
|
||||
@@ -594,7 +600,7 @@ void QSRSnippetWidget::paintEvent(QPaintEvent* /*event*/)
|
||||
painter.beginNativePainting();
|
||||
CVF_CHECK_OGL(currentOglContext);
|
||||
|
||||
cvf::OpenGLUtils::pushOpenGLState(currentOglContext);
|
||||
cvf::OpenGLUtils::pushOpenGLState(currentOglContext);
|
||||
CVF_CHECK_OGL(currentOglContext);
|
||||
|
||||
if (m_enableMultisampleWhenDrawing)
|
||||
|
||||
@@ -45,22 +45,36 @@
|
||||
|
||||
#include "cvfuTestSnippet.h"
|
||||
|
||||
#include "cvfqtGLWidget_deprecated.h"
|
||||
#include "cvfqtGLWidget.h"
|
||||
#include "cvfqtOpenGLWidget.h"
|
||||
|
||||
class QTimer;
|
||||
|
||||
|
||||
#define QSR_USE_OPENGLWIDGET
|
||||
|
||||
#ifdef QSR_USE_OPENGLWIDGET
|
||||
typedef cvfqt::OpenGLWidget OglWidgetBaseClass;
|
||||
#else
|
||||
typedef cvfqt::GLWidget OglWidgetBaseClass;
|
||||
#endif
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class QSRSnippetWidget : public cvfqt::GLWidget_deprecated
|
||||
class QSRSnippetWidget : public OglWidgetBaseClass
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
#ifdef QSR_USE_OPENGLWIDGET
|
||||
QSRSnippetWidget(cvfu::TestSnippet* snippet, cvf::OpenGLContextGroup* contextGroup, QWidget* parent);
|
||||
#else
|
||||
QSRSnippetWidget(cvfu::TestSnippet* snippet, cvf::OpenGLContextGroup* contextGroup, const QGLFormat& format, QWidget* parent);
|
||||
#endif
|
||||
~QSRSnippetWidget();
|
||||
|
||||
cvfu::TestSnippet* snippet();
|
||||
|
||||
@@ -461,7 +461,7 @@ void DepthPeelingFront::renderFrontToBackPeeling()
|
||||
// 3. Final Pass
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_openGLContext->defaultFramebufferObject());
|
||||
glDrawBuffer(GL_BACK);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user