Commit 4b99a3b0 authored by Marlin Frickenschmidt's avatar Marlin Frickenschmidt
Browse files

Added getter with sanity check for GLState depth function.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@10096 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 8673f47d
......@@ -824,6 +824,27 @@ void GLState::viewing_ray( int _x, int _y,
//-----------------------------------------------------------------------------
const GLenum& GLState::depthFunc() const
{
///\todo Remove this additional check if there are no errors here ever.
GLint prev_depth;
glGetIntegerv (GL_DEPTH_FUNC, &prev_depth);
if (depth_func_ != prev_depth)
std::cerr << "GLState depth_func_ doesn't match actual enabled GL_DEPTH_FUNC!" << std::endl;
return depth_func_;
}
//-----------------------------------------------------------------------------
void GLState:: set_depthFunc(const GLenum& _depth_func)
{
glDepthFunc(_depth_func);
depth_func_ = _depth_func;
}
//-----------------------------------------------------------------------------
void GLState::push_projection_matrix()
{
......
......@@ -315,9 +315,10 @@ public:
*/
void viewing_ray(int _x, int _y, Vec3d& _origin, Vec3d& _direction) const;
/// get and set glDepthFunc() parameter
GLenum& depthFunc() { return depth_func_; }
/// get glDepthFunc() parameter
const GLenum& depthFunc() const;
/// set glDepthFunc() parameter
void set_depthFunc(const GLenum& _depth_func);
//--- project and unproject points ------------------------------------------
......
......@@ -101,7 +101,7 @@ enter(GLState& _state , DrawModes::DrawMode _drawMode)
//set depth function and change GLState accordingly
glDepthFunc(GL_ALWAYS);
_state.depthFunc() = GL_ALWAYS;
_state.set_depthFunc(GL_ALWAYS);
}
}
......@@ -157,7 +157,7 @@ leave(GLState& _state , DrawModes::DrawMode _drawMode)
if (alwaysOnTop()) {
//restore depth function and change GLState accordingly
glDepthFunc(prev_depth_);
_state.depthFunc() = prev_depth_;
_state.set_depthFunc(prev_depth_);
}
MaterialNode::leave(_state, _drawMode);
......
......@@ -222,8 +222,7 @@ draw(GLState& _state, DrawModes::DrawMode _drawMode) {
// Update strips if necessary
stripProcessor_.stripify();
GLint prev_depth;
glGetIntegerv (GL_DEPTH_FUNC, &prev_depth);
GLenum prev_depth = _state.depthFunc();
unsigned int arrays = VERTEX_ARRAY;
......@@ -989,8 +988,7 @@ void
MeshNodeT<Mesh>::
pick_vertices(GLState& _state, bool _front)
{
GLint prev_depth;
glGetIntegerv (GL_DEPTH_FUNC, &prev_depth);
GLenum prev_depth = _state.depthFunc();
typename Mesh::ConstVertexIter v_it(mesh_.vertices_begin()),
v_end(mesh_.vertices_end());
......@@ -1076,8 +1074,7 @@ void
MeshNodeT<Mesh>::
pick_edges(GLState& _state, bool _front)
{
GLint prev_depth;
glGetIntegerv (GL_DEPTH_FUNC, &prev_depth);
GLenum prev_depth = _state.depthFunc();
if (!_state.pick_set_maximum (mesh_.n_edges())) {
omerr() << "MeshNode::pick_edges: color range too small, " << "picking failed\n";
......@@ -1238,8 +1235,7 @@ void
MeshNodeT<Mesh>::
pick_any(GLState& _state)
{
GLint prev_depth;
glGetIntegerv (GL_DEPTH_FUNC, &prev_depth);
GLenum prev_depth = _state.depthFunc();
unsigned int numElements = mesh_.n_faces() + mesh_.n_edges() + mesh_.n_vertices();
......
......@@ -564,8 +564,7 @@ void
MeshNodeT<Mesh>::
draw(GLState& _state, DrawModes::DrawMode _drawMode)
{
GLint prev_depth;
glGetIntegerv (GL_DEPTH_FUNC, &prev_depth);
GLenum prev_depth = _state.depthFunc();
if (_drawMode & DrawModes::POINTS)
{
......@@ -1237,8 +1236,7 @@ void
MeshNodeT<Mesh>::
pick_vertices(GLState& _state, bool _front)
{
GLint prev_depth;
glGetIntegerv (GL_DEPTH_FUNC, &prev_depth);
GLenum prev_depth = _state.depthFunc();
typename Mesh::ConstVertexIter v_it(mesh_.vertices_begin()),
v_end(mesh_.vertices_end());
......@@ -1492,8 +1490,7 @@ pick_edges(GLState& _state, bool _front)
typename Mesh::ConstEdgeIter e_it(mesh_.edges_sbegin()),
e_end(mesh_.edges_end());
GLint prev_depth;
glGetIntegerv (GL_DEPTH_FUNC, &prev_depth);
GLenum prev_depth = _state.depthFunc();
if (!_state.pick_set_maximum (mesh_.n_edges()))
{
......@@ -1594,8 +1591,7 @@ void
MeshNodeT<Mesh>::
pick_any(GLState& _state)
{
GLint prev_depth;
glGetIntegerv (GL_DEPTH_FUNC, &prev_depth);
GLenum prev_depth = _state.depthFunc();
unsigned int numElements = mesh_.n_faces() + mesh_.n_edges() + mesh_.n_vertices();
......
......@@ -208,7 +208,7 @@ update_cache()
template <class Mesh, class Mod>
void
StatusNodeT<Mesh, Mod>::
draw(GLState& /* _state */ , DrawModes::DrawMode _drawMode)
draw(GLState& _state, DrawModes::DrawMode _drawMode)
{
bool shaded = (_drawMode & ( DrawModes::SOLID_FLAT_SHADED |
DrawModes::SOLID_SMOOTH_SHADED |
......@@ -236,8 +236,7 @@ draw(GLState& /* _state */ , DrawModes::DrawMode _drawMode)
(_drawMode & DrawModes::SOLID_FLAT_SHADED));
GLint prev_depth;
glGetIntegerv (GL_DEPTH_FUNC, &prev_depth);
GLenum prev_depth = _state.depthFunc();
glDepthFunc(GL_LEQUAL);
......
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