![]() |
TAPs 0.7.7.3
|
00001 /****************************************************************************** 00002 STAPsGLUTCallbackFns.cpp 00003 00004 See STAPsGLUTCallbackFns.hpp 00005 00006 SUKITTI PUNAK (09/10/2010) 00007 UPDATE (09/10/2010) 00008 ******************************************************************************/ 00009 #include "STAPsGLUTCallbackFns.hpp" 00010 // Using Inclusion Model (i.e. definitions are included in declarations) 00011 // (this name.cpp is included in name.hpp) 00012 // Each friend is defined directly inside its declaration. 00013 00014 BEGIN_NAMESPACE_TAPs__OpenGL 00015 //============================================================================= 00016 // Constructor(s) and Destructor 00017 //----------------------------------------------------------------------------- 00018 GLUTCallbackFns::GLUTCallbackFns () 00019 {} 00020 //----------------------------------------------------------------------------- 00021 GLUTCallbackFns::~GLUTCallbackFns () 00022 {} 00023 //----------------------------------------------------------------------------- 00024 //============================================================================= 00025 // DisplayFn 00026 //----------------------------------------------------------------------------- 00027 void GLUTCallbackFns::DisplayFn () 00028 { 00029 glClearColor( 1, 1, 1, 1 ); 00030 glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); 00031 00032 //... 00033 00034 glutPostRedisplay(); 00035 glutSwapBuffers(); 00036 } 00037 //----------------------------------------------------------------------------- 00038 //============================================================================= 00039 // ReshapeFn 00040 //----------------------------------------------------------------------------- 00041 void GLUTCallbackFns::ReshapeFn ( int width, int height ) 00042 { 00043 /* 00044 static const float K_FOV_Y = 40; 00045 static const float K_CANONICAL_SPHERE_RADIUS = sqrt( 3.0f ); 00046 static const float K_PI = 3.1415926535897932384626433832795; 00047 //------------------------------------------------------------------- 00048 glViewport( 0, 0, static_cast<GLsizei>(width), static_cast<GLsizei>(height) ); 00049 //------------------------------------------------------------------- 00050 // Compute the viewing parameters based on a fixed fov and viewing 00051 // sphere enclosing a canonical box centered at the origin 00052 //T nearDist = K_CANONICAL_SPHERE_RADIUS / tan( (K_FOV_Y/2.0) * K_PI / 180.0 ); 00053 //T farDist = nearDist + 2.0 * K_CANONICAL_SPHERE_RADIUS; 00054 float nearDist = 1; 00055 float farDist = 100; 00056 //std::cout << "nearDist: " << nearDist << " farDist: " << farDist << std::endl; 00057 float aspect = static_cast<float>(width) / static_cast<float>(height); 00058 //------------------------------------------------------------------- 00059 glMatrixMode( GL_PROJECTION ); 00060 glLoadIdentity(); 00061 gluPerspective( K_FOV_Y, aspect, nearDist, farDist ); 00062 */ 00063 00064 //glViewport( 0, 0, width, height ); 00065 //glMatrixMode( GL_PROJECTION ); 00066 //glLoadIdentity(); 00067 //gluPerspective( 45.0, (float)width / (float)height, 0.1, 1000.0 ); 00068 //glMatrixMode( GL_MODELVIEW ); 00069 //glLoadIdentity(); 00070 //gluLookAt( 00071 // 0, 0, 200, // eye position 00072 // 0, 0, 0, // look at 00073 // 0, 1, 0 // up vector 00074 //); 00075 00076 } 00077 //----------------------------------------------------------------------------- 00078 //============================================================================= 00079 // KeyboardFn 00080 //----------------------------------------------------------------------------- 00081 void GLUTCallbackFns::KeyboardFn ( unsigned char key, int x, int y ) 00082 { 00083 //---------------------------------------------------------------- 00084 switch ( key ) { 00085 case 'q': 00086 case 'Q': 00087 case 27: // ESC for exit the program 00088 exit( EXIT_SUCCESS ); 00089 break; 00090 } 00091 //---------------------------------------------------------------- 00092 //glutPostRedisplay(); 00093 //---------------------------------------------------------------- 00094 } 00095 //----------------------------------------------------------------------------- 00096 //============================================================================= 00097 // SpecialFn 00098 //----------------------------------------------------------------------------- 00099 void GLUTCallbackFns::SpecialFn ( int key, int x, int y ) 00100 { 00101 //---------------------------------------------------------------- 00102 switch ( key ) { 00103 case GLUT_KEY_F1: 00104 break; 00105 case GLUT_KEY_UP: 00106 break; 00107 case GLUT_KEY_DOWN: 00108 break; 00109 case GLUT_KEY_LEFT: 00110 break; 00111 case GLUT_KEY_RIGHT: 00112 break; 00113 } 00114 //---------------------------------------------------------------- 00115 //glutPostRedisplay(); 00116 //---------------------------------------------------------------- 00117 } 00118 //----------------------------------------------------------------------------- 00119 //============================================================================= 00120 // MouseFn 00121 //----------------------------------------------------------------------------- 00122 void GLUTCallbackFns::MouseFn ( int button, int state, int x, int y ) 00123 { 00124 //---------------------------------------------------------------- 00125 if ( state == GLUT_DOWN ) { 00126 //------------------------------------------------------ 00127 if ( button == GLUT_LEFT_BUTTON ) { 00128 } 00129 //------------------------------------------------------ 00130 else if ( button == GLUT_MIDDLE_BUTTON ) { 00131 } 00132 //------------------------------------------------------ 00133 else if ( button == GLUT_RIGHT_BUTTON ) { 00134 } 00135 } 00136 else if ( state == GLUT_UP ) { 00137 //------------------------------------------------------ 00138 if ( button == GLUT_LEFT_BUTTON ) { 00139 } 00140 //------------------------------------------------------ 00141 else if ( button == GLUT_MIDDLE_BUTTON ) { 00142 } 00143 //------------------------------------------------------ 00144 else if ( button == GLUT_RIGHT_BUTTON ) { 00145 } 00146 } 00147 //---------------------------------------------------------------- 00148 } 00149 //----------------------------------------------------------------------------- 00150 //============================================================================= 00151 // MotionFn 00152 //----------------------------------------------------------------------------- 00153 void GLUTCallbackFns::MotionFn ( int x, int y ) 00154 { 00155 //---------------------------------------------------------------- 00156 //---------------------------------------------------------------- 00157 } 00158 //----------------------------------------------------------------------------- 00159 //============================================================================= 00160 // IdleFn 00161 //----------------------------------------------------------------------------- 00162 void GLUTCallbackFns::IdleFn () 00163 { 00164 //---------------------------------------------------------------- 00165 //---------------------------------------------------------------- 00166 } 00167 //----------------------------------------------------------------------------- 00168 //============================================================================= 00169 // Initialize 00170 //----------------------------------------------------------------------------- 00171 void GLUTCallbackFns::Initialize () 00172 { 00173 //---------------------------------------------------------------- 00174 //---------------------------------------------------------------- 00175 } 00176 //----------------------------------------------------------------------------- 00177 //============================================================================= 00178 END_NAMESPACE_TAPs__OpenGL 00179 //345678901234567890123456789012345678901234567890123456789012345678901234567890 00180 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8