diff options
author | Sean Harmer <sean.harmer.qnx@kdab.com> | 2012-06-08 11:18:18 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-14 03:03:38 +0200 |
commit | 6a66f29ead9cd354c6da542358eb82c2519b10c5 (patch) | |
tree | c3bb37c181e204a76576ac32be51be9ddb7899f6 /src | |
parent | 9e9ea7c0e604e50ef66393f85fa2e5b6dafe187e (diff) |
OpenGL: Update QOpenGLFunctions docs to remove widget code
Change-Id: I4246a49444c09d899f2bd7cd2e9353ee0a6859bf
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/opengl/qopenglfunctions.cpp | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/gui/opengl/qopenglfunctions.cpp b/src/gui/opengl/qopenglfunctions.cpp index c2e177c162..f19d4735e1 100644 --- a/src/gui/opengl/qopenglfunctions.cpp +++ b/src/gui/opengl/qopenglfunctions.cpp @@ -64,19 +64,37 @@ QT_BEGIN_NAMESPACE direct inheritance: \code - class MyGLWidget : public QOpenGLWidget, protected QOpenGLFunctions + class MyGLWindow : public QWindow, protected QOpenGLFunctions { Q_OBJECT public: - MyGLWidget(QWidget *parent = 0) : QOpenGLWidget(parent) {} + MyGLWindow(QScreen *screen = 0); protected: void initializeGL(); void paintGL(); + + QOpenGLContext *m_context; }; - void MyGLWidget::initializeGL() + MyGLWindow(QScreen *screen) + : QWindow(screen), QOpenGLWidget(parent) + { + setSurfaceType(OpenGLSurface); + create(); + + // Create an OpenGL context + m_context = new QOpenGLContext; + m_context->create(); + + // Setup scene and render it + initializeGL(); + paintGL() + } + + void MyGLWindow::initializeGL() { + m_context->makeCurrent(this); initializeGLFunctions(); } \endcode @@ -86,11 +104,14 @@ QT_BEGIN_NAMESPACE in the following example: \code - void MyGLWidget::paintGL() + void MyGLWindow::paintGL() { + m_context->makeCurrent(this); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, textureId); ... + m_context->swapBuffers(this); + m_context->doneCurrent(); } \endcode |