summaryrefslogtreecommitdiffstats
path: root/examples/opengl/hellowindow
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2011-06-21 13:39:26 +0200
committerSamuel Rødal <samuel.rodal@nokia.com>2011-06-21 14:02:22 +0200
commit176f30b13739b352cbe453cba7796d9a9c808bcd (patch)
tree8fa60b6ae4ef06455652863a0406bc5e86a22303 /examples/opengl/hellowindow
parent272daebaa07b21e372ad4274fafb51ce0be92396 (diff)
OpenGL API refactor.
Rename QGuiGLFormat to QSurfaceFormat, and make QWindow sub-class of QSurface and QPlatformWindow sub-class of QPlatformSurface, instead of having QPlatformGLSurface accessor in QWindow.
Diffstat (limited to 'examples/opengl/hellowindow')
-rw-r--r--examples/opengl/hellowindow/hellowindow.cpp13
-rw-r--r--examples/opengl/hellowindow/hellowindow.h6
2 files changed, 9 insertions, 10 deletions
diff --git a/examples/opengl/hellowindow/hellowindow.cpp b/examples/opengl/hellowindow/hellowindow.cpp
index a88fcf1edb..afdf08026a 100644
--- a/examples/opengl/hellowindow/hellowindow.cpp
+++ b/examples/opengl/hellowindow/hellowindow.cpp
@@ -15,7 +15,7 @@ Renderer::Renderer()
m_context = new QGuiGLContext(m_format);
}
-QGuiGLFormat Renderer::format() const
+QSurfaceFormat Renderer::format() const
{
return m_format;
}
@@ -24,10 +24,9 @@ HelloWindow::HelloWindow(Renderer *renderer)
: m_colorIndex(0)
, m_renderer(renderer)
{
- setSurfaceType(OpenGLSurface);
setWindowTitle(QLatin1String("Hello Window"));
- setGLFormat(renderer->format());
+ setFormat(renderer->format());
setGeometry(QRect(10, 10, 640, 480));
@@ -62,13 +61,13 @@ void HelloWindow::updateColor()
void HelloWindow::render()
{
- if (glSurface())
- m_renderer->render(glSurface(), m_color, geometry().size());
+ m_renderer->render(this, m_color, geometry().size());
}
-void Renderer::render(QPlatformGLSurface *surface, const QColor &color, const QSize &viewSize)
+void Renderer::render(QSurface *surface, const QColor &color, const QSize &viewSize)
{
- m_context->makeCurrent(surface);
+ if (!m_context->makeCurrent(surface))
+ return;
if (!m_initialized) {
initialize();
diff --git a/examples/opengl/hellowindow/hellowindow.h b/examples/opengl/hellowindow/hellowindow.h
index 274dc9ca17..3c5388cb76 100644
--- a/examples/opengl/hellowindow/hellowindow.h
+++ b/examples/opengl/hellowindow/hellowindow.h
@@ -12,9 +12,9 @@ class Renderer : public QObject
public:
Renderer();
- QGuiGLFormat format() const;
+ QSurfaceFormat format() const;
- void render(QPlatformGLSurface *surface, const QColor &color, const QSize &viewSize);
+ void render(QSurface *surface, const QColor &color, const QSize &viewSize);
private:
void initialize();
@@ -35,7 +35,7 @@ private:
int colorUniform;
bool m_initialized;
- QGuiGLFormat m_format;
+ QSurfaceFormat m_format;
QGuiGLContext *m_context;
};