From 38f80b10486bb7f10873d327564bfe075cabe54d Mon Sep 17 00:00:00 2001 From: Adrian Jeakins Date: Wed, 5 Dec 2018 22:27:04 +0000 Subject: Fix device view not showing anything on macOS. * Fix line shader when running under the core profile and make version match those elsewhere. * Make surface format version match the openGL functions we are using. --- gui/application.cc | 4 ++++ gui/lineshader.h | 13 +++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/gui/application.cc b/gui/application.cc index 7751e6f1..3cf8081d 100644 --- a/gui/application.cc +++ b/gui/application.cc @@ -42,6 +42,10 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv) QSurfaceFormat fmt; fmt.setSamples(10); fmt.setProfile(QSurfaceFormat::CoreProfile); + // macOS is very picky about this version matching + // the version of openGL used in ImGuiRenderer + fmt.setMajorVersion(3); + fmt.setMinorVersion(2); QSurfaceFormat::setDefaultFormat(fmt); #ifdef _WIN32 SetConsoleCtrlHandler((PHANDLER_ROUTINE)WinHandler, TRUE); diff --git a/gui/lineshader.h b/gui/lineshader.h index 98042051..74203261 100644 --- a/gui/lineshader.h +++ b/gui/lineshader.h @@ -172,10 +172,10 @@ class LineShader LineShader(QObject *parent) : parent_(parent), program_(nullptr) {} static constexpr const char *vertexShaderSource_ = - "#version 110\n" - "attribute highp vec2 position;\n" - "attribute highp vec2 normal;\n" - "attribute highp float miter;\n" + "#version 330\n" + "in highp vec2 position;\n" + "in highp vec2 normal;\n" + "in highp float miter;\n" "uniform highp float thickness;\n" "uniform highp mat4 projection;\n" "void main() {\n" @@ -183,10 +183,11 @@ class LineShader " gl_Position = projection * vec4(p, 0.0, 1.0);\n" "}\n"; - static constexpr const char *fragmentShaderSource_ = "#version 110\n" + static constexpr const char *fragmentShaderSource_ = "#version 330\n" "uniform lowp vec4 color;\n" + "out vec4 Out_Color;\n" "void main() {\n" - " gl_FragColor = color;\n" + " Out_Color = color;\n" "}\n"; // Must be called on initialization. -- cgit v1.2.3 From 3cdd83a3bed88d869c8aa97f66e4c88d3cfa7aff Mon Sep 17 00:00:00 2001 From: Adrian Jeakins Date: Thu, 20 Dec 2018 22:21:10 +0000 Subject: Remove format versioning now this is set at the top level application. --- gui/fpgaviewwidget.cc | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/gui/fpgaviewwidget.cc b/gui/fpgaviewwidget.cc index 3fba6bff..e0a81486 100644 --- a/gui/fpgaviewwidget.cc +++ b/gui/fpgaviewwidget.cc @@ -59,20 +59,6 @@ FPGAViewWidget::FPGAViewWidget(QWidget *parent) rendererArgs_->gridChanged = false; rendererArgs_->zoomOutbound = true; - auto fmt = format(); - fmt.setMajorVersion(3); - fmt.setMinorVersion(2); - setFormat(fmt); - - fmt = format(); - if (fmt.majorVersion() < 3) { - printf("Could not get OpenGL 3.0 context. Aborting.\n"); - log_abort(); - } - if (fmt.minorVersion() < 2) { - printf("Could not get OpenGL 3.2 context - trying anyway...\n "); - } - connect(&paintTimer_, SIGNAL(timeout()), this, SLOT(update())); paintTimer_.start(1000 / 20); // paint GL 20 times per second -- cgit v1.2.3 From 7f950a18524bf4cc6181c5c6e7210dad859b7983 Mon Sep 17 00:00:00 2001 From: Adrian Jeakins Date: Thu, 20 Dec 2018 22:28:53 +0000 Subject: Reduce GL shader version for wider compatibility. --- gui/lineshader.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gui/lineshader.h b/gui/lineshader.h index 74203261..4c54bf46 100644 --- a/gui/lineshader.h +++ b/gui/lineshader.h @@ -172,7 +172,7 @@ class LineShader LineShader(QObject *parent) : parent_(parent), program_(nullptr) {} static constexpr const char *vertexShaderSource_ = - "#version 330\n" + "#version 150\n" "in highp vec2 position;\n" "in highp vec2 normal;\n" "in highp float miter;\n" @@ -183,7 +183,7 @@ class LineShader " gl_Position = projection * vec4(p, 0.0, 1.0);\n" "}\n"; - static constexpr const char *fragmentShaderSource_ = "#version 330\n" + static constexpr const char *fragmentShaderSource_ = "#version 150\n" "uniform lowp vec4 color;\n" "out vec4 Out_Color;\n" "void main() {\n" -- cgit v1.2.3 From d00288198f14d9179c7983148812f2956299a54e Mon Sep 17 00:00:00 2001 From: Adrian Jeakins Date: Wed, 1 May 2019 21:32:48 +0100 Subject: Bring back check that GL contexts get the format requested. --- gui/application.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gui/application.cc b/gui/application.cc index 3cf8081d..9229f1cd 100644 --- a/gui/application.cc +++ b/gui/application.cc @@ -20,6 +20,8 @@ */ #include "application.h" +#include "log.h" +#include #include #include #include @@ -47,6 +49,17 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv) fmt.setMajorVersion(3); fmt.setMinorVersion(2); QSurfaceFormat::setDefaultFormat(fmt); + + QOpenGLContext glContext; + fmt = glContext.format(); + if (fmt.majorVersion() < 3) { + printf("Could not get OpenGL 3.0 context. Aborting.\n"); + log_abort(); + } + if (fmt.minorVersion() < 2) { + printf("Could not get OpenGL 3.2 context - trying anyway...\n "); + } + #ifdef _WIN32 SetConsoleCtrlHandler((PHANDLER_ROUTINE)WinHandler, TRUE); #endif -- cgit v1.2.3