/* Bullet Continuous Collision Detection and Physics Library Copyright (c) 2008 Advanced Micro Devices This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "clstuff.h" #include "gl_win.h" #include #include #include #include //#ifndef _WIN32 && !defined(__APPLE__) //#include //#endif //!_WIN32 //static GLuint vbo = 0; #ifdef _WIN32 #include #endif static unsigned int windowWidth = 1280; static unsigned int windowHeight = 1024; // mouse controls int mouseOldX; int mouseOldY; int mouseButtons = 0; float rotateX; float rotateY; float translateZ; float translateX; float translateY; static GLuint glProgram; void doFlags(); void render( void) { glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); // glDisable ( GL_CULL_FACE ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); glTranslatef( translateX, translateY, translateZ ); glRotatef( rotateX, 0.5f , 0.0f, 0.0f ); glRotatef( rotateY, 0.0f, 0.5f, 0.0f ); // glDisable (GL_BLEND); doFlags(); // TODO: //glBindBuffer(GL_ARRAY_BUFFER, vbo); //glVertexPointer(4, GL_FLOAT, 0, NULL); //glEnableClientState(GL_VERTEX_ARRAY); //glDrawArrays(GL_POINTS, 0, 4*4); // glDisableClientState(GL_VERTEX_ARRAY); // glBindBuffer(GL_ARRAY_BUFFER, 0); // glUseProgram(0); } static void initGL(void) { //glClearColor( 0.05f, 0.0f, 0.1f, 0.1f ); glClearColor( 0.0f, 0.45f, 0.45f, 1.f); #if 0 GLfloat mat_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f }; GLfloat mat_shininess[] = { 50.0f }; GLfloat light_position[] = { -10.f, 5.f, -1.f, 1.0f }; glEnable ( GL_COLOR_MATERIAL ); glShadeModel( GL_SMOOTH ); glEnable( GL_LINE_SMOOTH ); glMaterialfv( GL_FRONT, GL_SPECULAR, mat_specular ); glMaterialfv( GL_FRONT, GL_SHININESS, mat_shininess ); glLightfv( GL_LIGHT0, GL_POSITION, light_position ); //glEnable( GL_LIGHTING ); //glEnable( GL_LIGHT0 ); // Switch on and crashes! glEnable( GL_DEPTH_TEST ); #endif #if 0 glEnable ( GL_COLOR_MATERIAL ); glShadeModel( GL_SMOOTH ); glEnable( GL_LINE_SMOOTH ); glMaterialfv( GL_FRONT, GL_SPECULAR, mat_specular ); glMaterialfv( GL_FRONT, GL_SHININESS, mat_shininess ); glLightfv( GL_LIGHT0, GL_POSITION, light_position ); glEnable( GL_LIGHTING ); glEnable( GL_LIGHT0 ); glEnable( GL_DEPTH_TEST ); #endif rotateX = 0; rotateY = 30; translateX = 0.0f; translateY = -30.0f; translateZ = -120.0; } void display(void) { render(); glutSwapBuffers(); glutPostRedisplay(); } void keyboard( unsigned char key, int /*x*/, int /*y*/) { switch( key) { case('q') : #ifdef _WIN32 case VK_ESCAPE: #endif //_WIN32 exit(0); break; case('a'): translateY += 0.1f; break; case('z'): translateY -= 0.1f; break; case('d'): translateX += 0.1f; break; case('s'): translateX -= 0.1f; break; case('f'): translateZ += 0.1f; break; case('g'): translateZ -= 0.1f; break; } } void mouse(int button, int state, int x, int y) { if (state == GLUT_DOWN) { mouseButtons |= 1<