From 6d1136d09a928e9817fa1338488646bc06edb9de Mon Sep 17 00:00:00 2001 From: Joey de Vries Date: Wed, 29 Apr 2020 11:57:45 +0200 Subject: [PATCH] Update debugging example code to match Debugging chapter updates. --- .../hello_triangle_indexed.cpp | 1 + .../hello_triangle_exercise2.cpp | 1 + src/7.in_practice/1.debugging/debugging.cpp | 26 +++++++++---------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/1.getting_started/2.2.hello_triangle_indexed/hello_triangle_indexed.cpp b/src/1.getting_started/2.2.hello_triangle_indexed/hello_triangle_indexed.cpp index e791687..ffd8ef1 100644 --- a/src/1.getting_started/2.2.hello_triangle_indexed/hello_triangle_indexed.cpp +++ b/src/1.getting_started/2.2.hello_triangle_indexed/hello_triangle_indexed.cpp @@ -170,6 +170,7 @@ int main() glDeleteVertexArrays(1, &VAO); glDeleteBuffers(1, &VBO); glDeleteBuffers(1, &EBO); + glDeleteProgram(shaderProgram); // glfw: terminate, clearing all previously allocated GLFW resources. // ------------------------------------------------------------------ diff --git a/src/1.getting_started/2.4.hello_triangle_exercise2/hello_triangle_exercise2.cpp b/src/1.getting_started/2.4.hello_triangle_exercise2/hello_triangle_exercise2.cpp index f4f4ccb..cf451b0 100644 --- a/src/1.getting_started/2.4.hello_triangle_exercise2/hello_triangle_exercise2.cpp +++ b/src/1.getting_started/2.4.hello_triangle_exercise2/hello_triangle_exercise2.cpp @@ -164,6 +164,7 @@ int main() // ------------------------------------------------------------------------ glDeleteVertexArrays(2, VAOs); glDeleteBuffers(2, VBOs); + glDeleteProgram(shaderProgram); // glfw: terminate, clearing all previously allocated GLFW resources. // ------------------------------------------------------------------ diff --git a/src/7.in_practice/1.debugging/debugging.cpp b/src/7.in_practice/1.debugging/debugging.cpp index 6b1cde4..cde6d17 100644 --- a/src/7.in_practice/1.debugging/debugging.cpp +++ b/src/7.in_practice/1.debugging/debugging.cpp @@ -43,10 +43,10 @@ GLenum glCheckError_(const char *file, int line) void APIENTRY glDebugOutput(GLenum source, GLenum type, - GLuint id, + unsigned int id, GLenum severity, GLsizei length, - const GLchar *message, + const char *message, const void *userParam) { if(id == 131169 || id == 131185 || id == 131218 || id == 131204) return; // ignore these non-significant error codes @@ -95,7 +95,7 @@ int main() glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); - glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE); // comment this line in a release build! + glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, true); // comment this line in a release build! #ifdef __APPLE__ glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); @@ -125,7 +125,7 @@ int main() } // enable OpenGL debug context if context allows for debug context - GLint flags; glGetIntegerv(GL_CONTEXT_FLAGS, &flags); + int flags; glGetIntegerv(GL_CONTEXT_FLAGS, &flags); if (flags & GL_CONTEXT_FLAG_DEBUG_BIT) { glEnable(GL_DEBUG_OUTPUT); @@ -143,10 +143,10 @@ int main() Shader shader("debugging.vs", "debugging.fs"); // configure 3D cube - GLuint cubeVAO, cubeVBO; - GLfloat vertices[] = { + unsigned int cubeVAO, cubeVBO; + float vertices[] = { // back face - -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, // Bottom-left + -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, // bottom-left 0.5f, 0.5f, -0.5f, 1.0f, 1.0f, // top-right 0.5f, -0.5f, -0.5f, 1.0f, 0.0f, // bottom-right 0.5f, 0.5f, -0.5f, 1.0f, 1.0f, // top-right @@ -196,9 +196,9 @@ int main() // link vertex attributes glBindVertexArray(cubeVAO); glEnableVertexAttribArray(0); - glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), (GLvoid*)0); + glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)0); glEnableVertexAttribArray(1); - glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), (GLvoid*)(3 * sizeof(GLfloat))); + glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)(3 * sizeof(float))); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindVertexArray(0); @@ -243,8 +243,8 @@ int main() glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); shader.use(); - GLfloat rotationSpeed = 10.0f; - GLfloat angle = (float)glfwGetTime() * rotationSpeed; + float rotationSpeed = 10.0f; + float angle = (float)glfwGetTime() * rotationSpeed; glm::mat4 model = glm::mat4(1.0f); model = glm::translate(model, glm::vec3(0.0, 0.0f, -2.5)); model = glm::rotate(model, glm::radians(angle), glm::vec3(1.0f, 1.0f, 1.0f)); @@ -277,8 +277,8 @@ void renderQuad() // positions // texture Coords -1.0f, 1.0f, 0.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 0.0f, 0.0f, - 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, - 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, + 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, }; // setup plane VAO glGenVertexArrays(1, &quadVAO);