Nominate our 2022 Qt Champions!

Unused functions in the OpenGL Window Example

  • Hi, I'm new to Qt and fairly new to both C++ and OpenGL. I've been going over the OpenGL Window Example in detail, and I noticed that both OpenGLWindow::render() and TriangleWindow::loadShader(GLenum type, const char *source) are actually not used at all (running Qt 5.5.0 on Linux). Is there a particular reason for including these functions in the example?

  • Hi @Ailurus ,

    In that function, the OpenGL subclass can implement either OpenGLWindow::render() or OpenGL:: render(QPainter *painter) . virtual void render() is like your own set of openGL function. In TriangleWindow, the render function of Triangle class is overriding the render() of the openGLWindow. you can have look on it.

    TriangleWindow::loadShader(GLenum type, const char *source) has been used in the traingleWindow cpp file. Here they used this shader.

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    render is called in the renderNow function

    For loadShader, good question, it looks like it's not used currently so it looks like the sample code needs a small cleanup (WIP)

  • @SGaist Thanks! Yes, renderNow() calls the render() function, but in practise TriangleWindow::render() is used. OpenGLWindow::render() can therefore be an empty function I think :).

  • Lifetime Qt Champion

    If it does nothing useful, rather pure virtual but in this case, it's an example of basic reimplementation.

Log in to reply