// camera movement. Other keyboard input is handled by keyboardControl void moveTimer(int i) { glutTimerFunc(20, &moveTimer, i); vec3 camRight = Normalize(CrossProduct(camDir, camUp)); vec3 moveDir = {0,0,0}; if (glutKeyIsDown(GLUT_KEY_W)) { moveDir = VectorAdd(moveDir, Normalize(camDir)); } if (glutKeyIsDown(GLUT_KEY_A)) { moveDir = VectorSub(moveDir, camRight); } if (glutKeyIsDown(GLUT_KEY_S)) { moveDir = VectorSub(moveDir, Normalize(camDir)); } if (glutKeyIsDown(GLUT_KEY_D)) { moveDir = VectorAdd(moveDir, camRight); } if (Norm(moveDir) > 0.0) { cam = VectorAdd(cam, ScalarMult(Normalize(moveDir), camMoveSpeed)); } if (!freeCam) cam.y = 1.0 + GetMapHeight(tm, ttex.width, ttex.height, cam.x, cam.z); }
void Game::check_turn_key(){ if (early_turn_2_death || good_turn) { return; } GLfloat to_centrum = maze->length - fabs(x_pos) - (width_)/2.0 - next_start_pos; if (glutKeyIsDown('c') && wait_key < 1) { turn = true; pol_dir = -1.0; last_turn = 'r'; } if (glutKeyIsDown('z') && wait_key < 1) { turn = true; pol_dir = 1.0; last_turn = 'l'; } if (turn) { if (to_centrum < width_/2 + 5) { if (to_centrum >= 0){ //std::cout << "Wait to turn = " << to_centrum << std::endl; wait_turn_pos = true; //strafe_back(strafe_max/(turn_steps-1)); //<-- hur många delar rotare good_turn = true; } else if(to_centrum < 0){ late_turn_2_death = true; return; } } else{ early_turn_2_death = true; } if (!wait_turn_pos) { turn_angle = M_PI_2/turn_steps; ball_speed = 0; global_dir = ((global_dir+1*(int)pol_dir)%4+4)%4; world_angle += -turn_angle*pol_dir; maze->update_turn(turn_angle*pol_dir,x_pos,z_pos); wait_key = turn_steps-1; } return; } }
// camera movement. Other keyboard input is handled by keyboardControl void moveTimer(int i) { glutTimerFunc(20, &moveTimer, i); vec3 camRight = Normalize(CrossProduct(camDir, camUp)); vec3 moveDir = {0,0,0}; if (glutKeyIsDown(GLUT_KEY_W)) { moveDir = VectorAdd(moveDir, Normalize(camDir)); } if (glutKeyIsDown(GLUT_KEY_A)) { moveDir = VectorSub(moveDir, camRight); } if (glutKeyIsDown(GLUT_KEY_S)) { moveDir = VectorSub(moveDir, Normalize(camDir)); } if (glutKeyIsDown(GLUT_KEY_D)) { moveDir = VectorAdd(moveDir, camRight); } if (Norm(moveDir) > 0.0) { cam = VectorAdd(cam, ScalarMult(Normalize(moveDir), CAM_MOVE_SPEED)); } }
void display(void) { if (glutKeyIsDown('a')) { x=x-0.3; } if (glutKeyIsDown('d')) { x=x+0.3; } if (glutKeyIsDown('w')) { y=y+0.3; } if (glutKeyIsDown('s')) { y=y-0.3; } if (glutKeyIsDown('l')) { ry=ry-0.3; } if (glutKeyIsDown('j')) { ry=ry+0.3; } if (glutKeyIsDown('i')) { rx=rx-0.3; } if (glutKeyIsDown('k')) { rx=rx+0.3; } a += 0.1; mat4 rot, trans, trans2, transCam, transCam2, rot2, rotTot, totCam, total, bladeRotMat, windMillPos; //clear the screen glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); rot = Ry(ry/10); transCam = T(0, 0, 16); transCam2 = T(0,0,-16); totCam = Mult(rot, transCam); totCam = Mult(transCam2, totCam); vec3 p = SetVector(x, y+8, 10); vec4 s = vec3tovec4(p); vec4 d = MultVec4(totCam, s); vec3 q = vec4tovec3(d); vec3 l = SetVector(0,8,-16); vec3 v = SetVector(0,1,0); camera = lookAtv(q,l,v); glUniformMatrix4fv(glGetUniformLocation(program, "camMatrix"), 1, GL_TRUE, camera.m); // walls rot = Ry(0); windMillPos = T(0,0,-16); total = Mult(windMillPos, rot); glUniformMatrix4fv(glGetUniformLocation(program, "mdlMatrix"), 1, GL_TRUE, total.m); DrawModel(walls, program,"in_Position" , "in_Normal", "inTexCoord"); // Blade rotation matrix trans = T(0, -9, 16); trans2 = T(0, 9, -16); rot = Rz(a/6); bladeRotMat = Mult(rot, trans); bladeRotMat = Mult(trans2, bladeRotMat); // Bladener rot = Ry(1.57); trans = T(0, 9, -11); total = Mult(trans, rot); total = Mult(bladeRotMat, total); glUniformMatrix4fv(glGetUniformLocation(program, "mdlMatrix"), 1, GL_TRUE, total.m); DrawModel(blade, program,"in_Position" , "in_Normal", "inTexCoord"); // Bladupp rot = Ry(1.57); rot2 = Rz(3.14); rotTot = Mult(rot2, rot); trans = T(0, 9, -11); total = Mult(trans, rotTot); total = Mult(bladeRotMat, total); glUniformMatrix4fv(glGetUniformLocation(program, "mdlMatrix"), 1, GL_TRUE, total.m); DrawModel(blade, program,"in_Position" , "in_Normal", "inTexCoord"); // BladeV rot = Ry(1.57); rot2 = Rz(1.57); rotTot = Mult(rot2, rot); trans = T(0, 9, -11); total = Mult(trans, rotTot); total = Mult(bladeRotMat, total); glUniformMatrix4fv(glGetUniformLocation(program, "mdlMatrix"), 1, GL_TRUE, total.m); DrawModel(blade, program,"in_Position" , "in_Normal", "inTexCoord"); // BladeH rot = Ry(1.57); rot2 = Rz(-1.57); rotTot = Mult(rot2, rot); trans = T(0, 9, -11); total = Mult(trans, rotTot); total = Mult(bladeRotMat, total); glUniformMatrix4fv(glGetUniformLocation(program, "mdlMatrix"), 1, GL_TRUE, total.m); DrawModel(blade, program,"in_Position" , "in_Normal", "inTexCoord"); //roof model rot = Ry(0/6); trans = T(0,0,-16); total = Mult(trans, rot); glUniformMatrix4fv(glGetUniformLocation(program, "mdlMatrix"), 1, GL_TRUE, total.m); DrawModel(roof, program,"in_Position" , "in_Normal", "inTexCoord"); printError("display"); glutSwapBuffers(); }
void KeyEvent(){ if(glutKeyIsDown('i')) { pitch = pitch + speed*0.1; lx = cos(yaw) * cos(pitch); ly = sin(pitch); lz = sin(yaw) * cos(pitch); strafex = cos(yaw - M_PI_2); strafez = sin(yaw - M_PI_2); camera = lookAt(tx,ty,tz, tx + lx ,ty + ly , lz + tz , 0,1,0); } else if(glutKeyIsDown('k')) { pitch = pitch - speed*0.1; lx = cos(yaw) * cos(pitch); ly = sin(pitch); lz = sin(yaw) * cos(pitch); strafex = cos(yaw - M_PI_2); strafez = sin(yaw - M_PI_2); camera = lookAt(tx,ty,tz, tx + lx ,ty + ly , lz + tz , 0,1,0); } else if(glutKeyIsDown('j')) { yaw = yaw - speed*0.1; lx = cos(yaw) * cos(pitch); ly = sin(pitch); lz = sin(yaw) * cos(pitch); strafex = cos(yaw - M_PI_2); strafez = sin(yaw - M_PI_2); camera = lookAt(tx,ty,tz, tx + lx ,ty + ly , lz + tz , 0,1,0); } else if(glutKeyIsDown('l')) { yaw = yaw + speed*0.1; lx = cos(yaw) * cos(pitch); ly = sin(pitch); lz = sin(yaw) * cos(pitch); strafex = cos(yaw - M_PI_2); strafez = sin(yaw - M_PI_2); camera = lookAt(tx,ty,tz, tx + lx ,ty + ly , lz + tz , 0,1,0); } if(glutKeyIsDown('w')) { float tlx = cos(yaw)*cos(pitch); float tly = sin(pitch); float tlz = sin(yaw)*cos(pitch); tx = tx + speed*lx; ty = ty + speed*ly; tz = tz + speed*lz; camera = lookAt(tx,ty,tz, tx + tlx ,ty + tly , tlz + tz , 0,1,0); } else if(glutKeyIsDown('s')) { float tlx = cos(yaw)*cos(pitch); float tly = sin(pitch); float tlz = sin(yaw)*cos(pitch); tx = tx + -speed*lx; ty = ty + -speed*ly; tz = tz + -speed*lz; camera = lookAt(tx,ty,tz, tx + tlx ,ty + tly , tlz + tz , 0,1,0); } else if(glutKeyIsDown('a')) { tx = tx + speed*strafex; tz = tz + speed*strafez; lx = cos(yaw) * cos(pitch); ly = sin(pitch); lz = sin(yaw) * cos(pitch); strafex = cos(yaw - M_PI_2); strafez = sin(yaw - M_PI_2); camera = lookAt(tx,ty,tz, tx + lx ,ty + ly , lz + tz , 0,1,0); } else if(glutKeyIsDown('d')) { tx = tx + -speed*strafex; tz = tz + -speed*strafez; lx = cos(yaw) * cos(pitch); ly = sin(pitch); lz = sin(yaw) * cos(pitch); strafex = cos(yaw - M_PI_2); strafez = sin(yaw - M_PI_2); camera = lookAt(tx,ty,tz, tx + lx ,ty + ly , lz + tz , 0,1,0); } }
void display(void) { ballXPos = ballXPos + 0.03; ballZPos = ballZPos + 0.03; int d = floor(ballXPos * 5.0); int e = floor(ballZPos * 5.0); dx = ballXPos * 5.0 - d; dz = ballZPos * 5.0 - e; if(dx+dz<1){ dyx = tm->vertexArray[(d+1 + e * texWidth)*3+1] - tm->vertexArray[(d + e * texWidth)*3+1]; dyz = tm->vertexArray[(d + (e+1) * texWidth)*3+1] - tm->vertexArray[(d + e * texWidth)*3+1]; ballYPos = dyx*dx+dyz*dz + tm->vertexArray[(d + e * texWidth)*3+1]; } else{ dyx = tm->vertexArray[(d+1 + e * texWidth)*3+1] - tm->vertexArray[((d+1) + (e+1) * texWidth)*3+1]; dyz = tm->vertexArray[(d + (e+1) * texWidth)*3+1] - tm->vertexArray[((d+1) + (e+1) * texWidth)*3+1]; dx = (ceil(ballXPos * 5.0)-ballXPos * 5.0); dz = (ceil(ballZPos * 5.0)-ballZPos * 5.0); ballYPos = dyx*dx+dyz*dz + tm->vertexArray[((d+1) + (e+1) * texWidth)*3+1]; } //printf("%lf\n",ballYPos); vec3 lookingDir = Normalize(VectorSub(l, p)); vec3 walkSideways = Normalize(CrossProduct(lookingDir, v)); if (glutKeyIsDown('a')) { p = VectorSub(p, walkSideways); l = VectorSub(l, walkSideways); } if (glutKeyIsDown('d')) { p = VectorAdd(p, walkSideways); l = VectorAdd(l, walkSideways); } if (glutKeyIsDown('w')) { p = VectorAdd(p, lookingDir); l = VectorAdd(l, lookingDir); } if (glutKeyIsDown('s')) { p = VectorSub(p, lookingDir); l = VectorSub(l, lookingDir); } if (glutKeyIsDown('l')) { trans = T(-p.x, -p.y, -p.z); trans2 = T(p.x, p.y, p.z); rot = Ry(-0.05); l = MultVec3(trans2, MultVec3(rot, MultVec3(trans, l))); } if (glutKeyIsDown('j')) { trans = T(-p.x, -p.y, -p.z); trans2 = T(p.x, p.y, p.z); rot = Ry(0.05); l = MultVec3(trans2, MultVec3(rot, MultVec3(trans, l))); } if (glutKeyIsDown('i')) { trans = T(-p.x, -p.y, -p.z); trans2 = T(p.x, p.y, p.z); rotateUpDown = ArbRotate(walkSideways, 0.05); l = MultVec3(trans2, MultVec3(rotateUpDown, MultVec3(trans, l))); } if (glutKeyIsDown('k')) { trans = T(-p.x, -p.y, -p.z); trans2 = T(p.x, p.y, p.z); rotateUpDown = ArbRotate(walkSideways, -0.05); l = MultVec3(trans2, MultVec3(rotateUpDown, MultVec3(trans, l))); } // clear the screen glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); printError("pre display"); glUseProgram(program); // Build matrix camMatrix = lookAtv(p,l,v); modelView = IdentityMatrix(); total = Mult(camMatrix, modelView); glUniformMatrix4fv(glGetUniformLocation(program, "mdlMatrix"), 1, GL_TRUE, modelView.m); glUniformMatrix4fv(glGetUniformLocation(program, "cameraMatrix"), 1, GL_TRUE, camMatrix.m); DrawModel(tm, program, "inPosition", "inNormal", "inTexCoord"); //Draw sphere modelToWorld = T(ballXPos, ballYPos, ballZPos); glUniformMatrix4fv(glGetUniformLocation(program, "mdlMatrix"), 1, GL_TRUE, modelToWorld.m); DrawModel(sphere, program, "inPosition", "inNormal", NULL); printError("display 2"); glutSwapBuffers(); }
void display(void) { // Clear the screen____________________________________ if((cam.x < goalx + 2 && cam.x > goalx - 2) && (cam.z < goalz + 2 && cam.z > goalz - 2)) { third_person = true; } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Variables mat4 total, modelView, camMatrix; GLfloat t =(GLfloat)glutGet(GLUT_ELAPSED_TIME)/1000; //Scale with constant to make animation slower. //Read input_____________________________________________ if (third_person) { goal_found = true; if (glutKeyIsDown('t')) { third_person = false; } vec3 pos = {200, 200, 150};// SetVector(keyx,keyy,keyz); //Mouse control_____________________________________________ //fmin and fmax doesn't really make sense but looks good. GLfloat mousexlocal = 0; GLfloat mouseylocal = 0; if (mousex < 350 || mousex > 250) { mousexlocal = 300-mousex; } else { mousexlocal = 0; } deltaphi = deltaphi + deltaphi*-mousexlocal; deltaphi = fmin(0.0001,deltaphi); deltaphi = fmax(deltaphi,2 * PI - 0.0001); forward = MultVec3(Ry(deltaphi*-mousexlocal), forward); vec3 crossvec = CrossProduct(forward,up); if (mousey < 350 || mousey > 250) { mouseylocal = 300-mousey; } else { mouseylocal = 0; } deltatheta = deltatheta + deltatheta* -mouseylocal; deltatheta = fmin(0.0001,deltatheta); deltatheta = fmax(deltatheta,2*PI - 0.0001); forward = MultVec3( ArbRotate(crossvec,deltatheta*-mouseylocal), forward); //Create camera matrix_____________________________________________ camMatrix = lookAtv(pos,VectorAdd(forward,pos),up); } // FIRST PERSON VIEW -------------------------------------------------------- else { vec3 moveVec; if (glutKeyIsDown('w')) // forwards, obviously { vec3 oldcam = cam; //Save old position to check if its legal. moveVec = ScalarMult(VectorSub(cam, SetVector(lookAtPoint.x, cam.y, lookAtPoint.z)), 0.1); // VectorSub makes a vector in the direction we're looking. cam = VectorSub(cam, moveVec); // The new camera position is the old camera position + the move vector cam.y = getHeight(&ttex,cam.x, cam.z)+2; // Get the correct height from the new position GLfloat maze_height = getHeight(&ttexm, cam.x, cam.z); // Get the height of the maze at the new (possible) camera position GLfloat ground_height = getHeight(&ttex, cam.x, cam.z); // Get the height of the ground at the new (possible) camera position //Check if the new position is legal if ((ground_height - maze_height) < ground_height) // If 0, shouldn't move ever: OK! // When does it start to move?? { printf("woot"); cam = oldcam; } } else if (glutKeyIsDown('t')) { third_person = true; } GLfloat mousexlocal = 0; GLfloat mouseylocal = 0; if (mousex < 350 || mousex > 250) { mousexlocal = 300-mousex; } else { mousexlocal = 0; } deltaphi = deltaphi + deltaphi*-mousexlocal; deltaphi = fmin(0.0001,deltaphi); deltaphi = fmax(deltaphi,2 * PI - 0.0001); forward = MultVec3(Ry(deltaphi*-mousexlocal), forward); vec3 crossvec = CrossProduct(forward,up); if (mousey < 350 || mousey > 250) { mouseylocal = 300-mousey; } else { mouseylocal = 0; } deltatheta = deltatheta + deltatheta* -mouseylocal; deltatheta = fmin(0.0001,deltatheta); deltatheta = fmax(deltatheta,2*PI - 0.0001); forward = MultVec3( ArbRotate(crossvec,deltatheta*-mouseylocal), forward); lookAtPoint = VectorAdd(forward,cam); //Create camera matrix_____________________________________________ camMatrix = lookAtv(cam,lookAtPoint,up); } // --------------------------------------------------------// // SKYBOX // --------------------------------------------------------// glDisable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); glUseProgram(programSky); glActiveTexture(GL_TEXTURE2); //glBindTexture(GL_TEXTURE_2D, tex2); trans = T(0.0, 0.0, 0.0); rot = Rx(0); total = Mult(trans, rot); glUniformMatrix4fv(glGetUniformLocation(programSky, "mdlMatrix"), 1, GL_TRUE, total.m); lookSky = camMatrix; lookSky.m[3] = 0; lookSky.m[7] = 0; lookSky.m[11] = 0; glUniformMatrix4fv(glGetUniformLocation(programSky, "lookMatrix"), 1, GL_TRUE, lookSky.m); glUniformMatrix4fv(glGetUniformLocation(programSky, "projectionMatrix"), 1, GL_TRUE, projectionMatrix.m); glUniform1i(glGetUniformLocation(programSky, "texUnit2"), 2); // Texture unit 2 DrawModel(skybox, programSky, "in_Position", NULL, "inTexCoord"); glUseProgram(program); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); //------------------------------------------------------// //------------------------------------------------------// modelView = IdentityMatrix(); total = Mult(camMatrix, modelView); glActiveTexture(GL_TEXTURE1); glUseProgram(program); glUniformMatrix4fv(glGetUniformLocation(program, "mdlMatrix"), 1, GL_TRUE, total.m); glBindTexture(GL_TEXTURE_2D, tex2); // Bind Our Texture tex1 DrawModel(tm, program,"inPosition", "inNormal", "inTexCoord"); glUseProgram(program); glUniformMatrix4fv(glGetUniformLocation(program, "mdlMatrix"), 0, GL_TRUE, total.m); glBindTexture(GL_TEXTURE_2D, tex1); // Bind Our Texture tex1 DrawModel(mm, program,"inPosition", "inNormal", "inTexCoord"); GLfloat y = getHeight(&ttexm, 200, 147); mat4 trans = T(goalx, 2, goalz); mat4 scale = S(1, 1, 1); total = Mult(total, trans); total = Mult(total, scale); if (goal_found) { char* string = "GOOD JOB!! You won :D"; sfDrawString(100, 100, string); //while(true){}; } glUniformMatrix4fv(glGetUniformLocation(program, "mdlMatrix"), 1, GL_TRUE, total.m); glBindTexture(GL_TEXTURE_2D, tex3); // Bind Our Texture tex1 DrawModel(goal, program,"inPosition", "inNormal", "inTexCoord"); printError("display 2"); glutSwapBuffers(); printf("x %f\n", cam.x); printf("y %f\n", cam.y); printf("z %f\n", cam.z); /* if ( (cam.x < 95) && (cam.x > 85) && */ /* (cam.z < 85) && (cam.z > 75)) */ }
void Game::world_dir(){ if (early_turn_2_death) { return; } if (jump || duck || duck_camera) { if (!turn) { check_turn_key(); } return; } if (turn) { return; } if (glutKeyIsDown(' ')) { jump = true; jump_count = 0; } if (glutKeyIsDown('x')) { duck = true; duck_camera = true; duck_count = 0; } if (good_turn) { return; } check_turn_key(); if (turn) { return; } if(glutKeyIsDown(GLUT_KEY_LEFT)) { if (strafe > -strafe_max) { strafe -= 0.1; } else strafe = -strafe_max; } else if(glutKeyIsDown(GLUT_KEY_RIGHT)) { if (strafe < strafe_max) { strafe += 0.1; } else strafe = strafe_max; } else{ strafe_back(0.1); } player_->strafe = strafe; if(glutKeyIsDown(GLUT_KEY_UP)) { if (ball_speed_global < 0.72) { ball_speed_global +=0.01; ball_speed = ball_speed_global; } } else if(glutKeyIsDown(GLUT_KEY_DOWN)) { if (ball_speed_global > 0.00) { ball_speed_global -= 0.01; ball_speed = ball_speed_global; } } else if(glutKeyIsDown('p')) { ball_speed_global = 0.0; ball_speed = 0; } }
void display(void) { //Read input_____________________________________________ GLfloat t =(GLfloat)glutGet(GLUT_ELAPSED_TIME)/1000; //Scale with constant to make animation slower. if (glutKeyIsDown('w')) { keyz = keyz +1; } else if (glutKeyIsDown('s')) { keyz = keyz -1; } else if (glutKeyIsDown('a')) { keyx = keyx +1; } else if (glutKeyIsDown('d')) { keyx = keyx -1; } else if (glutKeyIsDown('e')) { keyy = keyy +1; } else if (glutKeyIsDown('q')) { keyy = keyy -1; } else if (glutKeyIsDown('r')) { exit(0); } // Clear the screen____________________________________ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); mat4 total, modelView, camMatrix; printError("pre display"); vec3 pos = SetVector(keyx,keyy,keyz); vec3 up = SetVector(0,1,0); //Mouse control_____________________________________________ //fmin and fmax doesn't really make sense but looks good. GLfloat mousexlocal = 0; GLfloat mouseylocal = 0; if (mousex < 350 || mousex > 250) { mousexlocal = 300-mousex; } else { mousexlocal = 0; } deltaphi = deltaphi + deltaphi*-mousexlocal; deltaphi = fmin(0.0001,deltaphi); deltaphi = fmax(deltaphi,2 * PI - 0.0001); forward = MultVec3(Ry(deltaphi*-mousexlocal), forward); vec3 crossvec = CrossProduct(forward,up); if (mousey < 350 || mousey > 250) { mouseylocal = 300-mousey; } else { mouseylocal = 0; } deltatheta = deltatheta + deltatheta* -mouseylocal; deltatheta = fmin(0.0001,deltatheta); deltatheta = fmax(deltatheta,2*PI - 0.0001); forward = MultVec3( ArbRotate(crossvec,deltatheta*-mouseylocal), forward); //Create camera matrix_____________________________________________ GLfloat x = cos(t)*5 + 35;//Mult(Ry(2*5),x); GLfloat z = sin(t)*5 + 75;//Mult(Ry //GLfloat z = 65; GLfloat y = getHeight(&ttex,x,z) + 0.8; // pos.y = pos.yy; camMatrix = lookAtv(pos,VectorAdd(forward,pos),up); modelView = IdentityMatrix(); total = Mult(camMatrix, modelView); glUseProgram(program); glUniformMatrix4fv(glGetUniformLocation(program, "mdlMatrix"), 1, GL_TRUE, total.m); glBindTexture(GL_TEXTURE_2D, tex1); // Bind Our Texture tex1 DrawModel(tm, program,"inPosition", "inNormal", "inTexCoord"); //total = Mult(Ry(2*t),T(10,0,0)); total = T(x,y,z); total = Mult(camMatrix,total); glUniformMatrix4fv(glGetUniformLocation(program, "mdlMatrix"), 1, GL_TRUE, total.m); glBindTexture(GL_TEXTURE_2D, tex2); // Bind Our Texture tex1 DrawModel(bunny, program, "inPosition", "inNormal", "inTexCoord"); printError("display 2"); glutSwapBuffers(); }