mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
fixed so that you can select graphics backend via gfx_threaded
This commit is contained in:
parent
4e923442e4
commit
b31abc4053
|
@ -1676,7 +1676,7 @@ void CClient::InitInterfaces()
|
|||
// fetch interfaces
|
||||
m_pEngine = Kernel()->RequestInterface<IEngine>();
|
||||
m_pEditor = Kernel()->RequestInterface<IEditor>();
|
||||
m_pGraphics = Kernel()->RequestInterface<IEngineGraphics>();
|
||||
//m_pGraphics = Kernel()->RequestInterface<IEngineGraphics>();
|
||||
m_pSound = Kernel()->RequestInterface<IEngineSound>();
|
||||
m_pGameClient = Kernel()->RequestInterface<IGameClient>();
|
||||
m_pInput = Kernel()->RequestInterface<IEngineInput>();
|
||||
|
@ -1698,10 +1698,21 @@ void CClient::Run()
|
|||
m_SnapshotParts = 0;
|
||||
|
||||
// init graphics
|
||||
if(m_pGraphics->Init() != 0)
|
||||
{
|
||||
dbg_msg("client", "couldn't init graphics");
|
||||
return;
|
||||
if(g_Config.m_GfxThreaded)
|
||||
m_pGraphics = CreateEngineGraphicsThreaded();
|
||||
else
|
||||
m_pGraphics = CreateEngineGraphics();
|
||||
|
||||
bool RegisterFail = false;
|
||||
RegisterFail = RegisterFail || !Kernel()->RegisterInterface(static_cast<IEngineGraphics*>(m_pGraphics)); // register graphics as both
|
||||
RegisterFail = RegisterFail || !Kernel()->RegisterInterface(static_cast<IGraphics*>(m_pGraphics));
|
||||
|
||||
if(RegisterFail || m_pGraphics->Init() != 0)
|
||||
{
|
||||
dbg_msg("client", "couldn't init graphics");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// open socket
|
||||
|
@ -2220,7 +2231,6 @@ int main(int argc, const char **argv) // ignore_convention
|
|||
IConsole *pConsole = CreateConsole(CFGFLAG_CLIENT);
|
||||
IStorage *pStorage = CreateStorage("Teeworlds", argc, argv); // ignore_convention
|
||||
IConfig *pConfig = CreateConfig();
|
||||
IEngineGraphics *pEngineGraphics = CreateEngineGraphics();
|
||||
IEngineSound *pEngineSound = CreateEngineSound();
|
||||
IEngineInput *pEngineInput = CreateEngineInput();
|
||||
IEngineTextRender *pEngineTextRender = CreateEngineTextRender();
|
||||
|
@ -2234,9 +2244,6 @@ int main(int argc, const char **argv) // ignore_convention
|
|||
RegisterFail = RegisterFail || !pKernel->RegisterInterface(pConsole);
|
||||
RegisterFail = RegisterFail || !pKernel->RegisterInterface(pConfig);
|
||||
|
||||
RegisterFail = RegisterFail || !pKernel->RegisterInterface(static_cast<IEngineGraphics*>(pEngineGraphics)); // register graphics as both
|
||||
RegisterFail = RegisterFail || !pKernel->RegisterInterface(static_cast<IGraphics*>(pEngineGraphics));
|
||||
|
||||
RegisterFail = RegisterFail || !pKernel->RegisterInterface(static_cast<IEngineSound*>(pEngineSound)); // register as both
|
||||
RegisterFail = RegisterFail || !pKernel->RegisterInterface(static_cast<ISound*>(pEngineSound));
|
||||
|
||||
|
|
|
@ -978,4 +978,4 @@ void CGraphics_SDL::WaitForIdle()
|
|||
{
|
||||
}
|
||||
|
||||
//extern IEngineGraphics *CreateEngineGraphics() { return new CGraphics_SDL(); }
|
||||
extern IEngineGraphics *CreateEngineGraphics() { return new CGraphics_SDL(); }
|
||||
|
|
|
@ -1293,4 +1293,4 @@ int CGraphics_Threaded::GetVideoModes(CVideoMode *pModes, int MaxModes)
|
|||
}
|
||||
|
||||
|
||||
extern IEngineGraphics *CreateEngineGraphics() { return new CGraphics_Threaded(); }
|
||||
extern IEngineGraphics *CreateEngineGraphicsThreaded() { return new CGraphics_Threaded(); }
|
||||
|
|
|
@ -157,5 +157,6 @@ public:
|
|||
};
|
||||
|
||||
extern IEngineGraphics *CreateEngineGraphics();
|
||||
extern IEngineGraphics *CreateEngineGraphicsThreaded();
|
||||
|
||||
#endif
|
||||
|
|
|
@ -72,6 +72,8 @@ MACRO_CONFIG_INT(GfxRefreshRate, gfx_refresh_rate, 0, 0, 0, CFGFLAG_SAVE|CFGFLAG
|
|||
MACRO_CONFIG_INT(GfxFinish, gfx_finish, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "")
|
||||
MACRO_CONFIG_INT(GfxAsyncRender, gfx_asyncrender, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Do rendering async from the the update")
|
||||
|
||||
MACRO_CONFIG_INT(GfxThreaded, gfx_threaded, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Use the threaded graphics backend")
|
||||
|
||||
MACRO_CONFIG_INT(InpMousesens, inp_mousesens, 100, 5, 100000, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Mouse sensitivity")
|
||||
|
||||
MACRO_CONFIG_STR(SvName, sv_name, 128, "unnamed server", CFGFLAG_SERVER, "Server name")
|
||||
|
|
|
@ -95,7 +95,6 @@ void CGameClient::OnConsoleInit()
|
|||
{
|
||||
m_pEngine = Kernel()->RequestInterface<IEngine>();
|
||||
m_pClient = Kernel()->RequestInterface<IClient>();
|
||||
m_pGraphics = Kernel()->RequestInterface<IGraphics>();
|
||||
m_pTextRender = Kernel()->RequestInterface<ITextRender>();
|
||||
m_pSound = Kernel()->RequestInterface<ISound>();
|
||||
m_pInput = Kernel()->RequestInterface<IInput>();
|
||||
|
@ -196,10 +195,6 @@ void CGameClient::OnConsoleInit()
|
|||
Console()->Register("vote", "r", CFGFLAG_SERVER, 0, 0, "Force a vote to yes/no");
|
||||
|
||||
|
||||
// propagate pointers
|
||||
m_UI.SetGraphics(Graphics(), TextRender());
|
||||
m_RenderTools.m_pGraphics = Graphics();
|
||||
m_RenderTools.m_pUI = UI();
|
||||
for(int i = 0; i < m_All.m_Num; i++)
|
||||
m_All.m_paComponents[i]->m_pClient = this;
|
||||
|
||||
|
@ -223,6 +218,13 @@ void CGameClient::OnConsoleInit()
|
|||
|
||||
void CGameClient::OnInit()
|
||||
{
|
||||
m_pGraphics = Kernel()->RequestInterface<IGraphics>();
|
||||
|
||||
// propagate pointers
|
||||
m_UI.SetGraphics(Graphics(), TextRender());
|
||||
m_RenderTools.m_pGraphics = Graphics();
|
||||
m_RenderTools.m_pUI = UI();
|
||||
|
||||
int64 Start = time_get();
|
||||
|
||||
// set the language
|
||||
|
|
Loading…
Reference in a new issue