int main(int argc, char *argv[]) { glutInit(&argc, argv); glutCreateWindow ("GL3 white triangle example"); glutDisplayFunc(display); initKeymapManager(); //glutPassiveMotionFunc(MouseController); glutTimerFunc(20, &OnTimer, 0); init (); glutMainLoop(); }
void init(void) { // vertex buffer object, used for uploading the geometry unsigned int vertexBufferObjID; unsigned int bunnyIndexBufferObjID; unsigned int bunnyNormalBufferObjID; unsigned int bunnyTexCoordBufferObjID; GLuint colorBufferObjID; glutPassiveMotionFunc(&mouseMove); initKeymapManager(); glutWarpPointer(1024 / 2, 768 / 2); // Load windmill vec3 position = { 0, 0, 0 }; load_windmill(position, &windmill); ground = LoadModelPlus("ground.obj"); castle = LoadModelPlus("models/various/teapot.obj"); skybox = LoadModelPlus("skybox.obj"); LoadTGATextureSimple("skybox512.tga", &skybox_texture); LoadTGATextureSimple("grass.tga", &grass_texture); LoadTGATextureSimple("conc.tga", &conc_texture); dumpInfo(); // GL inits glClearColor(1,0.2,0.5,0); //glFrontFace(GL_CW); glEnable(GL_DEPTH_TEST); //glEnable(GL_CULL_FACE); printError("GL inits"); // Load and compile shader program = loadShaders("lab3-5.vert", "lab3-5.frag"); printError("init shader"); // Upload projection matrix glUniformMatrix4fv(glGetUniformLocation(program, "gProjection"), 1, GL_TRUE, projectionMatrix); // Upload light data to the shader glUniform3fv(glGetUniformLocation(program, "lightSourcesDirPosArr"), 4, &lightSourcesDirectionsPositions[0].x); glUniform3fv(glGetUniformLocation(program, "lightSourcesColorArr"), 4, &lightSourcesColorsArr[0].x); glUniform1fv(glGetUniformLocation(program, "specularExponent"), 4, specularExponent); glUniform1iv(glGetUniformLocation(program, "isDirectional"), 4, isDirectional); glUniform1i(glGetUniformLocation(program, "TexUnit"), 0); glUniform1i(glGetUniformLocation(program, "TexUnit2"), 1); // End of upload of geometry printError("init arrays"); }
int main(int argc, char *argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); glutCreateWindow ("Laboration 3! Keyboard Control!"); glutDisplayFunc(&display); glutPassiveMotionFunc(&MouseMove); initKeymapManager(); glutTimerFunc(20, &OnTimer, 0); init (); glutMainLoop(); }
int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH); glutInitWindowSize (600, 600); glutCreateWindow ("I believe I can fly"); glutDisplayFunc(display); init (); initKeymapManager(); glutTimerFunc(20, &OnTimer, 0); glutMainLoop(); exit(0); }
//Constructor Camera::Camera(vec3 pos, GLfloat vel, GLfloat sens, vector<vector<TerrainPatch*>> * terrain, int sizePatch, int overlap,int sizeGrid) { vec3 r = vec3(0.5,0,0); position = pos; lookAtPoint = VectorAdd(position,r); upVector = vec3(0.0,1.0,0.0); //Terrain information terrainVector = terrain; patchSize = sizePatch; patchOverlap = overlap; blendedSize = patchSize-patchOverlap; gridSize = sizeGrid; //Set inital patch not to equal to starting patch for comparison in actualPatchXIndex = 100; actualPatchZIndex = 100; groundOffset = 10; flying = false; //cameraMatrix = lookAtv(position,lookAtPoint,upVector); velocity = 1.5; projectionNear = 0.8; #if LOWGRAPHICS == 1 projectionFar = 800.0; #else projectionFar = 1700.0; #endif projectionRight = 0.5/0.75; // for wide screen projectionLeft = -0.5/0.75; // for wide screen projectionTop = 0.5; projectionBottom = -0.5; warpPointer=true; lockFrustum=false; initKeymapManager(); cameraMatrix = lookAtv(position,lookAtPoint,upVector); velocity = vel; sensitivity = sens; projectionMatrix = frustum(projectionLeft, projectionRight, projectionBottom, projectionTop,projectionNear, projectionFar); frustumPlanes = new Frustum(this); timer = 30; followFlock = false; birdView = true; flockIndex = -1; // Is set to zero first time we choose to follow a flock. }
int main(int argc, char *argv[]) { glutInit(&argc, argv); glutInitContextVersion(3, 2); glutCreateWindow ("Ter"); glutDisplayFunc(display); glutTimerFunc(20, &OnTimer, 0); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); initKeymapManager(); //glutPassiveMotionFunc(&mouseMovement); init (); glutMainLoop(); }
int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH); glutInitWindowSize (600, 600); glutCreateWindow ("TSBK07 Lab 4"); glutDisplayFunc(display); init (); initKeymapManager(); glutTimerFunc(20, &timer, 0); glutPassiveMotionFunc(mouse); glutMainLoop(); exit(0); }
int main(int argc, char *argv[]) { glutInitWindowPosition (100, 100); glutInitWindowSize (800, 640); glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutCreateWindow ("GL3 mulitcolored triangles example"); glutDisplayFunc(display); initKeymapManager(); //glutPassiveMotionFunc(MouseController); glutTimerFunc(20, &OnTimer, 0); init (); //glBlendFunc(GL_ONE, GL_ONE); glBlendFunc(GL_SRC_ALPHA,GL_ONE); //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glutMainLoop(); }
void init(void) { dumpInfo(); mill = LoadModelPlus( "windmill/windmill-walls.obj"); blade = LoadModelPlus( "windmill/blade.obj"); balcony = LoadModelPlus( "windmill/windmill-balcony.obj"); roof = LoadModelPlus( "windmill/windmill-roof.obj"); // GL inits glClearColor(0.0,0.3,0.3,0); glEnable(GL_DEPTH_TEST); printError("GL inits"); // Load and compile shader program = loadShaders("lab3-2.vert", "lab3-2.frag"); printError("init shader"); glUniformMatrix4fv(glGetUniformLocation(program, "projectionMatrix"), 1, GL_TRUE, projectionMatrix); // Load texture //LoadTGATextureSimple("bilskissred.tga", &myBilTex); printError("init arrays"); // Init up vector up.x = 0; up.y = 1; up.z = 0; cam_pos.x = 0; cam_pos.y = 5; cam_pos.z = 0; obj_pos.x = 0; obj_pos.y = 5; obj_pos.z = -30; initKeymapManager(); }
///////////////////////////////////////// // M A I N // int main(int argc, char **argv) { srand(time(NULL)); mouse_x = 0; old_mouse_x = 0; mouse_y = 0; old_mouse_y = 0; m_angle = -300*M_PI; //FOULHACK! glutInit(&argc, argv); initKeymapManager(); glutPassiveMotionFunc(mouse); //glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GL_MULTISAMPLE); glutInitWindowSize(800, 600); glutInitContextVersion(3, 2); // Might not be needed in Linux glutCreateWindow("Farm Escape"); glutDisplayFunc(DisplayWindow); create_floor(&f); //create_plank(&p, SetVector(4,4,0), SetVector(0,5,0)); create_fence(&ff, 14, SetVector(0,0,0)); //f.model = generate_terrain(32); create_ball(&ball, SetVector(5,0,0)); create_wall(&wall, SetVector(0,10,0), SetVector(2,5,2)); create_joint(&legbase_joint[0], SetVector(-2.2, 3.8, .7), "legjoint0", "legcurrpos0", "legbonepos0", 0); create_joint(&legbase_joint[1], SetVector(-2.2, 3.8, -.7), "legjoint1", "legcurrpos1", "legbonepos1", 0); create_joint(&legbase_joint[2], SetVector(.2, 3.9, -.7), "legjoint2", "legcurrpos2", "legbonepos2", 0); create_joint(&legbase_joint[3], SetVector(.2, 3.9, .7), "legjoint3", "legcurrpos3", "legbonepos3", 0); create_joint(&thigh_joint[0], SetVector(-2.3, 1.8, .4), NULL, NULL, NULL, 0); create_joint(&thigh_joint[1], SetVector(-2.3, 1.8, -.4), NULL, NULL, NULL, 0); create_joint(&thigh_joint[2], SetVector(.1, 2, -.4), NULL, NULL, NULL, 0); create_joint(&thigh_joint[3], SetVector(.1, 2.0, .4), NULL, NULL, NULL, 0); create_joint(&knee_joint[0], SetVector(-2.6, .9, .4), NULL, NULL, NULL, 0); create_joint(&knee_joint[1], SetVector(-2.6, .9, -.4), NULL, NULL, NULL, 0); create_joint(&knee_joint[2], SetVector(.4, .9, -.4), NULL, NULL, NULL, 0); create_joint(&knee_joint[3], SetVector(.4, .9, .4), NULL, NULL, NULL, 0); create_joint(&foot_joint[0], SetVector(-2.75, 0, .4), NULL, NULL, NULL, 0); create_joint(&foot_joint[1], SetVector(-2.75, 0, -.4), NULL, NULL, NULL, 0); create_joint(&foot_joint[2], SetVector(.34, 0, -.4), NULL, NULL, NULL, 0); create_joint(&foot_joint[3], SetVector(.34, 0, .4), NULL, NULL, NULL, 0); //BODY JOINTS create_joint(&body_joint[0], SetVector(-1.8, 3.6, 0), "bodyjoint", "bodycurrpos", "bodybonepos", 0); create_joint(&body_joint[1], SetVector(-1, 3.3, 0), NULL, NULL, NULL, 0); create_joint(&body_joint[2], SetVector(.14, 3.9, 0), NULL, NULL, NULL, 0); //TAIL JOINTS create_joint(&tail_joint[0], SetVector(.7+.3, 3.75, 0), "tailjoint", "tailcurrpos", "tailbonepos", 0); create_joint(&tail_joint[1], SetVector(2.2, 3.8, 0), NULL, NULL, NULL, 0); create_joint(&tail_joint[2], SetVector(3.0, 3.75, 0), NULL, NULL, NULL, 0); create_joint(&tail_joint[3], SetVector(3.9, 3.65, 0), NULL, NULL, NULL, 0); //HEAD JOINTS create_joint(&head_joint[0], SetVector(-2.9, 3.2, 0), "headjoint", "headcurrpos", "headbonepos", 0); create_joint(&head_joint[1], SetVector(-3.85, 4, 0), NULL, NULL, NULL, 0); create_joint(&head_joint[2], SetVector(-4.7, 3, 0), NULL, NULL, NULL, 0); //EAR JOINTS //create_joint(&left_ear_joint[0], SetVector(-2.9, 3.2, -.4), //"leftearjoint", "leftearcurrpos", "leftearbonepos", 0); create_joint(&left_ear_joint[0], SetVector(-2.9, 3.2, .6), NULL, NULL, NULL, 0); create_joint(&right_ear_joint[0], SetVector(-2.9, 3.2, -.6), NULL, NULL, NULL, 0); //create_joint(&left_ear_joint[1], SetVector(-2.9, 3.2, .6), //NULL, NULL, NULL, 0); //create_joint(&right_ear_joint[1], SetVector(-2.9, 3.2, -.6), //NULL, NULL, NULL, 0); //create_joint(&right_ear_joint[0], SetVector(-2.9, 3.2, -.6), //"rightearjoint", "rightearcurrpos", "rightearbonepos", 0); //create_joint(&right_ear_joint[1], SetVector(-2.9, 3.2, -.8), //"rightearjoint", "rightearcurrpos", "rightearbonepos", 0); //SET CHILDREN! body_joint[0].child[0] = &body_joint[1]; body_joint[1].child[0] = &body_joint[2]; body_joint[2].child[0] = &tail_joint[0]; body_joint[2].child[1] = &legbase_joint[2]; body_joint[2].child[2] = &legbase_joint[3]; tail_joint[0].child[0] = &tail_joint[1]; tail_joint[1].child[0] = &tail_joint[2]; tail_joint[2].child[0] = &tail_joint[3]; tail_joint[3].child[0] = NULL; head_joint[0].child[0] = &head_joint[1]; head_joint[1].child[0] = &head_joint[2]; head_joint[2].child[0] = NULL; //head_joint[2].child[0] = &right_ear_joint[1]; head_joint[2].child[1] = &left_ear_joint[0]; head_joint[2].child[2] = &right_ear_joint[0]; //left_ear_joint[0].child[0] = &left_ear_joint[1]; //right_ear_joint[0].child[0] = &right_ear_joint[1]; //left_ear_joint[1].child[0] = NULL; //right_ear_joint[1].child[0] = NULL; //head_joint[0].child = &legbase_joint[0]; int i; for(i=0;i<4;i++) { legbase_joint[i].child[0] = &thigh_joint[i]; thigh_joint[i].child[0] = &knee_joint[i]; knee_joint[i].child[0] = &foot_joint[i]; foot_joint[i].child[0] = NULL; } //SET PARENTS legbase_joint[2].parent = &body_joint[2]; legbase_joint[3].parent = &body_joint[2]; //left_ear_joint[1].parent = &left_ear_joint[0]; left_ear_joint[0].parent = &head_joint[2]; //right_ear_joint[1].parent = &right_ear_joint[0]; right_ear_joint[0].parent = &head_joint[2]; create_cow(&cow); create_farmer(&farmer, SetVector(0,0,0)); create_ragdoll(&ragdoll); g_shader = loadShaders("shader.vert" , "shader.frag"); glUseProgram(g_shader); // Set up depth buffer glEnable(GL_DEPTH_TEST); //glEnable (GL_BLEND); //glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // initiering //#ifdef WIN32 // glewInit(); //#endif //glutSetCursor(0); //terr = generate_terrain(512); glutTimerFunc(20, &OnTimer, 0); glutMainLoop(); exit(0); }