diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index 637de85aa..05fd475c0 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -137,9 +137,9 @@ void FSimpleVertexBuffer::set(FSimpleVertex *verts, int count) //========================================================================== FFlatVertexBuffer::FFlatVertexBuffer(int width, int height) -: FVertexBuffer(gl.buffermethod == BM_PERSISTENT) +: FVertexBuffer(gl.buffermethod != BM_CLIENTARRAY) { - if (gl.buffermethod == BM_PERSISTENT) + if (gl.buffermethod != BM_CLIENTARRAY) { unsigned int bytesize = BUFFER_SIZE * sizeof(FFlatVertex); glBindBuffer(GL_ARRAY_BUFFER, vbo_id); @@ -157,10 +157,10 @@ FFlatVertexBuffer::FFlatVertexBuffer(int width, int height) vbo_shadowdata.Resize(mNumReserved); // the first quad is reserved for handling coordinates through uniforms. - vbo_shadowdata[0].Set(1, 0, 0, 0, 0); - vbo_shadowdata[1].Set(2, 0, 0, 0, 0); - vbo_shadowdata[2].Set(3, 0, 0, 0, 0); - vbo_shadowdata[3].Set(4, 0, 0, 0, 0); + vbo_shadowdata[0].Set(0, 0, 0, 0, 0); + vbo_shadowdata[1].Set(1, 0, 0, 0, 0); + vbo_shadowdata[2].Set(2, 0, 0, 0, 0); + vbo_shadowdata[3].Set(3, 0, 0, 0, 0); // and the second one for the fullscreen quad used for blend overlays. vbo_shadowdata[4].Set(0, 0, 0, 0, 0); diff --git a/src/gl/renderer/gl_quaddrawer.h b/src/gl/renderer/gl_quaddrawer.h index 3fcca65c2..b9db60684 100644 --- a/src/gl/renderer/gl_quaddrawer.h +++ b/src/gl/renderer/gl_quaddrawer.h @@ -14,7 +14,7 @@ public: FQuadDrawer() { - if (gl.flags & RFL_QUADHACK) + if (gl.buffermethod == BM_DEFERRED) { p = buffer; } @@ -29,7 +29,7 @@ public: } void Render(int type) { - if (gl.flags & RFL_QUADHACK) + if (gl.buffermethod == BM_DEFERRED) { DoRender(type); } diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index c3f0f83da..67b9a2d6a 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -125,6 +125,10 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * vp_comb = "#version 400 core\n#extension GL_ARB_shader_storage_buffer_object : require\n#define SHADER_STORAGE_LIGHTS\n"; } } + //if (gl.buffermethod == BM_DEFERRED) + { + vp_comb << "#define USE_QUAD_DRAWER\n"; + } vp_comb << defines << i_data.GetString().GetChars(); FString fp_comb = vp_comb; @@ -276,6 +280,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * } glUseProgram(hShader); + if (quadmode_index > 0) glUniform1i(quadmode_index, 0); // set up other texture units (if needed by the shader) for (int i = 2; i<16; i++) diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 8c1e4cd9b..4d83ebec0 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -156,7 +156,15 @@ void gl_LoadExtensions() gl.version = strtod(version, NULL) + 0.01f; - // Don't even start if it's lower than 3.0 + bool iscore = false; + if (gl.version >= 3.2) + { + int v; + glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &v); + iscore = !!(v & GL_CONTEXT_CORE_PROFILE_BIT); + } + + // Don't even start if it's lower than 2.0 or no framebuffers are available if ((gl.version < 2.0 || !CheckExtension("GL_EXT_framebuffer_object")) && gl.version < 3.0) { I_FatalError("Unsupported OpenGL version.\nAt least OpenGL 2.0 with framebuffer support is required to run " GAMENAME ".\n"); @@ -178,10 +186,10 @@ void gl_LoadExtensions() if (gl.version > 3.0f && (gl.version >= 3.3f || CheckExtension("GL_ARB_uniform_buffer_object"))) { gl.lightmethod = LM_DEFERRED; - // Only Apple requires the core profile for GL 3.x+. - // #ifdef __APPLE__ - // gl.buffermethod = BM_DEFERRED; - // #endif + if (iscore) + { + gl.buffermethod = BM_DEFERRED; + } } if (CheckExtension("GL_ARB_texture_compression")) gl.flags |= RFL_TEXTURE_COMPRESSION; @@ -256,7 +264,7 @@ void gl_LoadExtensions() lm = Args->CheckValue("-buffermethod"); if (lm != NULL) { - //if (!stricmp(lm, "deferred") && gl.buffermethod == BM_PERSISTENT) gl.buffermethod = BM_DEFERRED; + if (!stricmp(lm, "deferred") && gl.buffermethod == BM_PERSISTENT) gl.buffermethod = BM_DEFERRED; if (!stricmp(lm, "clientarray")) gl.buffermethod = BM_CLIENTARRAY; } diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index 9eca673f5..11b0573e5 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -25,8 +25,7 @@ enum RenderFlags RFL_NO_DEPTHSTENCIL = 64, RFL_NO_CLIP_PLANES = 128, - RFL_INVALIDATE_BUFFER = 256, - RFL_QUADHACK = 512 + RFL_INVALIDATE_BUFFER = 256 }; enum TexMode diff --git a/wadsrc/static/shaders/glsl/main.vp b/wadsrc/static/shaders/glsl/main.vp index 281c509d3..a2c1bac5b 100644 --- a/wadsrc/static/shaders/glsl/main.vp +++ b/wadsrc/static/shaders/glsl/main.vp @@ -15,6 +15,7 @@ void main() { vec2 parmTexCoord; vec4 parmPosition; + #ifndef USE_QUAD_DRAWER parmTexCoord = aTexCoord; parmPosition = aPosition; @@ -26,8 +27,8 @@ void main() } else { - parmPosition = uQuadVertices[int(aPosition.x)].st; - parmTexCoord = uQuadTexCoords[int(aPosition.x)]; + parmPosition = uQuadVertices[int(aPosition.x)]; + parmTexCoord = uQuadTexCoords[int(aPosition.x)].st; } #endif @@ -67,13 +68,7 @@ void main() #endif gl_Position = ProjectionMatrix * eyeCoordPos; - - #if defined __GLSL_CG_DATA_TYPES && defined GLSL12_COMPATIBILE - gl_ClipVertex = eyeCoordPos; - #endif - - - + if (uClipHeightDirection != 0.0) // clip planes used for reflective flats { gl_ClipDistance[0] = (worldcoord.y - uClipHeight) * uClipHeightDirection;