summaryrefslogtreecommitdiffstats
path: root/examples/opengl/hellowindow/hellowindow.h
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2011-06-07 17:25:22 +0200
committerSamuel Rødal <samuel.rodal@nokia.com>2011-06-10 09:24:56 +0200
commit4a189c188ccd2fb5f8d1d5ddadf06cbd6bc0916f (patch)
tree99bff9f015e869b5521836ea5667590939b22a53 /examples/opengl/hellowindow/hellowindow.h
parent4d10e64f2a78e32418a98e1c80c6579ae0779dfc (diff)
QWindowContext / QWindowFormat refactor.
To enable having a single GL context used for multiple drawables we need to de-couple the context class a bit more from the window class in the plugin API. Now contexts are created stand-alone based on a GL format and a share context, and when calling makeCurrent() a desired surface is specified. This maps well to GLX, EGL, Cocoa, AGL, and WGL, which all support this use case. QWindowContext is renamed to QGuiGLContext, and QWindowFormat is renamed to QGuiGLFormat. We have the ability to introduce a pbuffer or similar other offscreen GL drawable abstraction in the future.
Diffstat (limited to 'examples/opengl/hellowindow/hellowindow.h')
-rw-r--r--examples/opengl/hellowindow/hellowindow.h40
1 files changed, 30 insertions, 10 deletions
diff --git a/examples/opengl/hellowindow/hellowindow.h b/examples/opengl/hellowindow/hellowindow.h
index f0b8ee8b45..274dc9ca17 100644
--- a/examples/opengl/hellowindow/hellowindow.h
+++ b/examples/opengl/hellowindow/hellowindow.h
@@ -5,22 +5,19 @@
#include <QTime>
-class HelloWindow : public QWindow
+class QGuiGLContext;
+
+class Renderer : public QObject
{
- Q_OBJECT
public:
- HelloWindow();
+ Renderer();
-protected:
- void mousePressEvent(QMouseEvent *);
- void resizeEvent(QResizeEvent *);
+ QGuiGLFormat format() const;
-private slots:
- void render();
+ void render(QPlatformGLSurface *surface, const QColor &color, const QSize &viewSize);
private:
void initialize();
- void updateColor();
qreal m_fAngle;
bool m_showBubbles;
@@ -36,5 +33,28 @@ private:
int normalAttr;
int matrixUniform;
int colorUniform;
- uint colorIndex;
+
+ bool m_initialized;
+ QGuiGLFormat m_format;
+ QGuiGLContext *m_context;
+};
+
+class HelloWindow : public QWindow
+{
+ Q_OBJECT
+public:
+ HelloWindow(Renderer *renderer);
+
+private slots:
+ void render();
+
+protected:
+ void mousePressEvent(QMouseEvent *);
+
+private:
+ void updateColor();
+
+ int m_colorIndex;
+ QColor m_color;
+ Renderer *m_renderer;
};