Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#include "mainwindow.hxx"
#include <QApplication>
#include <QSurfaceFormat>
#include <QOpenGLContext>
#include <iostream>
#include <map>
extern Ui::MainWindow mainWindow;
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QSurfaceFormat fmt;
fmt.setMajorVersion(4); fmt.setMinorVersion(5);
fmt.setProfile(QSurfaceFormat::CoreProfile);
fmt.setSamples(4);
fmt.setDepthBufferSize(24);
QSurfaceFormat::setDefaultFormat(fmt);
MainWindow *w = new MainWindow;
QOpenGLContext *m_context = new QOpenGLContext;
m_context->create();
std::map<QSurfaceFormat::OpenGLContextProfile, std::string> profile_str = {
{ QSurfaceFormat::OpenGLContextProfile::NoProfile, "NO Profile"},
{ QSurfaceFormat::OpenGLContextProfile::CoreProfile, "Core Profile"},
{ QSurfaceFormat::OpenGLContextProfile::CompatibilityProfile, "Compatibility Profile"}
};
fmt = m_context->format();
qWarning("OpenGL %d.%d %s", fmt.version().first, fmt.version().second, profile_str[fmt.profile()].c_str());
w->show();
return a.exec();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.