diff --git a/Debug/Window_practice.exe b/Debug/Window_practice.exe index 4aa9ca9..60f6fff 100644 Binary files a/Debug/Window_practice.exe and b/Debug/Window_practice.exe differ diff --git a/Debug/Window_practice.pdb b/Debug/Window_practice.pdb index 057df45..fff6533 100644 Binary files a/Debug/Window_practice.pdb and b/Debug/Window_practice.pdb differ diff --git a/Window_practice/Debug/Main.obj b/Window_practice/Debug/Main.obj index e6646d7..8565a4a 100644 Binary files a/Window_practice/Debug/Main.obj and b/Window_practice/Debug/Main.obj differ diff --git a/Window_practice/Debug/Window_practice.ilk b/Window_practice/Debug/Window_practice.ilk index 418ac8e..d1f377a 100644 Binary files a/Window_practice/Debug/Window_practice.ilk and b/Window_practice/Debug/Window_practice.ilk differ diff --git a/Window_practice/Debug/vc142.idb b/Window_practice/Debug/vc142.idb index 36c22ed..08b7222 100644 Binary files a/Window_practice/Debug/vc142.idb and b/Window_practice/Debug/vc142.idb differ diff --git a/Window_practice/Debug/vc142.pdb b/Window_practice/Debug/vc142.pdb index 1e30569..ab9c5d6 100644 Binary files a/Window_practice/Debug/vc142.pdb and b/Window_practice/Debug/vc142.pdb differ diff --git a/Window_practice/src/Main.cpp b/Window_practice/src/Main.cpp index 9476c93..862fadf 100644 --- a/Window_practice/src/Main.cpp +++ b/Window_practice/src/Main.cpp @@ -112,9 +112,7 @@ int main(void){ } //Main window creation - GLFWwindow* window; - - window = glfwCreateWindow(640, 480, "OpenGl practice", NULL, NULL); + GLFWwindow* window = glfwCreateWindow(640, 480, "OpenGl practice", NULL, NULL); if (!window){ std::cout << "Window could not be created!" << std::endl; glfwTerminate(); @@ -123,9 +121,11 @@ int main(void){ glfwMakeContextCurrent(window); + glfwSwapInterval(1); //v-sync + //GLEW init if (glewInit() != GLEW_OK) { - std::cout << "GLEW Error" << std::endl; + std::cout << "GLEW could not be initialized" << std::endl; return -1; } @@ -169,15 +169,30 @@ int main(void){ unsigned int shader = CreateShader(source.VertexSource, source.FragmentSource); glUseProgram(shader); + //need to bound a shader before this + GLCall(int location = glGetUniformLocation(shader, "u_Color")); //finding u_Color location + ASSERT(location != -1); + GLCall(glUniform4f(location, 0.8f, 0.3f, 0.8f, 1.0f)); + GLCall(glBindBuffer(GL_ARRAY_BUFFER, 0)); //unbinding the buffer + float r = 0.0f; + float increment = 0.05f; //Main loop while (!glfwWindowShouldClose(window)){ /* Render here */ GLCall(glClear(GL_COLOR_BUFFER_BIT)); + GLCall(glUniform4f(location, r, 0.3f, 0.8f, 1.0f)); GLCall(glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, nullptr)); + if (r > 1.0f) + increment = -0.05f; + else if (r < 0.0f) + increment = 0.05f; + + r += increment; + /* Swap front and back buffers */ GLCall(glfwSwapBuffers(window));