From 1e18df9c73e5431083ac2983c8899823d5ce259d Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 3 Mar 2014 14:47:27 +0100 Subject: Extend QOpenGLFunctions with GL1 functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Jørgen Lind --- examples/opengl/hellowindow/hellowindow.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'examples/opengl/hellowindow/hellowindow.cpp') diff --git a/examples/opengl/hellowindow/hellowindow.cpp b/examples/opengl/hellowindow/hellowindow.cpp index 2864883f5eb..3b5971c0d37 100644 --- a/examples/opengl/hellowindow/hellowindow.cpp +++ b/examples/opengl/hellowindow/hellowindow.cpp @@ -41,6 +41,7 @@ #include "hellowindow.h" #include +#include #include 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;" -- cgit v1.2.3