hello,
i just start doing some opengl and i experiencing a problem which i don’t know wat i did wrong.
this is wat i have
============================================================
void displayCallback(void)
{
float eye[] = {0,4,20};
float center[] = {0,0,0};
float up[] = {0,1,0};
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
// position the camera in the world
gluLookAt(eye[0],eye[1],eye[2],center[0],center[1],center[2],up[0],up[1], up[2]);
// animate the global scene rotation
glRotatef(Angle,1,1,0);
// draw a wire-frame sphere; turn off lighting in order to get solid shading
glDisable(GL_LIGHTING);
glColor3f(1,1,1);
glutWireSphere(1,20,10); // sphere: r=1, 20 slices, 10 stacks
glEnable(GL_LIGHTING);
glPushMatrix();
// draw some colored teapots
/*
glTranslatef(-3,0,1);
glColor3f(1,0.5,0.5);
glutSolidTeapot(1.0);
glTranslatef(3,0,0);
glColor3f(0.5,1,0.5);
glutSolidTeapot(1.0);
glTranslatef(3,0,0);
glColor3f(0.5,0.5,1);
glutSolidTeapot(1.0);
glPopMatrix();
*/
// draw ground plane
glColor3f(1,1,1);
glNormal3f(0,1,0);
glBegin(GL_POLYGON);
glVertex3f(-10,0,-10);
glVertex3f(-10,0,10);
glVertex3f(10,0,10);
glVertex3f(10,0,-10);
//draw_t(1.0,5.0,10.0,100);
drawSquare(1);
glEnd();
glutSwapBuffers();
}
void keyCallback(unsigned char key, int x, int y)
{
switch(key) {
case ‘q’:
exit(0);
break;
case ‘r’:
exit(0);
break;
case 27: // 27 = number of esc key
exit(0);
break;
case 'a':
Angle = (Angle+500) / 360;
glutPostRedisplay();
break;
default:
break;
}
glutPostRedisplay();
//
}
…
…
…
glutKeyboardFunc(keyCallback);
glutDisplayFunc(displayCallback);
when i click on ‘a’, i believe that the angle of my picture should turn down and keep turning down when i keep clicking ‘a’. however, my pricturn just move down ‘once’ when i clicked ‘a’ for the first time.
my purpose is to let it getting down when i keep pressing ‘a’ …
any idea?
another problem that i having…
i trying to move the camera around my obj
says. when i click ‘z’ the camera turn left aorund the obj (clock wise if u look from top view) …however i don’t know how to do this… can any suggest me?
and last q : wat is the case that i need to use if i wanna use my ‘left cursor’ to turn left instead of ‘z’ …
thxx very much for any suggestion.
Tom