Commit ad41a2be authored by Jan Möbius's avatar Jan Möbius
Browse files

Max: Fixed client states which were not reset by the VolumeMeshNode

This fixes a strange OpenGL out of memory error.

closes #1881



git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@17847 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 72fc8bd3
...@@ -607,6 +607,11 @@ void VolumeMeshNodeT<VolumeMeshT>::draw(GLState& _state, const DrawModes::DrawMo ...@@ -607,6 +607,11 @@ void VolumeMeshNodeT<VolumeMeshT>::draw(GLState& _state, const DrawModes::DrawMo
GLboolean lightModel = _state.twosided_lighting(); GLboolean lightModel = _state.twosided_lighting();
_state.set_twosided_lighting(false); _state.set_twosided_lighting(false);
bool clientStateEnabledVertexArray = GLState::isClientStateEnabled(GL_VERTEX_ARRAY);
bool clientStateEnabledColorArray = GLState::isClientStateEnabled(GL_COLOR_ARRAY);
bool clientStateEnabledNormalArray = GLState::isClientStateEnabled(GL_NORMAL_ARRAY);
bool clientStateEnabledTexCoordArray = GLState::isClientStateEnabled(GL_TEXTURE_COORD_ARRAY);
DrawModes::DrawMode cellDrawMode = drawModes_.getFirstCellDrawMode(_drawMode); DrawModes::DrawMode cellDrawMode = drawModes_.getFirstCellDrawMode(_drawMode);
DrawModes::DrawMode faceDrawMode = drawModes_.getFirstFaceDrawMode(_drawMode); DrawModes::DrawMode faceDrawMode = drawModes_.getFirstFaceDrawMode(_drawMode);
DrawModes::DrawMode edgeDrawMode = drawModes_.getFirstEdgeDrawMode(_drawMode); DrawModes::DrawMode edgeDrawMode = drawModes_.getFirstEdgeDrawMode(_drawMode);
...@@ -687,6 +692,27 @@ void VolumeMeshNodeT<VolumeMeshT>::draw(GLState& _state, const DrawModes::DrawMo ...@@ -687,6 +692,27 @@ void VolumeMeshNodeT<VolumeMeshT>::draw(GLState& _state, const DrawModes::DrawMo
_state.set_color(oldColor); _state.set_color(oldColor);
_state.set_twosided_lighting(lightModel); _state.set_twosided_lighting(lightModel);
if (clientStateEnabledVertexArray)
GLState::enableClientState(GL_VERTEX_ARRAY);
else
GLState::disableClientState(GL_VERTEX_ARRAY);
if (clientStateEnabledColorArray)
GLState::enableClientState(GL_COLOR_ARRAY);
else
GLState::disableClientState(GL_COLOR_ARRAY);
if (clientStateEnabledNormalArray)
GLState::enableClientState(GL_NORMAL_ARRAY);
else
GLState::disableClientState(GL_NORMAL_ARRAY);
if (clientStateEnabledTexCoordArray)
GLState::enableClientState(GL_TEXTURE_COORD_ARRAY);
else
GLState::disableClientState(GL_TEXTURE_COORD_ARRAY);
} }
...@@ -1038,6 +1064,12 @@ void VolumeMeshNodeT<VolumeMeshT>::getRenderObjects(IRenderer* _renderer, GLStat ...@@ -1038,6 +1064,12 @@ void VolumeMeshNodeT<VolumeMeshT>::getRenderObjects(IRenderer* _renderer, GLStat
template<class VolumeMeshT> template<class VolumeMeshT>
void VolumeMeshNodeT<VolumeMeshT>::pick(GLState& _state, PickTarget _target) { void VolumeMeshNodeT<VolumeMeshT>::pick(GLState& _state, PickTarget _target) {
// save state
bool clientStateEnabledVertexArray = GLState::isClientStateEnabled(GL_VERTEX_ARRAY);
bool clientStateEnabledColorArray = GLState::isClientStateEnabled(GL_COLOR_ARRAY);
bool clientStateEnabledNormalArray = GLState::isClientStateEnabled(GL_NORMAL_ARRAY);
bool clientStateEnabledTexCoordArray = GLState::isClientStateEnabled(GL_TEXTURE_COORD_ARRAY);
GLState::depthRange(0.01, 1.0); GLState::depthRange(0.01, 1.0);
if (lastCellDrawMode_) if (lastCellDrawMode_)
{ {
...@@ -1137,6 +1169,27 @@ void VolumeMeshNodeT<VolumeMeshT>::pick(GLState& _state, PickTarget _target) { ...@@ -1137,6 +1169,27 @@ void VolumeMeshNodeT<VolumeMeshT>::pick(GLState& _state, PickTarget _target) {
lastPickTarget_ = _target; lastPickTarget_ = _target;
// restore state
if (clientStateEnabledVertexArray)
GLState::enableClientState(GL_VERTEX_ARRAY);
else
GLState::disableClientState(GL_VERTEX_ARRAY);
if (clientStateEnabledColorArray)
GLState::enableClientState(GL_COLOR_ARRAY);
else
GLState::disableClientState(GL_COLOR_ARRAY);
if (clientStateEnabledNormalArray)
GLState::enableClientState(GL_NORMAL_ARRAY);
else
GLState::disableClientState(GL_NORMAL_ARRAY);
if (clientStateEnabledTexCoordArray)
GLState::enableClientState(GL_TEXTURE_COORD_ARRAY);
else
GLState::disableClientState(GL_TEXTURE_COORD_ARRAY);
} }
template<class VolumeMeshT> template<class VolumeMeshT>
......
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