feat: set opengl format
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
#include <QApplication>
|
||||
#include <QPushButton>
|
||||
#include <QSurfaceFormat>
|
||||
|
||||
#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;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#include <QOpenGLWidget>
|
||||
#include <QOpenGLFunctions>
|
||||
#include <iostream>
|
||||
#include <QOpenGLFunctions_3_2_Core>
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user