diff options
author | Morten Johan Sørvig <morten.sorvig@digia.com> | 2013-11-28 23:45:36 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-11-29 10:05:24 +0100 |
commit | af1dbfd2239c7834187f3a702fb2029dc78d4526 (patch) | |
tree | 59f6e9852914bc91b9da36547df1c87fb9d30f81 | |
parent | d55db6dd535149adca77a5d5a1bb61823aee94b5 (diff) | |
download | qtbase-af1dbfd2239c7834187f3a702fb2029dc78d4526.tar.gz |
Make OpenGL examples work on retina displays.
glViewport expects device pixels, but the various
geometry accessors returns values in device-independent
pixels.
Change-Id: I8004692de82251e4f1f25bf8f2698895f222ede3
Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
-rw-r--r-- | examples/opengl/hellowindow/hellowindow.cpp | 2 | ||||
-rw-r--r-- | examples/opengl/paintedwindow/paintedwindow.cpp | 4 | ||||
-rw-r--r-- | examples/opengl/pbuffers/glwidget.cpp | 2 | ||||
-rw-r--r-- | examples/opengl/pbuffers2/glwidget.cpp | 2 |
4 files changed, 5 insertions, 5 deletions
diff --git a/examples/opengl/hellowindow/hellowindow.cpp b/examples/opengl/hellowindow/hellowindow.cpp index b5ffbd63a2..2864883f5e 100644 --- a/examples/opengl/hellowindow/hellowindow.cpp +++ b/examples/opengl/hellowindow/hellowindow.cpp @@ -142,7 +142,7 @@ void Renderer::render() m_initialized = true; } - glViewport(0, 0, viewSize.width(), viewSize.height()); + 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); diff --git a/examples/opengl/paintedwindow/paintedwindow.cpp b/examples/opengl/paintedwindow/paintedwindow.cpp index c8f1f236ba..d44b6308b3 100644 --- a/examples/opengl/paintedwindow/paintedwindow.cpp +++ b/examples/opengl/paintedwindow/paintedwindow.cpp @@ -175,9 +175,9 @@ void PaintedWindow::paint() { m_context->makeCurrent(this); - QRect rect(0, 0, width(), height()); + QRect rect(0, 0, width() * devicePixelRatio(), height() * devicePixelRatio()); - QOpenGLPaintDevice device(size()); + QOpenGLPaintDevice device(size() * devicePixelRatio()); QPainter painter(&device); QPainterPath path; diff --git a/examples/opengl/pbuffers/glwidget.cpp b/examples/opengl/pbuffers/glwidget.cpp index d3b82ff23f..b319951ccd 100644 --- a/examples/opengl/pbuffers/glwidget.cpp +++ b/examples/opengl/pbuffers/glwidget.cpp @@ -198,7 +198,7 @@ void GLWidget::orthographicProjection() void GLWidget::resizeGL(int width, int height) { - glViewport(0, 0, width, height); + glViewport(0, 0, width * devicePixelRatio(), height * devicePixelRatio()); aspect = (qreal)width / (qreal)(height ? height : 1); perspectiveProjection(); } diff --git a/examples/opengl/pbuffers2/glwidget.cpp b/examples/opengl/pbuffers2/glwidget.cpp index d1bb501386..de30bb8b21 100644 --- a/examples/opengl/pbuffers2/glwidget.cpp +++ b/examples/opengl/pbuffers2/glwidget.cpp @@ -156,7 +156,7 @@ void GLWidget::draw() glTranslatef(0.0f, 0.0f, -15.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - glViewport(0, 0, width(), height()); + glViewport(0, 0, width() * devicePixelRatio(), height() * devicePixelRatio()); glBindTexture(GL_TEXTURE_2D, dynamicTexture); glEnable(GL_TEXTURE_2D); |