summaryrefslogtreecommitdiffstats
path: root/examples/opengl/hellowindow
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/hellowindow
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/hellowindow')
-rw-r--r--examples/opengl/hellowindow/hellowindow.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/examples/opengl/hellowindow/hellowindow.cpp b/examples/opengl/hellowindow/hellowindow.cpp
index 2864883f5e..3b5971c0d3 100644
--- a/examples/opengl/hellowindow/hellowindow.cpp
+++ b/examples/opengl/hellowindow/hellowindow.cpp
@@ -41,6 +41,7 @@
#include "hellowindow.h"
#include <QOpenGLContext>
+#include <QOpenGLFunctions>
#include <qmath.h>
Renderer::Renderer(const QSurfaceFormat &format, Renderer *share, QScreen *screen)
@@ -142,15 +143,16 @@ void Renderer::render()
m_initialized = true;
}
- glViewport(0, 0, viewSize.width() * surface->devicePixelRatio(), viewSize.height() * surface->devicePixelRatio());
+ QOpenGLFunctions *f = m_context->functions();
+ f->glViewport(0, 0, viewSize.width() * surface->devicePixelRatio(), viewSize.height() * surface->devicePixelRatio());
- glClearColor(0.1f, 0.1f, 0.2f, 1.0f);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ f->glClearColor(0.1f, 0.1f, 0.2f, 1.0f);
+ f->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glFrontFace(GL_CW);
- glCullFace(GL_FRONT);
- glEnable(GL_CULL_FACE);
- glEnable(GL_DEPTH_TEST);
+ f->glFrontFace(GL_CW);
+ f->glCullFace(GL_FRONT);
+ f->glEnable(GL_CULL_FACE);
+ f->glEnable(GL_DEPTH_TEST);
QMatrix4x4 modelview;
modelview.rotate(m_fAngle, 0.0f, 1.0f, 0.0f);
@@ -164,8 +166,8 @@ void Renderer::render()
paintQtLogo();
m_program->release();
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_CULL_FACE);
+ f->glDisable(GL_DEPTH_TEST);
+ f->glDisable(GL_CULL_FACE);
m_context->swapBuffers(surface);
@@ -187,8 +189,6 @@ void Renderer::paintQtLogo()
void Renderer::initialize()
{
- glClearColor(0.1f, 0.1f, 0.2f, 1.0f);
-
QOpenGLShader *vshader = new QOpenGLShader(QOpenGLShader::Vertex, this);
vshader->compileSourceCode(
"attribute highp vec4 vertex;"