Commit ed4926d6 authored by Henrik Zimmer's avatar Henrik Zimmer
Browse files

Bug fix: LineSegment mode when no colors are specified

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@14562 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 9b1def34
...@@ -121,89 +121,105 @@ draw(GLState& /* _state */ , const DrawModes::DrawMode& _drawMode) ...@@ -121,89 +121,105 @@ draw(GLState& /* _state */ , const DrawModes::DrawMode& _drawMode)
// glBegin(GL_LINE_STRIP); // glBegin(GL_LINE_STRIP);
// first check if (new standard) 4-channel colors are specified if ((line_mode_ == LineSegmentsMode))
if ((line_mode_ == LineSegmentsMode) && (points_.size()/2 == colors4f_.size()) )
{ {
// enable blending of lines // first check if (new standard) 4-channel colors are specified
GLboolean blendb; if( (points_.size()/2 == colors4f_.size()) )
glGetBooleanv( GL_BLEND, &blendb); {
glEnable(GL_BLEND); // enable blending of lines
GLboolean blendb;
glGetBooleanv( GL_BLEND, &blendb);
glEnable(GL_BLEND);
// blend func to blend alpha values of lines
GLint sblendfunc;
GLint dblendfunc;
glGetIntegerv( GL_BLEND_SRC_ALPHA, &sblendfunc );
glGetIntegerv( GL_BLEND_DST_ALPHA, &dblendfunc );
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// blend ontop of prev. drawn mesh
GLboolean depthmaskb;
glGetBooleanv( GL_DEPTH_WRITEMASK, &depthmaskb);
glDepthMask(GL_FALSE);
glBegin(GL_LINES);
ConstPointIter p_it=points_.begin(), p_end=points_.end();
ConstColor4fIter c_it=colors4f_.begin();
Color4f c(1.0f,1.0f,1.0f,1.0f);
if(c_it != colors4f_.end()) {
c = *c_it;
}
// blend func to blend alpha values of lines int cnt = 0;
GLint sblendfunc; for (; p_it!=p_end; ++p_it)
GLint dblendfunc; {
glGetIntegerv( GL_BLEND_SRC_ALPHA, &sblendfunc ); if ((cnt > 0) && (cnt % 2 == 0) && (c_it+1) != colors4f_.end()) {
glGetIntegerv( GL_BLEND_DST_ALPHA, &dblendfunc ); ++c_it;
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); c = *c_it;
}
// blend ontop of prev. drawn mesh glColor(c);
GLboolean depthmaskb; glVertex(*p_it);
glGetBooleanv( GL_DEPTH_WRITEMASK, &depthmaskb);
glDepthMask(GL_FALSE);
glBegin(GL_LINES); ++cnt;
}
ConstPointIter p_it=points_.begin(), p_end=points_.end(); glEnd();
ConstColor4fIter c_it=colors4f_.begin();
// disable blending of lines
if( blendb == GL_FALSE )
glDisable(GL_BLEND);
// reset blend func
glBlendFunc( sblendfunc, dblendfunc );
// enable depth mask
if( depthmaskb == GL_TRUE )
glDepthMask(GL_TRUE);
Color4f c(1.0f,1.0f,1.0f,1.0f);
if(c_it != colors4f_.end()) {
c = *c_it;
} }
else if ((line_mode_ == LineSegmentsMode) && (points_.size()/2 == colors_.size()) )
int cnt = 0;
for (; p_it!=p_end; ++p_it)
{ {
if ((cnt > 0) && (cnt % 2 == 0) && (c_it+1) != colors4f_.end()) { glBegin(GL_LINES);
++c_it; ConstPointIter p_it=points_.begin(), p_end=points_.end();
ConstColorIter c_it=colors_.begin();
Color c((char)255, (char)255, (char)255);
if(c_it != colors_.end()) {
c = *c_it; c = *c_it;
} }
glColor(c);
glVertex(*p_it);
++cnt;
}
glEnd();
// disable blending of lines
if( blendb == GL_FALSE )
glDisable(GL_BLEND);
// reset blend func int cnt = 0;
glBlendFunc( sblendfunc, dblendfunc ); for (; p_it!=p_end; ++p_it)
{
if ((cnt > 0) && (cnt % 2 == 0) && (c_it+1) != colors_.end()) {
++c_it;
c = *c_it;
}
// enable depth mask glColor(c);
if( depthmaskb == GL_TRUE ) glVertex(*p_it);
glDepthMask(GL_TRUE);
} ++cnt;
else if ((line_mode_ == LineSegmentsMode) && (points_.size()/2 == colors_.size()) ) }
{ glEnd();
glBegin(GL_LINES);
ConstPointIter p_it=points_.begin(), p_end=points_.end();
ConstColorIter c_it=colors_.begin();
Color c((char)255, (char)255, (char)255);
if(c_it != colors_.end()) {
c = *c_it;
} }
else
int cnt = 0;
for (; p_it!=p_end; ++p_it)
{ {
if ((cnt > 0) && (cnt % 2 == 0) && (c_it+1) != colors_.end()) { glBegin(GL_LINES);
++c_it;
c = *c_it; ConstPointIter p_it=points_.begin(), p_end=points_.end();
for (; p_it!=p_end; ++p_it)
{
glVertex(*p_it);
} }
glColor(c);
glVertex(*p_it);
++cnt; glEnd();
} }
glEnd();
} }
else else
{ {
......
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