Newer
Older
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
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
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
for( ; i < len; i++ )
{
if( '.' == version[i] )
{
break;
}
}
std::string major_str = ver_copy.substr(start,i-start);
LLStringUtil::convertToS32(major_str, *major);
if( '.' == version[i] )
{
i++;
}
// Find the minor version
start = i;
for( ; i < len; i++ )
{
if( ('.' == version[i]) || isspace(version[i]) )
{
break;
}
}
std::string minor_str = ver_copy.substr(start,i-start);
LLStringUtil::convertToS32(minor_str, *minor);
// Find the release number (optional)
if( '.' == version[i] )
{
i++;
start = i;
for( ; i < len; i++ )
{
if( isspace(version[i]) )
{
break;
}
}
std::string release_str = ver_copy.substr(start,i-start);
LLStringUtil::convertToS32(release_str, *release);
}
// Skip over any white space
while( version[i] && isspace( version[i] ) )
{
i++;
}
// Copy the vendor-specific string (optional)
if( version[i] )
{
vendor_specific->assign( version + i );
}
}
LLGLUserClipPlane::LLGLUserClipPlane(const LLPlane& p, const glh::matrix4f& modelview, const glh::matrix4f& projection, bool apply)
mApply = apply;
if (mApply)
{
mModelview = modelview;
mProjection = projection;
setPlane(p[0], p[1], p[2], p[3]);
}
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
}
void LLGLUserClipPlane::setPlane(F32 a, F32 b, F32 c, F32 d)
{
glh::matrix4f& P = mProjection;
glh::matrix4f& M = mModelview;
glh::matrix4f invtrans_MVP = (P * M).inverse().transpose();
glh::vec4f oplane(a,b,c,d);
glh::vec4f cplane;
invtrans_MVP.mult_matrix_vec(oplane, cplane);
cplane /= fabs(cplane[2]); // normalize such that depth is not scaled
cplane[3] -= 1;
if(cplane[2] < 0)
cplane *= -1;
glh::matrix4f suffix;
suffix.set_row(2, cplane);
glh::matrix4f newP = suffix * P;
gGL.matrixMode(LLRender::MM_PROJECTION);
gGL.pushMatrix();
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);
}
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
}
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;
}
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
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();
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
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;
}
}
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
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);