X-Git-Url: http://git.lukelau.me/?p=opengl.git;a=blobdiff_plain;f=main.cpp;h=635e182dedd1ab047252afc38640c91dfb30b522;hp=fcc7a1eb90c033f6c1b3a5edec943ff759e16ac8;hb=be8759aec179d6d7bed58732134673870c596b4f;hpb=511a2c92fcb9dda82dd5d38b91ea03790d0cb7b2 diff --git a/main.cpp b/main.cpp index fcc7a1e..635e182 100644 --- a/main.cpp +++ b/main.cpp @@ -108,6 +108,7 @@ void drawLight(Light &light) { void display() { glClearColor(0.5, 0.5, 0.5, 1); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); + glViewport(0, 0, windowWidth * 2, windowHeight * 2); float d = (float)glutGet(GLUT_ELAPSED_TIME) * 0.001f; @@ -123,7 +124,7 @@ void display() { glUniform3fv(glGetUniformLocation(pbrProg->progId, "lightPositions"), 4, glm::value_ptr(lightPositions[0])); glUniform3fv(glGetUniformLocation(pbrProg->progId, "lightColors"), 4, glm::value_ptr(lightColors[0])); - pbr->draw(skyboxes[activeSkybox]); + pbr->draw(skyboxes[activeSkybox], d * 1000); for (Light &light: lights) drawLight(light); @@ -160,12 +161,14 @@ void init() { pbrProg = new Program("pbrvert.glsl", "pbrfrag.glsl"); glUseProgram(pbrProg->progId); - pbr = new Model("models/sphereMetal.gltf", *pbrProg); + pbr = new Model("models/newtonsCradle.gltf", *pbrProg); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); // prevent edge artifacts in specular cubemaps glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); + + glViewport(0, 0, windowWidth, windowHeight); } bool* keyStates = new bool[256]; @@ -248,7 +251,6 @@ void mouse(int button, int state, int x, int y) { } void reshape(int newWidth, int newHeight) { - glViewport(0, 0, newWidth * 2, newHeight * 2); windowWidth = newWidth, windowHeight = newHeight; } @@ -257,6 +259,7 @@ int main(int argc, char** argv) { glutInitDisplayMode(GLUT_DEPTH|GLUT_DOUBLE|GLUT_RGB|GLUT_3_2_CORE_PROFILE); glutInitWindowSize(windowWidth, windowHeight); int win = glutCreateWindow("Physically Based Rendering"); + makeRetina(); glutDisplayFunc(display); glutReshapeFunc(reshape); @@ -264,8 +267,6 @@ int main(int argc, char** argv) { init(); - makeRetina(); - glutKeyboardFunc(keyboard); glutKeyboardUpFunc(keyboardUp); glutTimerFunc(16, timer, 0);