cube example: always set required state in paintGL

...instead of expecting whatever was set in initializeGL will persist.

Task-number: QTBUG-111304
Change-Id: Ifcf75a3df9bed6a45d2e9264a5e3f32504b42313
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
(cherry picked from commit 25fcded977e5283ff0e33e0465abbb544a41f30e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Laszlo Agocs 2023-04-18 13:57:45 +02:00 committed by Qt Cherry-pick Bot
parent a95b43b972
commit aebb04fc43

View File

@ -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();