mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-11 07:11:39 +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;
|
bwglSetPixelFormatProcPtr bwglSetPixelFormat;
|
||||||
bwglSwapIntervalEXTProcPtr bwglSwapIntervalEXT;
|
bwglSwapIntervalEXTProcPtr bwglSwapIntervalEXT;
|
||||||
bwglCreateContextAttribsARBProcPtr bwglCreateContextAttribsARB;
|
bwglCreateContextAttribsARBProcPtr bwglCreateContextAttribsARB;
|
||||||
|
|
||||||
static HMODULE hGLDLL, hGLUDLL;
|
|
||||||
#else
|
#else
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined RENDERTYPESDL && defined _WIN32
|
||||||
|
static HMODULE hGLDLL;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined _WIN32
|
||||||
|
static HMODULE hGLUDLL;
|
||||||
|
#else
|
||||||
static void *gluhandle = NULL;
|
static void *gluhandle = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -332,7 +338,7 @@ int32_t loadgldriver(const char *driver)
|
||||||
{
|
{
|
||||||
int32_t err=0;
|
int32_t err=0;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#if !defined RENDERTYPESDL && defined _WIN32
|
||||||
if (hGLDLL) return 0;
|
if (hGLDLL) return 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -348,10 +354,18 @@ int32_t loadgldriver(const char *driver)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined RENDERTYPESDL
|
#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
|
#elif defined _WIN32
|
||||||
hGLDLL = LoadLibrary(driver);
|
hGLDLL = LoadLibrary(driver);
|
||||||
if (!hGLDLL) goto fail;
|
if (!hGLDLL)
|
||||||
|
{
|
||||||
|
initprintf("Failed loading \"%s\"\n", driver);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
gldriver = Bstrdup(driver);
|
gldriver = Bstrdup(driver);
|
||||||
|
|
||||||
|
@ -485,16 +499,12 @@ int32_t loadgldriver(const char *driver)
|
||||||
|
|
||||||
if (err) unloadgldriver();
|
if (err) unloadgldriver();
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
fail:
|
|
||||||
initprintf("Failed loading \"%s\"\n",driver);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t loadglextensions(void)
|
int32_t loadglextensions(void)
|
||||||
{
|
{
|
||||||
int32_t err = 0;
|
int32_t err = 0;
|
||||||
#ifdef _WIN32
|
#if !defined RENDERTYPESDL && defined _WIN32
|
||||||
if (!hGLDLL) return 0;
|
if (!hGLDLL) return 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -648,14 +658,14 @@ int32_t unloadgldriver(void)
|
||||||
{
|
{
|
||||||
unloadglulibrary();
|
unloadglulibrary();
|
||||||
|
|
||||||
#ifdef _WIN32
|
#if !defined RENDERTYPESDL && defined _WIN32
|
||||||
if (!hGLDLL) return 0;
|
if (!hGLDLL) return 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Bfree(gldriver);
|
Bfree(gldriver);
|
||||||
gldriver = NULL;
|
gldriver = NULL;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#if !defined RENDERTYPESDL && defined _WIN32
|
||||||
FreeLibrary(hGLDLL);
|
FreeLibrary(hGLDLL);
|
||||||
hGLDLL = NULL;
|
hGLDLL = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
@ -938,7 +948,7 @@ int32_t loadglulibrary(const char *driver)
|
||||||
{
|
{
|
||||||
int32_t err=0;
|
int32_t err=0;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#if defined _WIN32
|
||||||
if (hGLUDLL) return 0;
|
if (hGLUDLL) return 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -990,14 +1000,14 @@ fail:
|
||||||
|
|
||||||
int32_t unloadglulibrary(void)
|
int32_t unloadglulibrary(void)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#if defined _WIN32
|
||||||
if (!hGLUDLL) return 0;
|
if (!hGLUDLL) return 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Bfree(glulibrary);
|
Bfree(glulibrary);
|
||||||
glulibrary = NULL;
|
glulibrary = NULL;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#if defined _WIN32
|
||||||
FreeLibrary(hGLUDLL);
|
FreeLibrary(hGLUDLL);
|
||||||
hGLUDLL = NULL;
|
hGLUDLL = NULL;
|
||||||
#else
|
#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();
|
destroy_window_and_renderer();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
loadglextensions();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
sdl_texture = SDL_CreateTexture(sdl_renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, x, y);
|
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");
|
initprintf("Unable to set video mode!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#ifdef _WIN32
|
||||||
|
loadglextensions();
|
||||||
|
#endif
|
||||||
# else
|
# else
|
||||||
destroy_window_and_renderer();
|
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");
|
initprintf("Unable to set video mode!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#ifdef _WIN32
|
||||||
|
loadglextensions();
|
||||||
|
#endif
|
||||||
sdl_buffersurface = SDL_CreateRGBSurface(SURFACE_FLAGS, x, y, c, 0, 0, 0, 0);
|
sdl_buffersurface = SDL_CreateRGBSurface(SURFACE_FLAGS, x, y, c, 0, 0, 0, 0);
|
||||||
if (!sdl_buffersurface)
|
if (!sdl_buffersurface)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue