summaryrefslogtreecommitdiffstats
path: root/examples/opengl/contextinfo
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@digia.com>2014-03-03 14:47:27 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-04 15:59:05 +0100
commit1e18df9c73e5431083ac2983c8899823d5ce259d (patch)
tree06a5014d1d87b04b7611cf496fd9e082a9e7ed98 /examples/opengl/contextinfo
parent565f39aad1c02fda14f52fdd002eaba52abf8d27 (diff)
Extend QOpenGLFunctions with GL1 functions
This introduces the ability to indirectly invoke all common GL1-GLES2 functions via QOpenGLFunctions. The GL1 functions are not yet resolved, since this would not work anyway when linking to an OpenGL implementation directly. However this may change later but that will be a completely internal change without affecting any public APIs. Also migrate some of the opengl examples to use QOpenGLFunctions for everything. Once dynamic GL loading becomes available on some platforms, these examples should continue to function without any changes since they do not anymore invoke any OpenGL functions directly. Task-number: QTBUG-36483 Change-Id: Ie630029651e5a4863a480aac5306edd67ee36813 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
Diffstat (limited to 'examples/opengl/contextinfo')
-rw-r--r--examples/opengl/contextinfo/renderwindow.cpp12
-rw-r--r--examples/opengl/contextinfo/widget.cpp9
2 files changed, 12 insertions, 9 deletions
diff --git a/examples/opengl/contextinfo/renderwindow.cpp b/examples/opengl/contextinfo/renderwindow.cpp
index ab8e89fab8..85fb19bd1a 100644
--- a/examples/opengl/contextinfo/renderwindow.cpp
+++ b/examples/opengl/contextinfo/renderwindow.cpp
@@ -43,6 +43,7 @@
#include <QMatrix4x4>
#include <QOpenGLContext>
#include <QOpenGLShaderProgram>
+#include <QOpenGLFunctions>
RenderWindow::RenderWindow(const QSurfaceFormat &format)
: m_context(0),
@@ -177,10 +178,11 @@ void RenderWindow::render()
return;
}
+ QOpenGLFunctions *f = m_context->functions();
if (!m_initialized) {
m_initialized = true;
- glEnable(GL_DEPTH_TEST);
- glClearColor(0, 0, 0, 1);
+ f->glEnable(GL_DEPTH_TEST);
+ f->glClearColor(0, 0, 0, 1);
init();
emit ready();
}
@@ -189,8 +191,8 @@ void RenderWindow::render()
return;
const qreal retinaScale = devicePixelRatio();
- glViewport(0, 0, width() * retinaScale, height() * retinaScale);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ f->glViewport(0, 0, width() * retinaScale, height() * retinaScale);
+ f->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
m_program->bind();
QMatrix4x4 matrix;
@@ -204,7 +206,7 @@ void RenderWindow::render()
else // no VAO support, set the vertex attribute arrays now
setupVertexAttribs();
- glDrawArrays(GL_TRIANGLES, 0, 3);
+ f->glDrawArrays(GL_TRIANGLES, 0, 3);
m_vao.release();
m_program->release();
diff --git a/examples/opengl/contextinfo/widget.cpp b/examples/opengl/contextinfo/widget.cpp
index 6d4b97ca8f..ff78639e24 100644
--- a/examples/opengl/contextinfo/widget.cpp
+++ b/examples/opengl/contextinfo/widget.cpp
@@ -312,13 +312,14 @@ void Widget::renderWindowReady()
QString vendor, renderer, version, glslVersion;
const GLubyte *p;
- if ((p = glGetString(GL_VENDOR)))
+ QOpenGLFunctions *f = context->functions();
+ if ((p = f->glGetString(GL_VENDOR)))
vendor = QString::fromLatin1(reinterpret_cast<const char *>(p));
- if ((p = glGetString(GL_RENDERER)))
+ if ((p = f->glGetString(GL_RENDERER)))
renderer = QString::fromLatin1(reinterpret_cast<const char *>(p));
- if ((p = glGetString(GL_VERSION)))
+ if ((p = f->glGetString(GL_VERSION)))
version = QString::fromLatin1(reinterpret_cast<const char *>(p));
- if ((p = glGetString(GL_SHADING_LANGUAGE_VERSION)))
+ if ((p = f->glGetString(GL_SHADING_LANGUAGE_VERSION)))
glslVersion = QString::fromLatin1(reinterpret_cast<const char *>(p));
m_output->append(tr("\nVendor: %1").arg(vendor));