summaryrefslogtreecommitdiff
path: root/indra/llrender/llrender.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llrender/llrender.cpp')
-rw-r--r--indra/llrender/llrender.cpp78
1 files changed, 67 insertions, 11 deletions
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index 1d82dda30f..edcc47aa14 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -46,6 +46,7 @@ S32 gGLViewport[4];
U32 LLRender::sUICalls = 0;
U32 LLRender::sUIVerts = 0;
+U32 LLTexUnit::sWhiteTexture = 0;
static const U32 LL_NUM_TEXTURE_LAYERS = 32;
static const U32 LL_NUM_LIGHT_UNITS = 8;
@@ -126,7 +127,8 @@ void LLTexUnit::refreshState(void)
// Per apple spec, don't call glEnable/glDisable when index exceeds max texture units
// http://www.mailinglistarchive.com/html/mac-opengl@lists.apple.com/2008-07/msg00653.html
//
- bool enableDisable = (mIndex < gGLManager.mNumTextureUnits) && mCurrTexType != LLTexUnit::TT_MULTISAMPLE_TEXTURE;
+ bool enableDisable = !LLGLSLShader::sNoFixedFunction &&
+ (mIndex < gGLManager.mNumTextureUnits) && mCurrTexType != LLTexUnit::TT_MULTISAMPLE_TEXTURE;
if (mCurrTexType != TT_NONE)
{
@@ -184,7 +186,8 @@ void LLTexUnit::enable(eTextureType type)
mCurrTexType = type;
gGL.flush();
- if (type != LLTexUnit::TT_MULTISAMPLE_TEXTURE &&
+ if (!LLGLSLShader::sNoFixedFunction &&
+ type != LLTexUnit::TT_MULTISAMPLE_TEXTURE &&
mIndex < gGLManager.mNumTextureUnits)
{
glEnable(sGLTextureType[type]);
@@ -201,7 +204,8 @@ void LLTexUnit::disable(void)
activate();
unbind(mCurrTexType);
gGL.flush();
- if (mCurrTexType != LLTexUnit::TT_MULTISAMPLE_TEXTURE &&
+ if (!LLGLSLShader::sNoFixedFunction &&
+ mCurrTexType != LLTexUnit::TT_MULTISAMPLE_TEXTURE &&
mIndex < gGLManager.mNumTextureUnits)
{
glDisable(sGLTextureType[mCurrTexType]);
@@ -403,7 +407,14 @@ void LLTexUnit::unbind(eTextureType type)
activate();
mCurrTexture = 0;
- glBindTexture(sGLTextureType[type], 0);
+ if (LLGLSLShader::sNoFixedFunction && type == LLTexUnit::TT_TEXTURE)
+ {
+ glBindTexture(sGLTextureType[type], sWhiteTexture);
+ }
+ else
+ {
+ glBindTexture(sGLTextureType[type], 0);
+ }
stop_glerror();
}
}
@@ -474,6 +485,11 @@ void LLTexUnit::setTextureFilteringOption(LLTexUnit::eTextureFilterOptions optio
void LLTexUnit::setTextureBlendType(eTextureBlendType type)
{
+ if (LLGLSLShader::sNoFixedFunction)
+ { //texture blend type means nothing when using shaders
+ return;
+ }
+
if (mIndex < 0) return;
// Do nothing if it's already correctly set.
@@ -594,6 +610,11 @@ GLint LLTexUnit::getTextureSourceType(eTextureBlendSrc src, bool isAlpha)
void LLTexUnit::setTextureCombiner(eTextureBlendOp op, eTextureBlendSrc src1, eTextureBlendSrc src2, bool isAlpha)
{
+ if (LLGLSLShader::sNoFixedFunction)
+ { //register combiners do nothing when not using fixed function
+ return;
+ }
+
if (mIndex < 0) return;
activate();
@@ -906,13 +927,7 @@ LLRender::LLRender()
mMode(LLRender::TRIANGLES),
mCurrTextureUnitIndex(0),
mMaxAnisotropy(0.f)
-{
- mBuffer = new LLVertexBuffer(immediate_mask, 0);
- mBuffer->allocateBuffer(4096, 0, TRUE);
- mBuffer->getVertexStrider(mVerticesp);
- mBuffer->getTexCoord0Strider(mTexcoordsp);
- mBuffer->getColorStrider(mColorsp);
-
+{
mTexUnits.reserve(LL_NUM_TEXTURE_LAYERS);
for (U32 i = 0; i < LL_NUM_TEXTURE_LAYERS; i++)
{
@@ -943,6 +958,17 @@ LLRender::~LLRender()
shutdown();
}
+void LLRender::init()
+{
+ llassert_always(mBuffer.isNull()) ;
+
+ mBuffer = new LLVertexBuffer(immediate_mask, 0);
+ mBuffer->allocateBuffer(4096, 0, TRUE);
+ mBuffer->getVertexStrider(mVerticesp);
+ mBuffer->getTexCoord0Strider(mTexcoordsp);
+ mBuffer->getColorStrider(mColorsp);
+}
+
void LLRender::shutdown()
{
for (U32 i = 0; i < mTexUnits.size(); i++)
@@ -958,6 +984,7 @@ void LLRender::shutdown()
delete mLightState[i];
}
mLightState.clear();
+ mBuffer = NULL ;
}
void LLRender::refreshState(void)
@@ -1147,6 +1174,11 @@ void LLRender::setAlphaRejectSettings(eCompareFunc func, F32 value)
{
flush();
+ if (LLGLSLShader::sNoFixedFunction)
+ { //glAlphaFunc is deprecated in OpenGL 3.3
+ return;
+ }
+
if (mCurrAlphaFunc != func ||
mCurrAlphaFuncVal != value)
{
@@ -1161,6 +1193,30 @@ void LLRender::setAlphaRejectSettings(eCompareFunc func, F32 value)
glAlphaFunc(sGLCompareFunc[func], value);
}
}
+
+ if (gDebugGL)
+ { //make sure cached state is correct
+ GLint cur_func = 0;
+ glGetIntegerv(GL_ALPHA_TEST_FUNC, &cur_func);
+
+ if (func == CF_DEFAULT)
+ {
+ func = CF_GREATER;
+ }
+
+ if (cur_func != sGLCompareFunc[func])
+ {
+ llerrs << "Alpha test function corrupted!" << llendl;
+ }
+
+ F32 ref = 0.f;
+ glGetFloatv(GL_ALPHA_TEST_REF, &ref);
+
+ if (ref != value)
+ {
+ llerrs << "Alpha test value corrupted!" << llendl;
+ }
+ }
}
void LLRender::blendFunc(eBlendFactor sfactor, eBlendFactor dfactor)