void shutdown(void) { SGE_ASSERT(details::g_window != NULL); SGE_ASSERT(details::g_gl_context != NULL); SGE_ASSERT(s_imgui_context != NULL); shutdown_test(); s_program.Destroy(); ImGui::SetCurrentContext(s_imgui_context); ImGui_ImplOpenGL3_Shutdown(); ImGui_ImplSDL2_Shutdown(); ImGui::SetCurrentContext(NULL); ImGui::DestroyContext(s_imgui_context); s_imgui_context = NULL; if (details::g_gl_context == SDL_GL_GetCurrentContext()) SDL_GL_MakeCurrent(details::g_window, NULL); SDL_GL_DeleteContext(details::g_gl_context); details::g_gl_context = NULL; SDL_DestroyWindow(details::g_window); details::g_window = NULL; details::g_window_id = 0; }
static bool init_program(void) { if (!s_program.Create()) return false; SGE_LOGD("Building vertex shader...\n"); if (!s_program.AddShader(GL_VERTEX_SHADER, s_vertex_shader_source)) { SGE_LOGE("Failed to build vertex shader: %s\n", s_program.InfoLog()); s_program.Destroy(); return false; } SGE_LOGD("Building fragment shader...\n"); if (!s_program.AddShader(GL_FRAGMENT_SHADER, s_fragment_shader_source)) { SGE_LOGE("Failed to build fragment shader: %s\n", s_program.InfoLog()); s_program.Destroy(); return false; } SGE_LOGD("Linking program...\n"); if (!s_program.Link()) { SGE_LOGE("Failed to link program: %s\n", s_program.InfoLog()); s_program.Destroy(); return false; } // clearing uniform locations... for (int i = 0; i < UNIFORM_FLOAT_MAX; ++i) s_uniform_float_loc[i] = -1; for (int i = 0; i < UNIFORM_MAT4_MAX; ++i) s_uniform_mat4_loc[i] = -1; // getting uniform locations... s_uniform_mat4_loc[UNIFORM_MODEL_MATRIX] = s_program.UniformLocation("sge_model_matrix"); s_uniform_mat4_loc[UNIFORM_VIEW_MATRIX] = s_program.UniformLocation("sge_view_matrix"); s_uniform_mat4_loc[UNIFORM_PROJECTION_MATRIX] = s_program.UniformLocation("sge_projection_matrix"); return true; }