Hello to everybody

!
It''s about 1 week now that i started learning OpenGL so i am quite new in OpenGL.
My problem right now is that i cannot move in 3D space.
Ok to make myself clearer i post my code below (use up,down arrow keys and ''a'' and ''z'').
#include <GL/glut.h>
#include <math.h>
int window;
double posX = 0.0 ,
posY = 0.0 ,
posZ = 0.0 ,
lookX = 0.0 ,
lookY = 0.0 ,
lookZ = 0.0 ,
upX = 1.0 ,
upY = 0.0 ,
upZ = 0.0;
double i = 0.0;
double angle = 360.0;
int triangles;
int rotating_speed = 2;
double speed = 0.03;
double b = 0.5 , n = 0.5 , f = 0.5;
void init()
{
glClearColor( 0.0 , 0.0 , 0.0 , 0.0 );
glEnable( GL_DEPTH_TEST );
gluPerspective ( 90.0 , 1.0 , 1 , 5000.0 );
gluLookAt( posX , posY , posZ , lookX , lookY , lookZ , upX , upY , upZ );
}
void display()
{
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
angle = 360 * sin(i);
i += (double)rotating_speed / 100.0;
if ( i >= 360.0 )
i = 0.0;
glLoadIdentity();
glTranslatef( -posX , -posY , -posZ );
glPushMatrix();
// Rotate the triangles
// glRotatef( angle , 1.0, 1.0, 0.0);
glTranslatef( -1.0 , -1.0 , 0.0 );
for ( triangles = 1 ; triangles <= 2 ; triangles++ )
{
glBegin(GL_POLYGON);
glColor3f( 1.0 , 0.0 , 0.0 );
// glVertex3f( 250.0 , 500.0 , 0.0 );
glVertex3f( 1.0 , 1.5 , 0.0 );
glColor3f( 0.0 , 1.0 , 0.0);
// glVertex3f( 125.0 , 0.0 , 125.0 );
glVertex3f( 0.0 , 0.5 , 0.0 );
glColor3f( 0.0 , 0.0 , 1.0 );
// glVertex3f( 250 + 125.0 , 0.0 , 0 );
glVertex3f( 2.0 , 0.5 , 0.0 );
glEnd();
glTranslatef( b , n , f);
}
glPopMatrix();
glutSwapBuffers();
}
void move_camera(int direction)
{
posZ += direction * speed;
//glutPostRedisplay();
}
void handle_arrows(int key,int x , int y)
{
switch( key )
{
case GLUT_KEY_UP:
move_camera(1);
display();
break;
case GLUT_KEY_DOWN:
move_camera(-1);
display();
break;
case GLUT_KEY_RIGHT:
rotating_speed++;
break;
case GLUT_KEY_LEFT:
rotating_speed--;
break;
default:
break;
}
}
void hande_simple_keys (unsigned char key , int x , int y)
{
switch( key )
{
case 27:
glutDestroyWindow( window );
exit( 0 );
break;
case int(''a''):
posY += speed;
display();
break;
case int(''z''):
posY -= speed;
display();
break;
default:
break;
}
}
void main(int argc , char **argv)
{
glutInit(&argc , argv);
glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GL_DOUBLE );
glutInitWindowSize(500,500);
glutInitWindowPosition(100,100);
window = glutCreateWindow("move it");
init();
glutDisplayFunc( display );
glutIdleFunc( display );
glutSpecialFunc( handle_arrows );
glutKeyboardFunc( hande_simple_keys );
glutMainLoop();
}
Please somebody answer me cause that thing is driving me crazy. I have studied some tutorials and according to them my code should work (at least that''s what i think so).
Oh and sth else. why should i use gluLookAt in order to move in 3D space when i can use glTranslate and glRotate (which personaly i find much easier) bofore drawing anything. Besides that''s what gluLookAt does (but whithout telling it to you)
Thanks in advance.
What is "real"?
How do you define "real"?
If you''''re talking about
what you can feel. . . what you can smell, taste and see. . . then "real" is simply electrical
signals interpreted by your brain.
What is "real"? How do you define "real"? If you''re talking about what you can feel. . . what you can smell, taste and see. . . then "real" is simply electrical signals interpreted by your brain.