static void destroy_shader_program(shader_asset* shader) { Assert(shader->program_id != 0); glDeleteProgram(shader->program_id); CHECK_GL_ERROR(); destroy_shader(shader->vertex_shader_id); destroy_shader(shader->fragment_shader_id); shader->program_id = 0; }
int main(int argc, char const *argv[]) { GLFWwindow* window; glfwSetErrorCallback(error_callback); if(!glfwInit()) return EXIT_FAILURE; #if defined(__APPLE_CC__) glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); #else glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1); #endif window = glfwCreateWindow(800, 800, "cg-lab", NULL, NULL); if(!window) { glfwTerminate(); exit(EXIT_FAILURE); } glfwMakeContextCurrent(window); #if defined(_MSC_VER) glewExperimental = true; if (glewInit() != GL_NO_ERROR) { glfwTerminate(); exit(EXIT_FAILURE); } #endif glfwSetKeyCallback(window, key_callback); initialize_shader(); check(__LINE__); initialize_vao(); check(__LINE__); initialize_texture(); check(__LINE__); while(!glfwWindowShouldClose(window)) { draw(window); check(__LINE__); glfwSwapBuffers(window); glfwPollEvents(); } destroy_vao(); check(__LINE__); destroy_shader(); check(__LINE__); destroy_texture(); check(__LINE__); glfwDestroyWindow(window); glfwTerminate(); return EXIT_SUCCESS; }
int finalize() { /*bind_texture(texture, -1); destroy_imagebuffer(image); destroy_texture(texture);*/ cleanup_tetrahedrons(); destroy_shader(shader); return 0; }
void destroy_OGL() { destroy_shader(fragShader); destroy_shader(vertexShader); destroy_program(program); clear_attribute(vertPosAttrib); clear_attribute(texCoordAttrib); clear_uniform(colorUni); clear_uniform(diffuseSamplerUni); destroy_texture(whiteTexture); free(whiteTexture); free(program); free(fragShader); free(vertexShader); free(vertPosAttrib); free(texCoordAttrib); free(colorUni); free(diffuseSamplerUni); }