PDA

View Full Version : glutSolidSphere won't work after updating IDE



LReiter
10-02-2013, 03:34 AM
Hi everyone,
I recently updated to Qt5.1.1 from Qt5.0.2. Since I did this, my formerly fine working code mysteriously doesn't do what it's supposed to anymore.
Basically I'm displaying glutSolidSpheres in coordinates read from a file.
Everything works, except for the "seeing a sphere" part. Again, that used to work fine.
My (stripped down) code is

initializeGL()

void GLWidget::initializeGL() {
glShadeModel(GL_SMOOTH);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glEnable(GL_DEPTH_TEST);*/
glClearColor(0.2,0.2,0.2,1);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHTING);
glEnable(GL_COLOR_MATERIAL);
}

resizeGL()

void GLWidget::resizeGL(int width, int height) {
glViewport(0,0,width,height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(120.0, (float)width/height,0.01,100.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

paintGL()

void GLWidget::paintGL() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0f, 0.0f, 0.0f);
for(iii=0;iii<N_glw-1;iii++) {
drawsphere(fX_glw[iii], fY_glw[iii], fZ_glw[iii], 'r' /*, true*/);
}
}

drawsphere() is basically a glorified glutSolidSphere command


glColor3f(1.0f, 0.2f, 0.2f);
glPushMatrix();
glTranslatef(fX, fY, fZ);
glutSolidSphere(0.5,16,16);
glPopMatrix();
glFlush();

Could anyone tell me if I have maybe a perspective problem? I have absolutely no idea why it wouldn't work just because I updated the IDE.
Thanks a lot!