mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-16 01:11:44 +00:00
Fix OpenGL under SDL && Windows. (Almost. SDL 1.2 works fine, but SDL2 has an unresolved problem where OpenGL screen updates flicker over a black background.)
git-svn-id: https://svn.eduke32.com/eduke32@4088 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
75b6e81a2a
commit
7b551ba4fb
2 changed files with 35 additions and 15 deletions
|
@ -294,11 +294,17 @@ bwglGetPixelFormatProcPtr bwglGetPixelFormat;
|
|||
bwglSetPixelFormatProcPtr bwglSetPixelFormat;
|
||||
bwglSwapIntervalEXTProcPtr bwglSwapIntervalEXT;
|
||||
bwglCreateContextAttribsARBProcPtr bwglCreateContextAttribsARB;
|
||||
|
||||
static HMODULE hGLDLL, hGLUDLL;
|
||||
#else
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
#if !defined RENDERTYPESDL && defined _WIN32
|
||||
static HMODULE hGLDLL;
|
||||
#endif
|
||||
|
||||
#if defined _WIN32
|
||||
static HMODULE hGLUDLL;
|
||||
#else
|
||||
static void *gluhandle = NULL;
|
||||
#endif
|
||||
|
||||
|
@ -332,7 +338,7 @@ int32_t loadgldriver(const char *driver)
|
|||
{
|
||||
int32_t err=0;
|
||||
|
||||
#ifdef _WIN32
|
||||
#if !defined RENDERTYPESDL && defined _WIN32
|
||||
if (hGLDLL) return 0;
|
||||
#endif
|
||||
|
||||
|
@ -348,10 +354,18 @@ int32_t loadgldriver(const char *driver)
|
|||
}
|
||||
|
||||
#if defined RENDERTYPESDL
|
||||
if (SDL_GL_LoadLibrary(driver)) goto fail;
|
||||
if (SDL_GL_LoadLibrary(driver))
|
||||
{
|
||||
initprintf("Failed loading \"%s\": %s\n", driver, SDL_GetError());
|
||||
return -1;
|
||||
}
|
||||
#elif defined _WIN32
|
||||
hGLDLL = LoadLibrary(driver);
|
||||
if (!hGLDLL) goto fail;
|
||||
if (!hGLDLL)
|
||||
{
|
||||
initprintf("Failed loading \"%s\"\n", driver);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
gldriver = Bstrdup(driver);
|
||||
|
||||
|
@ -485,16 +499,12 @@ int32_t loadgldriver(const char *driver)
|
|||
|
||||
if (err) unloadgldriver();
|
||||
return err;
|
||||
|
||||
fail:
|
||||
initprintf("Failed loading \"%s\"\n",driver);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t loadglextensions(void)
|
||||
{
|
||||
int32_t err = 0;
|
||||
#ifdef _WIN32
|
||||
#if !defined RENDERTYPESDL && defined _WIN32
|
||||
if (!hGLDLL) return 0;
|
||||
#endif
|
||||
|
||||
|
@ -648,14 +658,14 @@ int32_t unloadgldriver(void)
|
|||
{
|
||||
unloadglulibrary();
|
||||
|
||||
#ifdef _WIN32
|
||||
#if !defined RENDERTYPESDL && defined _WIN32
|
||||
if (!hGLDLL) return 0;
|
||||
#endif
|
||||
|
||||
Bfree(gldriver);
|
||||
gldriver = NULL;
|
||||
|
||||
#ifdef _WIN32
|
||||
#if !defined RENDERTYPESDL && defined _WIN32
|
||||
FreeLibrary(hGLDLL);
|
||||
hGLDLL = NULL;
|
||||
#endif
|
||||
|
@ -938,7 +948,7 @@ int32_t loadglulibrary(const char *driver)
|
|||
{
|
||||
int32_t err=0;
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined _WIN32
|
||||
if (hGLUDLL) return 0;
|
||||
#endif
|
||||
|
||||
|
@ -990,14 +1000,14 @@ fail:
|
|||
|
||||
int32_t unloadglulibrary(void)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#if defined _WIN32
|
||||
if (!hGLUDLL) return 0;
|
||||
#endif
|
||||
|
||||
Bfree(glulibrary);
|
||||
glulibrary = NULL;
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined _WIN32
|
||||
FreeLibrary(hGLUDLL);
|
||||
hGLUDLL = NULL;
|
||||
#else
|
||||
|
|
|
@ -1256,6 +1256,10 @@ static int32_t create_window_and_renderer(int32_t x, int32_t y, int32_t c, int32
|
|||
destroy_window_and_renderer();
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
loadglextensions();
|
||||
#endif
|
||||
}
|
||||
|
||||
sdl_texture = SDL_CreateTexture(sdl_renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, x, y);
|
||||
|
@ -1409,6 +1413,9 @@ int32_t setvideomode(int32_t x, int32_t y, int32_t c, int32_t fs)
|
|||
initprintf("Unable to set video mode!\n");
|
||||
return -1;
|
||||
}
|
||||
#ifdef _WIN32
|
||||
loadglextensions();
|
||||
#endif
|
||||
# else
|
||||
destroy_window_and_renderer();
|
||||
|
||||
|
@ -1431,6 +1438,9 @@ int32_t setvideomode(int32_t x, int32_t y, int32_t c, int32_t fs)
|
|||
initprintf("Unable to set video mode!\n");
|
||||
return -1;
|
||||
}
|
||||
#ifdef _WIN32
|
||||
loadglextensions();
|
||||
#endif
|
||||
sdl_buffersurface = SDL_CreateRGBSurface(SURFACE_FLAGS, x, y, c, 0, 0, 0, 0);
|
||||
if (!sdl_buffersurface)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue