aboutsummaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
authorMiodrag Milanović <mmicko@gmail.com>2019-05-23 23:53:52 -0700
committerGitHub <noreply@github.com>2019-05-23 23:53:52 -0700
commit0d1c7118e3f35ed90744ee5319e32b8ef720d1a5 (patch)
treefbcef378b8269f21c64d53fa359478b8c1921594 /gui
parent95f3d4cc6ed3a4516893f1b0756a2104be5e995b (diff)
parentd00288198f14d9179c7983148812f2956299a54e (diff)
downloadnextpnr-0d1c7118e3f35ed90744ee5319e32b8ef720d1a5.tar.gz
nextpnr-0d1c7118e3f35ed90744ee5319e32b8ef720d1a5.tar.bz2
nextpnr-0d1c7118e3f35ed90744ee5319e32b8ef720d1a5.zip
Merge pull request #169 from ajeakins/master
Fix device view not showing anything on macOS.
Diffstat (limited to 'gui')
-rw-r--r--gui/application.cc17
-rw-r--r--gui/fpgaviewwidget.cc14
-rw-r--r--gui/lineshader.h13
3 files changed, 24 insertions, 20 deletions
diff --git a/gui/application.cc b/gui/application.cc
index 8c3db77b..0a82e40b 100644
--- a/gui/application.cc
+++ b/gui/application.cc
@@ -20,6 +20,8 @@
*/
#include "application.h"
+#include "log.h"
+#include <QOpenGLContext>
#include <QMessageBox>
#include <QSurfaceFormat>
#include <QTextStream>
@@ -42,7 +44,22 @@ 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);
+
+ 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
diff --git a/gui/fpgaviewwidget.cc b/gui/fpgaviewwidget.cc
index 5eab20ed..f2929d6e 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
diff --git a/gui/lineshader.h b/gui/lineshader.h
index 98042051..4c54bf46 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 150\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 150\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.