diff options
Diffstat (limited to 'examples/opengl/hellogles3')
-rw-r--r-- | examples/opengl/hellogles3/glwindow.cpp | 32 | ||||
-rw-r--r-- | examples/opengl/hellogles3/glwindow.h | 26 |
2 files changed, 19 insertions, 39 deletions
diff --git a/examples/opengl/hellogles3/glwindow.cpp b/examples/opengl/hellogles3/glwindow.cpp index 9458b74810..c644faa9a6 100644 --- a/examples/opengl/hellogles3/glwindow.cpp +++ b/examples/opengl/hellogles3/glwindow.cpp @@ -57,19 +57,10 @@ #include <QOpenGLVertexArrayObject> #include <QOpenGLExtraFunctions> #include <QPropertyAnimation> -#include <QPauseAnimation> #include <QSequentialAnimationGroup> #include <QTimer> GLWindow::GLWindow() - : m_texture(0), - m_program(0), - m_vbo(0), - m_vao(0), - m_target(0, 0, -1), - m_uniformsDirty(true), - m_r(0), - m_r2(0) { m_world.setToIdentity(); m_world.translate(0, 0, -1); @@ -197,18 +188,12 @@ void GLWindow::initializeGL() { QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions(); - if (m_texture) { - delete m_texture; - m_texture = 0; - } QImage img(":/qtlogo.png"); Q_ASSERT(!img.isNull()); + delete m_texture; m_texture = new QOpenGLTexture(img.scaled(32, 36).mirrored()); - if (m_program) { - delete m_program; - m_program = 0; - } + delete m_program; m_program = new QOpenGLShaderProgram; // Prepend the correct version directive to the sources. The rest is the // same, thanks to the common GLSL syntax. @@ -223,26 +208,21 @@ void GLWindow::initializeGL() m_lightPosLoc = m_program->uniformLocation("lightPos"); // Create a VAO. Not strictly required for ES 3, but it is for plain OpenGL. - if (m_vao) { - delete m_vao; - m_vao = 0; - } + delete m_vao; m_vao = new QOpenGLVertexArrayObject; if (m_vao->create()) m_vao->bind(); - if (m_vbo) { - delete m_vbo; - m_vbo = 0; - } m_program->bind(); + delete m_vbo; m_vbo = new QOpenGLBuffer; m_vbo->create(); m_vbo->bind(); m_vbo->allocate(m_logo.constData(), m_logo.count() * sizeof(GLfloat)); f->glEnableVertexAttribArray(0); f->glEnableVertexAttribArray(1); - f->glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(GLfloat), 0); + f->glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(GLfloat), + nullptr); f->glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(GLfloat), reinterpret_cast<void *>(3 * sizeof(GLfloat))); m_vbo->release(); diff --git a/examples/opengl/hellogles3/glwindow.h b/examples/opengl/hellogles3/glwindow.h index fba997bee4..dfa0680714 100644 --- a/examples/opengl/hellogles3/glwindow.h +++ b/examples/opengl/hellogles3/glwindow.h @@ -90,23 +90,23 @@ public: private slots: void startSecondStage(); private: - QOpenGLTexture *m_texture; - QOpenGLShaderProgram *m_program; - QOpenGLBuffer *m_vbo; - QOpenGLVertexArrayObject *m_vao; + QOpenGLTexture *m_texture = nullptr; + QOpenGLShaderProgram *m_program = nullptr; + QOpenGLBuffer *m_vbo = nullptr; + QOpenGLVertexArrayObject *m_vao = nullptr; Logo m_logo; - int m_projMatrixLoc; - int m_camMatrixLoc; - int m_worldMatrixLoc; - int m_myMatrixLoc; - int m_lightPosLoc; + int m_projMatrixLoc = 0; + int m_camMatrixLoc = 0; + int m_worldMatrixLoc = 0; + int m_myMatrixLoc = 0; + int m_lightPosLoc = 0; QMatrix4x4 m_proj; QMatrix4x4 m_world; QVector3D m_eye; - QVector3D m_target; - bool m_uniformsDirty; - float m_r; - float m_r2; + QVector3D m_target = {0, 0, -1}; + bool m_uniformsDirty = true; + float m_r = 0; + float m_r2 = 0; }; #endif |