Merge remote-tracking branch 'origin/fborender' into lugstuff
This commit is contained in:
commit
1a0bf67452
3 files changed
+79
-2
No files matched your search
@@ -141,4 +141,6 @@ void RefreshSDLSurface(void);
|
||||
|
||||
boolean I_UseNativeKeyboard(void);
|
||||
|
||||
extern boolean downsample;
|
||||
|
||||
#endif
|
||||
@@ -171,6 +171,11 @@ static SDL_bool exposevideo = SDL_FALSE;
|
||||
static SDL_bool usesdl2soft = SDL_FALSE;
|
||||
static SDL_bool borderlesswindow = SDL_FALSE;
|
||||
|
||||
static boolean displayinit = false;
|
||||
static int currentDisplayIndex = -1;
|
||||
static int previousDisplayIndex = -1;
|
||||
static int numDisplays = -1;
|
||||
|
||||
// SDL2 vars
|
||||
SDL_Window *window;
|
||||
SDL_Renderer *renderer;
|
||||
@@ -215,6 +220,8 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen);
|
||||
//static void Impl_SetWindowName(const char *title);
|
||||
static void Impl_SetWindowIcon(void);
|
||||
|
||||
boolean downsample = false;
|
||||
|
||||
#ifdef HWRENDER
|
||||
void RefreshSDLSurface(void)
|
||||
{
|
||||
@@ -743,11 +750,23 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which)
|
||||
return raxis;
|
||||
}
|
||||
|
||||
static void SDL_CheckDisplays(void)
|
||||
{
|
||||
if (!displayinit) // only do this once, dont think someone ever unplugs or adds a new display during gaming lul
|
||||
{
|
||||
numDisplays = SDL_GetNumVideoDisplays(); // get all available displays
|
||||
displayinit = true;
|
||||
}
|
||||
|
||||
currentDisplayIndex = SDL_GetWindowDisplayIndex(window); // this is the current display our game window resides in
|
||||
}
|
||||
|
||||
static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
|
||||
{
|
||||
static SDL_bool firsttimeonmouse = SDL_TRUE;
|
||||
static SDL_bool mousefocus = SDL_TRUE;
|
||||
static SDL_bool kbfocus = SDL_TRUE;
|
||||
static SDL_bool windowmoved = SDL_FALSE;
|
||||
|
||||
switch (evt.event)
|
||||
{
|
||||
@@ -767,6 +786,9 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
|
||||
break;
|
||||
case SDL_WINDOWEVENT_MAXIMIZED:
|
||||
break;
|
||||
case SDL_WINDOWEVENT_MOVED:
|
||||
windowmoved = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (mousefocus && kbfocus)
|
||||
@@ -806,6 +828,36 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
|
||||
}
|
||||
}
|
||||
|
||||
if (windowmoved)
|
||||
{
|
||||
SDL_CheckDisplays();
|
||||
if (numDisplays > 1)
|
||||
{
|
||||
currentDisplayIndex = SDL_GetWindowDisplayIndex(window); // check the display index
|
||||
if (currentDisplayIndex != previousDisplayIndex) // did the display change from previous index entry?
|
||||
{
|
||||
for (int i = 0; i < numDisplays; ++i) // go through all detected displays
|
||||
{
|
||||
if (currentDisplayIndex == i) // found our current display?
|
||||
{
|
||||
SDL_DisplayMode curmode;
|
||||
if (SDL_GetCurrentDisplayMode(i, &curmode) == 0) // get info for the current display
|
||||
{
|
||||
if (cv_grframebuffer.value && ((vid.width > curmode.w) || (vid.height > curmode.h))) //framebuffer downsampler thinge
|
||||
{
|
||||
downsample = true;
|
||||
RefreshSDLSurface();
|
||||
}
|
||||
else
|
||||
downsample = false;
|
||||
}
|
||||
break; // found our current display break outta here
|
||||
}
|
||||
}
|
||||
previousDisplayIndex = currentDisplayIndex; // set current display to index
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type)
|
||||
@@ -1884,6 +1936,25 @@ INT32 VID_SetMode(INT32 modeNum)
|
||||
}
|
||||
//Impl_SetWindowName("SRB2Kart "VERSIONSTRING);
|
||||
|
||||
for (int i = 0; i < numDisplays; ++i) // go through all displays again cause our vidya mode changed
|
||||
{
|
||||
if (currentDisplayIndex == i) // find the current display
|
||||
{
|
||||
SDL_DisplayMode curmode;
|
||||
if (SDL_GetCurrentDisplayMode(i, &curmode) == 0) // get the info on current display
|
||||
{
|
||||
if (cv_grframebuffer.value && ((vid.width > curmode.w) || (vid.height > curmode.h))) //framebuffer downsampler thinge
|
||||
{
|
||||
downsample = true;
|
||||
RefreshSDLSurface(); // refresh crap so our fbo and screentextures dont break
|
||||
}
|
||||
else
|
||||
downsample = false;
|
||||
}
|
||||
break; // did everything so done lul
|
||||
}
|
||||
}
|
||||
|
||||
SDLSetMode(vid.width, vid.height, USE_FULLSCREEN);
|
||||
Impl_VideoSetupBuffer();
|
||||
|
||||
@@ -2295,6 +2366,9 @@ void I_StartupGraphics(void)
|
||||
// Fury: we do window initialization after GL setup to allow
|
||||
// SDL_GL_LoadLibrary to work well on Windows
|
||||
|
||||
//check for display things
|
||||
SDL_CheckDisplays();
|
||||
|
||||
// Create window
|
||||
//Impl_CreateWindow(USE_FULLSCREEN);
|
||||
//Impl_SetWindowName("SRB2Kart "VERSIONSTRING);
|
||||
|
||||
+3
-2
@@ -42,6 +42,7 @@
|
||||
#include "../i_system.h"
|
||||
#include "hwsym_sdl.h"
|
||||
#include "../m_argv.h"
|
||||
#include "../i_video.h"
|
||||
|
||||
#ifdef DEBUG_TO_FILE
|
||||
#include <stdarg.h>
|
||||
@@ -195,7 +196,7 @@ boolean OglSdlSurface(INT32 w, INT32 h)
|
||||
RenderToFramebuffer = FrameBufferEnabled;
|
||||
GLFramebuffer_Disable();
|
||||
|
||||
if (RenderToFramebuffer)
|
||||
if (RenderToFramebuffer && downsample)
|
||||
GLFramebuffer_Enable();
|
||||
|
||||
HWR_Startup();
|
||||
@@ -236,7 +237,7 @@ void OglSdlFinishUpdate(boolean waitvbl)
|
||||
|
||||
HWR_DrawScreenFinalTexture(sdlw, sdlh);
|
||||
|
||||
if (RenderToFramebuffer)
|
||||
if (RenderToFramebuffer && downsample)
|
||||
GLFramebuffer_Enable();
|
||||
|
||||
SDL_GL_SwapWindow(window);
|
||||
|
||||
Reference in new issue
Block a user