Index: ddraw/glDirectDraw.cpp |
— | — | @@ -1264,6 +1264,8 @@ |
1265 | 1265 | {
|
1266 | 1266 | if(hRC)
|
1267 | 1267 | {
|
| 1268 | + DeleteShaders();
|
| 1269 | + DeleteFBO();
|
1268 | 1270 | wglMakeCurrent(NULL,NULL);
|
1269 | 1271 | wglDeleteContext(hRC);
|
1270 | 1272 | };
|
Index: ddraw/glExtensions.cpp |
— | — | @@ -21,6 +21,7 @@ |
22 | 22 | GLuint (APIENTRY *glCreateShader) (GLenum type) = NULL;
|
23 | 23 | void (APIENTRY *glShaderSource) (GLuint shader, GLsizei count, const GLchar** string, const GLint* length) = NULL;
|
24 | 24 | void (APIENTRY *glCompileShader) (GLuint shader) = NULL;
|
| 25 | +void (APIENTRY *glDeleteShader) (GLuint shader) = NULL;
|
25 | 26 | GLuint (APIENTRY *glCreateProgram) () = NULL;
|
26 | 27 | void (APIENTRY *glDeleteProgram) (GLuint program) = NULL;
|
27 | 28 | void (APIENTRY *glGetProgramiv) (GLuint program, GLenum pname, GLint* params) = NULL;
|
— | — | @@ -35,6 +36,7 @@ |
36 | 37 | void (APIENTRY *glBindRenderbuffer) (GLenum target, GLuint renderbuffer) = NULL;
|
37 | 38 | void (APIENTRY *glFramebufferTexture2D) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) = NULL;
|
38 | 39 | GLenum (APIENTRY *glCheckFramebufferStatus) (GLenum target) = NULL;
|
| 40 | +void (APIENTRY *glDeleteFramebuffers) (GLsizei n, const GLuint *framebuffers) = NULL;
|
39 | 41 |
|
40 | 42 | void (APIENTRY *glGenFramebuffersEXT) (GLsizei n, GLuint* ids) = NULL;
|
41 | 43 | void (APIENTRY *glBindFramebufferEXT) (GLenum target, GLuint framebuffer) = NULL;
|
— | — | @@ -42,6 +44,7 @@ |
43 | 45 | void (APIENTRY *glBindRenderbufferEXT) (GLenum target, GLuint renderbuffer) = NULL;
|
44 | 46 | void (APIENTRY *glFramebufferTexture2DEXT) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) = NULL;
|
45 | 47 | GLenum (APIENTRY *glCheckFramebufferStatusEXT) (GLenum target) = NULL;
|
| 48 | +void (APIENTRY *glDeleteFramebuffersEXT) (GLsizei n, const GLuint *framebuffers) = NULL;
|
46 | 49 |
|
47 | 50 | GLint (APIENTRY *glGetUniformLocation) (GLuint program, const GLchar* name) = NULL;
|
48 | 51 | void (APIENTRY *glUniform1i) (GLint location, GLint v0) = NULL;
|
— | — | @@ -86,6 +89,7 @@ |
87 | 90 | glCreateShader = (PFNGLCREATESHADERPROC)wglGetProcAddress("glCreateShader");
|
88 | 91 | glShaderSource = (PFNGLSHADERSOURCEPROC)wglGetProcAddress("glShaderSource");
|
89 | 92 | glCompileShader = (PFNGLCOMPILESHADERPROC)wglGetProcAddress("glCompileShader");
|
| 93 | + glDeleteShader = (PFNGLDELETESHADERPROC)wglGetProcAddress("glDeleteShader");
|
90 | 94 | glCreateProgram = (PFNGLCREATEPROGRAMPROC)wglGetProcAddress("glCreateProgram");
|
91 | 95 | glDeleteProgram = (PFNGLDELETEPROGRAMPROC)wglGetProcAddress("glDeleteProgram");
|
92 | 96 | glGetProgramiv = (PFNGLGETPROGRAMIVPROC)wglGetProcAddress("glGetProgramiv");
|
— | — | @@ -119,6 +123,7 @@ |
120 | 124 | glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)wglGetProcAddress("glBindRenderbuffer");
|
121 | 125 | glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)wglGetProcAddress("glFramebufferTexture2D");
|
122 | 126 | glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)wglGetProcAddress("glCheckFramebufferStatus");
|
| 127 | + glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)wglGetProcAddress("glDeleteFramebuffers");
|
123 | 128 | }
|
124 | 129 | if(GLEXT_EXT_framebuffer_object)
|
125 | 130 | {
|
— | — | @@ -128,6 +133,7 @@ |
129 | 134 | glBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC)wglGetProcAddress("glBindRenderbufferEXT");
|
130 | 135 | glFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC)wglGetProcAddress("glFramebufferTexture2D");
|
131 | 136 | glCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)wglGetProcAddress("glCheckFramebufferStatusEXT");
|
| 137 | + glDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC)wglGetProcAddress("glDeleteFramebuffersEXT");
|
132 | 138 | }
|
133 | 139 | wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT");
|
134 | 140 | wglGetSwapIntervalEXT = (PFNWGLGETSWAPINTERVALEXTPROC)wglGetProcAddress("wglGetSwapIntervalEXT");
|
Index: ddraw/glExtensions.h |
— | — | @@ -41,6 +41,7 @@ |
42 | 42 | GLAPI GLuint (APIENTRY *glCreateShader) (GLenum type);
|
43 | 43 | GLAPI void (APIENTRY *glShaderSource) (GLuint shader, GLsizei count, const GLchar** string, const GLint* length);
|
44 | 44 | GLAPI void (APIENTRY *glCompileShader) (GLuint shader);
|
| 45 | +GLAPI void (APIENTRY *glDeleteShader) (GLuint shader);
|
45 | 46 | GLAPI GLuint (APIENTRY *glCreateProgram) ();
|
46 | 47 | GLAPI void (APIENTRY *glDeleteProgram) (GLuint program);
|
47 | 48 | GLAPI void (APIENTRY *glGetProgramiv) (GLuint program, GLenum pname, GLint* params);
|
— | — | @@ -55,6 +56,7 @@ |
56 | 57 | GLAPI void (APIENTRY *glBindRenderbuffer) (GLenum target, GLuint renderbuffer);
|
57 | 58 | GLAPI void (APIENTRY *glFramebufferTexture2D) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
|
58 | 59 | GLAPI GLenum (APIENTRY *glCheckFramebufferStatus) (GLenum target);
|
| 60 | +GLAPI void (APIENTRY *glDeleteFramebuffers) (GLsizei n, const GLuint *framebuffers);
|
59 | 61 |
|
60 | 62 | GLAPI void (APIENTRY *glGenFramebuffersEXT) (GLsizei n, GLuint* ids);
|
61 | 63 | GLAPI void (APIENTRY *glBindFramebufferEXT) (GLenum target, GLuint framebuffer);
|
— | — | @@ -62,6 +64,7 @@ |
63 | 65 | GLAPI void (APIENTRY *glBindRenderbufferEXT) (GLenum target, GLuint renderbuffer);
|
64 | 66 | GLAPI void (APIENTRY *glFramebufferTexture2DEXT) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
|
65 | 67 | GLAPI GLenum (APIENTRY *glCheckFramebufferStatusEXT) (GLenum target);
|
| 68 | +GLAPI void (APIENTRY *glDeleteFramebuffersEXT) (GLsizei n, const GLuint *framebuffers);
|
66 | 69 |
|
67 | 70 | GLAPI GLint (APIENTRY *glGetUniformLocation) (GLuint program, const GLchar* name);
|
68 | 71 | GLAPI void (APIENTRY *glUniform1i) (GLint location, GLint v0);
|
Index: ddraw/glutil.cpp |
— | — | @@ -38,6 +38,15 @@ |
39 | 39 | }
|
40 | 40 | }
|
41 | 41 |
|
| 42 | +void DeleteFBO()
|
| 43 | +{
|
| 44 | + glBindFramebuffer(GL_FRAMEBUFFER,0);
|
| 45 | + if(GLEXT_ARB_framebuffer_object)
|
| 46 | + glDeleteFramebuffers(1,&fbo);
|
| 47 | + else if(GLEXT_EXT_framebuffer_object)
|
| 48 | + glDeleteFramebuffersEXT(1,&fbo);
|
| 49 | +}
|
| 50 | +
|
42 | 51 | GLenum SetFBO(GLint color, GLint z, bool stencil)
|
43 | 52 | {
|
44 | 53 | GLenum error;
|
Index: ddraw/glutil.h |
— | — | @@ -24,6 +24,7 @@ |
25 | 25 | extern bool stencil;
|
26 | 26 |
|
27 | 27 | void InitFBO();
|
| 28 | +void DeleteFBO();
|
28 | 29 | GLenum SetFBO(GLint color, GLint z, bool stencil);
|
29 | 30 |
|
30 | 31 | #endif //_GLUTIL_H |
\ No newline at end of file |
Index: ddraw/shaders.cpp |
— | — | @@ -147,3 +147,26 @@ |
148 | 148 | glLinkProgram(shaders[i].prog);
|
149 | 149 | }
|
150 | 150 | }
|
| 151 | +
|
| 152 | +void DeleteShaders()
|
| 153 | +{
|
| 154 | + glUseProgram(0);
|
| 155 | + for(int i = 0; i < NumberOfShaders; i++)
|
| 156 | + {
|
| 157 | + if(shaders[i].prog)
|
| 158 | + {
|
| 159 | + glDeleteProgram(shaders[i].prog);
|
| 160 | + shaders[i].prog = 0;
|
| 161 | + }
|
| 162 | + if(shaders[i].vs)
|
| 163 | + {
|
| 164 | + glDeleteShader(shaders[i].vs);
|
| 165 | + shaders[i].vs = 0;
|
| 166 | + }
|
| 167 | + if(shaders[i].fs)
|
| 168 | + {
|
| 169 | + glDeleteShader(shaders[i].fs);
|
| 170 | + shaders[i].fs = 0;
|
| 171 | + }
|
| 172 | + }
|
| 173 | +} |
\ No newline at end of file |
Index: ddraw/shaders.h |
— | — | @@ -38,5 +38,6 @@ |
39 | 39 | #define PROG_2CKEY 5
|
40 | 40 |
|
41 | 41 | void CompileShaders();
|
| 42 | +void DeleteShaders();
|
42 | 43 |
|
43 | 44 | #endif //__SHADERS_H |
\ No newline at end of file |