- float d = (float)glutGet(GLUT_ELAPSED_TIME) * 0.001f;
-
- /* glm::vec3 lightPos = glm::vec3(sin(d) * 10, 0, cos(d) * 10); */
- glm::vec3 lightPos = glm::vec3(0, 10, 10);
- glm::vec4 lightColor(1, 1, 1, 1);
-
- glViewport(0, 0, WIDTH, HEIGHT);
- /* drawPyramids(d, lightPos, lightColor); */
- drawLight(d, lightPos, lightColor);
-
- glUseProgram(solidProgId);
- setProjectionAndViewUniforms(solidProgId);
- setLightColorAndPos(solidProgId, lightPos, lightColor);
-
- GLuint colorLoc = glGetUniformLocation(solidProgId, "color");
- glm::vec4 c(1);
- glUniform4fv(colorLoc, 1, glm::value_ptr(c));
-
- monkeyHead->getRoot()->model = glm::translate(glm::mat4(1), glm::vec3(2, 0, 0));
- monkeyHead->draw();
-
- glUseProgram(textureProgId);
- setProjectionAndViewUniforms(textureProgId);
- setLightColorAndPos(textureProgId, lightPos, lightColor);
-
- Model::Node *top = chest->find("top");
- top->model = glm::translate(glm::mat4(1), glm::vec3(0, 1, -1));
- top->model = glm::rotate(top->model, sin(d / 2.5f) * 0.5f, glm::vec3(1, 0, 0));
- top->model = glm::translate(top->model, glm::vec3(0, -1, 1));
-
- /* Model::Node *jewels = chest->find("jewels"); */
- /* jewels->model = glm::scale(glm::mat4(1), glm::vec3((sin(d) + 1.2f) / 2.f)); */
-
- Model::Node *lock = chest->find("lock");
- lock->model = glm::translate(glm::mat4(1), glm::vec3(0.22610, 3.36478, -0.75649));
- lock->model = glm::rotate(lock->model, (d / 2.5f), glm::vec3(0, 1, 0.4));
- lock->model = glm::translate(lock->model, -glm::vec3(0.22610, 3.36478, -0.75649));
-
- Model::Node *key = chest->find("key");
- key->model = glm::translate(glm::mat4(1), glm::vec3(0, 0, sin(d)));
-
- chest->getRoot()->model = glm::translate(glm::mat4(1), chestPos);
- chest->draw();
-
- /* drawTeapot(teapotCamera, false, d, lightPos, lightColor); */
-
- /* glClear(GL_DEPTH_BUFFER_BIT); */
-
- /* glViewport(0, 0, WIDTH / 4, HEIGHT / 4); */
- /* drawTeapot(teapotOrtho, false, d, lightPos, lightColor); */
-
- /* glViewport(WIDTH / 4, 0, WIDTH / 4, HEIGHT / 4); */
- /* drawTeapot(teapotOrtho, true, d, lightPos, lightColor); */
-
- /* glViewport(WIDTH / 4 * 2, 0, WIDTH / 4, HEIGHT / 4); */
- /* drawTeapot(teapotPerspStatic, false, d, lightPos, lightColor); */
-
- /* glViewport(WIDTH / 4 * 3, 0, WIDTH / 4, HEIGHT / 4); */
- /* drawTeapot(teapotPerspAnimated, false, d, lightPos, lightColor); */
-
-
- glutSwapBuffers();
-}
-
-void attachShader(GLuint progId, const char* filePath, GLenum type) {
- GLuint shader = glCreateShader(type);
-
- if (!shader) {
- fprintf(stderr, "error creating shader\n");
- exit(1);
- }
-
- ifstream file(filePath);
- stringstream buffer;
- buffer << file.rdbuf();
- string str = buffer.str();
- const char* contents = str.c_str();
-
- glShaderSource(shader, 1, (const GLchar**)&contents, NULL);
- glCompileShader(shader);
- GLint success;
- glGetShaderiv(shader, GL_COMPILE_STATUS, &success);
- if (!success) {
- GLchar log[1024];
- glGetShaderInfoLog(shader, 1024, NULL, log);
- fprintf(stderr, "error: %s\n", log);
- exit(1);
- }
- glAttachShader(progId, shader);
-}