2016-09-14 18:01:13 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Copyright(C) 2009-2016 Christoph Oelckers
|
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with this program. If not, see http://www.gnu.org/licenses/
|
|
|
|
//
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
//
|
2013-06-23 07:49:34 +00:00
|
|
|
/*
|
|
|
|
** gl_renderstate.cpp
|
|
|
|
** Render state maintenance
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
2014-05-12 12:45:41 +00:00
|
|
|
#include "templates.h"
|
2013-06-23 07:49:34 +00:00
|
|
|
#include "gl/system/gl_system.h"
|
2013-09-03 16:29:39 +00:00
|
|
|
#include "gl/system/gl_interface.h"
|
2013-06-23 07:49:34 +00:00
|
|
|
#include "gl/data/gl_data.h"
|
2014-05-10 19:47:07 +00:00
|
|
|
#include "gl/data/gl_vertexbuffer.h"
|
2013-06-23 07:49:34 +00:00
|
|
|
#include "gl/system/gl_cvars.h"
|
|
|
|
#include "gl/shaders/gl_shader.h"
|
|
|
|
#include "gl/renderer/gl_renderer.h"
|
|
|
|
#include "gl/renderer/gl_renderstate.h"
|
|
|
|
#include "gl/renderer/gl_colormap.h"
|
2014-08-01 18:59:39 +00:00
|
|
|
#include "gl/dynlights//gl_lightbuffer.h"
|
2016-09-01 15:14:51 +00:00
|
|
|
#include "gl/renderer/gl_renderbuffers.h"
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2013-08-18 13:41:52 +00:00
|
|
|
void gl_SetTextureMode(int type);
|
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
FRenderState gl_RenderState;
|
|
|
|
|
|
|
|
CVAR(Bool, gl_direct_state_change, true, 0)
|
|
|
|
|
|
|
|
|
2014-07-13 18:41:20 +00:00
|
|
|
static VSMatrix identityMatrix(1);
|
2014-07-13 20:37:34 +00:00
|
|
|
TArray<VSMatrix> gl_MatrixStack;
|
2014-07-13 18:41:20 +00:00
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void FRenderState::Reset()
|
|
|
|
{
|
|
|
|
mTextureEnabled = true;
|
2016-04-28 23:48:06 +00:00
|
|
|
mClipLineEnabled = mSplitEnabled = mBrightmapEnabled = mFogEnabled = mGlowEnabled = false;
|
2015-12-31 16:57:21 +00:00
|
|
|
mColorMask[0] = mColorMask[1] = mColorMask[2] = mColorMask[3] = true;
|
|
|
|
currentColorMask[0] = currentColorMask[1] = currentColorMask[2] = currentColorMask[3] = true;
|
2014-06-29 09:00:21 +00:00
|
|
|
mFogColor.d = -1;
|
|
|
|
mTextureMode = -1;
|
2014-08-01 18:59:39 +00:00
|
|
|
mLightIndex = -1;
|
2014-05-12 12:45:41 +00:00
|
|
|
mDesaturation = 0;
|
2013-06-23 07:49:34 +00:00
|
|
|
mSrcBlend = GL_SRC_ALPHA;
|
|
|
|
mDstBlend = GL_ONE_MINUS_SRC_ALPHA;
|
|
|
|
mAlphaThreshold = 0.5f;
|
|
|
|
mBlendEquation = GL_FUNC_ADD;
|
2016-08-25 23:36:21 +00:00
|
|
|
mModelMatrixEnabled = false;
|
|
|
|
mTextureMatrixEnabled = false;
|
2014-05-11 14:06:25 +00:00
|
|
|
mObjectColor = 0xffffffff;
|
2014-05-10 19:47:07 +00:00
|
|
|
mVertexBuffer = mCurrentVertexBuffer = NULL;
|
2014-05-11 19:47:54 +00:00
|
|
|
mColormapState = CM_DEFAULT;
|
2016-08-25 23:36:21 +00:00
|
|
|
mSoftLight = 0;
|
|
|
|
mLightParms[0] = mLightParms[1] = mLightParms[2] = 0.0f;
|
2014-05-12 12:45:41 +00:00
|
|
|
mLightParms[3] = -1.f;
|
2014-06-29 09:00:21 +00:00
|
|
|
mSpecialEffect = EFF_NONE;
|
2016-04-26 22:41:00 +00:00
|
|
|
mClipHeight = 0.f;
|
|
|
|
mClipHeightDirection = 0.f;
|
2016-08-25 23:36:21 +00:00
|
|
|
mShaderTimer = 0.0f;
|
2015-04-05 16:55:21 +00:00
|
|
|
ClearClipSplit();
|
2014-07-27 10:33:54 +00:00
|
|
|
|
|
|
|
stSrcBlend = stDstBlend = -1;
|
|
|
|
stBlendEquation = -1;
|
|
|
|
stAlphaThreshold = -1.f;
|
2016-08-25 23:36:21 +00:00
|
|
|
stAlphaTest = 0;
|
2014-11-27 11:26:52 +00:00
|
|
|
mLastDepthClamp = true;
|
2016-08-25 23:36:21 +00:00
|
|
|
mInterpolationFactor = 0.0f;
|
|
|
|
|
2016-08-29 03:31:12 +00:00
|
|
|
mColor.Set(1.0f, 1.0f, 1.0f, 1.0f);
|
2016-08-25 23:36:21 +00:00
|
|
|
mCameraPos.Set(0.0f, 0.0f, 0.0f, 0.0f);
|
|
|
|
mGlowTop.Set(0.0f, 0.0f, 0.0f, 0.0f);
|
|
|
|
mGlowBottom.Set(0.0f, 0.0f, 0.0f, 0.0f);
|
|
|
|
mGlowTopPlane.Set(0.0f, 0.0f, 0.0f, 0.0f);
|
|
|
|
mGlowBottomPlane.Set(0.0f, 0.0f, 0.0f, 0.0f);
|
|
|
|
mSplitTopPlane.Set(0.0f, 0.0f, 0.0f, 0.0f);
|
|
|
|
mSplitBottomPlane.Set(0.0f, 0.0f, 0.0f, 0.0f);
|
|
|
|
mClipLine.Set(0.0f, 0.0f, 0.0f, 0.0f);
|
|
|
|
mDynColor.Set(0.0f, 0.0f, 0.0f, 0.0f);
|
|
|
|
mEffectState = 0;
|
|
|
|
activeShader = nullptr;
|
|
|
|
mProjectionMatrix.loadIdentity();
|
|
|
|
mViewMatrix.loadIdentity();
|
|
|
|
mModelMatrix.loadIdentity();
|
|
|
|
mTextureMatrix.loadIdentity();
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Apply shader settings
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
bool FRenderState::ApplyShader()
|
|
|
|
{
|
2016-01-30 22:01:11 +00:00
|
|
|
static const float nulvec[] = { 0.f, 0.f, 0.f, 0.f };
|
2014-06-21 13:50:32 +00:00
|
|
|
if (mSpecialEffect > EFF_NONE)
|
|
|
|
{
|
|
|
|
activeShader = GLRenderer->mShaderManager->BindEffect(mSpecialEffect);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-08-02 19:06:34 +00:00
|
|
|
activeShader = GLRenderer->mShaderManager->Get(mTextureEnabled ? mEffectState : 4, mAlphaThreshold >= 0.f);
|
2014-06-21 13:50:32 +00:00
|
|
|
activeShader->Bind();
|
|
|
|
}
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2014-06-21 13:50:32 +00:00
|
|
|
int fogset = 0;
|
2014-07-13 10:14:12 +00:00
|
|
|
|
2014-06-21 13:50:32 +00:00
|
|
|
if (mFogEnabled)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2014-06-21 13:50:32 +00:00
|
|
|
if ((mFogColor & 0xffffff) == 0)
|
2014-05-11 11:27:51 +00:00
|
|
|
{
|
2014-06-21 13:50:32 +00:00
|
|
|
fogset = gl_fogmode;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
2014-05-21 10:36:29 +00:00
|
|
|
else
|
2014-05-11 19:47:54 +00:00
|
|
|
{
|
2014-06-21 13:50:32 +00:00
|
|
|
fogset = -gl_fogmode;
|
2014-05-11 19:47:54 +00:00
|
|
|
}
|
2014-06-21 13:50:32 +00:00
|
|
|
}
|
2014-05-11 12:46:37 +00:00
|
|
|
|
2014-07-14 22:37:13 +00:00
|
|
|
glVertexAttrib4fv(VATTR_COLOR, mColor.vec);
|
2016-10-03 14:09:32 +00:00
|
|
|
glVertexAttrib4fv(VATTR_NORMAL, mNormal.vec);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2014-06-21 13:50:32 +00:00
|
|
|
activeShader->muDesaturation.Set(mDesaturation / 255.f);
|
|
|
|
activeShader->muFogEnabled.Set(fogset);
|
|
|
|
activeShader->muTextureMode.Set(mTextureMode);
|
|
|
|
activeShader->muCameraPos.Set(mCameraPos.vec);
|
|
|
|
activeShader->muLightParms.Set(mLightParms);
|
|
|
|
activeShader->muFogColor.Set(mFogColor);
|
|
|
|
activeShader->muObjectColor.Set(mObjectColor);
|
2014-07-01 07:52:41 +00:00
|
|
|
activeShader->muDynLightColor.Set(mDynColor.vec);
|
2014-06-29 09:00:21 +00:00
|
|
|
activeShader->muInterpolationFactor.Set(mInterpolationFactor);
|
2016-04-26 22:41:00 +00:00
|
|
|
activeShader->muClipHeight.Set(mClipHeight);
|
|
|
|
activeShader->muClipHeightDirection.Set(mClipHeightDirection);
|
2014-07-26 18:56:10 +00:00
|
|
|
activeShader->muTimer.Set(gl_frameMS * mShaderTimer / 1000.f);
|
2014-07-30 21:13:16 +00:00
|
|
|
activeShader->muAlphaThreshold.Set(mAlphaThreshold);
|
2014-08-01 18:59:39 +00:00
|
|
|
activeShader->muLightIndex.Set(mLightIndex); // will always be -1 for now
|
2015-04-05 16:55:21 +00:00
|
|
|
activeShader->muClipSplit.Set(mClipSplit);
|
2014-05-12 12:45:41 +00:00
|
|
|
|
2014-06-21 13:50:32 +00:00
|
|
|
if (mGlowEnabled)
|
|
|
|
{
|
|
|
|
activeShader->muGlowTopColor.Set(mGlowTop.vec);
|
|
|
|
activeShader->muGlowBottomColor.Set(mGlowBottom.vec);
|
|
|
|
activeShader->muGlowTopPlane.Set(mGlowTopPlane.vec);
|
|
|
|
activeShader->muGlowBottomPlane.Set(mGlowBottomPlane.vec);
|
|
|
|
activeShader->currentglowstate = 1;
|
|
|
|
}
|
|
|
|
else if (activeShader->currentglowstate)
|
|
|
|
{
|
|
|
|
// if glowing is on, disable it.
|
|
|
|
activeShader->muGlowTopColor.Set(nulvec);
|
|
|
|
activeShader->muGlowBottomColor.Set(nulvec);
|
|
|
|
activeShader->muGlowTopPlane.Set(nulvec);
|
|
|
|
activeShader->muGlowBottomPlane.Set(nulvec);
|
|
|
|
activeShader->currentglowstate = 0;
|
|
|
|
}
|
|
|
|
|
2016-01-30 22:01:11 +00:00
|
|
|
if (mSplitEnabled)
|
|
|
|
{
|
|
|
|
activeShader->muSplitTopPlane.Set(mSplitTopPlane.vec);
|
|
|
|
activeShader->muSplitBottomPlane.Set(mSplitBottomPlane.vec);
|
|
|
|
activeShader->currentsplitstate = 1;
|
|
|
|
}
|
2016-04-28 23:48:06 +00:00
|
|
|
else if (activeShader->currentsplitstate)
|
2016-01-30 22:01:11 +00:00
|
|
|
{
|
|
|
|
activeShader->muSplitTopPlane.Set(nulvec);
|
|
|
|
activeShader->muSplitBottomPlane.Set(nulvec);
|
2016-04-28 23:48:06 +00:00
|
|
|
activeShader->currentsplitstate = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mClipLineEnabled)
|
|
|
|
{
|
|
|
|
activeShader->muClipLine.Set(mClipLine.vec);
|
|
|
|
activeShader->currentcliplinestate = 1;
|
|
|
|
}
|
|
|
|
else if (activeShader->currentcliplinestate)
|
|
|
|
{
|
|
|
|
activeShader->muClipLine.Set(-10000000.0, 0, 0, 0);
|
|
|
|
activeShader->currentcliplinestate = 0;
|
2016-01-30 22:01:11 +00:00
|
|
|
}
|
|
|
|
|
2014-06-21 13:50:32 +00:00
|
|
|
if (mColormapState != activeShader->currentfixedcolormap)
|
|
|
|
{
|
|
|
|
float r, g, b;
|
|
|
|
activeShader->currentfixedcolormap = mColormapState;
|
|
|
|
if (mColormapState == CM_DEFAULT)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2014-06-21 13:50:32 +00:00
|
|
|
activeShader->muFixedColormap.Set(0);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
2016-09-01 15:14:51 +00:00
|
|
|
else if (mColormapState > CM_DEFAULT && mColormapState < CM_MAXCOLORMAP)
|
2014-05-10 15:09:43 +00:00
|
|
|
{
|
2016-09-01 15:14:51 +00:00
|
|
|
if (FGLRenderBuffers::IsEnabled())
|
|
|
|
{
|
|
|
|
// When using postprocessing to apply the colormap, we must render the image fullbright here.
|
|
|
|
activeShader->muFixedColormap.Set(2);
|
|
|
|
activeShader->muColormapStart.Set(1, 1, 1, 1.f);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FSpecialColormap *scm = &SpecialColormaps[gl_fixedcolormap - CM_FIRSTSPECIALCOLORMAP];
|
|
|
|
float m[] = { scm->ColorizeEnd[0] - scm->ColorizeStart[0],
|
|
|
|
scm->ColorizeEnd[1] - scm->ColorizeStart[1], scm->ColorizeEnd[2] - scm->ColorizeStart[2], 0.f };
|
2014-05-10 15:09:43 +00:00
|
|
|
|
2016-09-01 15:14:51 +00:00
|
|
|
activeShader->muFixedColormap.Set(1);
|
|
|
|
activeShader->muColormapStart.Set(scm->ColorizeStart[0], scm->ColorizeStart[1], scm->ColorizeStart[2], 0.f);
|
|
|
|
activeShader->muColormapRange.Set(m);
|
|
|
|
}
|
2014-05-11 14:06:25 +00:00
|
|
|
}
|
2014-06-21 13:50:32 +00:00
|
|
|
else if (mColormapState == CM_FOGLAYER)
|
2014-05-11 14:49:17 +00:00
|
|
|
{
|
2014-06-21 13:50:32 +00:00
|
|
|
activeShader->muFixedColormap.Set(3);
|
2014-05-11 14:49:17 +00:00
|
|
|
}
|
2014-06-21 13:50:32 +00:00
|
|
|
else if (mColormapState == CM_LITE)
|
2014-05-11 22:13:19 +00:00
|
|
|
{
|
2014-06-21 13:50:32 +00:00
|
|
|
if (gl_enhanced_nightvision)
|
2014-05-12 12:45:41 +00:00
|
|
|
{
|
2014-06-21 13:50:32 +00:00
|
|
|
r = 0.375f, g = 1.0f, b = 0.375f;
|
2014-05-12 12:45:41 +00:00
|
|
|
}
|
2014-06-21 13:50:32 +00:00
|
|
|
else
|
2014-05-12 12:45:41 +00:00
|
|
|
{
|
2014-06-21 13:50:32 +00:00
|
|
|
r = g = b = 1.f;
|
2014-05-12 12:45:41 +00:00
|
|
|
}
|
2014-06-21 13:50:32 +00:00
|
|
|
activeShader->muFixedColormap.Set(2);
|
|
|
|
activeShader->muColormapStart.Set(r, g, b, 1.f);
|
|
|
|
}
|
|
|
|
else if (mColormapState >= CM_TORCH)
|
|
|
|
{
|
|
|
|
int flicker = mColormapState - CM_TORCH;
|
|
|
|
r = (0.8f + (7 - flicker) / 70.0f);
|
|
|
|
if (r > 1.0f) r = 1.0f;
|
|
|
|
b = g = r;
|
|
|
|
if (gl_enhanced_nightvision) b = g * 0.75f;
|
|
|
|
activeShader->muFixedColormap.Set(2);
|
|
|
|
activeShader->muColormapStart.Set(r, g, b, 1.f);
|
2014-05-12 12:45:41 +00:00
|
|
|
}
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
2014-07-13 18:41:20 +00:00
|
|
|
if (mTextureMatrixEnabled)
|
|
|
|
{
|
|
|
|
mTextureMatrix.matrixToGL(activeShader->texturematrix_index);
|
|
|
|
activeShader->currentTextureMatrixState = true;
|
|
|
|
}
|
|
|
|
else if (activeShader->currentTextureMatrixState)
|
|
|
|
{
|
|
|
|
activeShader->currentTextureMatrixState = false;
|
|
|
|
identityMatrix.matrixToGL(activeShader->texturematrix_index);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mModelMatrixEnabled)
|
|
|
|
{
|
|
|
|
mModelMatrix.matrixToGL(activeShader->modelmatrix_index);
|
2016-10-03 14:09:32 +00:00
|
|
|
VSMatrix norm;
|
|
|
|
norm.computeNormalMatrix(mModelMatrix);
|
|
|
|
mNormalModelMatrix.matrixToGL(activeShader->normalmodelmatrix_index);
|
2014-07-13 18:41:20 +00:00
|
|
|
activeShader->currentModelMatrixState = true;
|
|
|
|
}
|
|
|
|
else if (activeShader->currentModelMatrixState)
|
|
|
|
{
|
|
|
|
activeShader->currentModelMatrixState = false;
|
|
|
|
identityMatrix.matrixToGL(activeShader->modelmatrix_index);
|
2016-10-03 14:09:32 +00:00
|
|
|
identityMatrix.matrixToGL(activeShader->normalmodelmatrix_index);
|
2014-07-13 18:41:20 +00:00
|
|
|
}
|
2014-06-21 13:50:32 +00:00
|
|
|
return true;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Apply State
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2014-06-21 13:50:32 +00:00
|
|
|
void FRenderState::Apply()
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
|
|
|
if (!gl_direct_state_change)
|
|
|
|
{
|
2014-07-27 10:33:54 +00:00
|
|
|
if (mSrcBlend != stSrcBlend || mDstBlend != stDstBlend)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2014-07-27 10:33:54 +00:00
|
|
|
stSrcBlend = mSrcBlend;
|
|
|
|
stDstBlend = mDstBlend;
|
2013-06-23 07:49:34 +00:00
|
|
|
glBlendFunc(mSrcBlend, mDstBlend);
|
|
|
|
}
|
2014-07-27 10:33:54 +00:00
|
|
|
if (mBlendEquation != stBlendEquation)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2014-07-27 10:33:54 +00:00
|
|
|
stBlendEquation = mBlendEquation;
|
|
|
|
glBlendEquation(mBlendEquation);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-01 09:59:34 +00:00
|
|
|
//ApplyColorMask(); I don't think this is needed.
|
2015-12-31 16:57:21 +00:00
|
|
|
|
2014-05-10 19:47:07 +00:00
|
|
|
if (mVertexBuffer != mCurrentVertexBuffer)
|
|
|
|
{
|
|
|
|
if (mVertexBuffer == NULL) glBindBuffer(GL_ARRAY_BUFFER, 0);
|
|
|
|
else mVertexBuffer->BindVBO();
|
|
|
|
mCurrentVertexBuffer = mVertexBuffer;
|
|
|
|
}
|
2016-09-01 09:52:52 +00:00
|
|
|
if (!gl.legacyMode)
|
2016-04-26 13:01:23 +00:00
|
|
|
{
|
|
|
|
ApplyShader();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-04-26 16:24:02 +00:00
|
|
|
ApplyFixedFunction();
|
2016-04-26 13:01:23 +00:00
|
|
|
}
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
2014-07-13 20:37:34 +00:00
|
|
|
|
|
|
|
|
2015-12-31 16:57:21 +00:00
|
|
|
void FRenderState::ApplyColorMask()
|
|
|
|
{
|
|
|
|
if ((mColorMask[0] != currentColorMask[0]) ||
|
|
|
|
(mColorMask[1] != currentColorMask[1]) ||
|
|
|
|
(mColorMask[2] != currentColorMask[2]) ||
|
|
|
|
(mColorMask[3] != currentColorMask[3]))
|
|
|
|
{
|
|
|
|
glColorMask(mColorMask[0], mColorMask[1], mColorMask[2], mColorMask[3]);
|
|
|
|
currentColorMask[0] = mColorMask[0];
|
|
|
|
currentColorMask[1] = mColorMask[1];
|
|
|
|
currentColorMask[2] = mColorMask[2];
|
|
|
|
currentColorMask[3] = mColorMask[3];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-13 20:37:34 +00:00
|
|
|
void FRenderState::ApplyMatrices()
|
|
|
|
{
|
2014-07-13 21:13:40 +00:00
|
|
|
if (GLRenderer->mShaderManager != NULL)
|
|
|
|
{
|
|
|
|
GLRenderer->mShaderManager->ApplyMatrices(&mProjectionMatrix, &mViewMatrix);
|
|
|
|
}
|
2014-07-13 20:37:34 +00:00
|
|
|
}
|
2014-08-01 18:59:39 +00:00
|
|
|
|
|
|
|
void FRenderState::ApplyLightIndex(int index)
|
|
|
|
{
|
2016-09-01 09:52:52 +00:00
|
|
|
if (!gl.legacyMode)
|
2014-08-01 18:59:39 +00:00
|
|
|
{
|
2016-04-26 14:44:03 +00:00
|
|
|
if (index > -1 && GLRenderer->mLights->GetBufferType() == GL_UNIFORM_BUFFER)
|
|
|
|
{
|
|
|
|
index = GLRenderer->mLights->BindUBO(index);
|
|
|
|
}
|
|
|
|
activeShader->muLightIndex.Set(index);
|
2014-08-01 18:59:39 +00:00
|
|
|
}
|
2016-04-26 22:41:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FRenderState::SetClipHeight(float height, float direction)
|
|
|
|
{
|
|
|
|
mClipHeight = height;
|
|
|
|
mClipHeightDirection = direction;
|
2016-05-12 21:41:06 +00:00
|
|
|
#if 1
|
|
|
|
// This still doesn't work... :(
|
2016-08-08 10:55:09 +00:00
|
|
|
if (gl.flags & RFL_NO_CLIP_PLANES) return;
|
2016-05-12 21:41:06 +00:00
|
|
|
#endif
|
2016-04-26 22:41:00 +00:00
|
|
|
if (direction != 0.f)
|
|
|
|
{
|
2016-05-12 21:41:06 +00:00
|
|
|
/*
|
2016-08-08 10:55:09 +00:00
|
|
|
if (gl.flags & RFL_NO_CLIP_PLANES)
|
2016-04-26 22:41:00 +00:00
|
|
|
{
|
2016-05-12 21:41:06 +00:00
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
glPushMatrix();
|
|
|
|
glLoadMatrixf(mViewMatrix.get());
|
2016-04-26 22:41:00 +00:00
|
|
|
// Plane mirrors never are slopes.
|
2016-05-12 21:41:06 +00:00
|
|
|
double d[4] = { 0, direction, 0, -direction * height };
|
|
|
|
glClipPlane(GL_CLIP_PLANE0, d);
|
|
|
|
glPopMatrix();
|
2016-04-26 22:41:00 +00:00
|
|
|
}
|
2016-05-12 21:41:06 +00:00
|
|
|
*/
|
|
|
|
glEnable(GL_CLIP_DISTANCE0);
|
2016-04-26 22:41:00 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-05-12 21:41:06 +00:00
|
|
|
glDisable(GL_CLIP_DISTANCE0); // GL_CLIP_PLANE0 is the same value so no need to make a distinction
|
2016-04-26 22:41:00 +00:00
|
|
|
}
|
|
|
|
}
|