#52 Possible fix for getting shaders to work on macOS

This commit is contained in:
FunkyFr3sh 2020-10-23 03:17:03 +02:00
parent e295515694
commit 7d4075e314
6 changed files with 891 additions and 3 deletions

View file

@ -81,6 +81,7 @@ PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus;
PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers;
PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT;
PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB;
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB;
PFNGLTEXBUFFERPROC glTexBuffer;
HMODULE g_oglu_hmodule;
@ -206,7 +207,13 @@ void oglu_init()
glCheckFramebufferStatus && glUniform4f && glActiveTexture && glUniform1i &&
glGetAttribLocation && glGenBuffers && glBindBuffer && glBufferData && glVertexAttribPointer &&
glEnableVertexAttribArray && glUniform2fv && glUniformMatrix4fv && glGenVertexArrays && glBindVertexArray &&
glGetUniformLocation && glversion && glversion[0] != '2';
glGetUniformLocation;
if (g_oglu_got_version3 && glversion && glversion[0] == '2') // macOS
{
g_oglu_got_version3 = FALSE;
wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)xwglGetProcAddress("wglCreateContextAttribsARB");
}
}
BOOL oglu_ext_exists(char *ext, HDC hdc)

View file

@ -10,6 +10,7 @@
#include "debug.h"
static HGLRC ogl_create_core_context(HDC hdc);
static HGLRC ogl_create_context(HDC hdc);
static void ogl_set_max_fps();
static void ogl_build_programs();
@ -32,6 +33,9 @@ DWORD WINAPI ogl_render_main(void)
if (g_ogl.context)
{
oglu_init();
g_ogl.context = ogl_create_core_context(g_ddraw->render.hdc);
ogl_set_max_fps();
ogl_build_programs();
ogl_create_textures(g_ddraw->width, g_ddraw->height);
@ -58,6 +62,34 @@ DWORD WINAPI ogl_render_main(void)
return 0;
}
static HGLRC ogl_create_core_context(HDC hdc)
{
if (!wglCreateContextAttribsARB)
return g_ogl.context;
int attribs[] = {
WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
WGL_CONTEXT_MINOR_VERSION_ARB, 2,
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
0 };
HGLRC context = wglCreateContextAttribsARB(hdc, 0, attribs);
BOOL made_current = context && xwglMakeCurrent(hdc, context);
if (made_current)
{
g_oglu_got_version3 = TRUE;
xwglDeleteContext(g_ogl.context);
return context;
}
else if (context)
{
xwglDeleteContext(context);
}
return g_ogl.context;
}
static HGLRC ogl_create_context(HDC hdc)
{
HGLRC context = xwglCreateContext(hdc);