feat: set opengl format
This commit is contained in:
@@ -31,7 +31,7 @@ qt_add_executable(${AppExec}
|
|||||||
src/gui/network/NodeIconGraphic.cpp
|
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)
|
target_include_directories(${AppExec} PUBLIC src)
|
||||||
|
|
||||||
# tests
|
# tests
|
||||||
|
|||||||
@@ -1,10 +1,17 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
#include <QSurfaceFormat>
|
||||||
|
|
||||||
#include "Interface.h"
|
#include "Interface.h"
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
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);
|
QApplication app (argc, argv);
|
||||||
|
|
||||||
EnzoUI interface;
|
EnzoUI interface;
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
#include <QOpenGLWidget>
|
#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:
|
public:
|
||||||
MyGLWidget(QWidget *parent) : QOpenGLWidget(parent) { }
|
MyGLWidget(QWidget *parent) : QOpenGLWidget(parent) { }
|
||||||
@@ -11,24 +12,28 @@ protected:
|
|||||||
void initializeGL() override
|
void initializeGL() override
|
||||||
{
|
{
|
||||||
// Set up the rendering context, load shaders and other resources, etc.:
|
// Set up the rendering context, load shaders and other resources, etc.:
|
||||||
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
|
initializeOpenGLFunctions();
|
||||||
f->glClearColor(0.16f, 0.16f, 0.16f, 1.0f);
|
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
|
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
|
void paintGL() override
|
||||||
{
|
{
|
||||||
// Draw the scene:
|
initializeOpenGLFunctions();
|
||||||
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
f->glClear(GL_COLOR_BUFFER_BIT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user