GLuint lightVao;
-Program *textureProg, *plainProg;
+Program *textureProg, *plainProg, *reflectProg;
Skybox *skybox;
glm::vec3 camPos = glm::vec3(0.0f, 0.0f, 0.0f);
glm::vec3 camUp = glm::vec3(0.0f, 1.0f, 0.0f);
float yaw = 1.57, pitch = 0;
bool doScale, doRotate, doTranslate;
-Model *chest;
-glm::vec3 lightPos(0);
+Model *chest, *mirrorCube;
+glm::vec3 lightPos(3);
const int WIDTH = 800, HEIGHT = 600;
const float ASPECT = (float)WIDTH / (float)HEIGHT;
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
float d = (float)glutGet(GLUT_ELAPSED_TIME) * 0.001f;
- skybox->draw(projMat(), viewMat());
-
glm::vec4 lightColor(1, 1, 1, 1);
drawLight(d, lightPos, lightColor);
setProjectionAndViewUniforms(textureProg->progId);
setLightColorAndPos(textureProg->progId, 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 *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 *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), lightPos); */
- chest->draw();
+ /* chest->draw(); */
+
+ mirrorCube->draw();
+
+ skybox->draw(projMat(), viewMat());
glutSwapBuffers();
}
glVertexAttribPointer(posLoc, 3, GL_FLOAT, GL_FALSE, 0, 0);
}
-void validateProgram(GLuint progId) {
- glValidateProgram(progId);
-
- GLint success;
- glGetProgramiv(progId, GL_VALIDATE_STATUS, &success);
- if (!success) {
- GLchar log[1024];
- glGetProgramInfoLog(progId, sizeof(log), NULL, log);
- fprintf(stderr, "error: %s\n", log);
- exit(1);
- }
-}
-
void init() {
plainProg = new Program("plainvertex.glsl", "plainfrag.glsl");
glUseProgram(plainProg->progId);
setupLightBuffers(plainProg->progId);
- validateProgram(plainProg->progId);
-
- textureProg = new Program("texturevertex.glsl", "texturefrag.glsl");
- glUseProgram(textureProg->progId);
-
- chest = new Model("models/chest.dae", *textureProg);
+ plainProg->validate();
std::vector<std::string> faces = {
"models/skybox/right.jpg",
};
skybox = new Skybox(faces);
+ textureProg = new Program("texturevertex.glsl", "texturefrag.glsl");
+ /* chest = new Model("models/chest.dae", *textureProg, *skybox); */
+
+ mirrorCube = new Model("models/mirrorCube.dae", *textureProg, *skybox);
+
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
}