mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 01:01:33 +00:00
Merge remote-tracking branch 'Furyhunter/sdl2' into sdl2
This commit is contained in:
commit
4c635c67a6
3 changed files with 14 additions and 235 deletions
|
@ -216,7 +216,7 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
|
||||||
|
|
||||||
if (rendermode == render_opengl)
|
if (rendermode == render_opengl)
|
||||||
{
|
{
|
||||||
OglSdlSurface(vid.width, vid.height, (USE_FULLSCREEN));
|
OglSdlSurface(vid.width, vid.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rendermode == render_soft)
|
if (rendermode == render_soft)
|
||||||
|
@ -1318,17 +1318,6 @@ void I_UpdateNoBlit(void)
|
||||||
SDL_RenderPresent(renderer);
|
SDL_RenderPresent(renderer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
#ifdef HWRENDER
|
|
||||||
if (rendermode != render_soft)
|
|
||||||
OglSdlFinishUpdate(cv_vidwait.value);
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
if (vidSurface->flags&SDL_DOUBLEBUF)
|
|
||||||
SDL_Flip(vidSurface);
|
|
||||||
else if (exposevideo)
|
|
||||||
SDL_UpdateRect(vidSurface, 0, 0, 0, 0);
|
|
||||||
#endif
|
|
||||||
exposevideo = SDL_FALSE;
|
exposevideo = SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1666,112 +1655,6 @@ INT32 VID_SetMode(INT32 modeNum)
|
||||||
}
|
}
|
||||||
|
|
||||||
return SDL_TRUE;
|
return SDL_TRUE;
|
||||||
#if 0
|
|
||||||
SDLdoUngrabMouse();
|
|
||||||
vid.recalc = true;
|
|
||||||
BitsPerPixel = (Uint8)cv_scr_depth.value;
|
|
||||||
//vid.bpp = BitsPerPixel==8?1:2;
|
|
||||||
// Window title
|
|
||||||
SDL_WM_SetCaption("SRB2 "VERSIONSTRING, "SRB2");
|
|
||||||
|
|
||||||
if (render_soft == rendermode)
|
|
||||||
{
|
|
||||||
//Alam: SDL_Video system free vidSurface for me
|
|
||||||
if (vid.buffer) free(vid.buffer);
|
|
||||||
vid.buffer = NULL;
|
|
||||||
if (bufSurface) SDL_FreeSurface(bufSurface);
|
|
||||||
bufSurface = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (USE_FULLSCREEN)
|
|
||||||
{
|
|
||||||
if (numVidModes != -1)
|
|
||||||
{
|
|
||||||
modeNum += firstEntry;
|
|
||||||
vid.width = modeList[modeNum]->w;
|
|
||||||
vid.height = modeList[modeNum]->h;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
vid.width = windowedModes[modeNum][0];
|
|
||||||
vid.height = windowedModes[modeNum][1];
|
|
||||||
}
|
|
||||||
if (render_soft == rendermode)
|
|
||||||
{
|
|
||||||
SDLSetMode(vid.width, vid.height, BitsPerPixel, surfaceFlagsF);
|
|
||||||
|
|
||||||
if (!vidSurface)
|
|
||||||
{
|
|
||||||
cv_fullscreen.value = 0;
|
|
||||||
modeNum = VID_GetModeForSize(vid.width,vid.height);
|
|
||||||
vid.width = windowedModes[modeNum][0];
|
|
||||||
vid.height = windowedModes[modeNum][1];
|
|
||||||
SDLSetMode(vid.width, vid.height, BitsPerPixel, surfaceFlagsW);
|
|
||||||
if (!vidSurface)
|
|
||||||
I_Error("Could not set vidmode: %s\n",SDL_GetError());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#ifdef HWRENDER
|
|
||||||
else // (render_soft != rendermode)
|
|
||||||
{
|
|
||||||
if (!OglSdlSurface(vid.width, vid.height, true))
|
|
||||||
{
|
|
||||||
cv_fullscreen.value = 0;
|
|
||||||
modeNum = VID_GetModeForSize(vid.width,vid.height);
|
|
||||||
vid.width = windowedModes[modeNum][0];
|
|
||||||
vid.height = windowedModes[modeNum][1];
|
|
||||||
if (!OglSdlSurface(vid.width, vid.height,false))
|
|
||||||
I_Error("Could not set vidmode: %s\n",SDL_GetError());
|
|
||||||
}
|
|
||||||
|
|
||||||
realwidth = (Uint16)vid.width;
|
|
||||||
realheight = (Uint16)vid.height;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else //(cv_fullscreen.value)
|
|
||||||
{
|
|
||||||
vid.width = windowedModes[modeNum][0];
|
|
||||||
vid.height = windowedModes[modeNum][1];
|
|
||||||
|
|
||||||
if (render_soft == rendermode)
|
|
||||||
{
|
|
||||||
SDLSetMode(vid.width, vid.height, BitsPerPixel, surfaceFlagsW);
|
|
||||||
if (!vidSurface)
|
|
||||||
I_Error("Could not set vidmode: %s\n",SDL_GetError());
|
|
||||||
}
|
|
||||||
#ifdef HWRENDER
|
|
||||||
else //(render_soft != rendermode)
|
|
||||||
{
|
|
||||||
if (!OglSdlSurface(vid.width, vid.height, false))
|
|
||||||
I_Error("Could not set vidmode: %s\n",SDL_GetError());
|
|
||||||
realwidth = (Uint16)vid.width;
|
|
||||||
realheight = (Uint16)vid.height;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
vid.modenum = VID_GetModeForSize(vidSurface->w,vidSurface->h);
|
|
||||||
|
|
||||||
if (render_soft == rendermode)
|
|
||||||
{
|
|
||||||
vid.rowbytes = vid.width*vid.bpp;
|
|
||||||
vid.direct = SDLGetDirect();
|
|
||||||
vid.buffer = malloc(vid.rowbytes*vid.height*NUMSCREENS);
|
|
||||||
if (vid.buffer) memset(vid.buffer,0x00,vid.rowbytes*vid.height*NUMSCREENS);
|
|
||||||
else I_Error ("Not enough memory for video buffer\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0 // broken
|
|
||||||
if (!cv_stretch.value && (float)vid.width/vid.height != ((float)BASEVIDWIDTH/BASEVIDHEIGHT))
|
|
||||||
vid.height = (INT32)(vid.width * ((float)BASEVIDHEIGHT/BASEVIDWIDTH));// Adjust the height to match
|
|
||||||
#endif
|
|
||||||
I_StartupMouse();
|
|
||||||
|
|
||||||
SDLWMSet();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool Impl_CreateWindow(SDL_bool fullscreen)
|
static SDL_bool Impl_CreateWindow(SDL_bool fullscreen)
|
||||||
|
@ -1790,30 +1673,10 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen)
|
||||||
#ifdef HWRENDER
|
#ifdef HWRENDER
|
||||||
if (rendermode == render_opengl)
|
if (rendermode == render_opengl)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
* We want at least 1 bit R, G, and B,
|
|
||||||
* and at least 16 bpp. Why 1 bit? May be more?
|
|
||||||
*/
|
|
||||||
/*SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 1);
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 1);
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 1);
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);*/
|
|
||||||
|
|
||||||
window = SDL_CreateWindow("SRB2", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
|
window = SDL_CreateWindow("SRB2", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
|
||||||
realwidth, realheight, flags | SDL_WINDOW_OPENGL);
|
realwidth, realheight, flags | SDL_WINDOW_OPENGL);
|
||||||
if (window != NULL)
|
if (window != NULL)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
renderer = SDL_CreateRenderer(window, -1, 0);
|
|
||||||
if (renderer != NULL)
|
|
||||||
{
|
|
||||||
//SDL_RenderSetLogicalSize(renderer, BASEVIDWIDTH, BASEVIDHEIGHT);
|
|
||||||
sdlglcontext = SDL_GL_CreateContext(window);
|
|
||||||
SDL_GL_MakeCurrent(window, sdlglcontext);
|
|
||||||
}
|
|
||||||
else return SDL_FALSE;
|
|
||||||
*/
|
|
||||||
|
|
||||||
sdlglcontext = SDL_GL_CreateContext(window);
|
sdlglcontext = SDL_GL_CreateContext(window);
|
||||||
SDL_GL_MakeCurrent(window, sdlglcontext);
|
SDL_GL_MakeCurrent(window, sdlglcontext);
|
||||||
}
|
}
|
||||||
|
@ -2014,15 +1877,10 @@ 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));
|
if (!OglSdlSurface(vid.width, vid.height))
|
||||||
|
{
|
||||||
// Contrary to SDL1 implementation, all we need is a window and a GL context.
|
rendermode = render_soft;
|
||||||
// No setting up a special surface to draw to.
|
}
|
||||||
// If the GL context was already made, we're good to go.
|
|
||||||
|
|
||||||
/*if (!OglSdlSurface(vid.width, vid.height, (USE_FULLSCREEN)))
|
|
||||||
if (!OglSdlSurface(vid.width, vid.height, !(USE_FULLSCREEN)))
|
|
||||||
rendermode = render_soft;*/
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
rendermode = render_soft;
|
rendermode = render_soft;
|
||||||
|
@ -2033,19 +1891,6 @@ void I_StartupGraphics(void)
|
||||||
if (render_soft == rendermode)
|
if (render_soft == rendermode)
|
||||||
{
|
{
|
||||||
VID_SetMode(VID_GetModeForSize(BASEVIDWIDTH, BASEVIDHEIGHT));
|
VID_SetMode(VID_GetModeForSize(BASEVIDWIDTH, BASEVIDHEIGHT));
|
||||||
#if 0
|
|
||||||
vid.width = BASEVIDWIDTH;
|
|
||||||
vid.height = BASEVIDHEIGHT;
|
|
||||||
SDLSetMode(vid.width, vid.height, USE_FULLSCREEN);
|
|
||||||
if (!vidSurface)
|
|
||||||
{
|
|
||||||
CONS_Printf(M_GetText("Could not set vidmode: %s\n") ,SDL_GetError());
|
|
||||||
vid.rowbytes = 0;
|
|
||||||
graphics_started = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Impl_VideoSetupBuffer();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
if (M_CheckParm("-nomousegrab"))
|
if (M_CheckParm("-nomousegrab"))
|
||||||
mousegrabok = SDL_FALSE;
|
mousegrabok = SDL_FALSE;
|
||||||
|
@ -2098,6 +1943,10 @@ void I_ShutdownGraphics(void)
|
||||||
#ifdef HWRENDER
|
#ifdef HWRENDER
|
||||||
if (GLUhandle)
|
if (GLUhandle)
|
||||||
hwClose(GLUhandle);
|
hwClose(GLUhandle);
|
||||||
|
if (sdlglcontext)
|
||||||
|
{
|
||||||
|
SDL_GL_DeleteContext(sdlglcontext);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||||
framebuffer = SDL_FALSE;
|
framebuffer = SDL_FALSE;
|
||||||
|
|
|
@ -150,12 +150,10 @@ boolean LoadGL(void)
|
||||||
|
|
||||||
\return if true, changed video mode
|
\return if true, changed video mode
|
||||||
*/
|
*/
|
||||||
boolean OglSdlSurface(INT32 w, INT32 h, boolean isFullscreen)
|
boolean OglSdlSurface(INT32 w, INT32 h)
|
||||||
{
|
{
|
||||||
INT32 cbpp;
|
INT32 cbpp;
|
||||||
//Uint32 OGLFlags;
|
|
||||||
const GLvoid *glvendor = NULL, *glrenderer = NULL, *glversion = NULL;
|
const GLvoid *glvendor = NULL, *glrenderer = NULL, *glversion = NULL;
|
||||||
(void)isFullscreen; //unused
|
|
||||||
|
|
||||||
cbpp = cv_scr_depth.value < 16 ? 16 : cv_scr_depth.value;
|
cbpp = cv_scr_depth.value < 16 ? 16 : cv_scr_depth.value;
|
||||||
|
|
||||||
|
@ -173,55 +171,18 @@ boolean OglSdlSurface(INT32 w, INT32 h, boolean isFullscreen)
|
||||||
DBG_Printf("Extensions : %s\n", gl_extensions);
|
DBG_Printf("Extensions : %s\n", gl_extensions);
|
||||||
oglflags = 0;
|
oglflags = 0;
|
||||||
|
|
||||||
#ifdef _WIN32
|
maximumAnisotropy = 0;
|
||||||
// BP: disable advenced feature that don't work on somes hardware
|
|
||||||
// Hurdler: Now works on G400 with bios 1.6 and certified drivers 6.04
|
|
||||||
if (strstr(glrenderer, "810")) oglflags |= GLF_NOZBUFREAD;
|
|
||||||
#elif defined (unix) || defined (UNIXCOMMON)
|
|
||||||
// disable advanced features not working on somes hardware
|
|
||||||
if (strstr(glrenderer, "G200")) oglflags |= GLF_NOTEXENV;
|
|
||||||
if (strstr(glrenderer, "G400")) oglflags |= GLF_NOTEXENV;
|
|
||||||
#endif
|
|
||||||
DBG_Printf("oglflags : 0x%X\n", oglflags );
|
|
||||||
|
|
||||||
#ifdef USE_PALETTED_TEXTURE
|
|
||||||
if (isExtAvailable("GL_EXT_paletted_texture", gl_extensions))
|
|
||||||
glColorTableEXT = SDL_GL_GetProcAddress("glColorTableEXT");
|
|
||||||
else
|
|
||||||
glColorTableEXT = NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_WGL_SWAP
|
|
||||||
if (isExtAvailable("WGL_EXT_swap_control", gl_extensions))
|
|
||||||
wglSwapIntervalEXT = SDL_GL_GetProcAddress("wglSwapIntervalEXT");
|
|
||||||
else
|
|
||||||
wglSwapIntervalEXT = NULL;
|
|
||||||
#else
|
|
||||||
if (isExtAvailable("GLX_SGI_swap_control", gl_extensions))
|
|
||||||
glXSwapIntervalSGIEXT = SDL_GL_GetProcAddress("glXSwapIntervalSGI");
|
|
||||||
else
|
|
||||||
glXSwapIntervalSGIEXT = NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef KOS_GL_COMPATIBILITY
|
|
||||||
if (isExtAvailable("GL_EXT_texture_filter_anisotropic", gl_extensions))
|
|
||||||
pglGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maximumAnisotropy);
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
maximumAnisotropy = 0;
|
|
||||||
|
|
||||||
granisotropicmode_cons_t[1].value = maximumAnisotropy;
|
granisotropicmode_cons_t[1].value = maximumAnisotropy;
|
||||||
|
|
||||||
|
SDL_GL_SetSwapInterval(cv_vidwait.value ? 1 : 0);
|
||||||
|
|
||||||
SetModelView(w, h);
|
SetModelView(w, h);
|
||||||
SetStates();
|
SetStates();
|
||||||
pglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
pglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
HWR_Startup();
|
HWR_Startup();
|
||||||
#ifdef KOS_GL_COMPATIBILITY
|
|
||||||
textureformatGL = GL_ARGB4444;
|
|
||||||
#else
|
|
||||||
textureformatGL = cbpp > 16 ? GL_RGBA : GL_RGB5_A1;
|
textureformatGL = cbpp > 16 ? GL_RGBA : GL_RGB5_A1;
|
||||||
#endif
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -235,19 +196,6 @@ 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)
|
|
||||||
{
|
|
||||||
#ifdef USE_WGL_SWAP
|
|
||||||
if (wglSwapIntervalEXT)
|
|
||||||
wglSwapIntervalEXT(waitvbl);
|
|
||||||
#else
|
|
||||||
if (glXSwapIntervalSGIEXT)
|
|
||||||
glXSwapIntervalSGIEXT(waitvbl);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
oldwaitvbl = waitvbl;*/
|
|
||||||
|
|
||||||
if (oldwaitvbl != waitvbl)
|
if (oldwaitvbl != waitvbl)
|
||||||
{
|
{
|
||||||
SDL_GL_SetSwapInterval(waitvbl ? 1 : 0);
|
SDL_GL_SetSwapInterval(waitvbl ? 1 : 0);
|
||||||
|
@ -263,10 +211,6 @@ EXPORT void HWRAPI( OglSdlSetPalette) (RGBA_t *palette, RGBA_t *pgamma)
|
||||||
UINT32 redgamma = pgamma->s.red, greengamma = pgamma->s.green,
|
UINT32 redgamma = pgamma->s.red, greengamma = pgamma->s.green,
|
||||||
bluegamma = pgamma->s.blue;
|
bluegamma = pgamma->s.blue;
|
||||||
|
|
||||||
#if 0 // changing the gamma to 127 is a bad idea
|
|
||||||
i = SDL_SetGamma(byteasfloat(redgamma), byteasfloat(greengamma), byteasfloat(bluegamma));
|
|
||||||
#endif
|
|
||||||
if (i == 0) redgamma = greengamma = bluegamma = 0x7F; //Alam: cool
|
|
||||||
for (i = 0; i < 256; i++)
|
for (i = 0; i < 256; i++)
|
||||||
{
|
{
|
||||||
myPaletteData[i].s.red = (UINT8)MIN((palette[i].s.red * redgamma) /127, 255);
|
myPaletteData[i].s.red = (UINT8)MIN((palette[i].s.red * redgamma) /127, 255);
|
||||||
|
@ -274,20 +218,6 @@ EXPORT void HWRAPI( OglSdlSetPalette) (RGBA_t *palette, RGBA_t *pgamma)
|
||||||
myPaletteData[i].s.blue = (UINT8)MIN((palette[i].s.blue * bluegamma) /127, 255);
|
myPaletteData[i].s.blue = (UINT8)MIN((palette[i].s.blue * bluegamma) /127, 255);
|
||||||
myPaletteData[i].s.alpha = palette[i].s.alpha;
|
myPaletteData[i].s.alpha = palette[i].s.alpha;
|
||||||
}
|
}
|
||||||
#ifdef USE_PALETTED_TEXTURE
|
|
||||||
if (glColorTableEXT)
|
|
||||||
{
|
|
||||||
for (i = 0; i < 256; i++)
|
|
||||||
{
|
|
||||||
palette_tex[(3*i)+0] = palette[i].s.red;
|
|
||||||
palette_tex[(3*i)+1] = palette[i].s.green;
|
|
||||||
palette_tex[(3*i)+2] = palette[i].s.blue;
|
|
||||||
}
|
|
||||||
glColorTableEXT(GL_TEXTURE_2D, GL_RGB8, 256, GL_RGB, GL_UNSIGNED_BYTE, palette_tex);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
// on a chang<6E>de palette, il faut recharger toutes les textures
|
|
||||||
// jaja, und noch viel mehr ;-)
|
|
||||||
Flush();
|
Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
extern void *GLUhandle;
|
extern void *GLUhandle;
|
||||||
|
|
||||||
boolean OglSdlSurface(INT32 w, INT32 h, boolean isFullscreen);
|
boolean OglSdlSurface(INT32 w, INT32 h);
|
||||||
|
|
||||||
void OglSdlFinishUpdate(boolean vidwait);
|
void OglSdlFinishUpdate(boolean vidwait);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue