mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2025-01-25 02:31:14 +00:00
sdl2: fix opengl (almost) entirely
This commit is contained in:
parent
fea559398a
commit
d078e3e17f
3 changed files with 32 additions and 49 deletions
|
@ -29,9 +29,6 @@
|
||||||
|
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
|
|
||||||
// SDL2 stub macro
|
|
||||||
#define SDL2STUB(name) CONS_Printf("SDL2: stubbed: %s:%d\n", __func__, __LINE__)
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(default : 4214 4244)
|
#pragma warning(default : 4214 4244)
|
||||||
#endif
|
#endif
|
||||||
|
@ -172,54 +169,32 @@ static void Impl_SetWindowIcon(void);
|
||||||
|
|
||||||
static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
|
static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
const char *SDLVD = I_GetEnv("SDL_VIDEODRIVER");
|
|
||||||
if (SDLVD && strncasecmp(SDLVD,"glSDL",6) == 0) //for glSDL videodriver
|
|
||||||
vidSurface = SDL_SetVideoMode(width, height,0,SDL_DOUBLEBUF);
|
|
||||||
else if (cv_vidwait.value && videoblitok && SDL_VideoModeOK(width, height, bpp, flags|SDL_HWSURFACE|SDL_DOUBLEBUF) >= bpp)
|
|
||||||
vidSurface = SDL_SetVideoMode(width, height, bpp, flags|SDL_HWSURFACE|SDL_DOUBLEBUF);
|
|
||||||
else if (videoblitok && SDL_VideoModeOK(width, height, bpp, flags|SDL_HWSURFACE) >= bpp)
|
|
||||||
vidSurface = SDL_SetVideoMode(width, height, bpp, flags|SDL_HWSURFACE);
|
|
||||||
else if (SDL_VideoModeOK(width, height, bpp, flags|SDL_SWSURFACE) >= bpp)
|
|
||||||
vidSurface = SDL_SetVideoMode(width, height, bpp, flags|SDL_SWSURFACE);
|
|
||||||
else return;
|
|
||||||
realwidth = (Uint16)width;
|
|
||||||
realheight = (Uint16)height;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static SDL_bool wasfullscreen = SDL_FALSE;
|
static SDL_bool wasfullscreen = SDL_FALSE;
|
||||||
int rmask;
|
int rmask;
|
||||||
int gmask;
|
int gmask;
|
||||||
int bmask;
|
int bmask;
|
||||||
int amask;
|
int amask;
|
||||||
|
|
||||||
|
realwidth = vid.width;
|
||||||
|
realheight = vid.height;
|
||||||
|
|
||||||
if (window)
|
if (window)
|
||||||
{
|
{
|
||||||
if (fullscreen && !wasfullscreen)
|
if (fullscreen && !wasfullscreen)
|
||||||
{
|
{
|
||||||
// Recreate window in fullscreen
|
|
||||||
/*
|
|
||||||
SDL_DestroyRenderer(renderer);
|
|
||||||
renderer = NULL;
|
|
||||||
SDL_DestroyWindow(window);
|
|
||||||
window = NULL;
|
|
||||||
Impl_CreateWindow(SDL_TRUE);
|
|
||||||
Impl_SetWindowIcon();
|
|
||||||
*/
|
|
||||||
wasfullscreen = SDL_TRUE;
|
wasfullscreen = SDL_TRUE;
|
||||||
SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP);
|
SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP);
|
||||||
|
// Logical fullscreen is not implemented yet for OpenGL, so...
|
||||||
|
// Special case handling
|
||||||
|
if (rendermode == render_opengl)
|
||||||
|
{
|
||||||
|
int sdlw, sdlh;
|
||||||
|
SDL_GetWindowSize(window, &sdlw, &sdlh);
|
||||||
|
VID_SetMode(VID_GetModeForSize(sdlw, sdlh));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (!fullscreen && wasfullscreen)
|
else if (!fullscreen && wasfullscreen)
|
||||||
{
|
{
|
||||||
// Recreate window in windowed mode
|
|
||||||
/*
|
|
||||||
SDL_DestroyRenderer(renderer);
|
|
||||||
renderer = NULL;
|
|
||||||
SDL_DestroyWindow(window);
|
|
||||||
window = NULL;
|
|
||||||
Impl_CreateWindow(SDL_FALSE);
|
|
||||||
Impl_SetWindowIcon();
|
|
||||||
*/
|
|
||||||
wasfullscreen = SDL_FALSE;
|
wasfullscreen = SDL_FALSE;
|
||||||
SDL_SetWindowFullscreen(window, 0);
|
SDL_SetWindowFullscreen(window, 0);
|
||||||
SDL_SetWindowSize(window, width, height);
|
SDL_SetWindowSize(window, width, height);
|
||||||
|
@ -239,10 +214,14 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
|
||||||
wasfullscreen = fullscreen ? SDL_TRUE : SDL_FALSE;
|
wasfullscreen = fullscreen ? SDL_TRUE : SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_RenderSetLogicalSize(renderer, width, height);
|
if (rendermode == render_opengl)
|
||||||
|
{
|
||||||
|
OglSdlSurface(vid.width, vid.height, (USE_FULLSCREEN));
|
||||||
|
}
|
||||||
|
|
||||||
if (rendermode == render_soft)
|
if (rendermode == render_soft)
|
||||||
{
|
{
|
||||||
|
SDL_RenderSetLogicalSize(renderer, width, height);
|
||||||
// Set up Texture
|
// Set up Texture
|
||||||
realwidth = width;
|
realwidth = width;
|
||||||
realheight = height;
|
realheight = height;
|
||||||
|
@ -270,15 +249,6 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
|
||||||
#endif
|
#endif
|
||||||
vidSurface = SDL_CreateRGBSurface(0, width, height, 32, rmask, gmask, bmask, amask);
|
vidSurface = SDL_CreateRGBSurface(0, width, height, 32, rmask, gmask, bmask, amask);
|
||||||
}
|
}
|
||||||
#ifdef HWRENDER
|
|
||||||
else if (rendermode == render_opengl)
|
|
||||||
{
|
|
||||||
if (sdlglcontext == NULL)
|
|
||||||
{
|
|
||||||
sdlglcontext = SDL_GL_CreateContext(window);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1339,7 +1309,6 @@ void I_UpdateNoBlit(void)
|
||||||
if (rendermode == render_opengl)
|
if (rendermode == render_opengl)
|
||||||
{
|
{
|
||||||
OglSdlFinishUpdate(cv_vidwait.value);
|
OglSdlFinishUpdate(cv_vidwait.value);
|
||||||
SDL_RenderPresent(renderer);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
@ -1444,7 +1413,6 @@ void I_FinishUpdate(void)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
OglSdlFinishUpdate(cv_vidwait.value);
|
OglSdlFinishUpdate(cv_vidwait.value);
|
||||||
//SDL_RenderPresent(renderer);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
exposevideo = SDL_FALSE;
|
exposevideo = SDL_FALSE;
|
||||||
|
@ -1835,13 +1803,19 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen)
|
||||||
realwidth, realheight, flags | SDL_WINDOW_OPENGL);
|
realwidth, realheight, flags | SDL_WINDOW_OPENGL);
|
||||||
if (window != NULL)
|
if (window != NULL)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
renderer = SDL_CreateRenderer(window, -1, 0);
|
renderer = SDL_CreateRenderer(window, -1, 0);
|
||||||
if (renderer != NULL)
|
if (renderer != NULL)
|
||||||
{
|
{
|
||||||
//SDL_RenderSetLogicalSize(renderer, BASEVIDWIDTH, BASEVIDHEIGHT);
|
//SDL_RenderSetLogicalSize(renderer, BASEVIDWIDTH, BASEVIDHEIGHT);
|
||||||
sdlglcontext = SDL_GL_CreateContext(window);
|
sdlglcontext = SDL_GL_CreateContext(window);
|
||||||
|
SDL_GL_MakeCurrent(window, sdlglcontext);
|
||||||
}
|
}
|
||||||
else return SDL_FALSE;
|
else return SDL_FALSE;
|
||||||
|
*/
|
||||||
|
|
||||||
|
sdlglcontext = SDL_GL_CreateContext(window);
|
||||||
|
SDL_GL_MakeCurrent(window, sdlglcontext);
|
||||||
}
|
}
|
||||||
else return SDL_FALSE;
|
else return SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
@ -2040,6 +2014,7 @@ void I_StartupGraphics(void)
|
||||||
vid.height = BASEVIDHEIGHT;
|
vid.height = BASEVIDHEIGHT;
|
||||||
if (HWD.pfnInit(I_Error)) // let load the OpenGL library
|
if (HWD.pfnInit(I_Error)) // let load the OpenGL library
|
||||||
{
|
{
|
||||||
|
OglSdlSurface(vid.width, vid.height, (USE_FULLSCREEN));
|
||||||
|
|
||||||
// Contrary to SDL1 implementation, all we need is a window and a GL context.
|
// Contrary to SDL1 implementation, all we need is a window and a GL context.
|
||||||
// No setting up a special surface to draw to.
|
// No setting up a special surface to draw to.
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
|
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
|
|
||||||
|
#include "sdlmain.h"
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(default : 4214 4244)
|
#pragma warning(default : 4214 4244)
|
||||||
#endif
|
#endif
|
||||||
|
@ -232,6 +234,7 @@ boolean OglSdlSurface(INT32 w, INT32 h, boolean isFullscreen)
|
||||||
void OglSdlFinishUpdate(boolean waitvbl)
|
void OglSdlFinishUpdate(boolean waitvbl)
|
||||||
{
|
{
|
||||||
static boolean oldwaitvbl = false;
|
static boolean oldwaitvbl = false;
|
||||||
|
/*
|
||||||
if (oldwaitvbl != waitvbl)
|
if (oldwaitvbl != waitvbl)
|
||||||
{
|
{
|
||||||
#ifdef USE_WGL_SWAP
|
#ifdef USE_WGL_SWAP
|
||||||
|
@ -242,7 +245,7 @@ void OglSdlFinishUpdate(boolean waitvbl)
|
||||||
glXSwapIntervalSGIEXT(waitvbl);
|
glXSwapIntervalSGIEXT(waitvbl);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
oldwaitvbl = waitvbl;
|
oldwaitvbl = waitvbl;*/
|
||||||
|
|
||||||
SDL_GL_SwapWindow(window);
|
SDL_GL_SwapWindow(window);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,11 @@
|
||||||
extern SDL_bool consolevent;
|
extern SDL_bool consolevent;
|
||||||
extern SDL_bool framebuffer;
|
extern SDL_bool framebuffer;
|
||||||
|
|
||||||
|
#include "../m_fixed.h"
|
||||||
|
|
||||||
|
// SDL2 stub macro
|
||||||
|
#define SDL2STUB(name) CONS_Printf("SDL2: stubbed: %s:%d\n", __func__, __LINE__)
|
||||||
|
|
||||||
/** \brief The JoyInfo_s struct
|
/** \brief The JoyInfo_s struct
|
||||||
|
|
||||||
info about joystick
|
info about joystick
|
||||||
|
|
Loading…
Reference in a new issue