mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Add GLES support
This commit is contained in:
parent
826a979b05
commit
c0d6ce6d25
|
@ -1686,7 +1686,9 @@ if(CLIENT)
|
||||||
add_library(${TARGET_STEAMAPI} ${STEAMAPI_KIND} ${STEAMAPI_SRC})
|
add_library(${TARGET_STEAMAPI} ${STEAMAPI_KIND} ${STEAMAPI_SRC})
|
||||||
list(APPEND TARGETS_OWN ${TARGET_STEAMAPI})
|
list(APPEND TARGETS_OWN ${TARGET_STEAMAPI})
|
||||||
|
|
||||||
set_src(ENGINE_CLIENT GLOB src/engine/client
|
set_src(ENGINE_CLIENT GLOB_RECURSE src/engine/client
|
||||||
|
backend/backend_opengl.cpp
|
||||||
|
backend/backend_opengl3.cpp
|
||||||
backend_sdl.cpp
|
backend_sdl.cpp
|
||||||
backend_sdl.h
|
backend_sdl.h
|
||||||
blocklist_driver.cpp
|
blocklist_driver.cpp
|
||||||
|
|
|
@ -10,8 +10,8 @@ noperspective in vec4 outVertColor;
|
||||||
out vec4 FragClr;
|
out vec4 FragClr;
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec4 textColor = gVertColor * outVertColor * texture(gTextSampler, texCoord);
|
vec4 textColor = gVertColor * outVertColor * vec4(1.0, 1.0, 1.0, texture(gTextSampler, texCoord).r);
|
||||||
vec4 textOutlineTex = gVertOutlineColor * texture(gTextOutlineSampler, texCoord);
|
vec4 textOutlineTex = gVertOutlineColor * vec4(1.0, 1.0, 1.0, texture(gTextOutlineSampler, texCoord).r);
|
||||||
|
|
||||||
// ratio between the two textures
|
// ratio between the two textures
|
||||||
float OutlineBlend = (1.0 - textColor.a);
|
float OutlineBlend = (1.0 - textColor.a);
|
||||||
|
|
|
@ -24,14 +24,14 @@ void main()
|
||||||
vec4 VertPos = vec4(inVertex, 0.0, 1.0);
|
vec4 VertPos = vec4(inVertex, 0.0, 1.0);
|
||||||
int XCount = gl_InstanceID - (int(gl_InstanceID/gJumpIndex) * gJumpIndex);
|
int XCount = gl_InstanceID - (int(gl_InstanceID/gJumpIndex) * gJumpIndex);
|
||||||
int YCount = (int(gl_InstanceID/gJumpIndex));
|
int YCount = (int(gl_InstanceID/gJumpIndex));
|
||||||
VertPos.x += gOffset.x + gDir.x * XCount;
|
VertPos.x += gOffset.x + gDir.x * float(XCount);
|
||||||
VertPos.y += gOffset.y + gDir.y * YCount;
|
VertPos.y += gOffset.y + gDir.y * float(YCount);
|
||||||
|
|
||||||
gl_Position = vec4(gPos * VertPos, 0.0, 1.0);
|
gl_Position = vec4(gPos * VertPos, 0.0, 1.0);
|
||||||
#elif defined(TW_TILE_BORDER_LINE)
|
#elif defined(TW_TILE_BORDER_LINE)
|
||||||
vec4 VertPos = vec4(inVertex.x + gOffset.x, inVertex.y + gOffset.y, 0.0, 1.0);
|
vec4 VertPos = vec4(inVertex.x + gOffset.x, inVertex.y + gOffset.y, 0.0, 1.0);
|
||||||
VertPos.x += gDir.x * gl_InstanceID;
|
VertPos.x += gDir.x * float(gl_InstanceID);
|
||||||
VertPos.y += gDir.y * gl_InstanceID;
|
VertPos.y += gDir.y * float(gl_InstanceID);
|
||||||
|
|
||||||
gl_Position = vec4(gPos * VertPos, 0.0, 1.0);
|
gl_Position = vec4(gPos * VertPos, 0.0, 1.0);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -51,6 +51,7 @@
|
||||||
#define CONF_FAMILY_STRING "unix"
|
#define CONF_FAMILY_STRING "unix"
|
||||||
#define CONF_PLATFORM_LINUX 1
|
#define CONF_PLATFORM_LINUX 1
|
||||||
#define PLATFORM_STRING "linux"
|
#define PLATFORM_STRING "linux"
|
||||||
|
#define CONF_BACKEND_OPENGL_ES 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__GNU__) || defined(__gnu__)
|
#if defined(__GNU__) || defined(__gnu__)
|
||||||
|
|
2279
src/engine/client/backend/backend_opengl.cpp
Normal file
2279
src/engine/client/backend/backend_opengl.cpp
Normal file
File diff suppressed because it is too large
Load diff
1613
src/engine/client/backend/backend_opengl3.cpp
Normal file
1613
src/engine/client/backend/backend_opengl3.cpp
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -2,7 +2,17 @@
|
||||||
#define ENGINE_CLIENT_BACKEND_SDL_H
|
#define ENGINE_CLIENT_BACKEND_SDL_H
|
||||||
|
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
#include "SDL_opengl.h"
|
|
||||||
|
#include <base/detect.h>
|
||||||
|
|
||||||
|
#ifndef CONF_BACKEND_OPENGL_ES
|
||||||
|
#include <GL/glew.h>
|
||||||
|
#else
|
||||||
|
#define GL_GLEXT_PROTOTYPES 1
|
||||||
|
#include "SDL_opengles2.h"
|
||||||
|
#include <GLES/gl.h>
|
||||||
|
#include <GLES3/gl3.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "blocklist_driver.h"
|
#include "blocklist_driver.h"
|
||||||
#include "graphics_threaded.h"
|
#include "graphics_threaded.h"
|
||||||
|
@ -79,6 +89,12 @@ public:
|
||||||
bool RunCommand(const CCommandBuffer::SCommand *pBaseCommand);
|
bool RunCommand(const CCommandBuffer::SCommand *pBaseCommand);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum EBackendType
|
||||||
|
{
|
||||||
|
BACKEND_TYPE_OPENGL = 0,
|
||||||
|
BACKEND_TYPE_OPENGL_ES,
|
||||||
|
};
|
||||||
|
|
||||||
struct SBackendCapabilites
|
struct SBackendCapabilites
|
||||||
{
|
{
|
||||||
bool m_TileBuffering;
|
bool m_TileBuffering;
|
||||||
|
@ -150,6 +166,8 @@ protected:
|
||||||
|
|
||||||
int m_OpenGLTextureLodBIAS;
|
int m_OpenGLTextureLodBIAS;
|
||||||
|
|
||||||
|
bool m_IsOpenGLES;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -165,6 +183,22 @@ public:
|
||||||
std::atomic<int> *m_pTextureMemoryUsage;
|
std::atomic<int> *m_pTextureMemoryUsage;
|
||||||
SBackendCapabilites *m_pCapabilities;
|
SBackendCapabilites *m_pCapabilities;
|
||||||
int *m_pInitError;
|
int *m_pInitError;
|
||||||
|
|
||||||
|
const char **m_pErrStringPtr;
|
||||||
|
|
||||||
|
char *m_pVendorString;
|
||||||
|
char *m_pVersionString;
|
||||||
|
char *m_pRendererString;
|
||||||
|
|
||||||
|
int m_RequestedMajor;
|
||||||
|
int m_RequestedMinor;
|
||||||
|
int m_RequestedPatch;
|
||||||
|
|
||||||
|
EBackendType m_RequestedBackend;
|
||||||
|
|
||||||
|
int m_GlewMajor;
|
||||||
|
int m_GlewMinor;
|
||||||
|
int m_GlewPatch;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SCommand_Shutdown : public CCommandBuffer::SCommand
|
struct SCommand_Shutdown : public CCommandBuffer::SCommand
|
||||||
|
@ -175,6 +209,10 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool IsTexturedState(const CCommandBuffer::SState &State);
|
bool IsTexturedState(const CCommandBuffer::SState &State);
|
||||||
|
static bool Texture2DTo3D(void *pImageBuffer, int ImageWidth, int ImageHeight, int ImageColorChannelCount, int SplitCountWidth, int SplitCountHeight, void *pTarget3DImageData, int &Target3DImageWidth, int &Target3DImageHeight);
|
||||||
|
|
||||||
|
void InitOpenGL(const SCommand_Init *pCommand);
|
||||||
|
|
||||||
void SetState(const CCommandBuffer::SState &State, bool Use2DArrayTexture = false);
|
void SetState(const CCommandBuffer::SState &State, bool Use2DArrayTexture = false);
|
||||||
virtual bool IsNewApi() { return false; }
|
virtual bool IsNewApi() { return false; }
|
||||||
void DestroyTexture(int Slot);
|
void DestroyTexture(int Slot);
|
||||||
|
@ -427,23 +465,6 @@ public:
|
||||||
SCommand(CMD_INIT) {}
|
SCommand(CMD_INIT) {}
|
||||||
SDL_Window *m_pWindow;
|
SDL_Window *m_pWindow;
|
||||||
SDL_GLContext m_GLContext;
|
SDL_GLContext m_GLContext;
|
||||||
SBackendCapabilites *m_pCapabilities;
|
|
||||||
|
|
||||||
const char **m_pErrStringPtr;
|
|
||||||
|
|
||||||
int *m_pInitError;
|
|
||||||
|
|
||||||
char *m_pVendorString;
|
|
||||||
char *m_pVersionString;
|
|
||||||
char *m_pRendererString;
|
|
||||||
|
|
||||||
int m_RequestedMajor;
|
|
||||||
int m_RequestedMinor;
|
|
||||||
int m_RequestedPatch;
|
|
||||||
|
|
||||||
int m_GlewMajor;
|
|
||||||
int m_GlewMinor;
|
|
||||||
int m_GlewPatch;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SCommand_Update_Viewport : public CCommandBuffer::SCommand
|
struct SCommand_Update_Viewport : public CCommandBuffer::SCommand
|
||||||
|
@ -484,8 +505,10 @@ class CCommandProcessor_SDL_OpenGL : public CGraphicsBackend_Threaded::ICommandP
|
||||||
CCommandProcessorFragment_SDL m_SDL;
|
CCommandProcessorFragment_SDL m_SDL;
|
||||||
CCommandProcessorFragment_General m_General;
|
CCommandProcessorFragment_General m_General;
|
||||||
|
|
||||||
|
EBackendType m_BackendType;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CCommandProcessor_SDL_OpenGL(int OpenGLMajor, int OpenGLMinor, int OpenGLPatch);
|
CCommandProcessor_SDL_OpenGL(EBackendType BackendType, int OpenGLMajor, int OpenGLMinor, int OpenGLPatch);
|
||||||
virtual ~CCommandProcessor_SDL_OpenGL();
|
virtual ~CCommandProcessor_SDL_OpenGL();
|
||||||
virtual void RunBuffer(CCommandBuffer *pBuffer);
|
virtual void RunBuffer(CCommandBuffer *pBuffer);
|
||||||
};
|
};
|
||||||
|
@ -511,6 +534,9 @@ class CGraphicsBackend_SDL_OpenGL : public CGraphicsBackend_Threaded
|
||||||
|
|
||||||
char m_aErrorString[256];
|
char m_aErrorString[256];
|
||||||
|
|
||||||
|
static EBackendType DetectBackend();
|
||||||
|
static void ClampDriverVersion(EBackendType BackendType);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual int Init(const char *pName, int *Screen, int *pWidth, int *pHeight, int FsaaSamples, int Flags, int *pDesktopWidth, int *pDesktopHeight, int *pCurrentWidth, int *pCurrentHeight, class IStorage *pStorage);
|
virtual int Init(const char *pName, int *Screen, int *pWidth, int *pHeight, int FsaaSamples, int Flags, int *pDesktopWidth, int *pDesktopHeight, int *pCurrentWidth, int *pCurrentHeight, class IStorage *pStorage);
|
||||||
virtual int Shutdown();
|
virtual int Shutdown();
|
||||||
|
@ -560,6 +586,8 @@ public:
|
||||||
{
|
{
|
||||||
return m_aRendererString;
|
return m_aRendererString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool IsModernAPI(EBackendType BackendType);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ENGINE_CLIENT_BACKEND_SDL_H
|
#endif // ENGINE_CLIENT_BACKEND_SDL_H
|
||||||
|
|
|
@ -456,8 +456,6 @@ IGraphics::CTextureHandle CGraphics_Threaded::LoadTextureRaw(int Width, int Heig
|
||||||
Cmd.m_Flags = 0;
|
Cmd.m_Flags = 0;
|
||||||
if(Flags & IGraphics::TEXLOAD_NOMIPMAPS)
|
if(Flags & IGraphics::TEXLOAD_NOMIPMAPS)
|
||||||
Cmd.m_Flags |= CCommandBuffer::TEXFLAG_NOMIPMAPS;
|
Cmd.m_Flags |= CCommandBuffer::TEXFLAG_NOMIPMAPS;
|
||||||
if(g_Config.m_GfxTextureCompressionOld && ((Flags & IGraphics::TEXLOAD_NO_COMPRESSION) == 0))
|
|
||||||
Cmd.m_Flags |= CCommandBuffer::TEXFLAG_COMPRESSED;
|
|
||||||
if(g_Config.m_GfxTextureQualityOld || Flags & TEXLOAD_NORESAMPLE)
|
if(g_Config.m_GfxTextureQualityOld || Flags & TEXLOAD_NORESAMPLE)
|
||||||
Cmd.m_Flags |= CCommandBuffer::TEXFLAG_QUALITY;
|
Cmd.m_Flags |= CCommandBuffer::TEXFLAG_QUALITY;
|
||||||
if((Flags & IGraphics::TEXLOAD_TO_2D_ARRAY_TEXTURE) != 0)
|
if((Flags & IGraphics::TEXLOAD_TO_2D_ARRAY_TEXTURE) != 0)
|
||||||
|
|
|
@ -136,7 +136,6 @@ public:
|
||||||
TEXFORMAT_ALPHA,
|
TEXFORMAT_ALPHA,
|
||||||
|
|
||||||
TEXFLAG_NOMIPMAPS = 1,
|
TEXFLAG_NOMIPMAPS = 1,
|
||||||
TEXFLAG_COMPRESSED = 2,
|
|
||||||
TEXFLAG_QUALITY = 4,
|
TEXFLAG_QUALITY = 4,
|
||||||
TEXFLAG_TO_3D_TEXTURE = (1 << 3),
|
TEXFLAG_TO_3D_TEXTURE = (1 << 3),
|
||||||
TEXFLAG_TO_2D_ARRAY_TEXTURE = (1 << 4),
|
TEXFLAG_TO_2D_ARRAY_TEXTURE = (1 << 4),
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <engine/client/backend_sdl.h>
|
||||||
|
|
||||||
bool CGLSL::LoadShader(CGLSLCompiler *pCompiler, IStorage *pStorage, const char *pFile, int Type)
|
bool CGLSL::LoadShader(CGLSLCompiler *pCompiler, IStorage *pStorage, const char *pFile, int Type)
|
||||||
{
|
{
|
||||||
if(m_IsLoaded)
|
if(m_IsLoaded)
|
||||||
|
@ -14,10 +16,14 @@ bool CGLSL::LoadShader(CGLSLCompiler *pCompiler, IStorage *pStorage, const char
|
||||||
std::vector<std::string> Lines;
|
std::vector<std::string> Lines;
|
||||||
if(f)
|
if(f)
|
||||||
{
|
{
|
||||||
bool IsNewOpenGL = pCompiler->m_OpenGLVersionMajor >= 4 || (pCompiler->m_OpenGLVersionMajor == 3 && pCompiler->m_OpenGLVersionMinor == 3);
|
EBackendType BackendType = pCompiler->m_IsOpenGLES ? BACKEND_TYPE_OPENGL_ES : BACKEND_TYPE_OPENGL;
|
||||||
|
bool IsNewOpenGL = (BackendType == BACKEND_TYPE_OPENGL ? (pCompiler->m_OpenGLVersionMajor >= 4 || (pCompiler->m_OpenGLVersionMajor == 3 && pCompiler->m_OpenGLVersionMinor == 3)) : pCompiler->m_OpenGLVersionMajor >= 3);
|
||||||
|
std::string GLShaderStringPostfix = std::string(" core\r\n");
|
||||||
|
if(BackendType == BACKEND_TYPE_OPENGL_ES)
|
||||||
|
GLShaderStringPostfix = std::string(" es\r\n");
|
||||||
//add compiler specific values
|
//add compiler specific values
|
||||||
if(IsNewOpenGL)
|
if(IsNewOpenGL)
|
||||||
Lines.push_back(std::string("#version ") + std::string(std::to_string(pCompiler->m_OpenGLVersionMajor)) + std::string(std::to_string(pCompiler->m_OpenGLVersionMinor)) + std::string(std::to_string(pCompiler->m_OpenGLVersionPatch)) + std::string(" core\r\n"));
|
Lines.push_back(std::string("#version ") + std::string(std::to_string(pCompiler->m_OpenGLVersionMajor)) + std::string(std::to_string(pCompiler->m_OpenGLVersionMinor)) + std::string(std::to_string(pCompiler->m_OpenGLVersionPatch)) + GLShaderStringPostfix);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(pCompiler->m_OpenGLVersionMajor == 3)
|
if(pCompiler->m_OpenGLVersionMajor == 3)
|
||||||
|
@ -38,6 +44,21 @@ bool CGLSL::LoadShader(CGLSLCompiler *pCompiler, IStorage *pStorage, const char
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(BackendType == BACKEND_TYPE_OPENGL_ES)
|
||||||
|
{
|
||||||
|
if(Type == GL_FRAGMENT_SHADER)
|
||||||
|
{
|
||||||
|
Lines.push_back("precision highp float; \r\n");
|
||||||
|
Lines.push_back("precision highp sampler2D; \r\n");
|
||||||
|
Lines.push_back("precision highp sampler3D; \r\n");
|
||||||
|
Lines.push_back("precision highp samplerCube; \r\n");
|
||||||
|
Lines.push_back("precision highp samplerCubeShadow; \r\n");
|
||||||
|
Lines.push_back("precision highp sampler2DShadow; \r\n");
|
||||||
|
Lines.push_back("precision highp sampler2DArray; \r\n");
|
||||||
|
Lines.push_back("precision highp sampler2DArrayShadow; \r\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for(CGLSLCompiler::SGLSLCompilerDefine &Define : pCompiler->m_Defines)
|
for(CGLSLCompiler::SGLSLCompilerDefine &Define : pCompiler->m_Defines)
|
||||||
{
|
{
|
||||||
Lines.push_back(std::string("#define ") + Define.m_DefineName + std::string(" ") + Define.m_DefineValue + std::string("\r\n"));
|
Lines.push_back(std::string("#define ") + Define.m_DefineName + std::string(" ") + Define.m_DefineValue + std::string("\r\n"));
|
||||||
|
@ -129,12 +150,16 @@ CGLSL::~CGLSL()
|
||||||
DeleteShader();
|
DeleteShader();
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLSLCompiler::CGLSLCompiler(int OpenGLVersionMajor, int OpenGLVersionMinor, int OpenGLVersionPatch)
|
CGLSLCompiler::CGLSLCompiler(int OpenGLVersionMajor, int OpenGLVersionMinor, int OpenGLVersionPatch, bool IsOpenGLES, float TextureLODBias)
|
||||||
{
|
{
|
||||||
m_OpenGLVersionMajor = OpenGLVersionMajor;
|
m_OpenGLVersionMajor = OpenGLVersionMajor;
|
||||||
m_OpenGLVersionMinor = OpenGLVersionMinor;
|
m_OpenGLVersionMinor = OpenGLVersionMinor;
|
||||||
m_OpenGLVersionPatch = OpenGLVersionPatch;
|
m_OpenGLVersionPatch = OpenGLVersionPatch;
|
||||||
|
|
||||||
|
m_IsOpenGLES = IsOpenGLES;
|
||||||
|
|
||||||
|
m_TextureLODBias = TextureLODBias;
|
||||||
|
|
||||||
m_HasTextureArray = false;
|
m_HasTextureArray = false;
|
||||||
m_TextureReplaceType = 0;
|
m_TextureReplaceType = 0;
|
||||||
}
|
}
|
||||||
|
@ -156,7 +181,8 @@ void CGLSLCompiler::ClearDefines()
|
||||||
|
|
||||||
void CGLSLCompiler::ParseLine(std::string &Line, const char *pReadLine, int Type)
|
void CGLSLCompiler::ParseLine(std::string &Line, const char *pReadLine, int Type)
|
||||||
{
|
{
|
||||||
bool IsNewOpenGL = m_OpenGLVersionMajor >= 4 || (m_OpenGLVersionMajor == 3 && m_OpenGLVersionMinor == 3);
|
EBackendType BackendType = m_IsOpenGLES ? BACKEND_TYPE_OPENGL_ES : BACKEND_TYPE_OPENGL;
|
||||||
|
bool IsNewOpenGL = (BackendType == BACKEND_TYPE_OPENGL ? (m_OpenGLVersionMajor >= 4 || (m_OpenGLVersionMajor == 3 && m_OpenGLVersionMinor == 3)) : m_OpenGLVersionMajor >= 3);
|
||||||
if(!IsNewOpenGL)
|
if(!IsNewOpenGL)
|
||||||
{
|
{
|
||||||
const char *pBuff = pReadLine;
|
const char *pBuff = pReadLine;
|
||||||
|
@ -274,6 +300,92 @@ void CGLSLCompiler::ParseLine(std::string &Line, const char *pReadLine, int Type
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if(BackendType == BACKEND_TYPE_OPENGL_ES)
|
||||||
|
{
|
||||||
|
const char *pBuff = pReadLine;
|
||||||
|
char aTmpStr[1024];
|
||||||
|
size_t TmpStrSize = 0;
|
||||||
|
while(*pBuff)
|
||||||
|
{
|
||||||
|
while(*pBuff && str_isspace(*pBuff))
|
||||||
|
{
|
||||||
|
Line.append(1, *pBuff);
|
||||||
|
++pBuff;
|
||||||
|
}
|
||||||
|
|
||||||
|
while(*pBuff && !str_isspace(*pBuff) && *pBuff != '(' && *pBuff != '.')
|
||||||
|
{
|
||||||
|
aTmpStr[TmpStrSize++] = *pBuff;
|
||||||
|
++pBuff;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(TmpStrSize > 0)
|
||||||
|
{
|
||||||
|
aTmpStr[TmpStrSize] = 0;
|
||||||
|
TmpStrSize = 0;
|
||||||
|
|
||||||
|
if(str_comp(aTmpStr, "noperspective") == 0)
|
||||||
|
{
|
||||||
|
Line.append("smooth");
|
||||||
|
Line.append(pBuff);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// since GLES doesnt support texture LOD bias as global state, use the shader function instead(since GLES 3.0 uses shaders only anyway)
|
||||||
|
else if(str_comp(aTmpStr, "texture") == 0)
|
||||||
|
{
|
||||||
|
Line.append("texture");
|
||||||
|
// check opening and closing brackets to find the end
|
||||||
|
int CurBrackets = 1;
|
||||||
|
while(*pBuff && *pBuff != '(')
|
||||||
|
{
|
||||||
|
Line.append(1, *pBuff);
|
||||||
|
|
||||||
|
++pBuff;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(*pBuff)
|
||||||
|
{
|
||||||
|
Line.append(1, *pBuff);
|
||||||
|
++pBuff;
|
||||||
|
}
|
||||||
|
|
||||||
|
while(*pBuff)
|
||||||
|
{
|
||||||
|
if(*pBuff == '(')
|
||||||
|
++CurBrackets;
|
||||||
|
if(*pBuff == ')')
|
||||||
|
--CurBrackets;
|
||||||
|
|
||||||
|
if(CurBrackets == 0)
|
||||||
|
{
|
||||||
|
// found end
|
||||||
|
Line.append(std::string(", ") + std::to_string(m_TextureLODBias) + ")");
|
||||||
|
++pBuff;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Line.append(1, *pBuff);
|
||||||
|
++pBuff;
|
||||||
|
}
|
||||||
|
|
||||||
|
Line.append(pBuff);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Line.append(aTmpStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(*pBuff)
|
||||||
|
{
|
||||||
|
Line.append(1, *pBuff);
|
||||||
|
++pBuff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
Line = pReadLine;
|
Line = pReadLine;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,15 @@
|
||||||
#ifndef ENGINE_CLIENT_OPENGL_SL_H
|
#ifndef ENGINE_CLIENT_OPENGL_SL_H
|
||||||
#define ENGINE_CLIENT_OPENGL_SL_H
|
#define ENGINE_CLIENT_OPENGL_SL_H
|
||||||
|
|
||||||
|
#include <base/detect.h>
|
||||||
|
|
||||||
|
#ifndef CONF_BACKEND_OPENGL_ES
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
|
#else
|
||||||
|
#define GL_GLEXT_PROTOTYPES 1
|
||||||
|
#include "SDL_opengles2.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -47,10 +55,14 @@ private:
|
||||||
int m_OpenGLVersionMinor;
|
int m_OpenGLVersionMinor;
|
||||||
int m_OpenGLVersionPatch;
|
int m_OpenGLVersionPatch;
|
||||||
|
|
||||||
|
bool m_IsOpenGLES;
|
||||||
|
|
||||||
|
float m_TextureLODBias;
|
||||||
|
|
||||||
bool m_HasTextureArray;
|
bool m_HasTextureArray;
|
||||||
int m_TextureReplaceType; // @see EGLSLCompilerTextureReplaceType
|
int m_TextureReplaceType; // @see EGLSLCompilerTextureReplaceType
|
||||||
public:
|
public:
|
||||||
CGLSLCompiler(int OpenGLVersionMajor, int OpenGLVersionMinor, int OpenGLVersionPatch);
|
CGLSLCompiler(int OpenGLVersionMajor, int OpenGLVersionMinor, int OpenGLVersionPatch, bool IsOpenGLES, float TextureLODBias);
|
||||||
void SetHasTextureArray(bool TextureArray) { m_HasTextureArray = TextureArray; }
|
void SetHasTextureArray(bool TextureArray) { m_HasTextureArray = TextureArray; }
|
||||||
void SetTextureReplaceType(int TextureReplaceType) { m_TextureReplaceType = TextureReplaceType; }
|
void SetTextureReplaceType(int TextureReplaceType) { m_TextureReplaceType = TextureReplaceType; }
|
||||||
|
|
||||||
|
|
|
@ -99,11 +99,6 @@ void CGLSLProgram::SetUniform(int Loc, const int Value)
|
||||||
glUniform1i(Loc, Value);
|
glUniform1i(Loc, Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGLSLProgram::SetUniform(int Loc, const unsigned int Value)
|
|
||||||
{
|
|
||||||
glUniform1ui(Loc, Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CGLSLProgram::SetUniform(int Loc, const float Value)
|
void CGLSLProgram::SetUniform(int Loc, const float Value)
|
||||||
{
|
{
|
||||||
glUniform1f(Loc, Value);
|
glUniform1f(Loc, Value);
|
||||||
|
|
|
@ -1,7 +1,14 @@
|
||||||
#ifndef ENGINE_CLIENT_OPENGL_SL_PROGRAM_H
|
#ifndef ENGINE_CLIENT_OPENGL_SL_PROGRAM_H
|
||||||
#define ENGINE_CLIENT_OPENGL_SL_PROGRAM_H
|
#define ENGINE_CLIENT_OPENGL_SL_PROGRAM_H
|
||||||
|
|
||||||
|
#include <base/detect.h>
|
||||||
|
|
||||||
|
#ifndef CONF_BACKEND_OPENGL_ES
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
|
#else
|
||||||
|
#define GL_GLEXT_PROTOTYPES 1
|
||||||
|
#include "SDL_opengles2.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
class CGLSL;
|
class CGLSL;
|
||||||
|
|
||||||
|
@ -25,7 +32,6 @@ public:
|
||||||
void SetUniformVec2(int Loc, int Count, const float *pValue);
|
void SetUniformVec2(int Loc, int Count, const float *pValue);
|
||||||
void SetUniformVec4(int Loc, int Count, const float *pValue);
|
void SetUniformVec4(int Loc, int Count, const float *pValue);
|
||||||
void SetUniform(int Loc, const int Value);
|
void SetUniform(int Loc, const int Value);
|
||||||
void SetUniform(int Loc, const unsigned int Value);
|
|
||||||
void SetUniform(int Loc, const bool Value);
|
void SetUniform(int Loc, const bool Value);
|
||||||
void SetUniform(int Loc, const float Value);
|
void SetUniform(int Loc, const float Value);
|
||||||
void SetUniform(int Loc, int Count, const float *pValues);
|
void SetUniform(int Loc, int Count, const float *pValues);
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
#ifndef ENGINE_CLIENT_VIDEO_H
|
#ifndef ENGINE_CLIENT_VIDEO_H
|
||||||
#define ENGINE_CLIENT_VIDEO_H
|
#define ENGINE_CLIENT_VIDEO_H
|
||||||
|
|
||||||
#if defined(__ANDROID__)
|
#include <base/system.h>
|
||||||
|
|
||||||
|
#if defined(CONF_BACKEND_OPENGL_ES)
|
||||||
#define GL_GLEXT_PROTOTYPES
|
#define GL_GLEXT_PROTOTYPES
|
||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
#include <GLES/gl.h>
|
#include <GLES/gl.h>
|
||||||
|
@ -26,8 +28,6 @@ extern "C" {
|
||||||
#include <libswscale/swscale.h>
|
#include <libswscale/swscale.h>
|
||||||
};
|
};
|
||||||
|
|
||||||
#include <base/system.h>
|
|
||||||
|
|
||||||
#include <engine/shared/demo.h>
|
#include <engine/shared/demo.h>
|
||||||
#include <engine/shared/video.h>
|
#include <engine/shared/video.h>
|
||||||
#define ALEN 2048
|
#define ALEN 2048
|
||||||
|
|
|
@ -112,7 +112,6 @@ MACRO_CONFIG_INT(GfxColorDepth, gfx_color_depth, 24, 16, 24, CFGFLAG_SAVE | CFGF
|
||||||
MACRO_CONFIG_INT(GfxVsync, gfx_vsync, 0, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Vertical sync (may cause delay)")
|
MACRO_CONFIG_INT(GfxVsync, gfx_vsync, 0, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Vertical sync (may cause delay)")
|
||||||
MACRO_CONFIG_INT(GfxResizable, gfx_resizable, 0, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Enables window resizing")
|
MACRO_CONFIG_INT(GfxResizable, gfx_resizable, 0, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Enables window resizing")
|
||||||
MACRO_CONFIG_INT(GfxDisplayAllModes, gfx_display_all_modes, 0, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "")
|
MACRO_CONFIG_INT(GfxDisplayAllModes, gfx_display_all_modes, 0, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "")
|
||||||
MACRO_CONFIG_INT(GfxTextureCompressionOld, gfx_texture_compression_old, 0, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Use texture compression")
|
|
||||||
MACRO_CONFIG_INT(GfxTextureQualityOld, gfx_texture_quality_old, 1, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "")
|
MACRO_CONFIG_INT(GfxTextureQualityOld, gfx_texture_quality_old, 1, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "")
|
||||||
MACRO_CONFIG_INT(GfxHighDetail, gfx_high_detail, 1, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "High detail")
|
MACRO_CONFIG_INT(GfxHighDetail, gfx_high_detail, 1, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "High detail")
|
||||||
MACRO_CONFIG_INT(GfxFsaaSamples, gfx_fsaa_samples, 0, 0, 16, CFGFLAG_SAVE | CFGFLAG_CLIENT, "FSAA Samples")
|
MACRO_CONFIG_INT(GfxFsaaSamples, gfx_fsaa_samples, 0, 0, 16, CFGFLAG_SAVE | CFGFLAG_CLIENT, "FSAA Samples")
|
||||||
|
|
|
@ -1080,7 +1080,11 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
|
||||||
static int s_GfxColorDepth = g_Config.m_GfxColorDepth;
|
static int s_GfxColorDepth = g_Config.m_GfxColorDepth;
|
||||||
static int s_GfxVsync = g_Config.m_GfxVsync;
|
static int s_GfxVsync = g_Config.m_GfxVsync;
|
||||||
static int s_GfxFsaaSamples = g_Config.m_GfxFsaaSamples;
|
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;
|
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_GfxEnableTextureUnitOptimization = g_Config.m_GfxEnableTextureUnitOptimization;
|
static int s_GfxEnableTextureUnitOptimization = g_Config.m_GfxEnableTextureUnitOptimization;
|
||||||
static int s_GfxUsePreinitBuffer = g_Config.m_GfxUsePreinitBuffer;
|
static int s_GfxUsePreinitBuffer = g_Config.m_GfxUsePreinitBuffer;
|
||||||
static int s_GfxHighdpi = g_Config.m_GfxHighdpi;
|
static int s_GfxHighdpi = g_Config.m_GfxHighdpi;
|
||||||
|
@ -1201,10 +1205,16 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
|
||||||
g_Config.m_GfxHighDetail ^= 1;
|
g_Config.m_GfxHighDetail ^= 1;
|
||||||
|
|
||||||
MainView.HSplitTop(20.0f, &Button, &MainView);
|
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;
|
bool IsNewOpenGL = (g_Config.m_GfxOpenGLMajor == 3 && g_Config.m_GfxOpenGLMinor == 3) || g_Config.m_GfxOpenGLMajor >= 4;
|
||||||
if(DoButton_CheckBox(&g_Config.m_GfxOpenGLMajor, Localize("Use OpenGL 3.3 (experimental)"), IsNewOpenGL, &Button))
|
#else
|
||||||
|
bool IsNewOpenGL = g_Config.m_GfxOpenGLMajor >= 3;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(DoButton_CheckBox(&g_Config.m_GfxOpenGLMajor, Localize("Use modern OpenGL"), IsNewOpenGL, &Button))
|
||||||
{
|
{
|
||||||
CheckSettings = true;
|
CheckSettings = true;
|
||||||
|
#ifndef CONF_BACKEND_OPENGL_ES
|
||||||
if(IsNewOpenGL)
|
if(IsNewOpenGL)
|
||||||
{
|
{
|
||||||
g_Config.m_GfxOpenGLMajor = 3;
|
g_Config.m_GfxOpenGLMajor = 3;
|
||||||
|
@ -1219,6 +1229,22 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
|
||||||
g_Config.m_GfxOpenGLPatch = 0;
|
g_Config.m_GfxOpenGLPatch = 0;
|
||||||
IsNewOpenGL = true;
|
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)
|
if(IsNewOpenGL)
|
||||||
|
|
Loading…
Reference in a new issue