// this is the render function. It contains flags to set up the differnt shaders and what // to draw. One can remove most of is not all of theem void renderFun() { // DEBUGGING FLAGS static int drawTri = 1; static int drawSkybox = 1; static int drawLines = 0; static Vector3f pos=Vector3f(0,0,100); static Vector3f lookat=Vector3f(0 ,0 ,0); static Vector3f up=Vector3f(0,1,0); static int zoom = -70; static int camZoom = 1; static int setCam = 0; // setting up the camera manually if needed // can be remved if (setCam) { cam.setCamera(pos, lookat, up); setCam = 0; } // setting up the camera zoom manually if needed // can be remved if (camZoom) { cam.zoomIn(zoom); camZoom = 0; } // setting opengl - clearing the buffers glEnable(GL_DEPTH_TEST); // need depth test to correctly draw 3D objects glClearColor(1.0,1.0,1.0,1); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); if (drawSkybox) { skybox.displaySkybox(cam); } if (drawTri) { glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); displayBoxFun(sphereBoxProg); } // if (drawLines) { // glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); // displayBoxFun(sphereLinesBoxProg); // } glutSwapBuffers(); }
int main(int argc, char** argv) { int rc; Shader s; // set the camera to an initial position cam.setCamera(Vector3f(0,-10,100), Vector3f(0,0,0), Vector3f(0,1,0)); glutInit(&argc, argv); // glutInitDisplayMode(GLUT_RGBA|GLUT_DOUBLE|GLUT_DEPTH|GLUT_3_2_CORE_PROFILE); glutInitDisplayMode(GLUT_RGBA|GLUT_DOUBLE|GLUT_DEPTH); glutInitWindowSize(600,600); glutInitWindowPosition(10, 10); glutCreateWindow("skybox"); glutDisplayFunc(renderFun); glutIdleFunc(idleFun); // setCallbackFun(); // initialize GLEW // GLenum err = glewInit(); // if ( err != GLEW_OK) printf(" Error initializing GLEW! \n"); loadTextures(); skybox.init(); // skybox2.init(); Init_Geometry(); InitVBO(); rc = loadShaders(s); if (rc != 0) { printf("error after createing shaders rc = %d \n", rc); getchar(); } glutMainLoop(); }