try to clean up downsampling and resolution checking stuff
- global function that updates variables with current display resolution -smol boolean function that quickly checks if the game res matches the desktop res - i_downsample has been simplyfied a bit
This commit is contained in:
1 parent
5b46ae2eb9
commit
0c7851bd26
1 file changed
+40
-44
+40
-44
@@ -128,6 +128,11 @@ consvar_t cv_keyboardlayout = {"keyboardlayout", "Default US", CV_SAVE|CV_CALL,
|
||||
|
||||
static void Impl_SetVsync(void);
|
||||
|
||||
static INT32 desktopwidth = 0, desktopheight = 0;
|
||||
|
||||
static void I_CheckDesktopRes(void);
|
||||
static void I_ResetFBOSurface(void);
|
||||
|
||||
// synchronize page flipping with screen refresh
|
||||
consvar_t cv_vidwait = {"vid_wait", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, Impl_SetVsync, 0, NULL, NULL, 0, 0, NULL};
|
||||
static consvar_t cv_stretch = {"stretch", "Off", CV_SAVE|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
@@ -274,6 +279,7 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
|
||||
#ifdef HWRENDER
|
||||
if (rendermode == render_opengl)
|
||||
{
|
||||
I_CheckDesktopRes();
|
||||
#ifdef USE_FBO_OGL
|
||||
I_DownSample();
|
||||
#endif
|
||||
@@ -695,21 +701,14 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which)
|
||||
return raxis;
|
||||
}
|
||||
|
||||
boolean I_CheckNativeRes(void)
|
||||
static void I_CheckDesktopRes(void)
|
||||
{
|
||||
static INT32 oldwidth = 0, oldheight = 0;
|
||||
static boolean resstate = false;
|
||||
int currentDisplayIndex = -1;
|
||||
SDL_DisplayMode curmode;
|
||||
|
||||
if (cv_glscreentextures.value == 0)
|
||||
if (desktopwidth == vid.width && desktopheight == vid.height)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (oldwidth == vid.width && oldheight == vid.height)
|
||||
{
|
||||
return resstate;
|
||||
return;
|
||||
}
|
||||
|
||||
currentDisplayIndex = SDL_GetWindowDisplayIndex(window);
|
||||
@@ -717,72 +716,68 @@ boolean I_CheckNativeRes(void)
|
||||
// No valid index
|
||||
if (currentDisplayIndex < 0)
|
||||
{
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (SDL_GetCurrentDisplayMode(currentDisplayIndex, &curmode) != 0)
|
||||
{
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
resstate = ((vid.width == curmode.w) && (vid.height == curmode.h));
|
||||
oldwidth = vid.width;
|
||||
oldheight = vid.height;
|
||||
desktopwidth = curmode.w;
|
||||
desktopheight = curmode.h;
|
||||
}
|
||||
|
||||
return resstate;
|
||||
boolean I_CheckNativeRes(void)
|
||||
{
|
||||
return (vid.width == desktopwidth && vid.height == desktopheight);
|
||||
}
|
||||
|
||||
#ifdef USE_FBO_OGL
|
||||
void I_DownSample(void)
|
||||
{
|
||||
int currentDisplayIndex = -1;
|
||||
SDL_DisplayMode curmode;
|
||||
boolean needrefresh = false;
|
||||
|
||||
if (!cv_glframebuffer.value || !supportFBO || I_CheckNativeRes()) //no sense to do this crap if we cant benefit from it
|
||||
if (!cv_glframebuffer.value || !supportFBO || (cv_glscreentextures.value == 0)) // no sense to do this crap if we cant benefit from it
|
||||
{
|
||||
downsample = false;
|
||||
return;
|
||||
}
|
||||
|
||||
currentDisplayIndex = SDL_GetWindowDisplayIndex(window);
|
||||
|
||||
// No valid index
|
||||
if (currentDisplayIndex < 0)
|
||||
if (I_CheckNativeRes() && (downsample == true))
|
||||
{
|
||||
downsample = false;
|
||||
I_ResetFBOSurface();
|
||||
return;
|
||||
}
|
||||
|
||||
if (SDL_GetCurrentDisplayMode(currentDisplayIndex, &curmode) != 0)
|
||||
{
|
||||
downsample = false; // couldnt get display info so turn the thing off
|
||||
RefreshOGLSDLSurface();
|
||||
return;
|
||||
}
|
||||
|
||||
if ((vid.width > curmode.w) || (vid.height > curmode.h)) //check if current resolution is higher than current display resolution
|
||||
if ((vid.width > desktopwidth) || (vid.height > desktopheight)) //check if current resolution is higher than current display resolution
|
||||
{
|
||||
downsample = true;
|
||||
RefreshOGLSDLSurface();
|
||||
needrefresh = true;
|
||||
}
|
||||
else
|
||||
else if (downsample == true)
|
||||
{
|
||||
if (downsample == true)
|
||||
{
|
||||
downsample = false; // its not so no need to do crap
|
||||
RefreshOGLSDLSurface();
|
||||
}
|
||||
downsample = false;
|
||||
needrefresh = true;
|
||||
}
|
||||
|
||||
if (needrefresh)
|
||||
I_ResetFBOSurface();
|
||||
}
|
||||
|
||||
static void I_ResetFBOSurface(void)
|
||||
{
|
||||
InvSupersampleFactorX = (float)(desktopwidth) / vid.width;
|
||||
InvSupersampleFactorY = (float)(desktopheight) / vid.height;
|
||||
RefreshOGLSDLSurface();
|
||||
}
|
||||
#endif
|
||||
|
||||
static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
|
||||
{
|
||||
#ifdef USE_FBO_OGL
|
||||
#define FOCUSUNION (mousefocus | (kbfocus << 1) | (windowmoved << 2))
|
||||
#else
|
||||
#define FOCUSUNION (mousefocus | (kbfocus << 1))
|
||||
#endif
|
||||
|
||||
static SDL_bool firsttimeonmouse = SDL_TRUE;
|
||||
static SDL_bool mousefocus = SDL_TRUE;
|
||||
static SDL_bool kbfocus = SDL_TRUE;
|
||||
@@ -822,12 +817,13 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef USE_FBO_OGL
|
||||
if (windowmoved && rendermode == render_opengl)
|
||||
{
|
||||
I_CheckDesktopRes();
|
||||
#ifdef USE_FBO_OGL
|
||||
I_DownSample();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (mousefocus && kbfocus)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user