From Farshid Lashkari, Added GLBeginEndAdapter::reset(), and _overallNormalAssigned, _overallColorAssigned flags to avoid the GLBeginEndAdapter adapter setting colour and normals when none has been assigned.
This commit is contained in:
parent
d511288718
commit
01c7d87b1a
@ -70,6 +70,7 @@ class OSG_EXPORT GLBeginEndAdapter
|
|||||||
|
|
||||||
void Color4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
|
void Color4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
|
||||||
{
|
{
|
||||||
|
_overallColorAssigned = true;
|
||||||
_colorAssigned = true;
|
_colorAssigned = true;
|
||||||
_color.set(red,green,blue,alpha);
|
_color.set(red,green,blue,alpha);
|
||||||
}
|
}
|
||||||
@ -80,6 +81,7 @@ class OSG_EXPORT GLBeginEndAdapter
|
|||||||
|
|
||||||
void Normal3f(GLfloat x, GLfloat y, GLfloat z)
|
void Normal3f(GLfloat x, GLfloat y, GLfloat z)
|
||||||
{
|
{
|
||||||
|
_overallNormalAssigned = true;
|
||||||
_normalAssigned = true;
|
_normalAssigned = true;
|
||||||
_normal.set(x,y,z);
|
_normal.set(x,y,z);
|
||||||
}
|
}
|
||||||
@ -125,6 +127,8 @@ class OSG_EXPORT GLBeginEndAdapter
|
|||||||
void Begin(GLenum mode);
|
void Begin(GLenum mode);
|
||||||
void End();
|
void End();
|
||||||
|
|
||||||
|
void reset();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
State* _state;
|
State* _state;
|
||||||
@ -140,6 +144,8 @@ class OSG_EXPORT GLBeginEndAdapter
|
|||||||
bool _colorAssigned;
|
bool _colorAssigned;
|
||||||
osg::Vec4f _color;
|
osg::Vec4f _color;
|
||||||
|
|
||||||
|
bool _overallNormalAssigned;
|
||||||
|
bool _overallColorAssigned;
|
||||||
osg::Vec3f _overallNormal;
|
osg::Vec3f _overallNormal;
|
||||||
osg::Vec4f _overallColor;
|
osg::Vec4f _overallColor;
|
||||||
|
|
||||||
|
@ -578,7 +578,9 @@ void ArrayDispatchers::reset()
|
|||||||
if (!_initialized) init();
|
if (!_initialized) init();
|
||||||
|
|
||||||
_useVertexAttribAlias = false;
|
_useVertexAttribAlias = false;
|
||||||
_useGLBeginEndAdapter = false;
|
|
||||||
|
_useGLBeginEndAdapter = false;
|
||||||
|
_glBeginEndAdapter->reset();
|
||||||
|
|
||||||
for(ActiveDispatchList::iterator itr = _activeDispatchList.begin();
|
for(ActiveDispatchList::iterator itr = _activeDispatchList.begin();
|
||||||
itr != _activeDispatchList.end();
|
itr != _activeDispatchList.end();
|
||||||
|
@ -25,6 +25,8 @@ GLBeginEndAdapter::GLBeginEndAdapter(State* state):
|
|||||||
_normal(0.0f,0.0f,1.0f),
|
_normal(0.0f,0.0f,1.0f),
|
||||||
_colorAssigned(false),
|
_colorAssigned(false),
|
||||||
_color(1.0f,1.0f,1.0f,1.0f),
|
_color(1.0f,1.0f,1.0f,1.0f),
|
||||||
|
_overallNormalAssigned(false),
|
||||||
|
_overallColorAssigned(false),
|
||||||
_primitiveMode(0)
|
_primitiveMode(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -249,7 +251,7 @@ void GLBeginEndAdapter::End()
|
|||||||
{
|
{
|
||||||
_state->setColorPointer(_colors.get());
|
_state->setColorPointer(_colors.get());
|
||||||
}
|
}
|
||||||
else
|
else if (_overallColorAssigned)
|
||||||
{
|
{
|
||||||
_state->Color(_overallColor.r(), _overallColor.g(), _overallColor.b(), _overallColor.a());
|
_state->Color(_overallColor.r(), _overallColor.g(), _overallColor.b(), _overallColor.a());
|
||||||
}
|
}
|
||||||
@ -258,7 +260,7 @@ void GLBeginEndAdapter::End()
|
|||||||
{
|
{
|
||||||
_state->setNormalPointer(_normals.get());
|
_state->setNormalPointer(_normals.get());
|
||||||
}
|
}
|
||||||
else
|
else if (_overallNormalAssigned)
|
||||||
{
|
{
|
||||||
_state->Normal(_overallNormal.x(), _overallNormal.y(), _overallNormal.z());
|
_state->Normal(_overallNormal.x(), _overallNormal.y(), _overallNormal.z());
|
||||||
}
|
}
|
||||||
@ -296,3 +298,9 @@ void GLBeginEndAdapter::End()
|
|||||||
else if (_primitiveMode==GL_POLYGON) glDrawArrays(GL_TRIANGLE_FAN, 0, _vertices->size());
|
else if (_primitiveMode==GL_POLYGON) glDrawArrays(GL_TRIANGLE_FAN, 0, _vertices->size());
|
||||||
else glDrawArrays(_primitiveMode, 0, _vertices->size());
|
else glDrawArrays(_primitiveMode, 0, _vertices->size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLBeginEndAdapter::reset()
|
||||||
|
{
|
||||||
|
_overallNormalAssigned = false;
|
||||||
|
_overallColorAssigned = false;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user