Scaling QOpenGLWidget
Unsolved
General and Desktop
-
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(); }
-
Hi,
It's a little bit more complex than that. See this article about the various transformation that you can apply.