diff --git a/inc/opengl_utils.h b/inc/opengl_utils.h index b201b07..c4fb9b2 100644 --- a/inc/opengl_utils.h +++ b/inc/opengl_utils.h @@ -37,7 +37,7 @@ BOOL oglu_load_dll(); void oglu_init(); BOOL oglu_ext_exists(char *ext, HDC hdc); GLuint oglu_build_program(const GLchar *vert_source, const GLchar *frag_source); -GLuint oglu_build_program_from_file(const char *file_path); +GLuint oglu_build_program_from_file(const char *file_path, BOOL core_profile); extern PFNGLVIEWPORTPROC glViewport; extern PFNGLBINDTEXTUREPROC glBindTexture; diff --git a/src/opengl_utils.c b/src/opengl_utils.c index ad14929..15f7cbc 100644 --- a/src/opengl_utils.c +++ b/src/opengl_utils.c @@ -317,7 +317,7 @@ GLuint oglu_build_program(const GLchar *vert_source, const GLchar *frag_source) return program; } -GLuint oglu_build_program_from_file(const char *file_path) +GLuint oglu_build_program_from_file(const char *file_path, BOOL core_profile) { GLuint program = 0; @@ -344,6 +344,15 @@ GLuint oglu_build_program_from_file(const char *file_path) if (version_start) { + if (core_profile) + { + if (strnicmp(version_start, "#version 130", 12) == 0 || + strnicmp(version_start, "#version 140", 12) == 0) + { + memcpy(version_start, "#version 150", 12); + } + } + const char deli[2] = "\n"; char *version = strtok(version_start, deli); @@ -358,8 +367,10 @@ GLuint oglu_build_program_from_file(const char *file_path) } else { - strcpy(vert_source, "#define VERTEX\n"); - strcpy(frag_source, "#define FRAGMENT\n"); + strcpy(vert_source, core_profile ? "#version 150\n" : "#version 130\n"); + strcpy(frag_source, core_profile ? "#version 150\n" : "#version 130\n"); + strcat(vert_source, "#define VERTEX\n"); + strcat(frag_source, "#define FRAGMENT\n"); strcat(vert_source, source); strcat(frag_source, source); diff --git a/src/render_ogl.c b/src/render_ogl.c index 48a4a1b..162fec9 100644 --- a/src/render_ogl.c +++ b/src/render_ogl.c @@ -140,7 +140,7 @@ static void ogl_build_programs() if (g_ogl.main_program) { - g_ogl.scale_program = oglu_build_program_from_file(g_ddraw->shader); + g_ogl.scale_program = oglu_build_program_from_file(g_ddraw->shader, wglCreateContextAttribsARB != NULL); } else {