- Add OpenGL ES 3 support to GL renderer

This commit is contained in:
Magnus Norddahl 2017-04-07 04:09:04 +02:00 committed by Rachael Alexanderson
parent b7482e10e2
commit 85a9984807
5 changed files with 18 additions and 7 deletions

View file

@ -85,8 +85,11 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
unsigned int lightbuffersize = GLRenderer->mLights->GetBlockSize(); unsigned int lightbuffersize = GLRenderer->mLights->GetBlockSize();
if (lightbuffertype == GL_UNIFORM_BUFFER) if (lightbuffertype == GL_UNIFORM_BUFFER)
{ {
// This differentiation is for some Intel drivers which fail on #extension, so use of #version 140 is necessary if (gl.es)
if (gl.glslversion < 1.4f) {
vp_comb.Format("#version 300 es\n#define NUM_UBO_LIGHTS %d\n", lightbuffersize);
}
else if (gl.glslversion < 1.4f) // This differentiation is for some Intel drivers which fail on #extension, so use of #version 140 is necessary
{ {
vp_comb.Format("#version 130\n#extension GL_ARB_uniform_buffer_object : require\n#define NUM_UBO_LIGHTS %d\n", lightbuffersize); vp_comb.Format("#version 130\n#extension GL_ARB_uniform_buffer_object : require\n#define NUM_UBO_LIGHTS %d\n", lightbuffersize);
} }
@ -410,10 +413,17 @@ static const FEffectShader effectshaders[]=
FShaderManager::FShaderManager() FShaderManager::FShaderManager()
{ {
if (!gl.legacyMode) if (!gl.legacyMode)
{
if (gl.es) // OpenGL ES does not support multiple fragment shader outputs. As a result, no GBUFFER passes are possible.
{
mPassShaders.Push(new FShaderCollection(NORMAL_PASS));
}
else
{ {
for (int passType = 0; passType < MAX_PASS_TYPES; passType++) for (int passType = 0; passType < MAX_PASS_TYPES; passType++)
mPassShaders.Push(new FShaderCollection((EPassType)passType)); mPassShaders.Push(new FShaderCollection((EPassType)passType));
} }
}
} }
FShaderManager::~FShaderManager() FShaderManager::~FShaderManager()

View file

@ -176,6 +176,7 @@ void gl_LoadExtensions()
gl.legacyMode = false; gl.legacyMode = false;
gl.lightmethod = LM_DEFERRED; gl.lightmethod = LM_DEFERRED;
gl.buffermethod = BM_DEFERRED; gl.buffermethod = BM_DEFERRED;
gl.flags |= RFL_NO_CLIP_PLANES;
} }
else else
{ {

View file

@ -5,7 +5,7 @@ vec4 ProcessTexel()
{ {
vec2 texCoord = vTexCoord.st; vec2 texCoord = vTexCoord.st;
vec4 basicColor = getTexel(texCoord); vec4 basicColor = getTexel(texCoord);
ivec2 texSize = textureSize(tex, 0); vec2 texSize = vec2(textureSize(tex, 0));
texCoord.x = float( int(texCoord.x * texSize.x) ) / texSize.x; texCoord.x = float( int(texCoord.x * texSize.x) ) / texSize.x;
texCoord.y = float( int(texCoord.y * texSize.y) ) / texSize.y; texCoord.y = float( int(texCoord.y * texSize.y) ) / texSize.y;

View file

@ -5,7 +5,7 @@ vec4 ProcessTexel()
{ {
vec2 texCoord = vTexCoord.st; vec2 texCoord = vTexCoord.st;
vec4 basicColor = getTexel(texCoord); vec4 basicColor = getTexel(texCoord);
ivec2 texSize = textureSize(tex, 0); vec2 texSize = vec2(textureSize(tex, 0));
texCoord.x = float( int(texCoord.x * texSize.x) ) / texSize.x; texCoord.x = float( int(texCoord.x * texSize.x) ) / texSize.x;
texCoord.y = float( int(texCoord.y * texSize.y) ) / texSize.y; texCoord.y = float( int(texCoord.y * texSize.y) ) / texSize.y;

View file

@ -90,7 +90,7 @@ vec4 getTexel(vec2 st)
} }
break; break;
} }
if (uObjectColor2.a == 0) texel *= uObjectColor; if (uObjectColor2.a == 0.0) texel *= uObjectColor;
else texel *= mix(uObjectColor, uObjectColor2, glowdist.z); else texel *= mix(uObjectColor, uObjectColor2, glowdist.z);
return desaturate(texel); return desaturate(texel);