#ifdef WIN32 # include # ifndef WINAPI # define WINAPI __stdcall # endif #else # ifndef WINAPI # define WINAPI # endif #endif // WIN32 #include #include #include void WINAPI displayfunc( void ); int main( int argc, char *argv[] ) { ::auxInitDisplayMode( AUX_RGBA | AUX_SINGLE | AUX_DEPTH ); ::auxInitPosition( 0, 0, 500, 500 ); ::auxInitWindow( argv[0] ); ::auxMainLoop( &displayfunc ); return 0; } void WINAPI displayfunc( void ) { // TODO STUDENT EXERCISE: // Define a translation matrix of -5 on the z-axis static const float matrix[16] = { 1.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 0.f, 1.f }; static const float vector[3] = { 1.f, -1.f, 0.f }; float result_vector[4]; // TODO STUDENT EXERCISE // Transform the given vector by the matrix result_vector[0] = 0.f; result_vector[1] = 0.f; result_vector[2] = 0.f; result_vector[3] = 0.f; ::glMatrixMode( GL_PROJECTION ); ::glLoadIdentity(); ::gluPerspective( 90.0, 1.0, 1.0, 10.0 ); ::glMatrixMode( GL_MODELVIEW ); ::glLoadIdentity(); ::glTranslatef( result_vector[0], result_vector[1], result_vector[2] ); ::auxSolidSphere( 1.0 ); ::glFlush(); }