mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-24 17:49:52 +01:00
detach shaders and delete program
This commit is contained in:
parent
b053bc377e
commit
d55a025ee2
@ -130,7 +130,7 @@ BOOL OpenGL_ExtExists(char *ext)
|
|||||||
GLuint OpenGL_BuildProgram(const GLchar **vertSource, const GLchar **fragSource)
|
GLuint OpenGL_BuildProgram(const GLchar **vertSource, const GLchar **fragSource)
|
||||||
{
|
{
|
||||||
if (!glCreateShader || !glShaderSource || !glCompileShader || !glCreateProgram ||
|
if (!glCreateShader || !glShaderSource || !glCompileShader || !glCreateProgram ||
|
||||||
!glAttachShader || !glLinkProgram || !glUseProgram)
|
!glAttachShader || !glLinkProgram || !glUseProgram || !glDetachShader)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
GLuint vertShader = glCreateShader(GL_VERTEX_SHADER);
|
GLuint vertShader = glCreateShader(GL_VERTEX_SHADER);
|
||||||
@ -178,6 +178,11 @@ GLuint OpenGL_BuildProgram(const GLchar **vertSource, const GLchar **fragSource)
|
|||||||
|
|
||||||
glLinkProgram(program);
|
glLinkProgram(program);
|
||||||
|
|
||||||
|
glDetachShader(program, vertShader);
|
||||||
|
glDetachShader(program, fragShader);
|
||||||
|
glDeleteShader(vertShader);
|
||||||
|
glDeleteShader(fragShader);
|
||||||
|
|
||||||
if (glGetProgramiv)
|
if (glGetProgramiv)
|
||||||
{
|
{
|
||||||
GLint isLinked = 0;
|
GLint isLinked = 0;
|
||||||
|
13
src/render.c
13
src/render.c
@ -46,10 +46,6 @@ const GLchar *PaletteFragShaderSrc =
|
|||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
|
|
||||||
GLuint SurfaceTexId, PaletteTexId;
|
|
||||||
GLint SurfaceUniLoc, PaletteUniLoc;
|
|
||||||
GLuint PaletteConvProgram;
|
|
||||||
|
|
||||||
BOOL detect_cutscene();
|
BOOL detect_cutscene();
|
||||||
|
|
||||||
DWORD WINAPI render_main(void)
|
DWORD WINAPI render_main(void)
|
||||||
@ -86,10 +82,10 @@ DWORD WINAPI render_main(void)
|
|||||||
int tex_size = tex_width * tex_height * sizeof(int);
|
int tex_size = tex_width * tex_height * sizeof(int);
|
||||||
int *tex = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, tex_size);
|
int *tex = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, tex_size);
|
||||||
|
|
||||||
if (!PaletteConvProgram)
|
GLuint PaletteConvProgram = OpenGL_BuildProgram(&PaletteVertShaderSrc, &PaletteFragShaderSrc);
|
||||||
PaletteConvProgram = OpenGL_BuildProgram(&PaletteVertShaderSrc, &PaletteFragShaderSrc);
|
|
||||||
|
|
||||||
// primary surface texture
|
// primary surface texture
|
||||||
|
GLuint SurfaceTexId = 0;
|
||||||
glGenTextures(1, &SurfaceTexId);
|
glGenTextures(1, &SurfaceTexId);
|
||||||
glBindTexture(GL_TEXTURE_2D, SurfaceTexId);
|
glBindTexture(GL_TEXTURE_2D, SurfaceTexId);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
@ -101,6 +97,7 @@ DWORD WINAPI render_main(void)
|
|||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, tex_width, tex_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, tex);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, tex_width, tex_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, tex);
|
||||||
|
|
||||||
// palette texture
|
// palette texture
|
||||||
|
GLuint PaletteTexId = 0;
|
||||||
glGenTextures(1, &PaletteTexId);
|
glGenTextures(1, &PaletteTexId);
|
||||||
glBindTexture(GL_TEXTURE_2D, PaletteTexId);
|
glBindTexture(GL_TEXTURE_2D, PaletteTexId);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
@ -115,6 +112,7 @@ DWORD WINAPI render_main(void)
|
|||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
|
||||||
|
GLint SurfaceUniLoc = 0, PaletteUniLoc = 0;
|
||||||
if (PaletteConvProgram)
|
if (PaletteConvProgram)
|
||||||
{
|
{
|
||||||
glUseProgram(PaletteConvProgram);
|
glUseProgram(PaletteConvProgram);
|
||||||
@ -237,6 +235,9 @@ DWORD WINAPI render_main(void)
|
|||||||
glDeleteTextures(1, &SurfaceTexId);
|
glDeleteTextures(1, &SurfaceTexId);
|
||||||
glDeleteTextures(1, &PaletteTexId);
|
glDeleteTextures(1, &PaletteTexId);
|
||||||
|
|
||||||
|
if (PaletteConvProgram && glDeleteProgram)
|
||||||
|
glDeleteProgram(PaletteConvProgram);
|
||||||
|
|
||||||
wglMakeCurrent(NULL, NULL);
|
wglMakeCurrent(NULL, NULL);
|
||||||
wglDeleteContext(hRC);
|
wglDeleteContext(hRC);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user