From 89f36fb963bfbd51b370da773515a66727e080a5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 26 Apr 2016 20:45:56 +0200 Subject: [PATCH] - enabled texture and model matrices for shader-less rendering and fixed the sky cap color application. --- src/gl/compatibility/gl_20.cpp | 33 ++++++++++++++++++++++++++++++++- src/gl/scene/gl_skydome.cpp | 9 +++++++-- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index fc171686b..5498c0b0a 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -197,6 +197,8 @@ static bool ffFogEnabled; static PalEntry ffFogColor; static int ffSpecialEffect; static float ffFogDensity; +static bool currentTextureMatrixState; +static bool currentModelMatrixState; void FRenderState::ApplyFixedFunction() { @@ -282,13 +284,42 @@ void FRenderState::ApplyFixedFunction() if (mAlphaThreshold > 0) { glEnable(GL_ALPHA_TEST); - glAlphaFunc(GL_GREATER, mAlphaThreshold); + glAlphaFunc(GL_GREATER, mAlphaThreshold * col.vec[3]); } else { glDisable(GL_ALPHA_TEST); } + if (mTextureMatrixEnabled) + { + glMatrixMode(GL_TEXTURE); + glLoadMatrixf(mTextureMatrix.get()); + currentTextureMatrixState = true; + } + else if (currentTextureMatrixState) + { + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); + currentTextureMatrixState = false; + } + + if (mModelMatrixEnabled) + { + VSMatrix mult = mViewMatrix; + mult.multMatrix(mModelMatrix); + glMatrixMode(GL_MODELVIEW); + glLoadMatrixf(mult.get()); + currentModelMatrixState = true; + } + else if (currentModelMatrixState) + { + glMatrixMode(GL_MODELVIEW); + glLoadMatrixf(mViewMatrix.get()); + currentModelMatrixState = false; + } + + } void gl_FillScreen(); diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index b870b56ff..33c73d82c 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -104,7 +104,7 @@ void FSkyVertexBuffer::BindVBO() glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(FSkyVertex), &VSO->color); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glEnableClientState(GL_COLOR_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); } } @@ -254,6 +254,11 @@ void FSkyVertexBuffer::RenderDome(FMaterial *tex, int mode) gl_RenderState.Apply(); RenderRow(GL_TRIANGLE_FAN, rc); gl_RenderState.EnableTexture(true); + // The color array can only be activated now if this is drawn without shader + if (gl.glslversion == 0) + { + glEnableClientState(GL_COLOR_ARRAY); + } } gl_RenderState.SetObjectColor(0xffffffff); gl_RenderState.Apply(); @@ -523,7 +528,7 @@ void GLSkyPortal::DrawContents() gl_RenderState.SetTextureMode(TM_MODULATE); } - gl_RenderState.AlphaFunc(GL_GEQUAL, 0.05f); + gl_RenderState.AlphaFunc(GL_GREATER, 0.f); if (origin->doublesky && origin->texture[1]) {