A vertex is specified with something like,
glVertex3f(1.,1,1)
and the position is under a series of transformation, and the final position is projected.
The position of the first character in a character series is specified by something like,
and again, the character position (in 3D space) goes under a series of transformation, and the final position is projected.glRasterPos3f(1, 0, 0);
Now, the position of a light source is specified by something like,
GLfloat position[] = { 3.0, .0, .0, 1.0 }; glLightfv(GL_LIGHT0, GL_POSITION, position);
and it also goes under a series of transformation, and the final position of the light source is used for lighting computation, but NOT projected.
Three types light computation:
You also have to specify the color of both the lighting source and the object material.
Here are some other possible callback functions which can be registered with window system.
glutKeyboardFunc(keyboard); // the registered function is called if (ascii)key pressed. glutMotionFunc(motion); // the registered function is called if mouse moved. glutMouseFunc(mouse); // the registered function is called if mouse pressed or released. glutSpecialFunc(specialKey); // like glutKeyboardFunc(keyboard), deals some with non-ascii keys.
The signatures of these callback functions are as follow,
void mouse(int button, int state, int x, int y) void keyboard(unsigned char key, int x, int y) void motion(int x, int y) void specialKey(int key, int x, int y)
// use mouse() and motion() together to do translation based on mouse click and motion // moving whille left mouse button pressed will translate in xy direction. // moving whille right mouse button pressed will translate in z direction. float tran_x = 0, tran_y = 0, tran_z = 0; bool left_mouse_pressed = false; bool right_mouse_pressed = false; int last_x, last_y; void mouse(int button, int state, int x, int y) { if( (mouse_button = button) == GLUT_LEFT_BUTTON && state == GLUT_DOWN) { left_mouse_pressed = true; last_x = x; last_y = y; } else { left_mouse_pressed = false; if( (mouse_button = button) == GLUT_RIGHT_BUTTON && state == GLUT_DOWN) { right_mouse_pressed = true; last_x = x; last_y = y; } else right_mouse_pressed = false; } } void motion(int x, int y) { if(left_mouse_pressed) { float dist_x = (x - last_x) * .5; float dist_y = -(y - last_y) * .5; tran_x += dist_x * .1; tran_y += dist_y * .1; last_x = x; last_y = y; } glutPostRedisplay(); } else if(right_mouse_pressed) { trans_z += .1 * (x - last_x); last_x = x; glutPostRedisplay(); } }
Goto this link , and try to find the link named glutdlls37beta.zip on that page. Download and unzip it.
Here are the things you have to do after you unzip it,
1.3.6