Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Scaling QOpenGLWidget

Scaling QOpenGLWidget

Scheduled Pinned Locked Moved Unsolved General and Desktop
qopenglwidgetopengl
4 Posts 3 Posters 1.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vitek
    wrote on last edited by
    #1

    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();
    }
    
    
    1 Reply Last reply
    0
    • Y Offline
      Y Offline
      yoavmil
      wrote on last edited by
      #2

      @Vitek said:

      glViewport

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

      1 Reply Last reply
      0
      • V Offline
        V Offline
        Vitek
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

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

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved