mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
moving to sdl2, input is broken, build is broken; do not use
This commit is contained in:
parent
e7f1a8ab79
commit
8e8b1516e2
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -9,3 +9,4 @@ scripts/work/
|
||||||
/SDL.dll
|
/SDL.dll
|
||||||
/freetype.dll
|
/freetype.dll
|
||||||
/autoexec.cfg
|
/autoexec.cfg
|
||||||
|
*~
|
||||||
|
|
|
@ -9,10 +9,10 @@ SDL = {
|
||||||
option.use_winlib = 0
|
option.use_winlib = 0
|
||||||
option.lib_path = nil
|
option.lib_path = nil
|
||||||
|
|
||||||
if ExecuteSilent("pkg-config sdl") == 0 then
|
if ExecuteSilent("pkg-config sdl2") == 0 then
|
||||||
option.value = true
|
option.value = true
|
||||||
option.use_pkgconfig = true
|
option.use_pkgconfig = true
|
||||||
elseif ExecuteSilent("sdl-config") > 0 and ExecuteSilent("sdl-config --cflags") == 0 then
|
elseif ExecuteSilent("sdl2-config") > 0 and ExecuteSilent("sdl2-config --cflags") == 0 then
|
||||||
option.value = true
|
option.value = true
|
||||||
option.use_sdlconfig = true
|
option.use_sdlconfig = true
|
||||||
end
|
end
|
||||||
|
@ -28,11 +28,11 @@ SDL = {
|
||||||
|
|
||||||
local apply = function(option, settings)
|
local apply = function(option, settings)
|
||||||
if option.use_pkgconfig == true then
|
if option.use_pkgconfig == true then
|
||||||
settings.cc.flags:Add("`pkg-config --cflags sdl`")
|
settings.cc.flags:Add("`pkg-config --cflags sdl2`")
|
||||||
settings.link.flags:Add("`pkg-config --libs sdl`")
|
settings.link.flags:Add("`pkg-config --libs sdl2`")
|
||||||
elseif option.use_sdlconfig == true then
|
elseif option.use_sdlconfig == true then
|
||||||
settings.cc.flags:Add("`sdl-config --cflags`")
|
settings.cc.flags:Add("`sdl2-config --cflags`")
|
||||||
settings.link.flags:Add("`sdl-config --libs`")
|
settings.link.flags:Add("`sdl2-config --libs`")
|
||||||
elseif option.use_winlib > 0 then
|
elseif option.use_winlib > 0 then
|
||||||
settings.cc.includes:Add(SDL.basepath .. "/include")
|
settings.cc.includes:Add(SDL.basepath .. "/include")
|
||||||
if option.use_winlib == 32 then
|
if option.use_winlib == 32 then
|
||||||
|
@ -55,7 +55,7 @@ SDL = {
|
||||||
local display = function(option)
|
local display = function(option)
|
||||||
if option.value == true then
|
if option.value == true then
|
||||||
if option.use_pkgconfig == true then return "using pkg-config" end
|
if option.use_pkgconfig == true then return "using pkg-config" end
|
||||||
if option.use_sdlconfig == true then return "using sdl-config" end
|
if option.use_sdlconfig == true then return "using sdl2-config" end
|
||||||
if option.use_winlib == 32 then return "using supplied win32 libraries" end
|
if option.use_winlib == 32 then return "using supplied win32 libraries" end
|
||||||
if option.use_winlib == 64 then return "using supplied win64 libraries" end
|
if option.use_winlib == 64 then return "using supplied win64 libraries" end
|
||||||
return "using unknown method"
|
return "using unknown method"
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
|
|
||||||
#include "SDL.h"
|
#include <SDL2/SDL.h>
|
||||||
#include "SDL_opengl.h"
|
#include <SDL2/SDL_opengl.h>
|
||||||
|
#include <GL/gl.h>
|
||||||
|
#include <GL/glu.h>
|
||||||
|
|
||||||
#include <base/tl/threading.h>
|
#include <base/tl/threading.h>
|
||||||
|
|
||||||
|
@ -474,8 +476,8 @@ bool CCommandProcessorFragment_OpenGL::RunCommand(const CCommandBuffer::SCommand
|
||||||
|
|
||||||
void CCommandProcessorFragment_SDL::Cmd_Init(const SCommand_Init *pCommand)
|
void CCommandProcessorFragment_SDL::Cmd_Init(const SCommand_Init *pCommand)
|
||||||
{
|
{
|
||||||
m_GLContext = pCommand->m_Context;
|
m_GLContext = pCommand->m_GLContext;
|
||||||
GL_MakeCurrent(m_GLContext);
|
SDL_GL_MakeCurrent(m_pWindow, m_GLContext);
|
||||||
|
|
||||||
// set some default settings
|
// set some default settings
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
|
@ -491,12 +493,12 @@ void CCommandProcessorFragment_SDL::Cmd_Init(const SCommand_Init *pCommand)
|
||||||
|
|
||||||
void CCommandProcessorFragment_SDL::Cmd_Shutdown(const SCommand_Shutdown *pCommand)
|
void CCommandProcessorFragment_SDL::Cmd_Shutdown(const SCommand_Shutdown *pCommand)
|
||||||
{
|
{
|
||||||
GL_ReleaseContext(m_GLContext);
|
SDL_GL_MakeCurrent(NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCommandProcessorFragment_SDL::Cmd_Swap(const CCommandBuffer::SCommand_Swap *pCommand)
|
void CCommandProcessorFragment_SDL::Cmd_Swap(const CCommandBuffer::SCommand_Swap *pCommand)
|
||||||
{
|
{
|
||||||
GL_SwapBuffers(m_GLContext);
|
SDL_GL_SwapWindow(m_pWindow);
|
||||||
|
|
||||||
if(pCommand->m_Finish)
|
if(pCommand->m_Finish)
|
||||||
glFinish();
|
glFinish();
|
||||||
|
@ -504,36 +506,39 @@ void CCommandProcessorFragment_SDL::Cmd_Swap(const CCommandBuffer::SCommand_Swap
|
||||||
|
|
||||||
void CCommandProcessorFragment_SDL::Cmd_VideoModes(const CCommandBuffer::SCommand_VideoModes *pCommand)
|
void CCommandProcessorFragment_SDL::Cmd_VideoModes(const CCommandBuffer::SCommand_VideoModes *pCommand)
|
||||||
{
|
{
|
||||||
// TODO: fix this code on osx or windows
|
SDL_DisplayMode mode;
|
||||||
SDL_Rect **ppModes = SDL_ListModes(NULL, SDL_OPENGL|SDL_GL_DOUBLEBUFFER|SDL_FULLSCREEN);
|
int maxModes = SDL_GetNumDisplayModes(pCommand->m_Screen),
|
||||||
if(ppModes == NULL)
|
numModes = 0;
|
||||||
|
|
||||||
|
for(int i = 0; i < maxModes; i++)
|
||||||
{
|
{
|
||||||
// no modes
|
if(SDL_GetDisplayMode(pCommand->m_Screen, i, &mode) < 0)
|
||||||
*pCommand->m_pNumModes = 0;
|
|
||||||
}
|
|
||||||
else if(ppModes == (SDL_Rect**)-1)
|
|
||||||
{
|
{
|
||||||
// no modes
|
dbg_msg("gfx", "unable to get display mode: %s", SDL_GetError());
|
||||||
*pCommand->m_pNumModes = 0;
|
continue;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int NumModes = 0;
|
|
||||||
for(int i = 0; ppModes[i]; ++i)
|
|
||||||
{
|
|
||||||
if(NumModes == pCommand->m_MaxModes)
|
|
||||||
break;
|
|
||||||
pCommand->m_pModes[NumModes].m_Width = ppModes[i]->w;
|
|
||||||
pCommand->m_pModes[NumModes].m_Height = ppModes[i]->h;
|
|
||||||
pCommand->m_pModes[NumModes].m_Red = 8;
|
|
||||||
pCommand->m_pModes[NumModes].m_Green = 8;
|
|
||||||
pCommand->m_pModes[NumModes].m_Blue = 8;
|
|
||||||
NumModes++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*pCommand->m_pNumModes = NumModes;
|
bool alreadyFound = false;
|
||||||
|
for(int j = 0; j < numModes; j++)
|
||||||
|
{
|
||||||
|
if(pCommand->m_pModes[j].m_Width == mode.w && pCommand->m_pModes[j].m_Height == mode.h)
|
||||||
|
{
|
||||||
|
alreadyFound = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(alreadyFound)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
pCommand->m_pModes[numModes].m_Width = mode.w;
|
||||||
|
pCommand->m_pModes[numModes].m_Height = mode.h;
|
||||||
|
pCommand->m_pModes[numModes].m_Red = 8;
|
||||||
|
pCommand->m_pModes[numModes].m_Green = 8;
|
||||||
|
pCommand->m_pModes[numModes].m_Blue = 8;
|
||||||
|
numModes++;
|
||||||
|
}
|
||||||
|
*pCommand->m_pNumModes = numModes;
|
||||||
|
}
|
||||||
|
|
||||||
CCommandProcessorFragment_SDL::CCommandProcessorFragment_SDL()
|
CCommandProcessorFragment_SDL::CCommandProcessorFragment_SDL()
|
||||||
{
|
{
|
||||||
|
@ -579,7 +584,7 @@ void CCommandProcessor_SDL_OpenGL::RunBuffer(CCommandBuffer *pBuffer)
|
||||||
|
|
||||||
// ------------ CGraphicsBackend_SDL_OpenGL
|
// ------------ CGraphicsBackend_SDL_OpenGL
|
||||||
|
|
||||||
int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Width, int *Height, int FsaaSamples, int Flags, int *pDesktopWidth, int *pDesktopHeight)
|
int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int Screen, int *Width, int *Height, int FsaaSamples, int Flags, int *pDesktopWidth, int *pDesktopHeight)
|
||||||
{
|
{
|
||||||
if(!SDL_WasInit(SDL_INIT_VIDEO))
|
if(!SDL_WasInit(SDL_INIT_VIDEO))
|
||||||
{
|
{
|
||||||
|
@ -595,42 +600,36 @@ int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Width, int *Height
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
const SDL_VideoInfo *pInfo = SDL_GetVideoInfo();
|
SDL_Rect ScreenBounds;
|
||||||
SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE); // prevent stuck mouse cursor sdl-bug when loosing fullscreen focus in windows
|
if(SDL_GetDisplayBounds(Screen, &ScreenBounds) < 0)
|
||||||
|
{
|
||||||
|
dbg_msg("gfx", "unable to get current screen bounds: %s", SDL_GetError());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
// use current resolution as default
|
// use current resolution as default
|
||||||
if(*Width == 0 || *Height == 0)
|
if(*Width == 0 || *Height == 0)
|
||||||
{
|
{
|
||||||
*Width = pInfo->current_w;
|
*Width = ScreenBounds.w;
|
||||||
*Height = pInfo->current_h;
|
*Height = ScreenBounds.h;
|
||||||
}
|
}
|
||||||
|
|
||||||
// store desktop resolution for settings reset button
|
// store desktop resolution for settings reset button
|
||||||
*pDesktopWidth = pInfo->current_w;
|
*pDesktopWidth = ScreenBounds.w;
|
||||||
*pDesktopHeight = pInfo->current_h;
|
*pDesktopHeight = ScreenBounds.h;
|
||||||
|
|
||||||
// set flags
|
|
||||||
int SdlFlags = SDL_OPENGL;
|
|
||||||
if(Flags&IGraphicsBackend::INITFLAG_RESIZABLE)
|
|
||||||
SdlFlags |= SDL_RESIZABLE;
|
|
||||||
|
|
||||||
if(pInfo->hw_available) // ignore_convention
|
|
||||||
SdlFlags |= SDL_HWSURFACE;
|
|
||||||
else
|
|
||||||
SdlFlags |= SDL_SWSURFACE;
|
|
||||||
|
|
||||||
if(pInfo->blit_hw) // ignore_convention
|
|
||||||
SdlFlags |= SDL_HWACCEL;
|
|
||||||
|
|
||||||
dbg_assert(!(Flags&IGraphicsBackend::INITFLAG_BORDERLESS)
|
dbg_assert(!(Flags&IGraphicsBackend::INITFLAG_BORDERLESS)
|
||||||
|| !(Flags&IGraphicsBackend::INITFLAG_FULLSCREEN),
|
|| !(Flags&IGraphicsBackend::INITFLAG_FULLSCREEN),
|
||||||
"only one of borderless and fullscreen may be activated at the same time");
|
"only one of borderless and fullscreen may be activated at the same time");
|
||||||
|
|
||||||
|
// set flags
|
||||||
|
int SdlFlags = SDL_WINDOW_OPENGL;
|
||||||
|
if(Flags&IGraphicsBackend::INITFLAG_RESIZABLE)
|
||||||
|
SdlFlags |= SDL_WINDOW_RESIZABLE;
|
||||||
if(Flags&IGraphicsBackend::INITFLAG_BORDERLESS)
|
if(Flags&IGraphicsBackend::INITFLAG_BORDERLESS)
|
||||||
SdlFlags |= SDL_NOFRAME;
|
SdlFlags |= SDL_WINDOW_BORDERLESS;
|
||||||
|
|
||||||
if(Flags&IGraphicsBackend::INITFLAG_FULLSCREEN)
|
if(Flags&IGraphicsBackend::INITFLAG_FULLSCREEN)
|
||||||
SdlFlags |= SDL_FULLSCREEN;
|
SdlFlags |= SDL_WINDOW_FULLSCREEN;
|
||||||
|
|
||||||
// set gl attributes
|
// set gl attributes
|
||||||
if(FsaaSamples)
|
if(FsaaSamples)
|
||||||
|
@ -645,34 +644,29 @@ int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Width, int *Height
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||||
SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, Flags&IGraphicsBackend::INITFLAG_VSYNC ? 1 : 0);
|
SDL_GL_SetSwapInterval(Flags&IGraphicsBackend::INITFLAG_VSYNC ? 1 : 0);
|
||||||
|
|
||||||
// set caption
|
m_pWindow = SDL_CreateWindow(
|
||||||
SDL_WM_SetCaption(pName, pName);
|
pName,
|
||||||
|
SDL_WINDOWPOS_UNDEFINED_DISPLAY(0),
|
||||||
|
SDL_WINDOWPOS_UNDEFINED_DISPLAY(0),
|
||||||
|
*Width,
|
||||||
|
*Height,
|
||||||
|
SdlFlags);
|
||||||
|
|
||||||
// create window
|
if(m_pWindow == NULL)
|
||||||
m_pScreenSurface = SDL_SetVideoMode(*Width, *Height, 0, SdlFlags);
|
|
||||||
if(!m_pScreenSurface)
|
|
||||||
{
|
{
|
||||||
dbg_msg("gfx", "unable to set video mode: %s", SDL_GetError());
|
dbg_msg("gfx", "unable to create window: %s", SDL_GetError());
|
||||||
//*pCommand->m_pResult = -1;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CONF_FAMILY_WINDOWS)
|
m_GLContext = SDL_GL_CreateContext(m_pWindow);
|
||||||
glTexImage3D = (PFNGLTEXIMAGE3DPROC) wglGetProcAddress("glTexImage3D");
|
|
||||||
if(glTexImage3D == 0)
|
if(m_GLContext == NULL)
|
||||||
{
|
{
|
||||||
dbg_msg("gfx", "glTexImage3D not supported");
|
dbg_msg("gfx", "unable to create renderer: %s", SDL_GetError());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
SDL_ShowCursor(0);
|
|
||||||
|
|
||||||
// fetch gl contexts and release the context from this thread
|
|
||||||
m_GLContext = GL_GetCurrentContext();
|
|
||||||
GL_ReleaseContext(m_GLContext);
|
|
||||||
|
|
||||||
// start the command processor
|
// start the command processor
|
||||||
m_pProcessor = new CCommandProcessor_SDL_OpenGL;
|
m_pProcessor = new CCommandProcessor_SDL_OpenGL;
|
||||||
|
@ -684,7 +678,7 @@ int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Width, int *Height
|
||||||
CmdOpenGL.m_pTextureMemoryUsage = &m_TextureMemoryUsage;
|
CmdOpenGL.m_pTextureMemoryUsage = &m_TextureMemoryUsage;
|
||||||
CmdBuffer.AddCommand(CmdOpenGL);
|
CmdBuffer.AddCommand(CmdOpenGL);
|
||||||
CCommandProcessorFragment_SDL::SCommand_Init CmdSDL;
|
CCommandProcessorFragment_SDL::SCommand_Init CmdSDL;
|
||||||
CmdSDL.m_Context = m_GLContext;
|
CmdSDL.m_GLContext = m_GLContext;
|
||||||
CmdBuffer.AddCommand(CmdSDL);
|
CmdBuffer.AddCommand(CmdSDL);
|
||||||
RunBuffer(&CmdBuffer);
|
RunBuffer(&CmdBuffer);
|
||||||
WaitForIdle();
|
WaitForIdle();
|
||||||
|
@ -718,7 +712,7 @@ int CGraphicsBackend_SDL_OpenGL::MemoryUsage() const
|
||||||
|
|
||||||
void CGraphicsBackend_SDL_OpenGL::Minimize()
|
void CGraphicsBackend_SDL_OpenGL::Minimize()
|
||||||
{
|
{
|
||||||
SDL_WM_IconifyWindow();
|
SDL_MinimizeWindow(m_pWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGraphicsBackend_SDL_OpenGL::Maximize()
|
void CGraphicsBackend_SDL_OpenGL::Maximize()
|
||||||
|
@ -728,12 +722,12 @@ void CGraphicsBackend_SDL_OpenGL::Maximize()
|
||||||
|
|
||||||
int CGraphicsBackend_SDL_OpenGL::WindowActive()
|
int CGraphicsBackend_SDL_OpenGL::WindowActive()
|
||||||
{
|
{
|
||||||
return SDL_GetAppState()&SDL_APPINPUTFOCUS;
|
return SDL_GetWindowFlags(m_pWindow)&SDL_WINDOW_INPUT_FOCUS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CGraphicsBackend_SDL_OpenGL::WindowOpen()
|
int CGraphicsBackend_SDL_OpenGL::WindowOpen()
|
||||||
{
|
{
|
||||||
return SDL_GetAppState()&SDL_APPACTIVE;
|
return SDL_GetWindowFlags(m_pWindow)&SDL_WINDOW_SHOWN;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -218,7 +218,8 @@ public:
|
||||||
class CCommandProcessorFragment_SDL
|
class CCommandProcessorFragment_SDL
|
||||||
{
|
{
|
||||||
// SDL stuff
|
// SDL stuff
|
||||||
SGLContext m_GLContext;
|
SDL_Window *m_pWindow;
|
||||||
|
SDL_GLContext m_GLContext;
|
||||||
public:
|
public:
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -229,7 +230,8 @@ public:
|
||||||
struct SCommand_Init : public CCommandBuffer::SCommand
|
struct SCommand_Init : public CCommandBuffer::SCommand
|
||||||
{
|
{
|
||||||
SCommand_Init() : SCommand(CMD_INIT) {}
|
SCommand_Init() : SCommand(CMD_INIT) {}
|
||||||
SGLContext m_Context;
|
SDL_Window *m_pWindow;
|
||||||
|
SDL_GLContext m_GLContext;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SCommand_Shutdown : public CCommandBuffer::SCommand
|
struct SCommand_Shutdown : public CCommandBuffer::SCommand
|
||||||
|
@ -261,12 +263,12 @@ class CCommandProcessor_SDL_OpenGL : public CGraphicsBackend_Threaded::ICommandP
|
||||||
// graphics backend implemented with SDL and OpenGL
|
// graphics backend implemented with SDL and OpenGL
|
||||||
class CGraphicsBackend_SDL_OpenGL : public CGraphicsBackend_Threaded
|
class CGraphicsBackend_SDL_OpenGL : public CGraphicsBackend_Threaded
|
||||||
{
|
{
|
||||||
SDL_Surface *m_pScreenSurface;
|
SDL_Window *m_pWindow;
|
||||||
|
SDL_GLContext m_GLContext;
|
||||||
ICommandProcessor *m_pProcessor;
|
ICommandProcessor *m_pProcessor;
|
||||||
SGLContext m_GLContext;
|
|
||||||
volatile int m_TextureMemoryUsage;
|
volatile int m_TextureMemoryUsage;
|
||||||
public:
|
public:
|
||||||
virtual int Init(const char *pName, int *Width, int *Height, int FsaaSamples, int Flags, int *pDesktopWidth, int *pDesktopHeight);
|
virtual int Init(const char *pName, int Screen, int *Width, int *Height, int FsaaSamples, int Flags, int *pDesktopWidth, int *pDesktopHeight);
|
||||||
virtual int Shutdown();
|
virtual int Shutdown();
|
||||||
|
|
||||||
virtual int MemoryUsage() const;
|
virtual int MemoryUsage() const;
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "SDL.h"
|
#include "SDL2/SDL.h"
|
||||||
#ifdef main
|
#ifdef main
|
||||||
#undef main
|
#undef main
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -709,7 +709,7 @@ int CGraphics_Threaded::IssueInit()
|
||||||
if(g_Config.m_GfxVsync) Flags |= IGraphicsBackend::INITFLAG_VSYNC;
|
if(g_Config.m_GfxVsync) Flags |= IGraphicsBackend::INITFLAG_VSYNC;
|
||||||
if(g_Config.m_DbgResizable) Flags |= IGraphicsBackend::INITFLAG_RESIZABLE;
|
if(g_Config.m_DbgResizable) Flags |= IGraphicsBackend::INITFLAG_RESIZABLE;
|
||||||
|
|
||||||
return m_pBackend->Init("Teeworlds", &g_Config.m_GfxScreenWidth, &g_Config.m_GfxScreenHeight, g_Config.m_GfxFsaaSamples, Flags, &m_DesktopScreenWidth, &m_DesktopScreenHeight);
|
return m_pBackend->Init("Teeworlds", g_Config.m_GfxScreen, &g_Config.m_GfxScreenWidth, &g_Config.m_GfxScreenHeight, g_Config.m_GfxFsaaSamples, Flags, &m_DesktopScreenWidth, &m_DesktopScreenHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CGraphics_Threaded::InitWindow()
|
int CGraphics_Threaded::InitWindow()
|
||||||
|
@ -898,7 +898,7 @@ void CGraphics_Threaded::WaitForIdle()
|
||||||
m_pBackend->WaitForIdle();
|
m_pBackend->WaitForIdle();
|
||||||
}
|
}
|
||||||
|
|
||||||
int CGraphics_Threaded::GetVideoModes(CVideoMode *pModes, int MaxModes)
|
int CGraphics_Threaded::GetVideoModes(CVideoMode *pModes, int MaxModes, int Screen)
|
||||||
{
|
{
|
||||||
if(g_Config.m_GfxDisplayAllModes)
|
if(g_Config.m_GfxDisplayAllModes)
|
||||||
{
|
{
|
||||||
|
@ -914,7 +914,7 @@ int CGraphics_Threaded::GetVideoModes(CVideoMode *pModes, int MaxModes)
|
||||||
mem_zero(&Image, sizeof(Image));
|
mem_zero(&Image, sizeof(Image));
|
||||||
|
|
||||||
int NumModes = 0;
|
int NumModes = 0;
|
||||||
CCommandBuffer::SCommand_VideoModes Cmd;
|
CCommandBuffer::SCommand_VideoModes Cmd(Screen);
|
||||||
Cmd.m_pModes = pModes;
|
Cmd.m_pModes = pModes;
|
||||||
Cmd.m_MaxModes = MaxModes;
|
Cmd.m_MaxModes = MaxModes;
|
||||||
Cmd.m_pNumModes = &NumModes;
|
Cmd.m_pNumModes = &NumModes;
|
||||||
|
|
|
@ -193,11 +193,13 @@ public:
|
||||||
|
|
||||||
struct SCommand_VideoModes : public SCommand
|
struct SCommand_VideoModes : public SCommand
|
||||||
{
|
{
|
||||||
SCommand_VideoModes() : SCommand(CMD_VIDEOMODES) {}
|
SCommand_VideoModes(int screen) : SCommand(CMD_VIDEOMODES),
|
||||||
|
m_Screen(screen) {}
|
||||||
|
|
||||||
CVideoMode *m_pModes; // processor will fill this in
|
CVideoMode *m_pModes; // processor will fill this in
|
||||||
int m_MaxModes; // maximum of modes the processor can write to the m_pModes
|
int m_MaxModes; // maximum of modes the processor can write to the m_pModes
|
||||||
int *m_pNumModes; // processor will write to this pointer
|
int *m_pNumModes; // processor will write to this pointer
|
||||||
|
int m_Screen;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SCommand_Swap : public SCommand
|
struct SCommand_Swap : public SCommand
|
||||||
|
@ -305,7 +307,7 @@ public:
|
||||||
|
|
||||||
virtual ~IGraphicsBackend() {}
|
virtual ~IGraphicsBackend() {}
|
||||||
|
|
||||||
virtual int Init(const char *pName, int *Width, int *Height, int FsaaSamples, int Flags, int *pDesktopWidth, int *pDesktopHeight) = 0;
|
virtual int Init(const char *pName, int Screen, int *Width, int *Height, int FsaaSamples, int Flags, int *pDesktopWidth, int *pDesktopHeight) = 0;
|
||||||
virtual int Shutdown() = 0;
|
virtual int Shutdown() = 0;
|
||||||
|
|
||||||
virtual int MemoryUsage() const = 0;
|
virtual int MemoryUsage() const = 0;
|
||||||
|
@ -437,7 +439,7 @@ public:
|
||||||
virtual void TakeScreenshot(const char *pFilename);
|
virtual void TakeScreenshot(const char *pFilename);
|
||||||
virtual void Swap();
|
virtual void Swap();
|
||||||
|
|
||||||
virtual int GetVideoModes(CVideoMode *pModes, int MaxModes);
|
virtual int GetVideoModes(CVideoMode *pModes, int MaxModes, int Screen);
|
||||||
|
|
||||||
virtual int GetDesktopScreenWidth() { return m_DesktopScreenWidth; }
|
virtual int GetDesktopScreenWidth() { return m_DesktopScreenWidth; }
|
||||||
virtual int GetDesktopScreenHeight() { return m_DesktopScreenHeight; }
|
virtual int GetDesktopScreenHeight() { return m_DesktopScreenHeight; }
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
#include <engine/shared/config.h>
|
#include <engine/shared/config.h>
|
||||||
|
|
||||||
#include "SDL.h"
|
#include <SDL2/SDL.h>
|
||||||
|
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
|
|
||||||
|
|
|
@ -158,7 +158,7 @@ public:
|
||||||
virtual void SetColor4(vec4 TopLeft, vec4 TopRight, vec4 BottomLeft, vec4 BottomRight) = 0;
|
virtual void SetColor4(vec4 TopLeft, vec4 TopRight, vec4 BottomLeft, vec4 BottomRight) = 0;
|
||||||
|
|
||||||
virtual void TakeScreenshot(const char *pFilename) = 0;
|
virtual void TakeScreenshot(const char *pFilename) = 0;
|
||||||
virtual int GetVideoModes(CVideoMode *pModes, int MaxModes) = 0;
|
virtual int GetVideoModes(CVideoMode *pModes, int MaxModes, int Screen) = 0;
|
||||||
|
|
||||||
virtual int GetDesktopScreenWidth() = 0;
|
virtual int GetDesktopScreenWidth() = 0;
|
||||||
virtual int GetDesktopScreenHeight() = 0;
|
virtual int GetDesktopScreenHeight() = 0;
|
||||||
|
|
|
@ -57,6 +57,7 @@ MACRO_CONFIG_INT(SndDevice, snd_device, -1, 0, 0, CFGFLAG_SAVE|CFGFLAG_CLIENT, "
|
||||||
|
|
||||||
MACRO_CONFIG_INT(SndNonactiveMute, snd_nonactive_mute, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "")
|
MACRO_CONFIG_INT(SndNonactiveMute, snd_nonactive_mute, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "")
|
||||||
|
|
||||||
|
MACRO_CONFIG_INT(GfxScreen, gfx_screen, 0, 0, 0, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Screen index")
|
||||||
MACRO_CONFIG_INT(GfxScreenWidth, gfx_screen_width, 0, 0, 0, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Screen resolution width")
|
MACRO_CONFIG_INT(GfxScreenWidth, gfx_screen_width, 0, 0, 0, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Screen resolution width")
|
||||||
MACRO_CONFIG_INT(GfxScreenHeight, gfx_screen_height, 0, 0, 0, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Screen resolution height")
|
MACRO_CONFIG_INT(GfxScreenHeight, gfx_screen_height, 0, 0, 0, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Screen resolution height")
|
||||||
MACRO_CONFIG_INT(GfxBorderless, gfx_borderless, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Borderless window (not to be used with fullscreen)")
|
MACRO_CONFIG_INT(GfxBorderless, gfx_borderless, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Borderless window (not to be used with fullscreen)")
|
||||||
|
|
|
@ -1482,7 +1482,7 @@ void CMenus::UpdatedFilteredVideoModes()
|
||||||
|
|
||||||
void CMenus::OnInit()
|
void CMenus::OnInit()
|
||||||
{
|
{
|
||||||
m_NumModes = Graphics()->GetVideoModes(m_aModes, MAX_RESOLUTIONS);
|
m_NumModes = Graphics()->GetVideoModes(m_aModes, MAX_RESOLUTIONS, g_Config.m_GfxScreen);
|
||||||
UpdateVideoFormats();
|
UpdateVideoFormats();
|
||||||
|
|
||||||
bool Found = false;
|
bool Found = false;
|
||||||
|
|
|
@ -1318,7 +1318,7 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
|
||||||
if(DoButton_CheckBox(&s_GfxDisplayAllModes, Localize("Show only supported"), g_Config.m_GfxDisplayAllModes^1, &Button))
|
if(DoButton_CheckBox(&s_GfxDisplayAllModes, Localize("Show only supported"), g_Config.m_GfxDisplayAllModes^1, &Button))
|
||||||
{
|
{
|
||||||
g_Config.m_GfxDisplayAllModes ^= 1;
|
g_Config.m_GfxDisplayAllModes ^= 1;
|
||||||
m_NumModes = Graphics()->GetVideoModes(m_aModes, MAX_RESOLUTIONS);
|
m_NumModes = Graphics()->GetVideoModes(m_aModes, MAX_RESOLUTIONS, g_Config.m_GfxScreen);
|
||||||
UpdateVideoFormats();
|
UpdateVideoFormats();
|
||||||
|
|
||||||
bool Found = false;
|
bool Found = false;
|
||||||
|
@ -1444,7 +1444,7 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
|
||||||
if(g_Config.m_GfxDisplayAllModes)
|
if(g_Config.m_GfxDisplayAllModes)
|
||||||
{
|
{
|
||||||
g_Config.m_GfxDisplayAllModes = 0;
|
g_Config.m_GfxDisplayAllModes = 0;
|
||||||
m_NumModes = Graphics()->GetVideoModes(m_aModes, MAX_RESOLUTIONS);
|
m_NumModes = Graphics()->GetVideoModes(m_aModes, MAX_RESOLUTIONS, g_Config.m_GfxScreen);
|
||||||
UpdateVideoFormats();
|
UpdateVideoFormats();
|
||||||
|
|
||||||
bool Found = false;
|
bool Found = false;
|
||||||
|
|
Loading…
Reference in a new issue