Commit c9c4eee8 authored by Christopher Tenter's avatar Christopher Tenter
Browse files

Added glDepthRange lock.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@12591 383ad7c9-94d9-4d36-a494-682f7c89f535
parent f4d93d58
......@@ -73,6 +73,7 @@ const float GLState::default_shininess(100.0);
//-----------------------------------------------------------------------------
bool GLState::depthFuncLock_ = false;
bool GLState::depthRangeLock_ = false;
bool GLState::blendFuncLock_ = false;
bool GLState::blendEquationLock_ = false;
bool GLState::blendColorLock_ = false;
......@@ -1321,6 +1322,8 @@ void GLState::syncFromGL()
glGetIntegerv(GL_DEPTH_FUNC, &getparam);
stateStack_.back().depthFunc_ = getparam;
glGetDoublev(GL_DEPTH_RANGE, stateStack_.back().depthRange_);
// bound buffers
GLenum bufGets[8] = {
......@@ -1653,6 +1656,28 @@ void GLState::cullFace(GLenum _mode)
}
}
void GLState::depthRange(GLclampd _zNear, GLclampd _zFar)
{
if (!depthRangeLock_)
{
#ifdef GLSTATE_AVOID_REDUNDANT_GLCALLS
if (abs(_zNear - stateStack_.back().depthRange_[0]) > 1e-6 ||
abs(_zFar - stateStack_.back().depthRange_[1]) > 1e-6)
#endif
{
glDepthRange(_zNear, _zFar);
stateStack_.back().depthRange_[0] = _zNear;
stateStack_.back().depthRange_[1] = _zFar;
}
}
}
void GLState::getDepthRange(GLclampd* _zNearOut, GLclampd* _zFarOut)
{
if (_zNearOut) *_zNearOut = stateStack_.back().depthRange_[0];
if (_zFarOut) *_zFarOut = stateStack_.back().depthRange_[1];
}
//-----------------------------------------------------------------------------
int GLState::getBufferTargetIndex(GLenum _target)
......@@ -2009,6 +2034,8 @@ void GLState::popAttrib()
depthFunc(p->depthFunc_);
depthRange(p->depthRange_[0], p->depthRange_[1]);
bindBuffer(GL_ARRAY_BUFFER, p->glBufferTargetState_[0]);
bindBuffer(GL_ELEMENT_ARRAY_BUFFER, p->glBufferTargetState_[1]);
bindBuffer(GL_PIXEL_PACK_BUFFER, p->glBufferTargetState_[2]);
......
......@@ -164,6 +164,10 @@ public:
// current cull face mode: GL_FRONT, GL_FRONT_AND_BACK
GLenum cullFace_;
// current depth range: zNear and zFar
GLclampd depthRange_[2];
// vertex pointers, used in glVertexPointer, glTexcoordPointer..
struct GLVertexPointer
{
......@@ -362,6 +366,17 @@ public:
static void unlockCullFace() {cullFaceLock_ = false;}
/// get cull face locking state
static bool isCullFaceLocked() {return cullFaceLock_;}
/// replaces glDepthRange, supports locking
static void depthRange(GLclampd _zNear, GLclampd _zFar);
/// get current depth range
static void getDepthRange(GLclampd* _zNearOut, GLclampd* _zFarOut);
/// lock depth range
static void lockDepthRange() {depthRangeLock_ = true;}
/// unlock depth range
static void unlockDepthRange() {depthRangeLock_ = false;}
/// get depth range locking state
static bool isDepthRangeLocked() {return depthRangeLock_;}
/** @} */
......@@ -1118,6 +1133,8 @@ private: //--------------------------------------------------------------------
static bool blendColorLock_;
static bool alphaFuncLock_;
static bool depthRangeLock_;
// 4 buffer targets:
// GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER, GL_PIXEL_PACK_BUFFER, GL_PIXEL_UNPACK_BUFFER
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment