From 066d5c63e2599039bf69a2e1d4aa634af975f700 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 26 Apr 2016 21:55:17 +0200 Subject: [PATCH] - better be safe and not call GL_CLIP_DISTANCE functions on old hardware. --- src/gl/renderer/gl_renderstate.h | 15 ++++++++++++++- src/gl/scene/gl_decal.cpp | 4 ---- src/gl/scene/gl_drawinfo.cpp | 14 ++++++++++---- src/gl/scene/gl_sprite.cpp | 4 ---- src/gl/scene/gl_walls_draw.cpp | 4 ---- 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 04142a582..e61ab004d 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -233,7 +233,20 @@ public: void EnableSplit(bool on) { - mSplitEnabled = on; + if (gl.glslversion >= 1.3f) + { + mSplitEnabled = on; + if (on) + { + glEnable(GL_CLIP_DISTANCE3); + glEnable(GL_CLIP_DISTANCE4); + } + else + { + glDisable(GL_CLIP_DISTANCE3); + glDisable(GL_CLIP_DISTANCE4); + } + } } void SetLightIndex(int n) diff --git a/src/gl/scene/gl_decal.cpp b/src/gl/scene/gl_decal.cpp index 42d2eccbd..1a10b3f4d 100644 --- a/src/gl/scene/gl_decal.cpp +++ b/src/gl/scene/gl_decal.cpp @@ -388,8 +388,6 @@ void GLWall::DoDrawDecals() if (lightlist != NULL) { gl_RenderState.EnableSplit(true); - glEnable(GL_CLIP_DISTANCE3); - glEnable(GL_CLIP_DISTANCE4); } else { @@ -405,8 +403,6 @@ void GLWall::DoDrawDecals() if (lightlist != NULL) { - glDisable(GL_CLIP_DISTANCE3); - glDisable(GL_CLIP_DISTANCE4); gl_RenderState.EnableSplit(false); } diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index 8bfa3df4e..386dc6a4a 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -806,11 +806,17 @@ void GLDrawList::DrawSorted() sorted=DoSort(SortNodes[SortNodeStart]); } gl_RenderState.ClearClipSplit(); - glEnable(GL_CLIP_DISTANCE1); - glEnable(GL_CLIP_DISTANCE2); + if (gl.glslversion >= 1.3f) + { + glEnable(GL_CLIP_DISTANCE1); + glEnable(GL_CLIP_DISTANCE2); + } DoDrawSorted(sorted); - glDisable(GL_CLIP_DISTANCE1); - glDisable(GL_CLIP_DISTANCE2); + if (gl.glslversion >= 1.3f) + { + glDisable(GL_CLIP_DISTANCE1); + glDisable(GL_CLIP_DISTANCE2); + } gl_RenderState.ClearClipSplit(); } diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 40aae9165..942a2e555 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -226,8 +226,6 @@ void GLSprite::Draw(int pass) { clipping = true; gl_RenderState.EnableSplit(true); - glEnable(GL_CLIP_DISTANCE3); - glEnable(GL_CLIP_DISTANCE4); } secplane_t bottomp = { { 0, 0, -1. }, bottomclip }; @@ -333,8 +331,6 @@ void GLSprite::Draw(int pass) if (clipping) { - glDisable(GL_CLIP_DISTANCE3); - glDisable(GL_CLIP_DISTANCE4); gl_RenderState.EnableSplit(false); } diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 5d5a1a7c3..8fe9d948e 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -339,8 +339,6 @@ void GLWall::RenderTextured(int rflags) else { gl_RenderState.EnableSplit(true); - glEnable(GL_CLIP_DISTANCE3); - glEnable(GL_CLIP_DISTANCE4); for (unsigned i = 0; i < lightlist->Size(); i++) { @@ -363,8 +361,6 @@ void GLWall::RenderTextured(int rflags) if (low1 <= zbottom[0] && low2 <= zbottom[1]) break; } - glDisable(GL_CLIP_DISTANCE3); - glDisable(GL_CLIP_DISTANCE4); gl_RenderState.EnableSplit(false); } gl_RenderState.SetTextureMode(tmode);