Make GLES3 only makros

This commit is contained in:
Jupeyy 2021-05-01 02:39:06 +02:00
parent f5f05f3dcb
commit ecc5a7af81
5 changed files with 35 additions and 14 deletions

View file

@ -52,6 +52,7 @@
#define CONF_PLATFORM_LINUX 1
#define PLATFORM_STRING "linux"
#define CONF_BACKEND_OPENGL_ES 1
#define CONF_BACKEND_OPENGL_ES3 1
#endif
#if defined(__GNU__) || defined(__gnu__)

View file

@ -7,12 +7,14 @@
#else
#define GL_GLEXT_PROTOTYPES 1
#include "SDL_opengles2.h"
#include <GLES/gl.h>
#include <GLES3/gl3.h>
#define glOrtho glOrthof
#define GL_TEXTURE_2D_ARRAY_EXT GL_TEXTURE_2D_ARRAY
// GLES doesnt support GL_QUADS, but the code is also never executed
#define GL_QUADS GL_TRIANGLES
#ifndef CONF_BACKEND_OPENGL_ES3
#include <GLES/gl.h>
#define glOrtho glOrthof
#endif
#endif
#include <engine/client/opengl_sl.h>
@ -84,6 +86,7 @@ bool CCommandProcessorFragment_OpenGL::IsTexturedState(const CCommandBuffer::SSt
void CCommandProcessorFragment_OpenGL::SetState(const CCommandBuffer::SState &State, bool Use2DArrayTextures)
{
#ifndef BACKEND_GL_MODERN_API
// blend
switch(State.m_BlendMode)
{
@ -184,6 +187,7 @@ void CCommandProcessorFragment_OpenGL::SetState(const CCommandBuffer::SState &St
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(State.m_ScreenTL.x, State.m_ScreenBR.x, State.m_ScreenBR.y, State.m_ScreenTL.y, -10.0f, 10.f);
#endif
}
static void ParseVersionString(EBackendType BackendType, const char *pStr, int &VersionMajor, int &VersionMinor, int &VersionPatch)
@ -304,9 +308,14 @@ void CCommandProcessorFragment_OpenGL::InitOpenGL(const SCommand_Init *pCommand)
glDisable(GL_CULL_FACE);
glDisable(GL_DEPTH_TEST);
#ifndef BACKEND_GL_MODERN_API
if(!IsNewApi())
{
glAlphaFunc(GL_GREATER, 0);
glEnable(GL_ALPHA_TEST);
glEnable(GL_ALPHA_TEST);
}
#endif
glDepthMask(0);
#ifndef CONF_BACKEND_OPENGL_ES
@ -685,6 +694,7 @@ void CCommandProcessorFragment_OpenGL::Cmd_Texture_Destroy(const CCommandBuffer:
void CCommandProcessorFragment_OpenGL::Cmd_Texture_Create(const CCommandBuffer::SCommand_Texture_Create *pCommand)
{
#ifndef BACKEND_GL_MODERN_API
int Width = pCommand->m_Width;
int Height = pCommand->m_Height;
void *pTexData = pCommand->m_pData;
@ -916,6 +926,7 @@ void CCommandProcessorFragment_OpenGL::Cmd_Texture_Create(const CCommandBuffer::
m_pTextureMemoryUsage->store(m_pTextureMemoryUsage->load(std::memory_order_relaxed) + m_Textures[pCommand->m_Slot].m_MemSize, std::memory_order_relaxed);
free(pTexData);
#endif
}
void CCommandProcessorFragment_OpenGL::Cmd_Clear(const CCommandBuffer::SCommand_Clear *pCommand)
@ -926,6 +937,7 @@ void CCommandProcessorFragment_OpenGL::Cmd_Clear(const CCommandBuffer::SCommand_
void CCommandProcessorFragment_OpenGL::Cmd_Render(const CCommandBuffer::SCommand_Render *pCommand)
{
#ifndef BACKEND_GL_MODERN_API
SetState(pCommand->m_State);
glVertexPointer(2, GL_FLOAT, sizeof(CCommandBuffer::SVertex), (char *)pCommand->m_pVertices);
@ -951,6 +963,7 @@ void CCommandProcessorFragment_OpenGL::Cmd_Render(const CCommandBuffer::SCommand
default:
dbg_msg("render", "unknown primtype %d\n", pCommand->m_PrimType);
};
#endif
}
void CCommandProcessorFragment_OpenGL::Cmd_Screenshot(const CCommandBuffer::SCommand_Screenshot *pCommand)
@ -1240,6 +1253,7 @@ void CCommandProcessorFragment_OpenGL2::SetState(const CCommandBuffer::SState &S
}
}
#ifndef BACKEND_GL_MODERN_API
bool CCommandProcessorFragment_OpenGL2::DoAnalyzeStep(size_t StepN, size_t CheckCount, size_t VerticesCount, uint8_t aFakeTexture[], size_t SingleImageSize)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@ -2277,3 +2291,5 @@ void CCommandProcessorFragment_OpenGL2::Cmd_RenderTileLayer(const CCommandBuffer
glUseProgram(0);
}
}
#endif

View file

@ -591,6 +591,7 @@ void CGraphicsBackend_SDL_OpenGL::ClampDriverVersion(EBackendType BackendType)
}
else if(BackendType == BACKEND_TYPE_OPENGL_ES)
{
#ifndef BACKEND_GL_MODERN_API
// Make sure GLES is set to 1.0 (which is equivalent to OpenGL 1.3), if its not set to >= 3.0(which is equivalent to OpenGL 3.3)
if(g_Config.m_GfxOpenGLMajor < 3)
{
@ -601,6 +602,11 @@ void CGraphicsBackend_SDL_OpenGL::ClampDriverVersion(EBackendType BackendType)
// GLES also doesnt know GL_QUAD
g_Config.m_GfxQuadAsTriangle = 1;
}
#else
g_Config.m_GfxOpenGLMajor = 3;
g_Config.m_GfxOpenGLMinor = 0;
g_Config.m_GfxOpenGLPatch = 0;
#endif
}
}

View file

@ -10,10 +10,13 @@
#else
#define GL_GLEXT_PROTOTYPES 1
#include "SDL_opengles2.h"
#include <GLES/gl.h>
#include <GLES3/gl3.h>
#endif
#ifdef CONF_BACKEND_OPENGL_ES3
#define BACKEND_GL_MODERN_API 1
#endif
#include "blocklist_driver.h"
#include "graphics_threaded.h"
@ -285,17 +288,20 @@ class CCommandProcessorFragment_OpenGL2 : public CCommandProcessorFragment_OpenG
std::vector<SBufferObject> m_BufferObjectIndices;
#ifndef BACKEND_GL_MODERN_API
bool DoAnalyzeStep(size_t StepN, size_t CheckCount, size_t VerticesCount, uint8_t aFakeTexture[], size_t SingleImageSize);
bool IsTileMapAnalysisSucceeded();
void RenderBorderTileEmulation(SBufferContainer &BufferContainer, const CCommandBuffer::SState &State, const float *pColor, const char *pBuffOffset, unsigned int DrawNum, const float *pOffset, const float *pDir, int JumpIndex);
void RenderBorderTileLineEmulation(SBufferContainer &BufferContainer, const CCommandBuffer::SState &State, const float *pColor, const char *pBuffOffset, unsigned int IndexDrawNum, unsigned int DrawNum, const float *pOffset, const float *pDir);
#endif
void UseProgram(CGLSLTWProgram *pProgram);
protected:
void SetState(const CCommandBuffer::SState &State, CGLSLTWProgram *pProgram, bool Use2DArrayTextures = false);
#ifndef BACKEND_GL_MODERN_API
void Cmd_Init(const SCommand_Init *pCommand) override;
void Cmd_RenderTex3D(const CCommandBuffer::SCommand_RenderTex3D *pCommand) override;
@ -314,6 +320,7 @@ protected:
void Cmd_RenderTileLayer(const CCommandBuffer::SCommand_RenderTileLayer *pCommand) override;
void Cmd_RenderBorderTile(const CCommandBuffer::SCommand_RenderBorderTile *pCommand) override;
void Cmd_RenderBorderTileLine(const CCommandBuffer::SCommand_RenderBorderTileLine *pCommand) override;
#endif
CGLSLTileProgram *m_pTileProgram;
CGLSLTileProgram *m_pTileProgramTextured;

View file

@ -5,20 +5,11 @@
#if defined(CONF_BACKEND_OPENGL_ES)
#define GL_GLEXT_PROTOTYPES
#include <GL/glu.h>
#include <GLES/gl.h>
#include <GLES/glext.h>
#include <GLES3/gl3.h>
#define glOrtho glOrthof
#else
#include "SDL_opengl.h"
#if defined(CONF_PLATFORM_MACOS)
#include "OpenGL/glu.h"
#else
#include "GL/glu.h"
#endif
#endif
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>