summaryrefslogtreecommitdiffstats
path: root/examples/opengl/cube/mainwidget.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2023-04-18 13:57:45 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2023-04-20 14:01:22 +0200
commit25fcded977e5283ff0e33e0465abbb544a41f30e (patch)
treebb6e9e19d8f1d2c31451f0e8ec988897e0647a01 /examples/opengl/cube/mainwidget.cpp
parent84f9293ea2a769e419a9320e5309ce0c5971502e (diff)
cube example: always set required state in paintGL
...instead of expecting whatever was set in initializeGL will persist. Task-number: QTBUG-111304 Pick-to: 6.5 6.4 Change-Id: Ifcf75a3df9bed6a45d2e9264a5e3f32504b42313 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Diffstat (limited to 'examples/opengl/cube/mainwidget.cpp')
-rw-r--r--examples/opengl/cube/mainwidget.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/examples/opengl/cube/mainwidget.cpp b/examples/opengl/cube/mainwidget.cpp
index 50207a9f22..e67c93da5a 100644
--- a/examples/opengl/cube/mainwidget.cpp
+++ b/examples/opengl/cube/mainwidget.cpp
@@ -72,14 +72,6 @@ void MainWidget::initializeGL()
initShaders();
initTextures();
-//! [2]
- // Enable depth buffer
- glEnable(GL_DEPTH_TEST);
-
- // Enable back face culling
- glEnable(GL_CULL_FACE);
-//! [2]
-
geometries = new GeometryEngine;
// Use QBasicTimer because its faster than QTimer
@@ -147,6 +139,14 @@ void MainWidget::paintGL()
// Clear color and depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+//! [2]
+ // Enable depth buffer
+ glEnable(GL_DEPTH_TEST);
+
+ // Enable back face culling
+ glEnable(GL_CULL_FACE);
+//! [2]
+
texture->bind();
program.bind();