int main(void) { GLFWwindow* window; glfwSetErrorCallback(error_callback); if (!glfwInit()) exit(EXIT_FAILURE); window = glfwCreateWindow(1024, 768, "Simple example", NULL, NULL); if (!window) { glfwTerminate(); exit(EXIT_FAILURE); } glfwMakeContextCurrent(window); glfwSetKeyCallback(window, key_callback); // Initialize GLEW glewExperimental = true; // Needed for core profile if (glewInit() != GLEW_OK) { fprintf(stderr, "Failed to initialize GLEW\n"); return -1; } // Create and compile our GLSL program from the shaders GLuint programID = LoadShaders( "../resources/shaders/SimpleVertexShader.vertexshader", "../resources/shaders/SimpleFragmentShader.fragmentshader" ); initGL(); Tunnel *myTunnel = new Tunnel(vec3(0.0f,0.0f,1.0f), 2, 1.0f, 1.0f); Tunnel myTunnel2 = Tunnel(vec3(0.0f,0.0f,-3.0f), 2, 1.0f, 1.0f); for (int i=0; i<10; i++){ Cube3d *myCube = new Cube3d(0.5f, vec3(0.0f,0.0f,(GLfloat) -i)); myCubeVect.push_back(myCube); } //Cube3d *myCube = new Cube3d(0.5f); while (!glfwWindowShouldClose(window)) { playerPos = (int) camPosZ; int index = playerPos; if(index>10){ int div = (int) playerPos/10; index = playerPos - div*10; } // printf("playerPos=%d; index=%d\n", playerPos, index); if (index>0) { myCubeVect[index-1]->setTranslation(vec3(0.0f,0.0f,-10.0f)); } //myCube2->setTranslation(vec3(0.0f,0.0f,-playerPos)); /* Clear The Screen And The Depth Buffer */ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); float ratio; int width, height; glfwGetFramebufferSize(window, &width, &height); ratio = width / (float) height; glViewport(0, 0, width, height); // glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); /* Set our perspective */ gluPerspective( 45.0f, ratio, 0.1f, 500.0f ); //glOrtho(-ratio, ratio, -1.f, 1.f, 1.f, -1.f); //gluOrtho2D( 0,width,0,height ); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glLoadIdentity(); glRotatef(camRotY, 0.0f, 1.0f, 0.0f); //glTranslatef(0, 0, 5); glTranslatef(camPosX, camPosY, camPosZ); //>>>>>>>>>>>>>>>>>>START drawing our level<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< /*for(int i=0; i<myCubeVect.size(); ++i) { myCubeVect[i]->draw(); }*/ myTunnel->draw(); myTunnel2.draw(); /*glBegin(GL_LINES); glVertex3f(0.0f, 1.0f, 0.0f); glVertex3f(sinf(pi/4), cosf(pi/4),0.0f); glVertex3f(sinf(pi/4), cosf(pi/4),0.0f); glVertex3f(sinf(pi/2), cosf(pi/2),0.0f); glVertex3f(sinf(pi/2), cosf(pi/2),0.0f); glVertex3f(sinf(3*pi/4), cosf(3*pi/4),0.0f); glVertex3f(sinf(3*pi/4), cosf(3*pi/4),0.0f); glVertex3f(sinf(pi), cosf(pi),0.0f); glEnd();*/ rotTri+=3.0f; glfwSwapBuffers(window); glfwPollEvents(); } glfwDestroyWindow(window); glfwTerminate(); exit(EXIT_SUCCESS); }
void MapGenerator::JoinRooms(int a, int b) { Tunnel(rooms[a].Center(), rooms[b].Center()); }