Using makeCurrent() wrong?
Unsolved
General and Desktop

This is my resizeGL() function, I can see my cubes with no problem when I resize the window.
void OGLWidget::resizeGL(int w, int h) { static float aspectRatio; if(w < h) aspectRatio = (float)h / (float)w; else aspectRatio = (float)w / (float)h; glViewport(0,0,w,h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluPerspective(30, aspectRatio , 1.0, 1000); const float radius = sqrt(200 * 200 * 2); static float angle; const float x = radius * cos(angle * M_PI / 180), y = radius * sin(angle * M_PI / 180); gluLookAt(x, y, 200, 0, 0, 0, 0, 0, 20); angle += 1; }
When I try to do this inside on_pushButton_clicked() it only clears the screen and nothing happens but screen is cleared,
void MainWindow::on_pushButton_clicked() { ui>widget>makeCurrent(); const float radius = sqrt(300 * 300 * 2); static float angle; const float x = radius * cos(angle * M_PI / 180), y = radius * sin(angle * M_PI / 180); gluLookAt(x, y, 300, 0, 0, 0, 0, 0, 20); angle += 10; ui>widget>doneCurrent(); ui>widget>update(); }
Thanks

@peytuk 99.99% of the time, you have no reason to do explicit makeCurrent calls. Use all of your OpenGL functions in the paintGL method.
in the button click handler slot, just set some variables that you'll later use when you set up your view in paintGL, and tell it to update(). Don't do it right there in the slot.

@peytuk
gluLookAt
modifies existing modelview matrix, not replaces it. You need to reset it first before usinggluLookAt
.glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(x, y, 300, 0, 0, 0, 0, 0, 20);