mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Fix modern GL graphic settings for the multi backend
This commit is contained in:
parent
b8f96ce500
commit
6f01de1193
|
@ -620,6 +620,52 @@ bool CGraphicsBackend_SDL_OpenGL::IsModernAPI(EBackendType BackendType)
|
|||
return false;
|
||||
}
|
||||
|
||||
void CGraphicsBackend_SDL_OpenGL::GetDriverVersion(EGraphicsDriverAgeType DriverAgeType, int &Major, int &Minor, int &Patch)
|
||||
{
|
||||
if(m_BackendType == BACKEND_TYPE_OPENGL)
|
||||
{
|
||||
if(DriverAgeType == GRAPHICS_DRIVER_AGE_TYPE_LEGACY)
|
||||
{
|
||||
Major = 1;
|
||||
Minor = 4;
|
||||
Patch = 0;
|
||||
}
|
||||
else if(DriverAgeType == GRAPHICS_DRIVER_AGE_TYPE_DEFAULT)
|
||||
{
|
||||
Major = 3;
|
||||
Minor = 0;
|
||||
Patch = 0;
|
||||
}
|
||||
else if(DriverAgeType == GRAPHICS_DRIVER_AGE_TYPE_MODERN)
|
||||
{
|
||||
Major = 3;
|
||||
Minor = 3;
|
||||
Patch = 0;
|
||||
}
|
||||
}
|
||||
else if(m_BackendType == BACKEND_TYPE_OPENGL_ES)
|
||||
{
|
||||
if(DriverAgeType == GRAPHICS_DRIVER_AGE_TYPE_LEGACY)
|
||||
{
|
||||
Major = 1;
|
||||
Minor = 0;
|
||||
Patch = 0;
|
||||
}
|
||||
else if(DriverAgeType == GRAPHICS_DRIVER_AGE_TYPE_DEFAULT)
|
||||
{
|
||||
Major = 3;
|
||||
Minor = 0;
|
||||
Patch = 0;
|
||||
}
|
||||
else if(DriverAgeType == GRAPHICS_DRIVER_AGE_TYPE_MODERN)
|
||||
{
|
||||
Major = 3;
|
||||
Minor = 0;
|
||||
Patch = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Screen, int *pWidth, int *pHeight, int FsaaSamples, int Flags, int *pDesktopWidth, int *pDesktopHeight, int *pCurrentWidth, int *pCurrentHeight, IStorage *pStorage)
|
||||
{
|
||||
// print sdl version
|
||||
|
@ -642,17 +688,17 @@ int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Screen, int *pWidt
|
|||
}
|
||||
}
|
||||
|
||||
EBackendType BackendType = DetectBackend();
|
||||
m_BackendType = DetectBackend();
|
||||
|
||||
ClampDriverVersion(BackendType);
|
||||
ClampDriverVersion(m_BackendType);
|
||||
|
||||
m_UseNewOpenGL = IsModernAPI(BackendType);
|
||||
m_UseNewOpenGL = IsModernAPI(m_BackendType);
|
||||
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, g_Config.m_GfxOpenGLMajor);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, g_Config.m_GfxOpenGLMinor);
|
||||
dbg_msg("gfx", "Created OpenGL %zu.%zu context.", (size_t)g_Config.m_GfxOpenGLMajor, (size_t)g_Config.m_GfxOpenGLMinor);
|
||||
|
||||
if(BackendType == BACKEND_TYPE_OPENGL)
|
||||
if(m_BackendType == BACKEND_TYPE_OPENGL)
|
||||
{
|
||||
if(g_Config.m_GfxOpenGLMajor == 3 && g_Config.m_GfxOpenGLMinor == 0)
|
||||
{
|
||||
|
@ -663,7 +709,7 @@ int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Screen, int *pWidt
|
|||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
|
||||
}
|
||||
}
|
||||
else if(BackendType == BACKEND_TYPE_OPENGL_ES)
|
||||
else if(m_BackendType == BACKEND_TYPE_OPENGL_ES)
|
||||
{
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
|
||||
}
|
||||
|
@ -787,7 +833,7 @@ int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Screen, int *pWidt
|
|||
int GlewMinor = 0;
|
||||
int GlewPatch = 0;
|
||||
|
||||
if(!BackendInitGlew(BackendType, GlewMajor, GlewMinor, GlewPatch))
|
||||
if(!BackendInitGlew(m_BackendType, GlewMajor, GlewMinor, GlewPatch))
|
||||
{
|
||||
SDL_GL_DeleteContext(m_GLContext);
|
||||
SDL_DestroyWindow(m_pWindow);
|
||||
|
@ -797,7 +843,7 @@ int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Screen, int *pWidt
|
|||
int InitError = 0;
|
||||
const char *pErrorStr = NULL;
|
||||
|
||||
InitError = IsVersionSupportedGlew(BackendType, g_Config.m_GfxOpenGLMajor, g_Config.m_GfxOpenGLMinor, g_Config.m_GfxOpenGLPatch, GlewMajor, GlewMinor, GlewPatch);
|
||||
InitError = IsVersionSupportedGlew(m_BackendType, g_Config.m_GfxOpenGLMajor, g_Config.m_GfxOpenGLMinor, g_Config.m_GfxOpenGLPatch, GlewMajor, GlewMinor, GlewPatch);
|
||||
|
||||
SDL_GL_GetDrawableSize(m_pWindow, pCurrentWidth, pCurrentHeight);
|
||||
SDL_GL_SetSwapInterval(Flags & IGraphicsBackend::INITFLAG_VSYNC ? 1 : 0);
|
||||
|
@ -817,7 +863,7 @@ int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Screen, int *pWidt
|
|||
}
|
||||
|
||||
// start the command processor
|
||||
m_pProcessor = new CCommandProcessor_SDL_OpenGL(BackendType, g_Config.m_GfxOpenGLMajor, g_Config.m_GfxOpenGLMinor, g_Config.m_GfxOpenGLPatch);
|
||||
m_pProcessor = new CCommandProcessor_SDL_OpenGL(m_BackendType, g_Config.m_GfxOpenGLMajor, g_Config.m_GfxOpenGLMinor, g_Config.m_GfxOpenGLPatch);
|
||||
StartProcessor(m_pProcessor);
|
||||
|
||||
mem_zero(m_aErrorString, sizeof(m_aErrorString) / sizeof(m_aErrorString[0]));
|
||||
|
@ -852,7 +898,7 @@ int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Screen, int *pWidt
|
|||
CmdOpenGL.m_pVendorString = m_aVendorString;
|
||||
CmdOpenGL.m_pVersionString = m_aVersionString;
|
||||
CmdOpenGL.m_pRendererString = m_aRendererString;
|
||||
CmdOpenGL.m_RequestedBackend = BackendType;
|
||||
CmdOpenGL.m_RequestedBackend = m_BackendType;
|
||||
CmdBuffer.AddCommandUnsafe(CmdOpenGL);
|
||||
|
||||
RunBuffer(&CmdBuffer);
|
||||
|
|
|
@ -226,6 +226,7 @@ class CGraphicsBackend_SDL_OpenGL : public CGraphicsBackend_Threaded
|
|||
char m_aRendererString[gs_GPUInfoStringSize] = {};
|
||||
|
||||
bool m_UseNewOpenGL;
|
||||
EBackendType m_BackendType;
|
||||
|
||||
char m_aErrorString[256];
|
||||
|
||||
|
@ -252,6 +253,8 @@ public:
|
|||
virtual void GetViewportSize(int &w, int &h);
|
||||
virtual void NotifyWindow();
|
||||
|
||||
virtual void GetDriverVersion(EGraphicsDriverAgeType DriverAgeType, int &Major, int &Minor, int &Patch);
|
||||
virtual bool IsConfigModernAPI() { return IsModernAPI(m_BackendType); }
|
||||
virtual bool IsNewOpenGL() { return m_UseNewOpenGL; }
|
||||
virtual bool HasTileBuffering() { return m_Capabilites.m_TileBuffering; }
|
||||
virtual bool HasQuadBuffering() { return m_Capabilites.m_QuadBuffering; }
|
||||
|
|
|
@ -674,6 +674,9 @@ public:
|
|||
virtual bool IsIdle() const = 0;
|
||||
virtual void WaitForIdle() = 0;
|
||||
|
||||
virtual void GetDriverVersion(EGraphicsDriverAgeType DriverAgeType, int &Major, int &Minor, int &Patch) {}
|
||||
// checks if the current values of the config are a graphics modern API
|
||||
virtual bool IsConfigModernAPI() { return false; }
|
||||
virtual bool IsNewOpenGL() { return false; }
|
||||
virtual bool HasTileBuffering() { return false; }
|
||||
virtual bool HasQuadBuffering() { return false; }
|
||||
|
@ -1170,6 +1173,8 @@ public:
|
|||
|
||||
SWarning *GetCurWarning() override;
|
||||
|
||||
void GetDriverVersion(EGraphicsDriverAgeType DriverAgeType, int &Major, int &Minor, int &Patch) override { m_pBackend->GetDriverVersion(DriverAgeType, Major, Minor, Patch); }
|
||||
bool IsConfigModernAPI() override { return m_pBackend->IsConfigModernAPI(); }
|
||||
bool IsTileBufferingEnabled() override { return m_OpenGLTileBufferingEnabled; }
|
||||
bool IsQuadBufferingEnabled() override { return m_OpenGLQuadBufferingEnabled; }
|
||||
bool IsTextBufferingEnabled() override { return m_OpenGLTextBufferingEnabled; }
|
||||
|
|
|
@ -147,6 +147,13 @@ struct GL_SVertexTex3DStream
|
|||
GL_STexCoord3D m_Tex;
|
||||
};
|
||||
|
||||
enum EGraphicsDriverAgeType
|
||||
{
|
||||
GRAPHICS_DRIVER_AGE_TYPE_LEGACY = 0,
|
||||
GRAPHICS_DRIVER_AGE_TYPE_DEFAULT,
|
||||
GRAPHICS_DRIVER_AGE_TYPE_MODERN,
|
||||
};
|
||||
|
||||
typedef void (*WINDOW_RESIZE_FUNC)(void *pUser);
|
||||
|
||||
namespace client_data7 {
|
||||
|
@ -269,6 +276,8 @@ public:
|
|||
virtual void UpdateBufferContainer(int ContainerIndex, struct SBufferContainerInfo *pContainerInfo) = 0;
|
||||
virtual void IndicesNumRequiredNotify(unsigned int RequiredIndicesCount) = 0;
|
||||
|
||||
virtual void GetDriverVersion(EGraphicsDriverAgeType DriverAgeType, int &Major, int &Minor, int &Patch) = 0;
|
||||
virtual bool IsConfigModernAPI() = 0;
|
||||
virtual bool IsTileBufferingEnabled() = 0;
|
||||
virtual bool IsQuadBufferingEnabled() = 0;
|
||||
virtual bool IsTextBufferingEnabled() = 0;
|
||||
|
|
|
@ -1080,11 +1080,7 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
|
|||
static int s_GfxColorDepth = g_Config.m_GfxColorDepth;
|
||||
static int s_GfxVsync = g_Config.m_GfxVsync;
|
||||
static int s_GfxFsaaSamples = g_Config.m_GfxFsaaSamples;
|
||||
#ifndef CONF_BACKEND_OPENGL_ES
|
||||
static int s_GfxOpenGLVersion = (g_Config.m_GfxOpenGLMajor == 3 && g_Config.m_GfxOpenGLMinor == 3) || g_Config.m_GfxOpenGLMajor >= 4;
|
||||
#else
|
||||
static int s_GfxOpenGLVersion = g_Config.m_GfxOpenGLMajor >= 3;
|
||||
#endif
|
||||
static int s_GfxOpenGLVersion = Graphics()->IsConfigModernAPI();
|
||||
static int s_GfxEnableTextureUnitOptimization = g_Config.m_GfxEnableTextureUnitOptimization;
|
||||
static int s_GfxUsePreinitBuffer = g_Config.m_GfxUsePreinitBuffer;
|
||||
static int s_GfxHighdpi = g_Config.m_GfxHighdpi;
|
||||
|
@ -1205,46 +1201,21 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
|
|||
g_Config.m_GfxHighDetail ^= 1;
|
||||
|
||||
MainView.HSplitTop(20.0f, &Button, &MainView);
|
||||
#ifndef CONF_BACKEND_OPENGL_ES
|
||||
bool IsNewOpenGL = (g_Config.m_GfxOpenGLMajor == 3 && g_Config.m_GfxOpenGLMinor == 3) || g_Config.m_GfxOpenGLMajor >= 4;
|
||||
#else
|
||||
bool IsNewOpenGL = g_Config.m_GfxOpenGLMajor >= 3;
|
||||
#endif
|
||||
bool IsNewOpenGL = Graphics()->IsConfigModernAPI();
|
||||
|
||||
if(DoButton_CheckBox(&g_Config.m_GfxOpenGLMajor, Localize("Use modern OpenGL"), IsNewOpenGL, &Button))
|
||||
{
|
||||
CheckSettings = true;
|
||||
#ifndef CONF_BACKEND_OPENGL_ES
|
||||
if(IsNewOpenGL)
|
||||
{
|
||||
g_Config.m_GfxOpenGLMajor = 3;
|
||||
g_Config.m_GfxOpenGLMinor = 0;
|
||||
g_Config.m_GfxOpenGLPatch = 0;
|
||||
Graphics()->GetDriverVersion(GRAPHICS_DRIVER_AGE_TYPE_DEFAULT, g_Config.m_GfxOpenGLMajor, g_Config.m_GfxOpenGLMinor, g_Config.m_GfxOpenGLPatch);
|
||||
IsNewOpenGL = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_Config.m_GfxOpenGLMajor = 3;
|
||||
g_Config.m_GfxOpenGLMinor = 3;
|
||||
g_Config.m_GfxOpenGLPatch = 0;
|
||||
Graphics()->GetDriverVersion(GRAPHICS_DRIVER_AGE_TYPE_MODERN, g_Config.m_GfxOpenGLMajor, g_Config.m_GfxOpenGLMinor, g_Config.m_GfxOpenGLPatch);
|
||||
IsNewOpenGL = true;
|
||||
}
|
||||
#else
|
||||
if(IsNewOpenGL)
|
||||
{
|
||||
g_Config.m_GfxOpenGLMajor = 1;
|
||||
g_Config.m_GfxOpenGLMinor = 0;
|
||||
g_Config.m_GfxOpenGLPatch = 0;
|
||||
IsNewOpenGL = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_Config.m_GfxOpenGLMajor = 3;
|
||||
g_Config.m_GfxOpenGLMinor = 0;
|
||||
g_Config.m_GfxOpenGLPatch = 0;
|
||||
IsNewOpenGL = true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if(IsNewOpenGL)
|
||||
|
|
Loading…
Reference in a new issue