From 85a9984807c4074fffacf662838b3884baaf392f Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 7 Apr 2017 04:09:04 +0200 Subject: [PATCH] - Add OpenGL ES 3 support to GL renderer --- src/gl/shaders/gl_shader.cpp | 18 ++++++++++++++---- src/gl/system/gl_interface.cpp | 1 + wadsrc/static/shaders/glsl/fuzz_noise.fp | 2 +- wadsrc/static/shaders/glsl/fuzz_standard.fp | 2 +- wadsrc/static/shaders/glsl/main.fp | 2 +- 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 44be65ebe..2fdf9fbf3 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -85,8 +85,11 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * unsigned int lightbuffersize = GLRenderer->mLights->GetBlockSize(); 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.glslversion < 1.4f) + if (gl.es) + { + 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); } @@ -411,8 +414,15 @@ FShaderManager::FShaderManager() { if (!gl.legacyMode) { - for (int passType = 0; passType < MAX_PASS_TYPES; passType++) - mPassShaders.Push(new FShaderCollection((EPassType)passType)); + 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++) + mPassShaders.Push(new FShaderCollection((EPassType)passType)); + } } } diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index a0d16597f..1a3f4b1ae 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -176,6 +176,7 @@ void gl_LoadExtensions() gl.legacyMode = false; gl.lightmethod = LM_DEFERRED; gl.buffermethod = BM_DEFERRED; + gl.flags |= RFL_NO_CLIP_PLANES; } else { diff --git a/wadsrc/static/shaders/glsl/fuzz_noise.fp b/wadsrc/static/shaders/glsl/fuzz_noise.fp index 17f15d03b..75afc251f 100644 --- a/wadsrc/static/shaders/glsl/fuzz_noise.fp +++ b/wadsrc/static/shaders/glsl/fuzz_noise.fp @@ -5,7 +5,7 @@ vec4 ProcessTexel() { vec2 texCoord = vTexCoord.st; 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.y = float( int(texCoord.y * texSize.y) ) / texSize.y; diff --git a/wadsrc/static/shaders/glsl/fuzz_standard.fp b/wadsrc/static/shaders/glsl/fuzz_standard.fp index 95ba52431..b467f64b2 100644 --- a/wadsrc/static/shaders/glsl/fuzz_standard.fp +++ b/wadsrc/static/shaders/glsl/fuzz_standard.fp @@ -5,7 +5,7 @@ vec4 ProcessTexel() { vec2 texCoord = vTexCoord.st; 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.y = float( int(texCoord.y * texSize.y) ) / texSize.y; diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 9a682f386..5b4d1438f 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -90,7 +90,7 @@ vec4 getTexel(vec2 st) } break; } - if (uObjectColor2.a == 0) texel *= uObjectColor; + if (uObjectColor2.a == 0.0) texel *= uObjectColor; else texel *= mix(uObjectColor, uObjectColor2, glowdist.z); return desaturate(texel);