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,33 +559,35 @@ void Constraint::DrawOrGetDistance(Vector *labelPos) {
break;
}
// Let's adjust the color of this constraint to have the same
// rough luma as the point color, so that the constraint does not
// stand out in an ugly way.
RgbColor cd = Style::Color(Style::DATUM),
cc = Style::Color(Style::CONSTRAINT);
// convert from 8-bit color to a vector
Vector vd = Vector::From(cd.redF(), cd.greenF(), cd.blueF()),
vc = Vector::From(cc.redF(), cc.greenF(), cc.blueF());
// and scale the constraint color to have the same magnitude as
// the datum color, maybe a bit dimmer
vc = vc.WithMagnitude(vd.Magnitude()*0.9);
// and set the color to that.
ssglColorRGB(RGBf(vc.x, vc.y, vc.z));
if(dogd.drawing) {
// Let's adjust the color of this constraint to have the same
// rough luma as the point color, so that the constraint does not
// stand out in an ugly way.
RgbColor cd = Style::Color(Style::DATUM),
cc = Style::Color(Style::CONSTRAINT);
// convert from 8-bit color to a vector
Vector vd = Vector::From(cd.redF(), cd.greenF(), cd.blueF()),
vc = Vector::From(cc.redF(), cc.greenF(), cc.blueF());
// and scale the constraint color to have the same magnitude as
// the datum color, maybe a bit dimmer
vc = vc.WithMagnitude(vd.Magnitude()*0.9);
// and set the color to that.
ssglColorRGB(RGBf(vc.x, vc.y, vc.z));
for(int a = 0; a < 2; a++) {
Vector r = SS.GW.projRight.ScaledBy((a+1)/SS.GW.scale);
Vector d = SS.GW.projUp.ScaledBy((2-a)/SS.GW.scale);
for(int i = 0; i < 2; i++) {
Vector p = SK.GetEntity(i == 0 ? ptA : ptB)-> PointGetNum();
glBegin(GL_QUADS);
ssglVertex3v(p.Plus (r).Plus (d));
ssglVertex3v(p.Plus (r).Minus(d));
ssglVertex3v(p.Minus(r).Minus(d));
ssglVertex3v(p.Minus(r).Plus (d));
glEnd();
}
for(int a = 0; a < 2; a++) {
Vector r = SS.GW.projRight.ScaledBy((a+1)/SS.GW.scale);
Vector d = SS.GW.projUp.ScaledBy((2-a)/SS.GW.scale);
for(int i = 0; i < 2; i++) {
Vector p = SK.GetEntity(i == 0 ? ptA : ptB)-> PointGetNum();
glBegin(GL_QUADS);
ssglVertex3v(p.Plus (r).Plus (d));
ssglVertex3v(p.Plus (r).Minus(d));
ssglVertex3v(p.Minus(r).Minus(d));
ssglVertex3v(p.Minus(r).Plus (d));
glEnd();
}
}
break;
}
@ -1029,7 +1031,7 @@ s:
break;
case COMMENT: {
if(disp.style.v) {
if(dogd.drawing && disp.style.v) {
ssglLineWidth(Style::Width(disp.style));
ssglColorRGB(Style::Color(disp.style));
}

View File

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

View File

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