Skip to content
Snippets Groups Projects
llgl.cpp 66.9 KiB
Newer Older
	{
		gGL.flush();
		glDepthFunc(mPrevDepthFunc);
		sDepthFunc = mPrevDepthFunc;
	}
	if (sWriteEnabled != mPrevWriteEnabled )
	{
		gGL.flush();
		glDepthMask(mPrevWriteEnabled);
		sWriteEnabled = mPrevWriteEnabled;
	}
}

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;
			}
		}
	}
}

LLGLClampToFarClip::LLGLClampToFarClip(glh::matrix4f P)
{
	for (U32 i = 0; i < 4; i++)
	{
		P.element(2, i) = P.element(3, i) * 0.99999f;
	}

	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glLoadMatrixf(P.m);
	glMatrixMode(GL_MODELVIEW);
}

LLGLClampToFarClip::~LLGLClampToFarClip()
{
	glMatrixMode(GL_PROJECTION);
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);
}