diff options
Diffstat (limited to 'gui')
-rw-r--r-- | gui/application.cc | 24 | ||||
-rw-r--r-- | gui/application.h | 2 | ||||
-rw-r--r-- | gui/fpgaviewwidget.cc | 14 | ||||
-rw-r--r-- | gui/generic/mainwindow.cc | 13 | ||||
-rw-r--r-- | gui/lineshader.h | 13 | ||||
-rw-r--r-- | gui/pythontab.cc | 3 |
6 files changed, 36 insertions, 33 deletions
diff --git a/gui/application.cc b/gui/application.cc index 7751e6f1..33a106bc 100644 --- a/gui/application.cc +++ b/gui/application.cc @@ -21,9 +21,11 @@ #include "application.h" #include <QMessageBox> +#include <QOpenGLContext> #include <QSurfaceFormat> #include <QTextStream> #include <exception> +#include "log.h" NEXTPNR_NAMESPACE_BEGIN @@ -37,12 +39,28 @@ BOOL WINAPI WinHandler(DWORD dwCtrlType) } #endif -Application::Application(int &argc, char **argv) : QApplication(argc, argv) +Application::Application(int &argc, char **argv, bool noantialiasing) : QApplication(argc, argv) { QSurfaceFormat fmt; - fmt.setSamples(10); + if (!noantialiasing) + 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 @@ -53,7 +71,7 @@ bool Application::notify(QObject *receiver, QEvent *event) bool retVal = true; try { retVal = QApplication::notify(receiver, event); - } catch (assertion_failure ex) { + } catch (const assertion_failure &ex) { QString msg; QTextStream out(&msg); out << ex.filename.c_str() << " at " << ex.line << "\n"; diff --git a/gui/application.h b/gui/application.h index 321f6b65..ad5de62f 100644 --- a/gui/application.h +++ b/gui/application.h @@ -29,7 +29,7 @@ NEXTPNR_NAMESPACE_BEGIN class Application : public QApplication { public: - Application(int &argc, char **argv); + Application(int &argc, char **argv, bool noantialiasing); bool notify(QObject *receiver, QEvent *event); }; 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/generic/mainwindow.cc b/gui/generic/mainwindow.cc index 12912cc9..54d1f2c8 100644 --- a/gui/generic/mainwindow.cc +++ b/gui/generic/mainwindow.cc @@ -19,6 +19,9 @@ #include "mainwindow.h"
+#include <QMessageBox>
+#include <cstdlib>
+
static void initMainResource() { Q_INIT_RESOURCE(nextpnr); }
NEXTPNR_NAMESPACE_BEGIN
@@ -26,14 +29,8 @@ NEXTPNR_NAMESPACE_BEGIN MainWindow::MainWindow(std::unique_ptr<Context> context, ArchArgs args, QWidget *parent)
: BaseMainWindow(std::move(context), args, parent)
{
- initMainResource();
-
- std::string title = "nextpnr-generic - [EMPTY]";
- setWindowTitle(title.c_str());
-
- connect(this, &BaseMainWindow::contextChanged, this, &MainWindow::newContext);
-
- createMenu();
+ QMessageBox::critical(0, "Error - FIXME", "No GUI support for nextpnr-generic");
+ std::exit(1);
}
MainWindow::~MainWindow() {}
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. diff --git a/gui/pythontab.cc b/gui/pythontab.cc index 827f1907..c83f1ece 100644 --- a/gui/pythontab.cc +++ b/gui/pythontab.cc @@ -96,9 +96,10 @@ void PythonTab::newContext(Context *ctx) console->clear();
pyinterpreter_preinit();
- init_python("nextpnr", !initialized);
+ init_python("nextpnr", true);
pyinterpreter_initialize();
pyinterpreter_aquire();
+ init_python("nextpnr", false);
python_export_global("ctx", ctx);
pyinterpreter_release();
|