This commit is contained in:
Maxime Gimeno 2018-07-06 12:25:49 +02:00
parent 4086888964
commit 818e0d1f11
2 changed files with 7 additions and 36 deletions

View File

@ -223,7 +223,9 @@ void CGAL::QGLViewer::initializeGL() {
format.setSamples(0);
format.setOption(QSurfaceFormat::DebugContext);
QSurfaceFormat::setDefaultFormat(format);
needNewContext();
qDebug()<<"GL 4.3 context initialization failed. ";
is_ogl_4_3 = false;
}
else
@ -231,6 +233,11 @@ void CGAL::QGLViewer::initializeGL() {
is_ogl_4_3 = true;
}
QSurfaceFormat cur_f = QOpenGLContext::currentContext()->format();
const char* rt =(cur_f.renderableType() == QSurfaceFormat::OpenGLES) ? "GLES" : "GL";
qDebug()<<"Using context "
<<cur_f.majorVersion()<<"."<<cur_f.minorVersion()
<< rt;
QOpenGLFunctions::initializeOpenGLFunctions();
glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
// Default colors

View File

@ -9,36 +9,6 @@
#include <QSurfaceFormat>
#include <QOpenGLContext>
//taken from the Qt example opengl/computegles31
bool OGLSupports(int major, int minor, bool gles = false, QSurfaceFormat::OpenGLContextProfile profile = QSurfaceFormat::NoProfile)
{
QOpenGLContext ctx;
QSurfaceFormat fmt;
fmt.setVersion(major, minor);
if (gles) {
fmt.setRenderableType(QSurfaceFormat::OpenGLES);
}
else {
fmt.setRenderableType(QSurfaceFormat::OpenGL);
fmt.setProfile(profile);
}
ctx.setFormat(fmt);
ctx.create();
if (!ctx.isValid())
return false;
int ctxMajor = ctx.format().majorVersion();
int ctxMinor = ctx.format().minorVersion();
bool isGles = (ctx.format().renderableType() == QSurfaceFormat::OpenGLES);
if (isGles != gles) return false;
if (ctxMajor < major) return false;
if (ctxMajor == major && ctxMinor < minor)
return false;
if (!gles && ctx.format().profile() != profile)
return false;
return true;
}
struct Polyhedron_demo_impl {
bool catch_exceptions;
@ -101,12 +71,6 @@ Polyhedron_demo::Polyhedron_demo(int& argc, char **argv,
MainWindow& mainWindow = *d_ptr->mainWindow;
mainWindow.setWindowTitle(main_window_title);
//find a suitable context
if (OGLSupports(4, 3, false, QSurfaceFormat::CoreProfile))
{
}
mainWindow.show();
// On Apple, the first time the application is launched, the menus are unclicable, and