Make sure all DrawOrGetDistance style code only draws in Paint();

Otherwise, GL reports errors when used with FBOs, as well as
creates visual artifacts, especially when UI is also drawn
with OpenGL.
pull/3/head
whitequark 2015-03-26 03:34:28 +03:00
parent 4b86fb89f8
commit bbe4999033
3 changed files with 60 additions and 43 deletions

View File

@ -559,6 +559,7 @@ void Constraint::DrawOrGetDistance(Vector *labelPos) {
break; break;
} }
if(dogd.drawing) {
// Let's adjust the color of this constraint to have the same // Let's adjust the color of this constraint to have the same
// rough luma as the point color, so that the constraint does not // rough luma as the point color, so that the constraint does not
// stand out in an ugly way. // stand out in an ugly way.
@ -587,6 +588,7 @@ void Constraint::DrawOrGetDistance(Vector *labelPos) {
} }
} }
}
break; break;
} }
@ -1029,7 +1031,7 @@ s:
break; break;
case COMMENT: { case COMMENT: {
if(disp.style.v) { if(dogd.drawing && disp.style.v) {
ssglLineWidth(Style::Width(disp.style)); ssglLineWidth(Style::Width(disp.style));
ssglColorRGB(Style::Color(disp.style)); ssglColorRGB(Style::Color(disp.style));
} }

View File

@ -520,12 +520,16 @@ void Entity::DrawOrGetDistance(void) {
// dimmer for the ones at the model origin. // dimmer for the ones at the model origin.
int f = (i == 0 ? 100 : 255); int f = (i == 0 ? 100 : 255);
if(hr.v == Request::HREQUEST_REFERENCE_XY.v) { if(hr.v == Request::HREQUEST_REFERENCE_XY.v) {
if(dogd.drawing)
ssglColorRGB(RGBi(0, 0, f)); ssglColorRGB(RGBi(0, 0, f));
} else if(hr.v == Request::HREQUEST_REFERENCE_YZ.v) { } else if(hr.v == Request::HREQUEST_REFERENCE_YZ.v) {
if(dogd.drawing)
ssglColorRGB(RGBi(f, 0, 0)); ssglColorRGB(RGBi(f, 0, 0));
} else if(hr.v == Request::HREQUEST_REFERENCE_ZX.v) { } else if(hr.v == Request::HREQUEST_REFERENCE_ZX.v) {
if(dogd.drawing)
ssglColorRGB(RGBi(0, f, 0)); ssglColorRGB(RGBi(0, f, 0));
} else { } else {
if(dogd.drawing)
ssglColorRGB(Style::Color(Style::NORMALS)); ssglColorRGB(Style::Color(Style::NORMALS));
if(i > 0) break; if(i > 0) break;
} }
@ -534,6 +538,7 @@ void Entity::DrawOrGetDistance(void) {
Vector tail; Vector tail;
if(i == 0) { if(i == 0) {
tail = SK.GetEntity(point[0])->PointGetNum(); tail = SK.GetEntity(point[0])->PointGetNum();
if(dogd.drawing)
ssglLineWidth(1); ssglLineWidth(1);
} else { } else {
// Draw an extra copy of the x, y, and z axes, that's // Draw an extra copy of the x, y, and z axes, that's
@ -544,9 +549,11 @@ void Entity::DrawOrGetDistance(void) {
double w = 60 - SS.GW.width/2; double w = 60 - SS.GW.width/2;
tail = SS.GW.projRight.ScaledBy(w/s).Plus( tail = SS.GW.projRight.ScaledBy(w/s).Plus(
SS.GW.projUp. ScaledBy(h/s)).Minus(SS.GW.offset); SS.GW.projUp. ScaledBy(h/s)).Minus(SS.GW.offset);
if(dogd.drawing) {
ssglDepthRangeLockToFront(true); ssglDepthRangeLockToFront(true);
ssglLineWidth(2); ssglLineWidth(2);
} }
}
Vector v = (q.RotationN()).WithMagnitude(50/SS.GW.scale); Vector v = (q.RotationN()).WithMagnitude(50/SS.GW.scale);
Vector tip = tail.Plus(v); Vector tip = tail.Plus(v);
@ -557,6 +564,7 @@ void Entity::DrawOrGetDistance(void) {
LineDrawOrGetDistance(tip,tip.Minus(v.RotatedAbout(axis, 0.6))); LineDrawOrGetDistance(tip,tip.Minus(v.RotatedAbout(axis, 0.6)));
LineDrawOrGetDistance(tip,tip.Minus(v.RotatedAbout(axis,-0.6))); LineDrawOrGetDistance(tip,tip.Minus(v.RotatedAbout(axis,-0.6)));
} }
if(dogd.drawing)
ssglDepthRangeLockToFront(false); ssglDepthRangeLockToFront(false);
break; break;
} }
@ -583,10 +591,13 @@ void Entity::DrawOrGetDistance(void) {
Vector mm = p.Minus(us).Minus(vs), mm2 = mm; Vector mm = p.Minus(us).Minus(vs), mm2 = mm;
Vector mp = p.Minus(us).Plus (vs); Vector mp = p.Minus(us).Plus (vs);
if(dogd.drawing) {
ssglLineWidth(1); ssglLineWidth(1);
ssglColorRGB(Style::Color(Style::NORMALS)); ssglColorRGB(Style::Color(Style::NORMALS));
glEnable(GL_LINE_STIPPLE); glEnable(GL_LINE_STIPPLE);
glLineStipple(3, 0x1111); glLineStipple(3, 0x1111);
}
if(!h.isFromRequest()) { if(!h.isFromRequest()) {
mm = mm.Plus(v.ScaledBy(60/SS.GW.scale)); mm = mm.Plus(v.ScaledBy(60/SS.GW.scale));
mm2 = mm2.Plus(u.ScaledBy(60/SS.GW.scale)); mm2 = mm2.Plus(u.ScaledBy(60/SS.GW.scale));
@ -596,6 +607,8 @@ void Entity::DrawOrGetDistance(void) {
LineDrawOrGetDistance(pm, mm2); LineDrawOrGetDistance(pm, mm2);
LineDrawOrGetDistance(mm, mp); LineDrawOrGetDistance(mm, mp);
LineDrawOrGetDistance(mp, pp); LineDrawOrGetDistance(mp, pp);
if(dogd.drawing)
glDisable(GL_LINE_STIPPLE); glDisable(GL_LINE_STIPPLE);
char *str = DescriptionString()+5; char *str = DescriptionString()+5;

View File

@ -347,10 +347,12 @@ void TextWindow::DrawOrHitTestIcons(int how, double mx, double my)
int x = 20, y = 33 + LINE_HEIGHT; int x = 20, y = 33 + LINE_HEIGHT;
y -= scrollPos*(LINE_HEIGHT/2); y -= scrollPos*(LINE_HEIGHT/2);
if(how == PAINT) {
double grey = 30.0/255; double grey = 30.0/255;
double top = y - 28, bot = y + 4; double top = y - 28, bot = y + 4;
glColor4d(grey, grey, grey, 1.0); glColor4d(grey, grey, grey, 1.0);
ssglAxisAlignedQuad(0, width, top, bot); ssglAxisAlignedQuad(0, width, top, bot);
}
HideShowIcon *oldHovered = hoveredIcon; HideShowIcon *oldHovered = hoveredIcon;
if(how != PAINT) { if(how != PAINT) {