diff --git a/CMakeLists.txt b/CMakeLists.txt index be05445..869a931 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,7 @@ qt_add_executable(${AppExec} src/gui/network/NodeIconGraphic.cpp ) -target_link_libraries(${AppExec} PRIVATE Qt6::Core Qt6::Widgets Qt6::SvgWidgets Qt6::OpenGLWidgets) +target_link_libraries(${AppExec} PRIVATE Qt6::Core Qt6::Widgets Qt6::SvgWidgets Qt6::OpenGLWidgets GLU) target_include_directories(${AppExec} PUBLIC src) # tests diff --git a/src/gui/main.cpp b/src/gui/main.cpp index 738ccc6..baf48d7 100644 --- a/src/gui/main.cpp +++ b/src/gui/main.cpp @@ -1,10 +1,17 @@ #include #include +#include #include "Interface.h" int main(int argc, char **argv) { + QSurfaceFormat format; + format.setRenderableType(QSurfaceFormat::OpenGL); + format.setVersion(3, 2); + format.setProfile(QSurfaceFormat::CoreProfile); + QSurfaceFormat::setDefaultFormat(format); + QApplication app (argc, argv); EnzoUI interface; diff --git a/src/gui/viewport/OpenGLWidget.h b/src/gui/viewport/OpenGLWidget.h index 71b3e2a..b224605 100644 --- a/src/gui/viewport/OpenGLWidget.h +++ b/src/gui/viewport/OpenGLWidget.h @@ -1,7 +1,8 @@ #include -#include +#include +#include -class MyGLWidget : public QOpenGLWidget +class MyGLWidget : public QOpenGLWidget, protected QOpenGLFunctions_3_2_Core { public: MyGLWidget(QWidget *parent) : QOpenGLWidget(parent) { } @@ -11,24 +12,28 @@ protected: void initializeGL() override { // Set up the rendering context, load shaders and other resources, etc.: - QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions(); - f->glClearColor(0.16f, 0.16f, 0.16f, 1.0f); + initializeOpenGLFunctions(); + GLuint vao; + glGenVertexArrays(1,&vao); + glBindVertexArray(vao); + + QSurfaceFormat fmt = context()->format(); + std::cout << "format: " << (fmt.renderableType() == QSurfaceFormat::OpenGLES ? "GLES" : "Desktop") << "\n"; + std::cout << "format: " << (fmt.renderableType() == QSurfaceFormat::OpenGL ? "true" : "false") << "\n"; + + glClearColor(0.16f, 0.16f, 0.16f, 1.0f); } void resizeGL(int w, int h) override { - // // Update projection matrix and other size related settings: - // m_projection.setToIdentity(); - // m_projection.perspective(45.0f, w / float(h), 0.01f, 100.0f); } void paintGL() override { - // Draw the scene: - QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions(); - f->glClear(GL_COLOR_BUFFER_BIT); + initializeOpenGLFunctions(); + glClear(GL_COLOR_BUFFER_BIT); } };