Newer
Older
void rotate_quat(LLQuaternion& rotation)
{
F32 angle_radians, x, y, z;
rotation.getAngleAxis(&angle_radians, &x, &y, &z);
gGL.rotatef(angle_radians * RAD_TO_DEG, x, y, z);
}
void flush_glerror()
{
glGetError();
}
Xiaohong Bao
committed
//this function outputs gl error to the log file, does not crash the code.
void log_glerror()
{
if (LL_UNLIKELY(!gGLManager.mInited))
{
return ;
}
// Create or update texture to be used with this data
Xiaohong Bao
committed
while (LL_UNLIKELY(error))
{
GLubyte const * gl_error_msg = gluErrorString(error);
if (NULL != gl_error_msg)
{
LL_WARNS() << "GL Error: " << error << " GL Error String: " << gl_error_msg << LL_ENDL ;
Xiaohong Bao
committed
}
else
{
// gluErrorString returns NULL for some extensions' error codes.
// you'll probably have to grep for the number in glext.h.
LL_WARNS() << "GL Error: UNKNOWN 0x" << std::hex << error << std::dec << LL_ENDL;
Xiaohong Bao
committed
}
error = glGetError();
}
}
{
// Create or update texture to be used with this data
{
quit = TRUE;
GLubyte const * gl_error_msg = gluErrorString(error);
if (NULL != gl_error_msg)
{
LL_WARNS("RenderState") << "GL Error:" << error<< LL_ENDL;
LL_WARNS("RenderState") << "GL Error String:" << gl_error_msg << LL_ENDL;
if (gDebugSession)
{
gFailLog << "GL Error:" << gl_error_msg << std::endl;
}
}
else
{
// gluErrorString returns NULL for some extensions' error codes.
// you'll probably have to grep for the number in glext.h.
LL_WARNS("RenderState") << "GL Error: UNKNOWN 0x" << std::hex << error << std::dec << LL_ENDL;
if (gDebugSession)
{
gFailLog << "GL Error: UNKNOWN 0x" << std::hex << error << std::dec << std::endl;
}
}
error = glGetError();
}
if (quit)
{
if (gDebugSession)
{
ll_fail("assert_glerror failed");
}
else
{
LL_ERRS() << "One or more unhandled GL errors." << LL_ENDL;
//LL_WARNS() << "GL used while not active!" << LL_ENDL;
if (gDebugSession)
{
//ll_fail("GL used while not active");
}
}
if (!gDebugGL)
{
//funny looking if for branch prediction -- gDebugGL is almost always false and assert_glerror is called often
}
else
{
do_assert_glerror();
}
}
glGetError();
Don Kjer
committed
glGetError();
}
///////////////////////////////////////////////////////////////
//
// LLGLState
//
// Static members
absl::flat_hash_map<LLGLenum, LLGLboolean> LLGLState::sStateMap;
GLboolean LLGLDepthTest::sDepthEnabled = GL_FALSE; // OpenGL default
GLenum LLGLDepthTest::sDepthFunc = GL_LESS; // OpenGL default
GLboolean LLGLDepthTest::sWriteEnabled = GL_TRUE; // OpenGL default
//static
void LLGLState::initClass()
{
sStateMap[GL_DITHER] = GL_TRUE;
// sStateMap[GL_TEXTURE_2D] = GL_TRUE;
//make sure multisample defaults to disabled
sStateMap[GL_MULTISAMPLE] = GL_FALSE;
glDisable(GL_MULTISAMPLE);
}
//static
void LLGLState::restoreGL()
{
sStateMap.clear();
initClass();
}
//static
// Really shouldn't be needed, but seems we sometimes do.
void LLGLState::resetTextureStates()
{
gGL.flush();
GLint maxTextureUnits;
glGetIntegerv(GL_MAX_TEXTURE_UNITS, &maxTextureUnits);
for (S32 j = maxTextureUnits-1; j >=0; j--)
{
gGL.getTexUnit(j)->activate();
j == 0 ? gGL.getTexUnit(j)->enable(LLTexUnit::TT_TEXTURE) : gGL.getTexUnit(j)->disable();
}
}
void LLGLState::dumpStates()
{
LL_INFOS("RenderState") << "GL States:" << LL_ENDL;
for (const auto& state_pair : sStateMap)
LL_INFOS("RenderState") << llformat(" 0x%04x : %s",(S32)state_pair.first, state_pair.second?"TRUE":"FALSE") << LL_ENDL;
void LLGLState::checkStates(const std::string& msg)
{
if (!gDebugGL)
{
return;
}
stop_glerror();
GLint src;
GLint dst;
glGetIntegerv(GL_BLEND_SRC, &src);
glGetIntegerv(GL_BLEND_DST, &dst);
stop_glerror();
BOOL error = FALSE;
if (src != GL_SRC_ALPHA || dst != GL_ONE_MINUS_SRC_ALPHA)
{
if (gDebugSession)
{
gFailLog << "Blend function corrupted: " << std::hex << src << " " << std::hex << dst << " " << msg << std::dec << std::endl;
error = TRUE;
}
else
{
LL_GL_ERRS << "Blend function corrupted: " << std::hex << src << " " << std::hex << dst << " " << msg << std::dec << LL_ENDL;
}
for (auto iter = sStateMap.begin();
iter != sStateMap.end(); ++iter)
{
LLGLenum state = iter->first;
LLGLboolean cur_state = iter->second;
stop_glerror();
LLGLboolean gl_state = glIsEnabled(state);
stop_glerror();
if(cur_state != gl_state)
{
dumpStates();
if (gDebugSession)
{
gFailLog << llformat("LLGLState error. State: 0x%04x",state) << std::endl;
error = TRUE;
}
else
{
LL_GL_ERRS << llformat("LLGLState error. State: 0x%04x",state) << LL_ENDL;
if (error)
{
ll_fail("LLGLState::checkStates failed.");
}
void LLGLState::checkTextureChannels(const std::string& msg)
#if 0
if (!gDebugGL)
{
return;
}
stop_glerror();
stop_glerror();
{
GLint tex_env_mode = 0;
glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &tex_env_mode);
stop_glerror();
if (tex_env_mode != GL_MODULATE)
{
error = TRUE;
LL_WARNS("RenderState") << "GL_TEXTURE_ENV_MODE invalid: " << std::hex << tex_env_mode << std::dec << LL_ENDL;
if (gDebugSession)
{
gFailLog << "GL_TEXTURE_ENV_MODE invalid: " << std::hex << tex_env_mode << std::dec << std::endl;
}
}
}
static const char* label[] =
{
"GL_TEXTURE_2D",
"GL_TEXTURE_COORD_ARRAY",
"GL_TEXTURE_1D",
"GL_TEXTURE_GEN_S",
"GL_TEXTURE_GEN_T",
"GL_TEXTURE_GEN_Q",
"GL_TEXTURE_GEN_R",
David Parks
committed
"GL_TEXTURE_2D_MULTISAMPLE"
};
static GLint value[] =
{
GL_TEXTURE_2D,
GL_TEXTURE_COORD_ARRAY,
GL_TEXTURE_1D,
GL_TEXTURE_GEN_S,
GL_TEXTURE_GEN_T,
GL_TEXTURE_GEN_Q,
GL_TEXTURE_GEN_R,
David Parks
committed
GL_TEXTURE_2D_MULTISAMPLE
glh::matrix4f mat;
glh::matrix4f identity;
identity.identity();
for (GLint i = 1; i < gGLManager.mNumTextureUnits; i++)
{
gGL.getTexUnit(i)->activate();
if (i < gGLManager.mNumTextureUnits)
stop_glerror();
glGetIntegerv(GL_TEXTURE_STACK_DEPTH, &stackDepth);
stop_glerror();
if (stackDepth != 1)
error = TRUE;
LL_WARNS("RenderState") << "Texture matrix stack corrupted." << LL_ENDL;
if (gDebugSession)
{
gFailLog << "Texture matrix stack corrupted." << std::endl;
}
glGetFloatv(GL_TEXTURE_MATRIX, (GLfloat*) mat.m);
stop_glerror();
if (mat != identity)
error = TRUE;
LL_WARNS("RenderState") << "Texture matrix in channel " << i << " corrupt." << LL_ENDL;
if (gDebugSession)
{
gFailLog << "Texture matrix in channel " << i << " corrupt." << std::endl;
}
for (S32 j = (i == 0 ? 1 : 0);
j < 9; j++)
David Parks
committed
{
if (j == 8 && !gGLManager.mHasTextureRectangle ||
j == 9 && !gGLManager.mHasTextureMultisample)
{
continue;
}
David Parks
committed
if (glIsEnabled(value[j]))
{
error = TRUE;
LL_WARNS("RenderState") << "Texture channel " << i << " still has " << label[j] << " enabled." << LL_ENDL;
if (gDebugSession)
{
gFailLog << "Texture channel " << i << " still has " << label[j] << " enabled." << std::endl;
}
}
stop_glerror();
}
glGetFloatv(GL_TEXTURE_MATRIX, mat.m);
stop_glerror();
if (mat != identity)
LL_WARNS("RenderState") << "Texture matrix " << i << " is not identity." << LL_ENDL;
if (gDebugSession)
{
gFailLog << "Texture matrix " << i << " is not identity." << std::endl;
{
GLint tex = 0;
stop_glerror();
glGetIntegerv(GL_TEXTURE_BINDING_2D, &tex);
stop_glerror();
if (tex != 0)
error = TRUE;
LL_WARNS("RenderState") << "Texture channel " << i << " still has texture " << tex << " bound." << LL_ENDL;
if (gDebugSession)
{
gFailLog << "Texture channel " << i << " still has texture " << tex << " bound." << std::endl;
}
David Parks
committed
stop_glerror();
stop_glerror();
if (gDebugSession)
{
ll_fail("LLGLState::checkTextureChannels failed.");
}
else
{
LL_GL_ERRS << "GL texture state corruption detected. " << msg << LL_ENDL;
}
#endif
void LLGLState::checkClientArrays(const std::string& msg, U32 data_mask)
if (!gDebugGL || LLGLSLShader::sNoFixedFunction)
{
return;
}
stop_glerror();
BOOL error = FALSE;
GLint active_texture;
glGetIntegerv(GL_CLIENT_ACTIVE_TEXTURE, &active_texture);
LL_WARNS() << "Client active texture corrupted: " << active_texture << LL_ENDL;
if (gDebugSession)
{
gFailLog << "Client active texture corrupted: " << active_texture << std::endl;
}
/*glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture);
if (active_texture != GL_TEXTURE0)
LL_WARNS() << "Active texture corrupted: " << active_texture << LL_ENDL;
if (gDebugSession)
{
gFailLog << "Active texture corrupted: " << active_texture << std::endl;
}
static const char* label[] =
{
"GL_VERTEX_ARRAY",
"GL_NORMAL_ARRAY",
"GL_COLOR_ARRAY",
"GL_TEXTURE_COORD_ARRAY"
};
static GLint value[] =
{
GL_VERTEX_ARRAY,
GL_NORMAL_ARRAY,
GL_COLOR_ARRAY,
GL_TEXTURE_COORD_ARRAY
};
{ //copied from llvertexbuffer.h
0x0001, //MAP_VERTEX,
0x0002, //MAP_NORMAL,
0x0010, //MAP_COLOR,
0x0004, //MAP_TEXCOORD
};
for (S32 j = 1; j < 4; j++)
{
if (glIsEnabled(value[j]))
{
if (!(mask[j] & data_mask))
{
error = TRUE;
LL_WARNS("RenderState") << "GL still has " << label[j] << " enabled." << LL_ENDL;
if (gDebugSession)
{
gFailLog << "GL still has " << label[j] << " enabled." << std::endl;
}
}
}
else
{
if (mask[j] & data_mask)
{
error = TRUE;
LL_WARNS("RenderState") << "GL does not have " << label[j] << " enabled." << LL_ENDL;
if (gDebugSession)
{
gFailLog << "GL does not have " << label[j] << " enabled." << std::endl;
}
gGL.getTexUnit(1)->activate();
if (glIsEnabled(GL_TEXTURE_COORD_ARRAY))
{
if (!(data_mask & 0x0008))
{
error = TRUE;
LL_WARNS("RenderState") << "GL still has GL_TEXTURE_COORD_ARRAY enabled on channel 1." << LL_ENDL;
if (gDebugSession)
{
gFailLog << "GL still has GL_TEXTURE_COORD_ARRAY enabled on channel 1." << std::endl;
}
}
}
else
{
if (data_mask & 0x0008)
{
error = TRUE;
LL_WARNS("RenderState") << "GL does not have GL_TEXTURE_COORD_ARRAY enabled on channel 1." << LL_ENDL;
if (gDebugSession)
{
gFailLog << "GL does not have GL_TEXTURE_COORD_ARRAY enabled on channel 1." << std::endl;
}
/*if (glIsEnabled(GL_TEXTURE_2D))
{
if (!(data_mask & 0x0008))
{
error = TRUE;
LL_WARNS("RenderState") << "GL still has GL_TEXTURE_2D enabled on channel 1." << LL_ENDL;
if (gDebugSession)
{
gFailLog << "GL still has GL_TEXTURE_2D enabled on channel 1." << std::endl;
}
}
}
else
{
if (data_mask & 0x0008)
{
error = TRUE;
LL_WARNS("RenderState") << "GL does not have GL_TEXTURE_2D enabled on channel 1." << LL_ENDL;
if (gDebugSession)
{
gFailLog << "GL does not have GL_TEXTURE_2D enabled on channel 1." << std::endl;
}
}*/
gGL.getTexUnit(0)->activate();
David Parks
committed
if (gGLManager.mHasVertexShader && LLGLSLShader::sNoFixedFunction)
{ //make sure vertex attribs are all disabled
GLint count;
for (GLint i = 0; i < count; i++)
{
GLint enabled;
glGetVertexAttribiv((GLuint) i, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &enabled);
if (enabled)
{
error = TRUE;
LL_WARNS("RenderState") << "GL still has vertex attrib array " << i << " enabled." << LL_ENDL;
if (gDebugSession)
{
gFailLog << "GL still has vertex attrib array " << i << " enabled." << std::endl;
}
}
}
}
if (gDebugSession)
{
ll_fail("LLGLState::checkClientArrays failed.");
}
else
{
LL_GL_ERRS << "GL client array corruption detected. " << msg << LL_ENDL;
}
}
}
///////////////////////////////////////////////////////////////////////
LLGLState::LLGLState(LLGLenum state, S32 enabled) :
mState(state), mWasEnabled(FALSE), mIsEnabled(FALSE)
{
if (LLGLSLShader::sNoFixedFunction)
David Parks
committed
{ //always ignore state that's deprecated post GL 3.0
switch (state)
{
case GL_ALPHA_TEST:
David Parks
committed
case GL_NORMALIZE:
case GL_TEXTURE_GEN_R:
case GL_TEXTURE_GEN_S:
case GL_TEXTURE_GEN_T:
case GL_TEXTURE_GEN_Q:
case GL_LIGHTING:
case GL_COLOR_MATERIAL:
case GL_FOG:
case GL_LINE_STIPPLE:
case GL_POLYGON_STIPPLE:
David Parks
committed
mState = 0;
break;
}
}
David Parks
committed
if (mState)
{
mWasEnabled = sStateMap[state];
// we can't actually assert on this as queued changes to state are not reflected by glIsEnabled
//llassert(mWasEnabled == glIsEnabled(state));
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
setEnabled(enabled);
stop_glerror();
}
}
void LLGLState::setEnabled(S32 enabled)
{
if (!mState)
{
return;
}
if (enabled == CURRENT_STATE)
{
enabled = sStateMap[mState] == GL_TRUE ? TRUE : FALSE;
}
else if (enabled == TRUE && sStateMap[mState] != GL_TRUE)
{
gGL.flush();
glEnable(mState);
sStateMap[mState] = GL_TRUE;
}
else if (enabled == FALSE && sStateMap[mState] != GL_FALSE)
{
gGL.flush();
glDisable(mState);
sStateMap[mState] = GL_FALSE;
}
mIsEnabled = enabled;
}
LLGLState::~LLGLState()
{
stop_glerror();
if (mState)
{
if (gDebugGL)
{
if (!gDebugSession)
{
llassert_always(sStateMap[mState] == glIsEnabled(mState));
}
else
{
if (sStateMap[mState] != glIsEnabled(mState))
{
ll_fail("GL enabled state does not match expected");
}
}
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
}
if (mIsEnabled != mWasEnabled)
{
gGL.flush();
if (mWasEnabled)
{
glEnable(mState);
sStateMap[mState] = GL_TRUE;
}
else
{
glDisable(mState);
sStateMap[mState] = GL_FALSE;
}
}
}
stop_glerror();
}
////////////////////////////////////////////////////////////////////////////////
void LLGLManager::initGLStates()
{
//gl states moved to classes in llglstates.h
LLGLState::initClass();
}
////////////////////////////////////////////////////////////////////////////////
void parse_gl_version( S32* major, S32* minor, S32* release, std::string* vendor_specific, std::string* version_string )
{
// GL_VERSION returns a null-terminated string with the format:
// <major>.<minor>[.<release>] [<vendor specific>]
const char* version = (const char*) glGetString(GL_VERSION);
*major = 0;
*minor = 0;
*release = 0;
vendor_specific->assign("");
if( !version )
{
return;
}
version_string->assign(version);
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
std::string ver_copy( version );
S32 len = (S32)strlen( version ); /* Flawfinder: ignore */
S32 i = 0;
S32 start;
// Find the major version
start = i;
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 );
}
}
David Parks
committed
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
void parse_glsl_version(S32& major, S32& minor)
{
// GL_SHADING_LANGUAGE_VERSION returns a null-terminated string with the format:
// <major>.<minor>[.<release>] [<vendor specific>]
const char* version = (const char*) glGetString(GL_SHADING_LANGUAGE_VERSION);
major = 0;
minor = 0;
if( !version )
{
return;
}
std::string ver_copy( version );
S32 len = (S32)strlen( version ); /* Flawfinder: ignore */
S32 i = 0;
S32 start;
// Find the major version
start = i;
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);
}
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]);
}
void LLGLUserClipPlane::disable()
{
if (mApply)
{
gGL.matrixMode(LLRender::MM_PROJECTION);
gGL.popMatrix();
gGL.matrixMode(LLRender::MM_MODELVIEW);
}
mApply = false;
}
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()
{
}
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;
}
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
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();
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
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;
}
}
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
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;
}
}
}
}
LLGLSquashToFarClip::LLGLSquashToFarClip()
{
glh::matrix4f proj = get_current_projection();
setProjectionMatrix(proj, 0);
}
LLGLSquashToFarClip::LLGLSquashToFarClip(glh::matrix4f& P, U32 layer)
{
setProjectionMatrix(P, layer);
}
void LLGLSquashToFarClip::setProjectionMatrix(glh::matrix4f& projection, U32 layer)
David Parks
committed
F32 depth = 0.99999f - 0.0001f * layer;
gGL.matrixMode(LLRender::MM_PROJECTION);
gGL.pushMatrix();
gGL.loadMatrix(projection.m);
gGL.matrixMode(last_matrix_mode);
Merov Linden
committed
LLGLSquashToFarClip::~LLGLSquashToFarClip()
gGL.matrixMode(LLRender::MM_PROJECTION);
gGL.popMatrix();