void draw(void) { glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); /* 3D */ glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_COLOR_MATERIAL); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective( 60, 1, 0.05, WORLD_SIDE * 2 * 2.4142); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); illumination(); gluLookAt(compass[P].x, PLAYER_HEIGHT, compass[P].y, compass[W].x, PLAYER_HEIGHT, compass[W].y, 0, 1, 0); drawEnv(); drawCoins(); drawFixeds(); glDisable(GL_COLOR_MATERIAL); glDisable(GL_LIGHT0); glDisable(GL_LIGHTING); glDisable(GL_DEPTH_TEST); /* 2D */ /* Isso aqui só precisa ser chamado uma vez, e quando a janela muda de * tamanho */ glViewport(0, 0, WINDOW_SIZE, WINDOW_SIZE); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0, WINDOW_SIZE, WINDOW_SIZE, 0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); if(playing) { drawScoreBoard(20,20); if(map) drawMiniMap(3.5f * MAP_SIZE, 3.5f * MAP_SIZE); } else drawEnd(); glutSwapBuffers(); }
// Main int main(int argc, char *argv[]) { TwBar *bar; // Pointer to the tweak bar float axis[] = { 0.7f, 0.7f, 0.0f }; // initial model rotation float angle = 0.8f; // Initialize GLUT //OutputDebugStringA("Test\n"); glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize(800, 600); glutInitWindowPosition(100, 100); glutCreateWindow("SRTP Middle Check"); glutCreateMenu(NULL); glewInit(); initTextureList(); for (int i = 0; i < textpoint; i++){ glActiveTexture(GL_TEXTURE0 + i); glBindTexture(GL_TEXTURE_2D, textureObjects[i]); } glActiveTexture(GL_TEXTURE0); sprintf(path, "%sCook-Torrorence", root); programs[2] = setupShaders(path); // Set GLUT callbacks glutDisplayFunc(Display); glutReshapeFunc(Reshape); // Initialize AntTweakBar TwInit(TW_OPENGL, NULL); // Set GLUT event callbacks // - Directly redirect GLUT mouse button events to AntTweakBar glutMouseFunc((GLUTmousebuttonfun)TwEventMouseButtonGLUT); // - Directly redirect GLUT mouse motion events to AntTweakBar glutMotionFunc((GLUTmousemotionfun)TwEventMouseMotionGLUT); // - Directly redirect GLUT mouse "passive" motion events to AntTweakBar (same as MouseMotion) glutPassiveMotionFunc((GLUTmousemotionfun)TwEventMouseMotionGLUT); // - Directly redirect GLUT key events to AntTweakBar glutKeyboardFunc((GLUTkeyboardfun)TwEventKeyboardGLUT); // - Directly redirect GLUT special key events to AntTweakBar glutSpecialFunc((GLUTspecialfun)TwEventSpecialGLUT); // - Send 'glutGetModifers' function pointer to AntTweakBar; // required because the GLUT key event functions do not report key modifiers states. TwGLUTModifiersFunc(glutGetModifiers); // Create some 3D objects (stored in display lists) glNewList(SHAPE_TEAPOT, GL_COMPILE); glutSolidTeapot(1.0); glEndList(); glNewList(SHAPE_TORUS, GL_COMPILE); //glutSolidTorus(0.3, 1.0, 16, 32); glutSolidSphere(0.75f, 20, 20); glEndList(); glNewList(SHAPE_DRAGON, GL_COMPILE); drawBunny("dragon"); glEndList(); glNewList(SHAPE_SKULL, GL_COMPILE); drawBunny("skull"); glEndList(); glNewList(SHAPE_GARGO, GL_COMPILE); drawBunny("Gargoyle_ABF"); glEndList(); glNewList(DRAW_EN, GL_COMPILE); drawEnv(30); glEndList(); // Create a tweak bar bar = TwNewBar("TweakBar"); TwDefine(" GLOBAL help='This example shows how to integrate AntTweakBar with GLUT and OpenGL.' "); // Message added to the help bar. TwDefine(" TweakBar size='250 540' color='96 216 224' "); // change default tweak bar size and color TwAddVarRW(bar, "Zoom", TW_TYPE_FLOAT, &g_Zoom, " min=0.01 max=7.5 step=0.01 "); TwAddVarRW(bar, "ObjRotation", TW_TYPE_QUAT4F, &g_Rotation, " label='Object rotation' opened=true "); TwAddVarCB(bar, "AutoRotate", TW_TYPE_BOOL32, SetAutoRotateCB, GetAutoRotateCB, NULL, " label='Auto-rotate' key=space "); TwAddVarRW(bar, "LightDir", TW_TYPE_DIR3F, &lightDirection, " label='Light direction' opened=true "); TwAddVarRW(bar, "LightDist", TW_TYPE_FLOAT, &lightDistance, " label='Light distance' "); TwAddVarRW(bar, "Ambient", TW_TYPE_COLOR3F, &lightAmbient, ""); TwAddVarRW(bar, "Diffuse", TW_TYPE_COLOR3F, &lightDiffuse, ""); TwAddVarRW(bar, "Rf", TW_TYPE_COLOR3F, &rf, ""); TwAddVarRW(bar, "Roughness", TW_TYPE_FLOAT, &roughness, " label='Roughness' min=0.01 max=1.99 step=0.01 keyIncr='+' keyDecr='-' "); { TwEnumVal shaders[NUM_SHADERS] = { { SHADER_PHONG, "Phong" }, { SHADER_COOKTORRORENCE, "CookTorrorence" } }; TwType shaderType = TwDefineEnum("ShaderType", shaders, NUM_SHADERS); TwAddVarRW(bar, "Shader", shaderType, ¤tShader, ""); } // Add the enum variable 'g_CurrentShape' to 'bar' // (before adding an enum variable, its enum type must be declared to AntTweakBar as follow) { // ShapeEV associates Shape enum values with labels that will be displayed instead of enum values TwEnumVal shapeEV[NUM_SHAPES] = { { SHAPE_TEAPOT, "Teapot" }, { SHAPE_TORUS, "Sphere" }, { SHAPE_DRAGON, "Dragon" }, { SHAPE_SKULL, "Skull" }, { SHAPE_GARGO, "Gargo" } }; // Create a type for the enum shapeEV TwType shapeType = TwDefineEnum("ShapeType", shapeEV, NUM_SHAPES); // add 'g_CurrentShape' to 'bar': this is a variable of type ShapeType. Its key shortcuts are [<] and [>]. TwAddVarRW(bar, "Shape", shapeType, &g_CurrentShape, ""); } // Store time g_RotateTime = GetTimeMs(); // Init rotation SetQuaternionFromAxisAngle(axis, angle, g_Rotation); SetQuaternionFromAxisAngle(axis, angle, g_RotateStart); atexit(Terminate); // Called after glutMainLoop ends // Call the GLUT main loop glutMainLoop(); return 0; }