diff options
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp index a2ea0b8..04c1001 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -99,6 +99,7 @@ int main() gpuModel->set({triangles.data(), triangles.size()}, DeviceMemory::StorageType::STATIC); Texture2D model_texture(image); + delete image; DeviceMemory *model_gpu_texcoords = model_frame.get_input_by_name("texcoord_vert"); model_gpu_texcoords->set({texture_coords.data(), texture_coords.size()}, DeviceMemory::StorageType::STATIC); @@ -110,6 +111,9 @@ int main() proj_uniform->set(proj); tex_uniform->set(model_texture); + triangles.resize(0); + texture_coords.resize(0); + Userdata userdata; userdata.cam_dist = 3.0f; glm::vec3 character_pos(0.0f, 0.0f, userdata.cam_dist); @@ -190,7 +194,6 @@ int main() glfwSwapBuffers(window); } - delete image; //glfwTerminate(); return 0; } @@ -213,6 +216,7 @@ void create_sand(DeviceMemory *triangles, DeviceMemory *texcoords, Texture2D *te } Texture2D height_map_texture(height_map_image.unwrap()); + delete height_map_image.unwrap(); *texture = std::move(height_map_texture); texcoords->set({height_map_texcoord.data(), height_map_texcoord.size()}, DeviceMemory::StorageType::STATIC); } @@ -226,6 +230,12 @@ void glfwErrorHandler(int errorCode, const char *errorDescription) printf("GLFW error code: %d, description: %s\n", errorCode, errorDescription); } +static void GLAPIENTRY gl_debug_callback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *user_param) { + fprintf(stderr, "##### OPENGL ERROR #####\n"); + fprintf(stderr, "source: %d, type: %d, id: %d, severity: %d, message: %s\n", source, type, id, severity, message); + fprintf(stderr, "########################\n"); +} + void initGlfw() { if(!glfwInit()) @@ -240,6 +250,19 @@ void initGlfw() glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_RESIZABLE, GL_FALSE); + + // TODO: Only enable in debugging mode + glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE); + GLint flags; + glGetIntegerv(GL_CONTEXT_FLAGS, &flags); + if(flags & GL_CONTEXT_FLAG_DEBUG_BIT) { + glEnable(GL_DEBUG_OUTPUT); + glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); + glDebugMessageCallback(gl_debug_callback, nullptr); + glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, nullptr, GL_TRUE); + } else { + fprintf(stderr, "Warning: failed to enable gl debugging\n"); + } } void initGlew() { @@ -249,6 +272,7 @@ void initGlew() { glfwTerminate(); exit(-1); } + glGetError(); // Reset error to none } GLFWwindow* createWindow() { |