From 2205493862c29cdbd0205f18489eb244e9ec1204 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Sat, 30 Dec 2017 17:01:23 +0200 Subject: [PATCH] Bug fixes in the SDL port --- Core/gb.c | 3 +-- SDL/main.c | 2 +- SDL/shader.c | 10 +++++++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Core/gb.c b/Core/gb.c index c612231..bf41891 100755 --- a/Core/gb.c +++ b/Core/gb.c @@ -5,11 +5,10 @@ #include #include #include -#include #ifndef _WIN32 #include -#endif #include +#endif #include "gb.h" void GB_attributed_logv(GB_gameboy_t *gb, GB_log_attributes attributes, const char *fmt, va_list args) diff --git a/SDL/main.c b/SDL/main.c index 62101c0..7db2df6 100755 --- a/SDL/main.c +++ b/SDL/main.c @@ -451,7 +451,7 @@ usage: SDL_GLContext gl_context = SDL_GL_CreateContext(window); - GLint major, minor; + GLint major = 0, minor = 0; glGetIntegerv(GL_MAJOR_VERSION, &major); glGetIntegerv(GL_MINOR_VERSION, &minor); diff --git a/SDL/shader.c b/SDL/shader.c index 7aebc88..a34866e 100644 --- a/SDL/shader.c +++ b/SDL/shader.c @@ -64,7 +64,7 @@ static GLuint create_program(const char *vsh, const char *fsh) bool init_shader_with_name(shader_t *shader, const char *name) { - GLint major, minor; + GLint major = 0, minor = 0; glGetIntegerv(GL_MAJOR_VERSION, &major); glGetIntegerv(GL_MINOR_VERSION, &minor); @@ -184,6 +184,14 @@ void render_bitmap_with_shader(shader_t *shader, void *bitmap, void *previous,un void free_shader(shader_t *shader) { + GLint major = 0, minor = 0; + glGetIntegerv(GL_MAJOR_VERSION, &major); + glGetIntegerv(GL_MINOR_VERSION, &minor); + + if (major * 0x100 + minor < 0x302) { + return; + } + glDeleteProgram(shader->program); glDeleteTextures(1, &shader->texture); glDeleteTextures(1, &shader->previous_texture);