// --------------------------------------------------------------------------- // // @file TwSimpleGLFW.c // @brief A simple example that uses AntTweakBar with // OpenGL and the GLFW windowing system. // // AntTweakBar: http://anttweakbar.sourceforge.net/doc // OpenGL: http://www.opengl.org // GLFW: http://www.glfw.org // // @author Philippe Decaudin // @date 2006/05/20 // // --------------------------------------------------------------------------- #include #define GLFW_DLL #include "glfw.h" #include // Callback function called by GLFW when window size changes void GLFWCALL WindowSizeCB(int width, int height) { // Set OpenGL viewport and camera glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(40, (double)width/height, 1, 10); gluLookAt(-1,0,3, 0,0,0, 0,1,0); // Send the new window size to AntTweakBar TwWindowSize(width, height); } // This example program draws a possibly transparent cube void DrawModel(int wireframe) { int pass, numPass; // Enable OpenGL transparency and light (could have been done once at init) glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHT0); // use default light diffuse and position glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 1); glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); glEnable(GL_LINE_SMOOTH); glLineWidth(3.0); if( wireframe ) { glDisable(GL_CULL_FACE); glDisable(GL_LIGHTING); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); numPass = 1; } else { glEnable(GL_CULL_FACE); glEnable(GL_LIGHTING); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); numPass = 2; } for( pass=0; pass