From 0114162c95c1ec7f561f02cfa2513ff2386c7579 Mon Sep 17 00:00:00 2001 From: rich_b <56879808+rbarkmore@users.noreply.github.com> Date: Fri, 19 Jun 2020 08:25:13 -0400 Subject: [PATCH] Fix 'use' and 'ID' in two places each, delete second main() --- .../2.text_rendering/text_rendering.cpp | 36 +++---------------- 1 file changed, 4 insertions(+), 32 deletions(-) diff --git a/src/7.in_practice/2.text_rendering/text_rendering.cpp b/src/7.in_practice/2.text_rendering/text_rendering.cpp index 9ac0a84..7b54a70 100644 --- a/src/7.in_practice/2.text_rendering/text_rendering.cpp +++ b/src/7.in_practice/2.text_rendering/text_rendering.cpp @@ -76,8 +76,8 @@ int main() // ---------------------------- Shader shader("text.vs", "text.fs"); glm::mat4 projection = glm::ortho(0.0f, static_cast(SCR_WIDTH), 0.0f, static_cast(SCR_HEIGHT)); - shader.Use(); - glUniformMatrix4fv(glGetUniformLocation(shader.Program, "projection"), 1, GL_FALSE, glm::value_ptr(projection)); + shader.use(); + glUniformMatrix4fv(glGetUniformLocation(shader.ID, "projection"), 1, GL_FALSE, glm::value_ptr(projection)); // FreeType // -------- @@ -179,34 +179,6 @@ int main() return 0; } -// The MAIN function, from here we start our application and run the Game loop -int main() -{ - // Init GLFW - glfwInit(); - glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); - glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); - glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); - glfwWindowHint(GLFW_RESIZABLE, GL_FALSE); - - GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "LearnOpenGL", nullptr, nullptr); // Windowed - glfwMakeContextCurrent(window); - - // Initialize GLEW to setup the OpenGL Function pointers - glewExperimental = GL_TRUE; - glewInit(); - - // Define the viewport dimensions - glViewport(0, 0, WIDTH, HEIGHT); - - // Set OpenGL options - glEnable(GL_CULL_FACE); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - -} - // process all input: query GLFW whether relevant keys are pressed/released this frame and react accordingly // --------------------------------------------------------------------------------------------------------- void processInput(GLFWwindow *window) @@ -230,8 +202,8 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) void RenderText(Shader &shader, std::string text, float x, float y, float scale, glm::vec3 color) { // activate corresponding render state - shader.Use(); - glUniform3f(glGetUniformLocation(shader.Program, "textColor"), color.x, color.y, color.z); + shader.use(); + glUniform3f(glGetUniformLocation(shader.ID, "textColor"), color.x, color.y, color.z); glActiveTexture(GL_TEXTURE0); glBindVertexArray(VAO);