MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / opengl_Close

Function opengl_Close

renderer/HardwareOpenGL.cpp:816–877  ·  view source on GitHub ↗

Releases the rendering context

Source from the content-addressed store, hash-verified

814
815// Releases the rendering context
816void opengl_Close(const bool just_resizing) {
817 CHECK_ERROR(5)
818
819 uint32_t *delete_list = (uint32_t *)mem_malloc(Cur_texture_object_num * sizeof(int));
820 ASSERT(delete_list);
821 for (int i = 1; i < Cur_texture_object_num; i++)
822 delete_list[i] = i;
823
824 if (Cur_texture_object_num > 1)
825 dglDeleteTextures(Cur_texture_object_num, (const uint32_t *)delete_list);
826
827 mem_free(delete_list);
828
829 if (GSDLGLContext) {
830 SDL_GL_MakeCurrent(NULL, NULL);
831 SDL_GL_DeleteContext(GSDLGLContext);
832 GSDLGLContext = NULL;
833 GOpenGLFBOWidth = GOpenGLFBOHeight = GOpenGLFBO = GOpenGLRBOColor = GOpenGLRBODepth = 0;
834 }
835
836 if (!just_resizing && GSDLWindow) {
837 SDL_DestroyWindow(GSDLWindow);
838 GSDLWindow = NULL;
839 }
840
841
842 if (OpenGL_packed_pixels) {
843 if (opengl_packed_Upload_data) {
844 mem_free(opengl_packed_Upload_data);
845 }
846 if (opengl_packed_Translate_table) {
847 mem_free(opengl_packed_Translate_table);
848 }
849 if (opengl_packed_4444_translate_table) {
850 mem_free(opengl_packed_4444_translate_table);
851 }
852 opengl_packed_Upload_data = NULL;
853 opengl_packed_Translate_table = NULL;
854 opengl_packed_4444_translate_table = NULL;
855 } else {
856 if (opengl_Upload_data)
857 mem_free(opengl_Upload_data);
858 if (opengl_Translate_table)
859 mem_free(opengl_Translate_table);
860 if (opengl_4444_translate_table)
861 mem_free(opengl_4444_translate_table);
862 opengl_Upload_data = NULL;
863 opengl_Translate_table = NULL;
864 opengl_4444_translate_table = NULL;
865 }
866
867 if (OpenGL_cache_initted) {
868 mem_free(OpenGL_lightmap_remap);
869 mem_free(OpenGL_bitmap_remap);
870 mem_free(OpenGL_lightmap_states);
871 mem_free(OpenGL_bitmap_states);
872 OpenGL_cache_initted = 0;
873 }

Callers 4

opengl_InitFunction · 0.70
rend_CloseFunction · 0.70
rend_ReInitFunction · 0.70
rend_CloseOpenGLWindowFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected