From b1dd75ed87b0e57ecd1b9b9ed9107b80cced92dc Mon Sep 17 00:00:00 2001 From: dmaivel Date: Sat, 8 Jun 2024 20:21:07 -0400 Subject: [PATCH] Fix Windows ICD, applications above `1.1` run now * add windrv.h, WinDrvSetModuleAddress to get actual proc address * added wglGetExtensionsStringARB, wglCreateContextAttribsARB * added wglGetPixelFormatAttribivARB/fvARB, wglChoosePixelFormatARB --- inc/client/platform/windrv.h | 8 +++++ src/client/platform/windrv.c | 63 ++++++++++++++++++++++++++++++++---- src/client/winmain.c | 6 ++-- 3 files changed, 69 insertions(+), 8 deletions(-) create mode 100644 inc/client/platform/windrv.h diff --git a/inc/client/platform/windrv.h b/inc/client/platform/windrv.h new file mode 100644 index 0000000..1783014 --- /dev/null +++ b/inc/client/platform/windrv.h @@ -0,0 +1,8 @@ +#ifdef _WIN32 +#ifndef _WINDRV_H_ +#define _WINDRV_H_ + +void WinDrvSetModuleAddress(HMODULE module); + +#endif +#endif \ No newline at end of file diff --git a/src/client/platform/windrv.c b/src/client/platform/windrv.c index a90a643..c0a7c9c 100644 --- a/src/client/platform/windrv.c +++ b/src/client/platform/windrv.c @@ -3,6 +3,7 @@ #include #include #include +#include #include @@ -42,6 +43,57 @@ static struct pfd_depth_info pfd_depths[4] = { { 24, 8 } }; +static HMODULE g_hModule = 0; + +void WinDrvSetModuleAddress(HMODULE module) +{ + g_hModule = module; +} + +static const char *wgl_extensions = "WGL_ARB_create_context WGL_ARB_create_context_profile WGL_ARB_extensions_string WGL_ARB_pixel_format"; + +const char* wglGetExtensionsStringARB(HDC hdc) +{ + return wgl_extensions; +} + +HGLRC wglCreateContextAttribsARB(HDC hDC, HGLRC hShareContext, const int *attribList) +{ + return (HGLRC)1; +} + +BOOL wglGetPixelFormatAttribivARB(HDC hdc, + int iPixelFormat, + int iLayerPlane, + UINT nAttributes, + const int *piAttributes, + int *piValues) +{ + return TRUE; +} + +BOOL wglGetPixelFormatAttribfvARB(HDC hdc, + int iPixelFormat, + int iLayerPlane, + UINT nAttributes, + const int *piAttributes, + FLOAT *pfValues) +{ + return TRUE; +} + +BOOL wglChoosePixelFormatARB(HDC hdc, + const int *piAttribIList, + const FLOAT *pfAttribFList, + UINT nMaxFormats, + int *piFormats, + UINT *nNumFormats) +{ + *piFormats = 1; + *nNumFormats = 1; + return TRUE; +} + static void pfdAdd( bool doublebuffer, bool gdi, unsigned int accum, int rbits, int gbits, int bbits, int abits, @@ -168,13 +220,12 @@ BOOL APIENTRY DrvShareLists(DHGLRC dhglrc1, DHGLRC dhglrc2) PROC APIENTRY DrvGetProcAddress(LPCSTR lpszProc) { /* - * WGL Extensions + * WGL extensions, GL functions + * a table for WGL extensions makes sense, but we export every function so a table isn't needed + * commented out || (lpszProc[0] == 'w' && lpszProc[1] == 'g' && lpszProc[2] == 'l'), some apps dont like that part */ - if (lpszProc[0] == 'w' && lpszProc[1] == 'g' && lpszProc[2] == 'l') - return NULL; - - if (lpszProc[0] == 'g' && lpszProc[1] == 'l') - return GetProcAddress(GetModuleHandleW(NULL), lpszProc); + if ((lpszProc[0] == 'g' && lpszProc[1] == 'l')) + return GetProcAddress(g_hModule, lpszProc); return NULL; } diff --git a/src/client/winmain.c b/src/client/winmain.c index f2713d4..0240c83 100644 --- a/src/client/winmain.c +++ b/src/client/winmain.c @@ -1,7 +1,7 @@ #ifdef _WIN32 /* globbed */ #include -#include +#include #include VOID Main() @@ -14,8 +14,10 @@ VOID Main() BOOL APIENTRY DllMain(HMODULE module, DWORD reason, LPVOID reserved) { - if (reason == DLL_PROCESS_ATTACH) + if (reason == DLL_PROCESS_ATTACH) { + WinDrvSetModuleAddress(module); Main(); + } if (reason == DLL_PROCESS_DETACH) glimpl_goodbye();