simplify gl "downsampling" stuff
still kinda meh but whatever, shit works
This commit is contained in:
1 parent
486560d79e
commit
79d75aa08d
5 files changed
+35
-52
No files matched your search
@@ -255,6 +255,7 @@ static void CV_screentextures_OnChange(void)
|
||||
#endif
|
||||
intermissionbginit = false;
|
||||
}
|
||||
|
||||
GL_SetSpecialState(HWD_SET_SCREEN_TEXTURES, cv_glscreentextures.value);
|
||||
M_UpdateOGLMenu();
|
||||
}
|
||||
@@ -263,12 +264,11 @@ static void CV_screentextures_OnChange(void)
|
||||
static void CV_glframebuffer_OnChange(void)
|
||||
{
|
||||
ONLY_IF_GL_LOADED
|
||||
if ((cv_glframebuffer.value != 0 && cv_glscreentextures.value != 2)
|
||||
|| (!supportFBO && cv_glframebuffer.value != 0)) // screen FBO needs screen textures
|
||||
CV_SetValue(&cv_glframebuffer, 0);
|
||||
// screen FBO needs screen textures currently
|
||||
if (cv_glframebuffer.value != 0 && ((cv_glscreentextures.value != 2) || !supportFBO))
|
||||
CV_StealthSetValue(&cv_glframebuffer, 0); // dont recursively call this lul
|
||||
|
||||
I_DownSample();
|
||||
RefreshOGLSDLSurface();
|
||||
I_CheckDownSampleState(true);
|
||||
M_UpdateOGLMenu();
|
||||
intermissionbginit = false;
|
||||
}
|
||||
|
||||
@@ -3266,7 +3266,7 @@ static void GL_FBO_DeleteAttachments(void)
|
||||
|
||||
static void GL_FBO_Generate(void)
|
||||
{
|
||||
if (supportFBO == FBO_NONE || framebufferobject.init || !UseScreenFBO())
|
||||
if (supportFBO == FBO_NONE || framebufferobject.init)
|
||||
return;
|
||||
|
||||
// Generate the framebuffer
|
||||
@@ -3348,13 +3348,13 @@ void GL_FBO_BindMainFrameBuffer(void)
|
||||
|
||||
void GL_FBO_Enable(void)
|
||||
{
|
||||
if (supportFBO == FBO_NONE || !UseScreenFBO())
|
||||
if (supportFBO == FBO_NONE)
|
||||
return;
|
||||
|
||||
GL_FBO_Generate();
|
||||
|
||||
// failed
|
||||
if (supportFBO == FBO_NONE || !framebufferobject.init)
|
||||
if (!framebufferobject.init)
|
||||
return;
|
||||
|
||||
pglBindFramebuffer(GL_FRAMEBUFFER_EXT, framebufferobject.fboobj);
|
||||
|
||||
+2
-4
@@ -126,11 +126,9 @@ boolean I_CheckNativeRes(void);
|
||||
void I_SetBorderlessWindow(void);
|
||||
|
||||
#ifdef USE_FBO_OGL
|
||||
|
||||
void RefreshOGLSDLSurface(void);
|
||||
void I_DownSample(void);
|
||||
void I_CheckDownSampleState(boolean forcerefresh);
|
||||
boolean I_IsDownsampling(void);
|
||||
boolean UseScreenFBO(void);
|
||||
extern boolean downsample;
|
||||
#endif
|
||||
|
||||
// So we can call this from i_video event loop
|
||||
|
||||
+24
-39
@@ -197,10 +197,6 @@ static INT32 custom_height = 0;
|
||||
static SDL_bool Impl_CreateWindow(SDL_bool fullscreen);
|
||||
static void Impl_SetWindowIcon(void);
|
||||
|
||||
#ifdef USE_FBO_OGL
|
||||
boolean downsample = false;
|
||||
#endif
|
||||
|
||||
static INT32 Impl_SDL_Scancode_To_Keycode(SDL_Scancode code)
|
||||
{
|
||||
if (code >= SDL_SCANCODE_A && code <= SDL_SCANCODE_Z)
|
||||
@@ -522,7 +518,7 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
|
||||
{
|
||||
I_CheckDesktopRes();
|
||||
#ifdef USE_FBO_OGL
|
||||
I_DownSample();
|
||||
I_CheckDownSampleState(false);
|
||||
#endif
|
||||
windowmoved = SDL_FALSE;
|
||||
}
|
||||
@@ -1263,8 +1259,9 @@ static void I_CheckDesktopRes(void)
|
||||
int currentDisplayIndex = -1;
|
||||
SDL_DisplayMode curmode;
|
||||
|
||||
desktopwidth = 0;
|
||||
desktopheight = 0;
|
||||
// just fallback to game res ig?
|
||||
desktopwidth = vid.width;
|
||||
desktopheight = vid.height;
|
||||
|
||||
currentDisplayIndex = SDL_GetWindowDisplayIndex(window);
|
||||
|
||||
@@ -1274,7 +1271,7 @@ static void I_CheckDesktopRes(void)
|
||||
return;
|
||||
}
|
||||
|
||||
if (SDL_GetDesktopDisplayMode(currentDisplayIndex, &curmode) != 0)
|
||||
if (SDL_GetCurrentDisplayMode(currentDisplayIndex, &curmode) < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -1290,46 +1287,33 @@ boolean I_CheckNativeRes(void)
|
||||
}
|
||||
|
||||
#ifdef USE_FBO_OGL
|
||||
static boolean vid_downsampling = false;
|
||||
|
||||
void RefreshOGLSDLSurface(void)
|
||||
boolean I_IsDownsampling(void)
|
||||
{
|
||||
if (rendermode == render_opengl)
|
||||
OglSdlSurface(vid.width, vid.height);
|
||||
return vid_downsampling;
|
||||
}
|
||||
|
||||
void I_DownSample(void)
|
||||
void I_CheckDownSampleState(boolean forcerefresh)
|
||||
{
|
||||
boolean needrefresh = false;
|
||||
|
||||
if (!cv_glframebuffer.value || !supportFBO || (cv_glscreentextures.value == 0)) // no sense to do this crap if we cant benefit from it
|
||||
// no fbo support so we dont care
|
||||
if (!supportFBO)
|
||||
{
|
||||
downsample = false;
|
||||
vid_downsampling = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (I_CheckNativeRes() && (downsample == true))
|
||||
// no sense to do this crap if we cant benefit from it
|
||||
const boolean newdownsamplestate = cv_glframebuffer.value && (cv_glscreentextures.value == 2) && I_CheckAboveDesktopRes(vid.width, vid.height);
|
||||
|
||||
// state changed or fbo was toggled
|
||||
if (vid_downsampling != newdownsamplestate || forcerefresh)
|
||||
{
|
||||
downsample = false;
|
||||
RefreshOGLSDLSurface();
|
||||
return;
|
||||
//printf("downsample changed from %d to %d\n", vid_downsampling, curdownsamplestate);
|
||||
OglSdlSurface(vid.width, vid.height);
|
||||
}
|
||||
|
||||
if ((vid.width > desktopwidth) || (vid.height > desktopheight)) //check if current resolution is higher than current display resolution
|
||||
{
|
||||
downsample = true;
|
||||
needrefresh = true;
|
||||
}
|
||||
else if (downsample == true)
|
||||
{
|
||||
downsample = false;
|
||||
needrefresh = true;
|
||||
}
|
||||
|
||||
if (needrefresh)
|
||||
{
|
||||
RefreshOGLSDLSurface();
|
||||
needrefresh = false;
|
||||
}
|
||||
vid_downsampling = newdownsamplestate;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1359,10 +1343,11 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
|
||||
}
|
||||
|
||||
// Reposition window only in windowed mode
|
||||
const int windowpos = SDL_GetWindowDisplayIndex(window);
|
||||
SDL_SetWindowSize(window, width, height);
|
||||
SDL_SetWindowPosition(window,
|
||||
SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(window)),
|
||||
SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(window))
|
||||
SDL_WINDOWPOS_CENTERED_DISPLAY(windowpos),
|
||||
SDL_WINDOWPOS_CENTERED_DISPLAY(windowpos)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1384,7 +1369,7 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
|
||||
{
|
||||
I_CheckDesktopRes();
|
||||
#ifdef USE_FBO_OGL
|
||||
I_DownSample();
|
||||
I_CheckDownSampleState(false);
|
||||
#endif
|
||||
OglSdlSurface(vid.width, vid.height);
|
||||
}
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ PFNglGetString pglGetString;
|
||||
#ifdef USE_FBO_OGL
|
||||
boolean UseScreenFBO(void)
|
||||
{
|
||||
return (supportFBO && cv_glframebuffer.value && downsample);
|
||||
return (supportFBO && cv_glframebuffer.value && I_IsDownsampling() && (cv_glscreentextures.value == 2));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in new issue
Block a user