Newer
Older
gGL.loadMatrix(newP.m);
gGLObliqueProjectionInverse = LLMatrix4(newP.inverse().transpose().m);
gGL.matrixMode(LLRender::MM_MODELVIEW);
}
LLGLUserClipPlane::~LLGLUserClipPlane()
{
if (mApply)
{
gGL.matrixMode(LLRender::MM_PROJECTION);
gGL.popMatrix();
gGL.matrixMode(LLRender::MM_MODELVIEW);
}
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
}
LLGLNamePool::LLGLNamePool()
{
}
LLGLNamePool::~LLGLNamePool()
{
}
void LLGLNamePool::upkeep()
{
std::sort(mNameList.begin(), mNameList.end(), CompareUsed());
}
void LLGLNamePool::cleanup()
{
for (name_list_t::iterator iter = mNameList.begin(); iter != mNameList.end(); ++iter)
{
releaseName(iter->name);
}
mNameList.clear();
}
GLuint LLGLNamePool::allocate()
{
for (name_list_t::iterator iter = mNameList.begin(); iter != mNameList.end(); ++iter)
{
if (!iter->used)
{
iter->used = TRUE;
return iter->name;
}
}
NameEntry entry;
entry.name = allocateName();
entry.used = TRUE;
mNameList.push_back(entry);
return entry.name;
#else
return allocateName();
#endif
}
void LLGLNamePool::release(GLuint name)
{
for (name_list_t::iterator iter = mNameList.begin(); iter != mNameList.end(); ++iter)
{
if (iter->name == name)
{
if (iter->used)
{
iter->used = FALSE;
return;
}
else
{
llerrs << "Attempted to release a pooled name that is not in use!" << llendl;
}
llerrs << "Attempted to release a non pooled name!" << llendl;
#else
releaseName(name);
#endif
}
//static
void LLGLNamePool::upkeepPools()
{
LLMemType mt(LLMemType::MTYPE_UPKEEP_POOLS);
Richard Nelson
committed
for (tracker_t::instance_iter iter = beginInstances(); iter != endInstances(); ++iter)
LLGLNamePool & pool = *iter;
pool.upkeep();
}
}
//static
void LLGLNamePool::cleanupPools()
{
Richard Nelson
committed
for (tracker_t::instance_iter iter = beginInstances(); iter != endInstances(); ++iter)
LLGLNamePool & pool = *iter;
pool.cleanup();
}
}
LLGLDepthTest::LLGLDepthTest(GLboolean depth_enabled, GLboolean write_enabled, GLenum depth_func)
: mPrevDepthEnabled(sDepthEnabled), mPrevDepthFunc(sDepthFunc), mPrevWriteEnabled(sWriteEnabled)
{
stop_glerror();
checkState();
if (!depth_enabled)
{ // always disable depth writes if depth testing is disabled
// GL spec defines this as a requirement, but some implementations allow depth writes with testing disabled
// The proper way to write to depth buffer with testing disabled is to enable testing and use a depth_func of GL_ALWAYS
write_enabled = FALSE;
}
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
if (depth_enabled != sDepthEnabled)
{
gGL.flush();
if (depth_enabled) glEnable(GL_DEPTH_TEST);
else glDisable(GL_DEPTH_TEST);
sDepthEnabled = depth_enabled;
}
if (depth_func != sDepthFunc)
{
gGL.flush();
glDepthFunc(depth_func);
sDepthFunc = depth_func;
}
if (write_enabled != sWriteEnabled)
{
gGL.flush();
glDepthMask(write_enabled);
sWriteEnabled = write_enabled;
}
}
LLGLDepthTest::~LLGLDepthTest()
{
checkState();
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
if (sDepthEnabled != mPrevDepthEnabled )
{
gGL.flush();
if (mPrevDepthEnabled) glEnable(GL_DEPTH_TEST);
else glDisable(GL_DEPTH_TEST);
sDepthEnabled = mPrevDepthEnabled;
}
if (sDepthFunc != mPrevDepthFunc)
{
gGL.flush();
glDepthFunc(mPrevDepthFunc);
sDepthFunc = mPrevDepthFunc;
}
if (sWriteEnabled != mPrevWriteEnabled )
{
gGL.flush();
glDepthMask(mPrevWriteEnabled);
sWriteEnabled = mPrevWriteEnabled;
}
}
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
void LLGLDepthTest::checkState()
{
if (gDebugGL)
{
GLint func = 0;
GLboolean mask = FALSE;
glGetIntegerv(GL_DEPTH_FUNC, &func);
glGetBooleanv(GL_DEPTH_WRITEMASK, &mask);
if (glIsEnabled(GL_DEPTH_TEST) != sDepthEnabled ||
sWriteEnabled != mask ||
sDepthFunc != func)
{
if (gDebugSession)
{
gFailLog << "Unexpected depth testing state." << std::endl;
}
else
{
LL_GL_ERRS << "Unexpected depth testing state." << LL_ENDL;
}
}
}
}
David Parks
committed
LLGLSquashToFarClip::LLGLSquashToFarClip(glh::matrix4f P, U32 layer)
David Parks
committed
F32 depth = 0.99999f - 0.0001f * layer;
David Parks
committed
P.element(2, i) = P.element(3, i) * depth;
gGL.matrixMode(LLRender::MM_PROJECTION);
gGL.pushMatrix();
gGL.loadMatrix(P.m);
gGL.matrixMode(LLRender::MM_MODELVIEW);
Merov Linden
committed
LLGLSquashToFarClip::~LLGLSquashToFarClip()
gGL.matrixMode(LLRender::MM_PROJECTION);
gGL.popMatrix();
gGL.matrixMode(LLRender::MM_MODELVIEW);