1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-15 06:04:49 +01:00

adjust version numbers on shaders for core profiles

This commit is contained in:
FunkyFr3sh 2021-02-22 12:10:21 +01:00
parent c333ff832a
commit 8f8fd74e3b
3 changed files with 16 additions and 5 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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
{