Scaling QOpenGLWidget



  • Why does scaling work with no matter that i turned glViewport in resizeGL or not?

    Window::Window(QWidget *parent, Qt::WindowFlags f) : QOpenGLWidget(parent, f)
    {
    
    }
    
    void Window::initializeGL()
    {
        QOpenGLFunctions_1_5 *f = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_1_5>();
        f->glClearColor(.0f, .0f, .0f, .0f);
        f->glShadeModel(GL_FLAT);
    
    }
    
    void Window::resizeGL(int w, int h)
    {
        QOpenGLFunctions_1_5 *f = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_1_5>();
      //  f->glViewport(0, 0, 1000, 1000);
    }
    
    void Window::paintGL()
    {
        QOpenGLFunctions_1_5 *f = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_1_5>();
        f->glClear(GL_COLOR_BUFFER_BIT);
        f->glColor3f (1.0, 1.0, 1.0);
        f->glBegin(GL_POLYGON);
           f->glVertex2f(0.0, 0.0);
           f->glVertex2f(0.0, 0.5);
           f->glVertex2f(0.5, 0.5);
           f->glVertex2f(0.5, 0.0);
        f->glEnd();
        f->glFlush();
    }
    
    


  • @Vitek said:

    glViewport

    try changing your clearColor to some thing other than black, see what happens.
    f->glClearColor(.5f, .5f, .5f, 1.0f);



  • Background color changed. It is all. If change glViewport, for example as f->glViewport(0, 0, 2000, 2000); that nothing happened.


  • Lifetime Qt Champion

    Hi,

    It's a little bit more complex than that. See this article about the various transformation that you can apply.


Log in to reply