Renamed GL helper routines/identifiers to use "ssgl" prefix instead of "glx"
The "glx" prefix on the names of SolveSpace's various GL helper routines was confusingly similar to those used by official OpenGL-associated libraries (e.g. "glu" used by the GL Utility library, and "glX" used by GLX), and could thus give the erroneous impression that it represented a system API rather than ordinary application logic. We thus rename these routines to have an "ssgl" prefix, clearly identifying them with SolveSpace while retaining some visual kinship to GL function names.pull/3/head
parent
0afb5618ce
commit
c6203678e1
28
bsp.cpp
28
bsp.cpp
|
@ -432,31 +432,31 @@ void SBsp3::DebugDraw(void) {
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glEnable(GL_LIGHTING);
|
glEnable(GL_LIGHTING);
|
||||||
glBegin(GL_TRIANGLES);
|
glBegin(GL_TRIANGLES);
|
||||||
glxVertex3v(tri.a);
|
ssglVertex3v(tri.a);
|
||||||
glxVertex3v(tri.b);
|
ssglVertex3v(tri.b);
|
||||||
glxVertex3v(tri.c);
|
ssglVertex3v(tri.c);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
glDisable(GL_LIGHTING);
|
glDisable(GL_LIGHTING);
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||||
glxDepthRangeOffset(2);
|
ssglDepthRangeOffset(2);
|
||||||
glBegin(GL_TRIANGLES);
|
glBegin(GL_TRIANGLES);
|
||||||
glxVertex3v(tri.a);
|
ssglVertex3v(tri.a);
|
||||||
glxVertex3v(tri.b);
|
ssglVertex3v(tri.b);
|
||||||
glxVertex3v(tri.c);
|
ssglVertex3v(tri.c);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
glDisable(GL_LIGHTING);
|
glDisable(GL_LIGHTING);
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
|
glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
|
||||||
glPointSize(10);
|
glPointSize(10);
|
||||||
glxDepthRangeOffset(2);
|
ssglDepthRangeOffset(2);
|
||||||
glBegin(GL_TRIANGLES);
|
glBegin(GL_TRIANGLES);
|
||||||
glxVertex3v(tri.a);
|
ssglVertex3v(tri.a);
|
||||||
glxVertex3v(tri.b);
|
ssglVertex3v(tri.b);
|
||||||
glxVertex3v(tri.c);
|
ssglVertex3v(tri.c);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
glxDepthRangeOffset(0);
|
ssglDepthRangeOffset(0);
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
|
|
||||||
more->DebugDraw();
|
more->DebugDraw();
|
||||||
|
@ -669,8 +669,8 @@ void SBsp2::DebugDraw(Vector n, double d) {
|
||||||
|
|
||||||
glLineWidth(10);
|
glLineWidth(10);
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
glxVertex3v(edge.a);
|
ssglVertex3v(edge.a);
|
||||||
glxVertex3v(edge.b);
|
ssglVertex3v(edge.b);
|
||||||
glEnd();
|
glEnd();
|
||||||
pos->DebugDraw(n, d);
|
pos->DebugDraw(n, d);
|
||||||
neg->DebugDraw(n, d);
|
neg->DebugDraw(n, d);
|
||||||
|
|
82
draw.cpp
82
draw.cpp
|
@ -64,8 +64,8 @@ void GraphicsWindow::Selection::Draw(void) {
|
||||||
RgbColor rgb = Style::Color(Style::HOVERED);
|
RgbColor rgb = Style::Color(Style::HOVERED);
|
||||||
glColor4d(rgb.redF(), rgb.greenF(), rgb.blueF(), 0.2);
|
glColor4d(rgb.redF(), rgb.greenF(), rgb.blueF(), 0.2);
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
glxVertex3v(topLeft);
|
ssglVertex3v(topLeft);
|
||||||
glxVertex3v(refp);
|
ssglVertex3v(refp);
|
||||||
glEnd();
|
glEnd();
|
||||||
glLineWidth(1);
|
glLineWidth(1);
|
||||||
}
|
}
|
||||||
|
@ -560,21 +560,21 @@ void GraphicsWindow::Paint(void) {
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glTexCoord2d(0, 0);
|
glTexCoord2d(0, 0);
|
||||||
glxVertex3v(origin);
|
ssglVertex3v(origin);
|
||||||
|
|
||||||
glTexCoord2d(0, th);
|
glTexCoord2d(0, th);
|
||||||
glxVertex3v(origin.Plus(projUp.ScaledBy(mmh)));
|
ssglVertex3v(origin.Plus(projUp.ScaledBy(mmh)));
|
||||||
|
|
||||||
glTexCoord2d(tw, th);
|
glTexCoord2d(tw, th);
|
||||||
glxVertex3v(origin.Plus(projRight.ScaledBy(mmw).Plus(
|
ssglVertex3v(origin.Plus(projRight.ScaledBy(mmw).Plus(
|
||||||
projUp. ScaledBy(mmh))));
|
projUp. ScaledBy(mmh))));
|
||||||
|
|
||||||
glTexCoord2d(tw, 0);
|
glTexCoord2d(tw, 0);
|
||||||
glxVertex3v(origin.Plus(projRight.ScaledBy(mmw)));
|
ssglVertex3v(origin.Plus(projRight.ScaledBy(mmw)));
|
||||||
glEnd();
|
glEnd();
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
}
|
}
|
||||||
glxDepthRangeOffset(0);
|
ssglDepthRangeOffset(0);
|
||||||
|
|
||||||
// Nasty case when we're reloading the imported files; could be that
|
// Nasty case when we're reloading the imported files; could be that
|
||||||
// we get an error, so a dialog pops up, and a message loop starts, and
|
// we get an error, so a dialog pops up, and a message loop starts, and
|
||||||
|
@ -617,7 +617,7 @@ void GraphicsWindow::Paint(void) {
|
||||||
(float)SS.ambientIntensity, 1 };
|
(float)SS.ambientIntensity, 1 };
|
||||||
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient);
|
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient);
|
||||||
|
|
||||||
glxUnlockColor();
|
ssglUnlockColor();
|
||||||
|
|
||||||
if(showSnapGrid && LockedInWorkplane()) {
|
if(showSnapGrid && LockedInWorkplane()) {
|
||||||
hEntity he = ActiveWorkplane();
|
hEntity he = ActiveWorkplane();
|
||||||
|
@ -674,15 +674,15 @@ void GraphicsWindow::Paint(void) {
|
||||||
if(j0 > j1 || j1 - j0 > 400) goto nogrid;
|
if(j0 > j1 || j1 - j0 > 400) goto nogrid;
|
||||||
|
|
||||||
glLineWidth(1);
|
glLineWidth(1);
|
||||||
glxColorRGBa(Style::Color(Style::DATUM), 0.3);
|
ssglColorRGBa(Style::Color(Style::DATUM), 0.3);
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
for(i = i0 + 1; i < i1; i++) {
|
for(i = i0 + 1; i < i1; i++) {
|
||||||
glxVertex3v(wp.Plus(wu.ScaledBy(i*g)).Plus(wv.ScaledBy(j0*g)));
|
ssglVertex3v(wp.Plus(wu.ScaledBy(i*g)).Plus(wv.ScaledBy(j0*g)));
|
||||||
glxVertex3v(wp.Plus(wu.ScaledBy(i*g)).Plus(wv.ScaledBy(j1*g)));
|
ssglVertex3v(wp.Plus(wu.ScaledBy(i*g)).Plus(wv.ScaledBy(j1*g)));
|
||||||
}
|
}
|
||||||
for(j = j0 + 1; j < j1; j++) {
|
for(j = j0 + 1; j < j1; j++) {
|
||||||
glxVertex3v(wp.Plus(wu.ScaledBy(i0*g)).Plus(wv.ScaledBy(j*g)));
|
ssglVertex3v(wp.Plus(wu.ScaledBy(i0*g)).Plus(wv.ScaledBy(j*g)));
|
||||||
glxVertex3v(wp.Plus(wu.ScaledBy(i1*g)).Plus(wv.ScaledBy(j*g)));
|
ssglVertex3v(wp.Plus(wu.ScaledBy(i1*g)).Plus(wv.ScaledBy(j*g)));
|
||||||
}
|
}
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
|
@ -718,31 +718,31 @@ nogrid:;
|
||||||
|
|
||||||
// Draw the traced path, if one exists
|
// Draw the traced path, if one exists
|
||||||
glLineWidth(Style::Width(Style::ANALYZE));
|
glLineWidth(Style::Width(Style::ANALYZE));
|
||||||
glxColorRGB(Style::Color(Style::ANALYZE));
|
ssglColorRGB(Style::Color(Style::ANALYZE));
|
||||||
SContour *sc = &(SS.traced.path);
|
SContour *sc = &(SS.traced.path);
|
||||||
glBegin(GL_LINE_STRIP);
|
glBegin(GL_LINE_STRIP);
|
||||||
for(i = 0; i < sc->l.n; i++) {
|
for(i = 0; i < sc->l.n; i++) {
|
||||||
glxVertex3v(sc->l.elem[i].p);
|
ssglVertex3v(sc->l.elem[i].p);
|
||||||
}
|
}
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
// And the naked edges, if the user did Analyze -> Show Naked Edges.
|
// And the naked edges, if the user did Analyze -> Show Naked Edges.
|
||||||
glLineWidth(Style::Width(Style::DRAW_ERROR));
|
glLineWidth(Style::Width(Style::DRAW_ERROR));
|
||||||
glxColorRGB(Style::Color(Style::DRAW_ERROR));
|
ssglColorRGB(Style::Color(Style::DRAW_ERROR));
|
||||||
glxDrawEdges(&(SS.nakedEdges), true);
|
ssglDrawEdges(&(SS.nakedEdges), true);
|
||||||
|
|
||||||
// Then redraw whatever the mouse is hovering over, highlighted.
|
// Then redraw whatever the mouse is hovering over, highlighted.
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
glxLockColorTo(Style::Color(Style::HOVERED));
|
ssglLockColorTo(Style::Color(Style::HOVERED));
|
||||||
hover.Draw();
|
hover.Draw();
|
||||||
|
|
||||||
// And finally draw the selection, same mechanism.
|
// And finally draw the selection, same mechanism.
|
||||||
glxLockColorTo(Style::Color(Style::SELECTED));
|
ssglLockColorTo(Style::Color(Style::SELECTED));
|
||||||
for(Selection *s = selection.First(); s; s = selection.NextAfter(s)) {
|
for(Selection *s = selection.First(); s; s = selection.NextAfter(s)) {
|
||||||
s->Draw();
|
s->Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
glxUnlockColor();
|
ssglUnlockColor();
|
||||||
|
|
||||||
// If a marquee selection is in progress, then draw the selection
|
// If a marquee selection is in progress, then draw the selection
|
||||||
// rectangle, as an outline and a transparent fill.
|
// rectangle, as an outline and a transparent fill.
|
||||||
|
@ -759,19 +759,19 @@ nogrid:;
|
||||||
bl = UnProjectPoint(Point2d::From(xmin, ymax));
|
bl = UnProjectPoint(Point2d::From(xmin, ymax));
|
||||||
|
|
||||||
glLineWidth((GLfloat)1.3);
|
glLineWidth((GLfloat)1.3);
|
||||||
glxColorRGB(Style::Color(Style::HOVERED));
|
ssglColorRGB(Style::Color(Style::HOVERED));
|
||||||
glBegin(GL_LINE_LOOP);
|
glBegin(GL_LINE_LOOP);
|
||||||
glxVertex3v(tl);
|
ssglVertex3v(tl);
|
||||||
glxVertex3v(tr);
|
ssglVertex3v(tr);
|
||||||
glxVertex3v(br);
|
ssglVertex3v(br);
|
||||||
glxVertex3v(bl);
|
ssglVertex3v(bl);
|
||||||
glEnd();
|
glEnd();
|
||||||
glxColorRGBa(Style::Color(Style::HOVERED), 0.10);
|
ssglColorRGBa(Style::Color(Style::HOVERED), 0.10);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glxVertex3v(tl);
|
ssglVertex3v(tl);
|
||||||
glxVertex3v(tr);
|
ssglVertex3v(tr);
|
||||||
glxVertex3v(br);
|
ssglVertex3v(br);
|
||||||
glxVertex3v(bl);
|
ssglVertex3v(bl);
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -779,33 +779,33 @@ nogrid:;
|
||||||
// plane of the monitor.
|
// plane of the monitor.
|
||||||
if(SS.extraLine.draw) {
|
if(SS.extraLine.draw) {
|
||||||
glLineWidth(1);
|
glLineWidth(1);
|
||||||
glxLockColorTo(Style::Color(Style::DATUM));
|
ssglLockColorTo(Style::Color(Style::DATUM));
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
glxVertex3v(SS.extraLine.ptA);
|
ssglVertex3v(SS.extraLine.ptA);
|
||||||
glxVertex3v(SS.extraLine.ptB);
|
ssglVertex3v(SS.extraLine.ptB);
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
// A note to indicate the origin in the just-exported file.
|
// A note to indicate the origin in the just-exported file.
|
||||||
if(SS.justExportedInfo.draw) {
|
if(SS.justExportedInfo.draw) {
|
||||||
glxColorRGB(Style::Color(Style::DATUM));
|
ssglColorRGB(Style::Color(Style::DATUM));
|
||||||
Vector p = SS.justExportedInfo.pt,
|
Vector p = SS.justExportedInfo.pt,
|
||||||
u = SS.justExportedInfo.u,
|
u = SS.justExportedInfo.u,
|
||||||
v = SS.justExportedInfo.v;
|
v = SS.justExportedInfo.v;
|
||||||
|
|
||||||
glLineWidth(1.5);
|
glLineWidth(1.5);
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
glxVertex3v(p.Plus(u.WithMagnitude(-15/scale)));
|
ssglVertex3v(p.Plus(u.WithMagnitude(-15/scale)));
|
||||||
glxVertex3v(p.Plus(u.WithMagnitude(30/scale)));
|
ssglVertex3v(p.Plus(u.WithMagnitude(30/scale)));
|
||||||
glxVertex3v(p.Plus(v.WithMagnitude(-15/scale)));
|
ssglVertex3v(p.Plus(v.WithMagnitude(-15/scale)));
|
||||||
glxVertex3v(p.Plus(v.WithMagnitude(30/scale)));
|
ssglVertex3v(p.Plus(v.WithMagnitude(30/scale)));
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
glxWriteText("(x, y) = (0, 0) for file just exported",
|
ssglWriteText("(x, y) = (0, 0) for file just exported",
|
||||||
DEFAULT_TEXT_HEIGHT,
|
DEFAULT_TEXT_HEIGHT,
|
||||||
p.Plus(u.ScaledBy(10/scale)).Plus(v.ScaledBy(10/scale)),
|
p.Plus(u.ScaledBy(10/scale)).Plus(v.ScaledBy(10/scale)),
|
||||||
u, v, NULL, NULL);
|
u, v, NULL, NULL);
|
||||||
glxWriteText("press Esc to clear this message",
|
ssglWriteText("press Esc to clear this message",
|
||||||
DEFAULT_TEXT_HEIGHT,
|
DEFAULT_TEXT_HEIGHT,
|
||||||
p.Plus(u.ScaledBy(40/scale)).Plus(
|
p.Plus(u.ScaledBy(40/scale)).Plus(
|
||||||
v.ScaledBy(-(DEFAULT_TEXT_HEIGHT)/scale)),
|
v.ScaledBy(-(DEFAULT_TEXT_HEIGHT)/scale)),
|
||||||
|
|
|
@ -25,11 +25,11 @@ void Constraint::LineDrawOrGetDistance(Vector a, Vector b) {
|
||||||
// The only constraints with styles should be comments, so don't
|
// The only constraints with styles should be comments, so don't
|
||||||
// check otherwise, save looking up the styles constantly.
|
// check otherwise, save looking up the styles constantly.
|
||||||
if(type == COMMENT && Style::Width(hs) >= 3.0) {
|
if(type == COMMENT && Style::Width(hs) >= 3.0) {
|
||||||
glxFatLine(a, b, Style::Width(hs) / SS.GW.scale);
|
ssglFatLine(a, b, Style::Width(hs) / SS.GW.scale);
|
||||||
} else {
|
} else {
|
||||||
glBegin(GL_LINE_STRIP);
|
glBegin(GL_LINE_STRIP);
|
||||||
glxVertex3v(a);
|
ssglVertex3v(a);
|
||||||
glxVertex3v(b);
|
ssglVertex3v(b);
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,8 +87,8 @@ void Constraint::DoLabel(Vector ref, Vector *labelPos, Vector gr, Vector gu) {
|
||||||
}
|
}
|
||||||
|
|
||||||
char *s = Label();
|
char *s = Label();
|
||||||
double swidth = glxStrWidth(s, th),
|
double swidth = ssglStrWidth(s, th),
|
||||||
sheight = glxStrHeight(th);
|
sheight = ssglStrHeight(th);
|
||||||
|
|
||||||
// By default, the reference is from the center; but the style could
|
// By default, the reference is from the center; but the style could
|
||||||
// specify otherwise if one is present, and it could also specify a
|
// specify otherwise if one is present, and it could also specify a
|
||||||
|
@ -118,7 +118,7 @@ void Constraint::DoLabel(Vector ref, Vector *labelPos, Vector gr, Vector gu) {
|
||||||
|
|
||||||
|
|
||||||
if(dogd.drawing) {
|
if(dogd.drawing) {
|
||||||
glxWriteTextRefCenter(s, th, ref, gr, gu, LineCallback, this);
|
ssglWriteTextRefCenter(s, th, ref, gr, gu, LineCallback, this);
|
||||||
} else {
|
} else {
|
||||||
double l = swidth/2 - sheight/2;
|
double l = swidth/2 - sheight/2;
|
||||||
l = max(l, 5/SS.GW.scale);
|
l = max(l, 5/SS.GW.scale);
|
||||||
|
@ -158,8 +158,8 @@ int Constraint::DoLineTrimmedAgainstBox(Vector ref, Vector a, Vector b) {
|
||||||
|
|
||||||
double pixels = 1.0 / SS.GW.scale;
|
double pixels = 1.0 / SS.GW.scale;
|
||||||
char *s = Label();
|
char *s = Label();
|
||||||
double swidth = glxStrWidth(s, DEFAULT_TEXT_HEIGHT) + 4*pixels,
|
double swidth = ssglStrWidth(s, DEFAULT_TEXT_HEIGHT) + 4*pixels,
|
||||||
sheight = glxStrHeight(DEFAULT_TEXT_HEIGHT) + 8*pixels;
|
sheight = ssglStrHeight(DEFAULT_TEXT_HEIGHT) + 8*pixels;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
Vector n;
|
Vector n;
|
||||||
|
@ -364,8 +364,8 @@ void Constraint::DoArcForAngle(Vector a0, Vector da, Vector b0, Vector db,
|
||||||
// complex and this looks pretty good.
|
// complex and this looks pretty good.
|
||||||
double tl = atan2(rm.Dot(gu), rm.Dot(gr));
|
double tl = atan2(rm.Dot(gu), rm.Dot(gr));
|
||||||
double adj = EllipticalInterpolation(
|
double adj = EllipticalInterpolation(
|
||||||
glxStrWidth(Label(), DEFAULT_TEXT_HEIGHT)/2,
|
ssglStrWidth(Label(), DEFAULT_TEXT_HEIGHT)/2,
|
||||||
glxStrHeight(DEFAULT_TEXT_HEIGHT)/2,
|
ssglStrHeight(DEFAULT_TEXT_HEIGHT)/2,
|
||||||
tl);
|
tl);
|
||||||
*ref = (*ref).Plus(rm.WithMagnitude(adj + 3/SS.GW.scale));
|
*ref = (*ref).Plus(rm.WithMagnitude(adj + 3/SS.GW.scale));
|
||||||
} else {
|
} else {
|
||||||
|
@ -374,8 +374,8 @@ void Constraint::DoArcForAngle(Vector a0, Vector da, Vector b0, Vector db,
|
||||||
*ref = (*ref).ScaledBy(0.5).Plus(disp.offset);
|
*ref = (*ref).ScaledBy(0.5).Plus(disp.offset);
|
||||||
gu = gu.WithMagnitude(1);
|
gu = gu.WithMagnitude(1);
|
||||||
Vector trans =
|
Vector trans =
|
||||||
(*ref).Plus(gu.ScaledBy(-1.5*glxStrHeight(DEFAULT_TEXT_HEIGHT)));
|
(*ref).Plus(gu.ScaledBy(-1.5*ssglStrHeight(DEFAULT_TEXT_HEIGHT)));
|
||||||
glxWriteTextRefCenter("angle between skew lines", DEFAULT_TEXT_HEIGHT,
|
ssglWriteTextRefCenter("angle between skew lines", DEFAULT_TEXT_HEIGHT,
|
||||||
trans, gr, gu, LineCallback, this);
|
trans, gr, gu, LineCallback, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -571,7 +571,7 @@ void Constraint::DrawOrGetDistance(Vector *labelPos) {
|
||||||
// the datum color, maybe a bit dimmer
|
// the datum color, maybe a bit dimmer
|
||||||
vc = vc.WithMagnitude(vd.Magnitude()*0.9);
|
vc = vc.WithMagnitude(vd.Magnitude()*0.9);
|
||||||
// and set the color to that.
|
// and set the color to that.
|
||||||
glxColorRGB(RGBf(vc.x, vc.y, vc.z));
|
ssglColorRGB(RGBf(vc.x, vc.y, vc.z));
|
||||||
|
|
||||||
for(int a = 0; a < 2; a++) {
|
for(int a = 0; a < 2; a++) {
|
||||||
Vector r = SS.GW.projRight.ScaledBy((a+1)/SS.GW.scale);
|
Vector r = SS.GW.projRight.ScaledBy((a+1)/SS.GW.scale);
|
||||||
|
@ -579,10 +579,10 @@ void Constraint::DrawOrGetDistance(Vector *labelPos) {
|
||||||
for(int i = 0; i < 2; i++) {
|
for(int i = 0; i < 2; i++) {
|
||||||
Vector p = SK.GetEntity(i == 0 ? ptA : ptB)-> PointGetNum();
|
Vector p = SK.GetEntity(i == 0 ? ptA : ptB)-> PointGetNum();
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glxVertex3v(p.Plus (r).Plus (d));
|
ssglVertex3v(p.Plus (r).Plus (d));
|
||||||
glxVertex3v(p.Plus (r).Minus(d));
|
ssglVertex3v(p.Plus (r).Minus(d));
|
||||||
glxVertex3v(p.Minus(r).Minus(d));
|
ssglVertex3v(p.Minus(r).Minus(d));
|
||||||
glxVertex3v(p.Minus(r).Plus (d));
|
ssglVertex3v(p.Minus(r).Plus (d));
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -801,7 +801,7 @@ void Constraint::DrawOrGetDistance(Vector *labelPos) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(dogd.drawing) {
|
if(dogd.drawing) {
|
||||||
glxWriteTextRefCenter("T", DEFAULT_TEXT_HEIGHT,
|
ssglWriteTextRefCenter("T", DEFAULT_TEXT_HEIGHT,
|
||||||
textAt, u, v, LineCallback, this);
|
textAt, u, v, LineCallback, this);
|
||||||
} else {
|
} else {
|
||||||
dogd.refp = textAt;
|
dogd.refp = textAt;
|
||||||
|
@ -984,7 +984,7 @@ s:
|
||||||
(type == VERTICAL) ? "V" : (
|
(type == VERTICAL) ? "V" : (
|
||||||
(type == AT_MIDPOINT) ? "M" : NULL));
|
(type == AT_MIDPOINT) ? "M" : NULL));
|
||||||
|
|
||||||
glxWriteTextRefCenter(s, DEFAULT_TEXT_HEIGHT,
|
ssglWriteTextRefCenter(s, DEFAULT_TEXT_HEIGHT,
|
||||||
m.Plus(offset), r, u, LineCallback, this);
|
m.Plus(offset), r, u, LineCallback, this);
|
||||||
} else {
|
} else {
|
||||||
dogd.refp = m.Plus(offset);
|
dogd.refp = m.Plus(offset);
|
||||||
|
@ -1015,10 +1015,10 @@ s:
|
||||||
dp = dp.WithMagnitude(2/SS.GW.scale);
|
dp = dp.WithMagnitude(2/SS.GW.scale);
|
||||||
if(dogd.drawing) {
|
if(dogd.drawing) {
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glxVertex3v((c.Plus(d)).Plus(dp));
|
ssglVertex3v((c.Plus(d)).Plus(dp));
|
||||||
glxVertex3v((c.Minus(d)).Plus(dp));
|
ssglVertex3v((c.Minus(d)).Plus(dp));
|
||||||
glxVertex3v((c.Minus(d)).Minus(dp));
|
ssglVertex3v((c.Minus(d)).Minus(dp));
|
||||||
glxVertex3v((c.Plus(d)).Minus(dp));
|
ssglVertex3v((c.Plus(d)).Minus(dp));
|
||||||
glEnd();
|
glEnd();
|
||||||
} else {
|
} else {
|
||||||
Point2d ref = SS.GW.ProjectPoint(c);
|
Point2d ref = SS.GW.ProjectPoint(c);
|
||||||
|
@ -1031,7 +1031,7 @@ s:
|
||||||
case COMMENT: {
|
case COMMENT: {
|
||||||
if(disp.style.v) {
|
if(disp.style.v) {
|
||||||
glLineWidth(Style::Width(disp.style));
|
glLineWidth(Style::Width(disp.style));
|
||||||
glxColorRGB(Style::Color(disp.style));
|
ssglColorRGB(Style::Color(disp.style));
|
||||||
}
|
}
|
||||||
Vector u, v;
|
Vector u, v;
|
||||||
if(workplane.v == Entity::FREE_IN_3D.v) {
|
if(workplane.v == Entity::FREE_IN_3D.v) {
|
||||||
|
@ -1055,7 +1055,7 @@ void Constraint::Draw(void) {
|
||||||
dogd.sel = NULL;
|
dogd.sel = NULL;
|
||||||
|
|
||||||
glLineWidth(Style::Width(Style::CONSTRAINT));
|
glLineWidth(Style::Width(Style::CONSTRAINT));
|
||||||
glxColorRGB(Style::Color(Style::CONSTRAINT));
|
ssglColorRGB(Style::Color(Style::CONSTRAINT));
|
||||||
|
|
||||||
DrawOrGetDistance(NULL);
|
DrawOrGetDistance(NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,19 +20,19 @@ char *Entity::DescriptionString(void) {
|
||||||
void Entity::LineDrawOrGetDistance(Vector a, Vector b, bool maybeFat) {
|
void Entity::LineDrawOrGetDistance(Vector a, Vector b, bool maybeFat) {
|
||||||
if(dogd.drawing) {
|
if(dogd.drawing) {
|
||||||
// Draw lines from active group in front of those from previous
|
// Draw lines from active group in front of those from previous
|
||||||
glxDepthRangeOffset((group.v == SS.GW.activeGroup.v) ? 4 : 3);
|
ssglDepthRangeOffset((group.v == SS.GW.activeGroup.v) ? 4 : 3);
|
||||||
// Narrow lines are drawn as lines, but fat lines must be drawn as
|
// Narrow lines are drawn as lines, but fat lines must be drawn as
|
||||||
// filled polygons, to get the line join style right.
|
// filled polygons, to get the line join style right.
|
||||||
if(!maybeFat || dogd.lineWidth < 3) {
|
if(!maybeFat || dogd.lineWidth < 3) {
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
glxVertex3v(a);
|
ssglVertex3v(a);
|
||||||
glxVertex3v(b);
|
ssglVertex3v(b);
|
||||||
glEnd();
|
glEnd();
|
||||||
} else {
|
} else {
|
||||||
glxFatLine(a, b, dogd.lineWidth/SS.GW.scale);
|
ssglFatLine(a, b, dogd.lineWidth/SS.GW.scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
glxDepthRangeOffset(0);
|
ssglDepthRangeOffset(0);
|
||||||
} else {
|
} else {
|
||||||
Point2d ap = SS.GW.ProjectPoint(a);
|
Point2d ap = SS.GW.ProjectPoint(a);
|
||||||
Point2d bp = SS.GW.ProjectPoint(b);
|
Point2d bp = SS.GW.ProjectPoint(b);
|
||||||
|
@ -54,8 +54,8 @@ void Entity::DrawAll(void) {
|
||||||
double s = 3.5/SS.GW.scale;
|
double s = 3.5/SS.GW.scale;
|
||||||
Vector r = SS.GW.projRight.ScaledBy(s);
|
Vector r = SS.GW.projRight.ScaledBy(s);
|
||||||
Vector d = SS.GW.projUp.ScaledBy(s);
|
Vector d = SS.GW.projUp.ScaledBy(s);
|
||||||
glxColorRGB(Style::Color(Style::DATUM));
|
ssglColorRGB(Style::Color(Style::DATUM));
|
||||||
glxDepthRangeOffset(6);
|
ssglDepthRangeOffset(6);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
for(i = 0; i < SK.entity.n; i++) {
|
for(i = 0; i < SK.entity.n; i++) {
|
||||||
Entity *e = &(SK.entity.elem[i]);
|
Entity *e = &(SK.entity.elem[i]);
|
||||||
|
@ -84,21 +84,21 @@ void Entity::DrawAll(void) {
|
||||||
if(free) {
|
if(free) {
|
||||||
Vector re = r.ScaledBy(2.5), de = d.ScaledBy(2.5);
|
Vector re = r.ScaledBy(2.5), de = d.ScaledBy(2.5);
|
||||||
|
|
||||||
glxColorRGB(Style::Color(Style::ANALYZE));
|
ssglColorRGB(Style::Color(Style::ANALYZE));
|
||||||
glxVertex3v(v.Plus (re).Plus (de));
|
ssglVertex3v(v.Plus (re).Plus (de));
|
||||||
glxVertex3v(v.Plus (re).Minus(de));
|
ssglVertex3v(v.Plus (re).Minus(de));
|
||||||
glxVertex3v(v.Minus(re).Minus(de));
|
ssglVertex3v(v.Minus(re).Minus(de));
|
||||||
glxVertex3v(v.Minus(re).Plus (de));
|
ssglVertex3v(v.Minus(re).Plus (de));
|
||||||
glxColorRGB(Style::Color(Style::DATUM));
|
ssglColorRGB(Style::Color(Style::DATUM));
|
||||||
}
|
}
|
||||||
|
|
||||||
glxVertex3v(v.Plus (r).Plus (d));
|
ssglVertex3v(v.Plus (r).Plus (d));
|
||||||
glxVertex3v(v.Plus (r).Minus(d));
|
ssglVertex3v(v.Plus (r).Minus(d));
|
||||||
glxVertex3v(v.Minus(r).Minus(d));
|
ssglVertex3v(v.Minus(r).Minus(d));
|
||||||
glxVertex3v(v.Minus(r).Plus (d));
|
ssglVertex3v(v.Minus(r).Plus (d));
|
||||||
}
|
}
|
||||||
glEnd();
|
glEnd();
|
||||||
glxDepthRangeOffset(0);
|
ssglDepthRangeOffset(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < SK.entity.n; i++) {
|
for(i = 0; i < SK.entity.n; i++) {
|
||||||
|
@ -115,7 +115,7 @@ void Entity::Draw(void) {
|
||||||
hStyle hs = Style::ForEntity(h);
|
hStyle hs = Style::ForEntity(h);
|
||||||
dogd.lineWidth = Style::Width(hs);
|
dogd.lineWidth = Style::Width(hs);
|
||||||
glLineWidth((float)dogd.lineWidth);
|
glLineWidth((float)dogd.lineWidth);
|
||||||
glxColorRGB(Style::Color(hs));
|
ssglColorRGB(Style::Color(hs));
|
||||||
|
|
||||||
dogd.drawing = true;
|
dogd.drawing = true;
|
||||||
DrawOrGetDistance();
|
DrawOrGetDistance();
|
||||||
|
@ -484,15 +484,15 @@ void Entity::DrawOrGetDistance(void) {
|
||||||
Vector r = SS.GW.projRight.ScaledBy(s/SS.GW.scale);
|
Vector r = SS.GW.projRight.ScaledBy(s/SS.GW.scale);
|
||||||
Vector d = SS.GW.projUp.ScaledBy(s/SS.GW.scale);
|
Vector d = SS.GW.projUp.ScaledBy(s/SS.GW.scale);
|
||||||
|
|
||||||
glxColorRGB(Style::Color(Style::DATUM));
|
ssglColorRGB(Style::Color(Style::DATUM));
|
||||||
glxDepthRangeOffset(6);
|
ssglDepthRangeOffset(6);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glxVertex3v(v.Plus (r).Plus (d));
|
ssglVertex3v(v.Plus (r).Plus (d));
|
||||||
glxVertex3v(v.Plus (r).Minus(d));
|
ssglVertex3v(v.Plus (r).Minus(d));
|
||||||
glxVertex3v(v.Minus(r).Minus(d));
|
ssglVertex3v(v.Minus(r).Minus(d));
|
||||||
glxVertex3v(v.Minus(r).Plus (d));
|
ssglVertex3v(v.Minus(r).Plus (d));
|
||||||
glEnd();
|
glEnd();
|
||||||
glxDepthRangeOffset(0);
|
ssglDepthRangeOffset(0);
|
||||||
} else {
|
} else {
|
||||||
Point2d pp = SS.GW.ProjectPoint(v);
|
Point2d pp = SS.GW.ProjectPoint(v);
|
||||||
dogd.dmin = pp.DistanceTo(dogd.mp) - 6;
|
dogd.dmin = pp.DistanceTo(dogd.mp) - 6;
|
||||||
|
@ -520,13 +520,13 @@ 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) {
|
||||||
glxColorRGB(RGB(0, 0, f));
|
ssglColorRGB(RGB(0, 0, f));
|
||||||
} else if(hr.v == Request::HREQUEST_REFERENCE_YZ.v) {
|
} else if(hr.v == Request::HREQUEST_REFERENCE_YZ.v) {
|
||||||
glxColorRGB(RGB(f, 0, 0));
|
ssglColorRGB(RGB(f, 0, 0));
|
||||||
} else if(hr.v == Request::HREQUEST_REFERENCE_ZX.v) {
|
} else if(hr.v == Request::HREQUEST_REFERENCE_ZX.v) {
|
||||||
glxColorRGB(RGB(0, f, 0));
|
ssglColorRGB(RGB(0, f, 0));
|
||||||
} else {
|
} else {
|
||||||
glxColorRGB(Style::Color(Style::NORMALS));
|
ssglColorRGB(Style::Color(Style::NORMALS));
|
||||||
if(i > 0) break;
|
if(i > 0) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -544,7 +544,7 @@ 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);
|
||||||
glxDepthRangeLockToFront(true);
|
ssglDepthRangeLockToFront(true);
|
||||||
glLineWidth(2);
|
glLineWidth(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -557,7 +557,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)));
|
||||||
}
|
}
|
||||||
glxDepthRangeLockToFront(false);
|
ssglDepthRangeLockToFront(false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -584,7 +584,7 @@ void Entity::DrawOrGetDistance(void) {
|
||||||
Vector mp = p.Minus(us).Plus (vs);
|
Vector mp = p.Minus(us).Plus (vs);
|
||||||
|
|
||||||
glLineWidth(1);
|
glLineWidth(1);
|
||||||
glxColorRGB(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()) {
|
||||||
|
@ -601,10 +601,10 @@ void Entity::DrawOrGetDistance(void) {
|
||||||
char *str = DescriptionString()+5;
|
char *str = DescriptionString()+5;
|
||||||
double th = DEFAULT_TEXT_HEIGHT;
|
double th = DEFAULT_TEXT_HEIGHT;
|
||||||
if(dogd.drawing) {
|
if(dogd.drawing) {
|
||||||
glxWriteText(str, th, mm2, u, v, NULL, NULL);
|
ssglWriteText(str, th, mm2, u, v, NULL, NULL);
|
||||||
} else {
|
} else {
|
||||||
Vector pos = mm2.Plus(u.ScaledBy(glxStrWidth(str, th)/2)).Plus(
|
Vector pos = mm2.Plus(u.ScaledBy(ssglStrWidth(str, th)/2)).Plus(
|
||||||
v.ScaledBy(glxStrHeight(th)/2));
|
v.ScaledBy(ssglStrHeight(th)/2));
|
||||||
Point2d pp = SS.GW.ProjectPoint(pos);
|
Point2d pp = SS.GW.ProjectPoint(pos);
|
||||||
dogd.dmin = min(dogd.dmin, pp.DistanceTo(dogd.mp) - 10);
|
dogd.dmin = min(dogd.dmin, pp.DistanceTo(dogd.mp) - 10);
|
||||||
// If a line lies in a plane, then select the line, not
|
// If a line lies in a plane, then select the line, not
|
||||||
|
|
|
@ -208,17 +208,17 @@ void SolveSpace::GenerateAll(int first, int last, bool andFindFree) {
|
||||||
|
|
||||||
double left = 80, top = -20, width = 240, height = 24;
|
double left = 80, top = -20, width = 240, height = 24;
|
||||||
glColor3d(0.9, 0.8, 0.8);
|
glColor3d(0.9, 0.8, 0.8);
|
||||||
glxAxisAlignedQuad(left, left+width, top, top-height);
|
ssglAxisAlignedQuad(left, left+width, top, top-height);
|
||||||
glLineWidth(1);
|
glLineWidth(1);
|
||||||
glColor3d(0.0, 0.0, 0.0);
|
glColor3d(0.0, 0.0, 0.0);
|
||||||
glxAxisAlignedLineLoop(left, left+width, top, top-height);
|
ssglAxisAlignedLineLoop(left, left+width, top, top-height);
|
||||||
|
|
||||||
glxCreateBitmapFont();
|
ssglCreateBitmapFont();
|
||||||
glColor3d(0, 0, 0);
|
glColor3d(0, 0, 0);
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslated(left+8, top-20, 0);
|
glTranslated(left+8, top-20, 0);
|
||||||
glScaled(1, -1, 1);
|
glScaled(1, -1, 1);
|
||||||
glxBitmapText(msg, Vector::From(0, 0, 0));
|
ssglBitmapText(msg, Vector::From(0, 0, 0));
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
glFlush();
|
glFlush();
|
||||||
glDrawBuffer(GL_BACK);
|
glDrawBuffer(GL_BACK);
|
||||||
|
|
166
glhelper.cpp
166
glhelper.cpp
|
@ -15,7 +15,7 @@ static bool ColorLocked;
|
||||||
static bool DepthOffsetLocked;
|
static bool DepthOffsetLocked;
|
||||||
|
|
||||||
#define FONT_SCALE(h) ((h)/22.0)
|
#define FONT_SCALE(h) ((h)/22.0)
|
||||||
double glxStrWidth(const char *str, double h)
|
double ssglStrWidth(const char *str, double h)
|
||||||
{
|
{
|
||||||
int w = 0;
|
int w = 0;
|
||||||
for(; *str; str++) {
|
for(; *str; str++) {
|
||||||
|
@ -27,42 +27,42 @@ double glxStrWidth(const char *str, double h)
|
||||||
}
|
}
|
||||||
return w*FONT_SCALE(h)/SS.GW.scale;
|
return w*FONT_SCALE(h)/SS.GW.scale;
|
||||||
}
|
}
|
||||||
double glxStrHeight(double h)
|
double ssglStrHeight(double h)
|
||||||
{
|
{
|
||||||
// The characters have height ~22, as they appear in the table.
|
// The characters have height ~22, as they appear in the table.
|
||||||
return 22.0*FONT_SCALE(h)/SS.GW.scale;
|
return 22.0*FONT_SCALE(h)/SS.GW.scale;
|
||||||
}
|
}
|
||||||
void glxWriteTextRefCenter(const char *str, double h, Vector t, Vector u, Vector v,
|
void ssglWriteTextRefCenter(const char *str, double h, Vector t, Vector u, Vector v,
|
||||||
glxLineFn *fn, void *fndata)
|
ssglLineFn *fn, void *fndata)
|
||||||
{
|
{
|
||||||
u = u.WithMagnitude(1);
|
u = u.WithMagnitude(1);
|
||||||
v = v.WithMagnitude(1);
|
v = v.WithMagnitude(1);
|
||||||
|
|
||||||
double scale = FONT_SCALE(h)/SS.GW.scale;
|
double scale = FONT_SCALE(h)/SS.GW.scale;
|
||||||
double fh = glxStrHeight(h);
|
double fh = ssglStrHeight(h);
|
||||||
double fw = glxStrWidth(str, h);
|
double fw = ssglStrWidth(str, h);
|
||||||
|
|
||||||
t = t.Plus(u.ScaledBy(-fw/2));
|
t = t.Plus(u.ScaledBy(-fw/2));
|
||||||
t = t.Plus(v.ScaledBy(-fh/2));
|
t = t.Plus(v.ScaledBy(-fh/2));
|
||||||
|
|
||||||
// Undo the (+5, +5) offset that glxWriteText applies.
|
// Undo the (+5, +5) offset that ssglWriteText applies.
|
||||||
t = t.Plus(u.ScaledBy(-5*scale));
|
t = t.Plus(u.ScaledBy(-5*scale));
|
||||||
t = t.Plus(v.ScaledBy(-5*scale));
|
t = t.Plus(v.ScaledBy(-5*scale));
|
||||||
|
|
||||||
glxWriteText(str, h, t, u, v, fn, fndata);
|
ssglWriteText(str, h, t, u, v, fn, fndata);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LineDrawCallback(void *fndata, Vector a, Vector b)
|
static void LineDrawCallback(void *fndata, Vector a, Vector b)
|
||||||
{
|
{
|
||||||
glLineWidth(1);
|
glLineWidth(1);
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
glxVertex3v(a);
|
ssglVertex3v(a);
|
||||||
glxVertex3v(b);
|
ssglVertex3v(b);
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
void glxWriteText(const char *str, double h, Vector t, Vector u, Vector v,
|
void ssglWriteText(const char *str, double h, Vector t, Vector u, Vector v,
|
||||||
glxLineFn *fn, void *fndata)
|
ssglLineFn *fn, void *fndata)
|
||||||
{
|
{
|
||||||
if(!fn) fn = LineDrawCallback;
|
if(!fn) fn = LineDrawCallback;
|
||||||
u = u.WithMagnitude(1);
|
u = u.WithMagnitude(1);
|
||||||
|
@ -101,12 +101,12 @@ void glxWriteText(const char *str, double h, Vector t, Vector u, Vector v,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void glxVertex3v(Vector u)
|
void ssglVertex3v(Vector u)
|
||||||
{
|
{
|
||||||
glVertex3f((GLfloat)u.x, (GLfloat)u.y, (GLfloat)u.z);
|
glVertex3f((GLfloat)u.x, (GLfloat)u.y, (GLfloat)u.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
void glxAxisAlignedQuad(double l, double r, double t, double b, bool lone)
|
void ssglAxisAlignedQuad(double l, double r, double t, double b, bool lone)
|
||||||
{
|
{
|
||||||
if(lone) glBegin(GL_QUADS);
|
if(lone) glBegin(GL_QUADS);
|
||||||
glVertex2d(l, t);
|
glVertex2d(l, t);
|
||||||
|
@ -116,7 +116,7 @@ void glxAxisAlignedQuad(double l, double r, double t, double b, bool lone)
|
||||||
if(lone) glEnd();
|
if(lone) glEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
void glxAxisAlignedLineLoop(double l, double r, double t, double b)
|
void ssglAxisAlignedLineLoop(double l, double r, double t, double b)
|
||||||
{
|
{
|
||||||
glBegin(GL_LINE_LOOP);
|
glBegin(GL_LINE_LOOP);
|
||||||
glVertex2d(l, t);
|
glVertex2d(l, t);
|
||||||
|
@ -145,12 +145,12 @@ static void FatLineEndcap(Vector p, Vector u, Vector v)
|
||||||
glBegin(GL_TRIANGLE_FAN);
|
glBegin(GL_TRIANGLE_FAN);
|
||||||
for(int i = 0; i <= 10; i++) {
|
for(int i = 0; i <= 10; i++) {
|
||||||
double c = Circle[i][0], s = Circle[i][1];
|
double c = Circle[i][0], s = Circle[i][1];
|
||||||
glxVertex3v(p.Plus(u.ScaledBy(c)).Plus(v.ScaledBy(s)));
|
ssglVertex3v(p.Plus(u.ScaledBy(c)).Plus(v.ScaledBy(s)));
|
||||||
}
|
}
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
void glxFatLine(Vector a, Vector b, double width)
|
void ssglFatLine(Vector a, Vector b, double width)
|
||||||
{
|
{
|
||||||
// The half-width of the line we're drawing.
|
// The half-width of the line we're drawing.
|
||||||
double hw = width / 2;
|
double hw = width / 2;
|
||||||
|
@ -167,10 +167,10 @@ void glxFatLine(Vector a, Vector b, double width)
|
||||||
|
|
||||||
// The body of a line is a quad
|
// The body of a line is a quad
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glxVertex3v(a.Minus(abn));
|
ssglVertex3v(a.Minus(abn));
|
||||||
glxVertex3v(b.Minus(abn));
|
ssglVertex3v(b.Minus(abn));
|
||||||
glxVertex3v(b.Plus (abn));
|
ssglVertex3v(b.Plus (abn));
|
||||||
glxVertex3v(a.Plus (abn));
|
ssglVertex3v(a.Plus (abn));
|
||||||
glEnd();
|
glEnd();
|
||||||
// And the line has two semi-circular end caps.
|
// And the line has two semi-circular end caps.
|
||||||
FatLineEndcap(a, ab, abn);
|
FatLineEndcap(a, ab, abn);
|
||||||
|
@ -178,26 +178,26 @@ void glxFatLine(Vector a, Vector b, double width)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void glxLockColorTo(RgbColor rgb)
|
void ssglLockColorTo(RgbColor rgb)
|
||||||
{
|
{
|
||||||
ColorLocked = false;
|
ColorLocked = false;
|
||||||
glColor3d(rgb.redF(), rgb.greenF(), rgb.blueF());
|
glColor3d(rgb.redF(), rgb.greenF(), rgb.blueF());
|
||||||
ColorLocked = true;
|
ColorLocked = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void glxUnlockColor(void)
|
void ssglUnlockColor(void)
|
||||||
{
|
{
|
||||||
ColorLocked = false;
|
ColorLocked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void glxColorRGB(RgbColor rgb)
|
void ssglColorRGB(RgbColor rgb)
|
||||||
{
|
{
|
||||||
// Is there a bug in some graphics drivers where this is not equivalent
|
// Is there a bug in some graphics drivers where this is not equivalent
|
||||||
// to glColor3d? There seems to be...
|
// to glColor3d? There seems to be...
|
||||||
glxColorRGBa(rgb, 1.0);
|
ssglColorRGBa(rgb, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void glxColorRGBa(RgbColor rgb, double a)
|
void ssglColorRGBa(RgbColor rgb, double a)
|
||||||
{
|
{
|
||||||
if(!ColorLocked) glColor4d(rgb.redF(), rgb.greenF(), rgb.blueF(), a);
|
if(!ColorLocked) glColor4d(rgb.redF(), rgb.greenF(), rgb.blueF(), a);
|
||||||
}
|
}
|
||||||
|
@ -237,19 +237,19 @@ static void StippleTriangle(STriangle *tr, bool s, RgbColor rgb)
|
||||||
{
|
{
|
||||||
glEnd();
|
glEnd();
|
||||||
glDisable(GL_LIGHTING);
|
glDisable(GL_LIGHTING);
|
||||||
glxColorRGB(rgb);
|
ssglColorRGB(rgb);
|
||||||
Stipple(s);
|
Stipple(s);
|
||||||
glBegin(GL_TRIANGLES);
|
glBegin(GL_TRIANGLES);
|
||||||
glxVertex3v(tr->a);
|
ssglVertex3v(tr->a);
|
||||||
glxVertex3v(tr->b);
|
ssglVertex3v(tr->b);
|
||||||
glxVertex3v(tr->c);
|
ssglVertex3v(tr->c);
|
||||||
glEnd();
|
glEnd();
|
||||||
glEnable(GL_LIGHTING);
|
glEnable(GL_LIGHTING);
|
||||||
glDisable(GL_POLYGON_STIPPLE);
|
glDisable(GL_POLYGON_STIPPLE);
|
||||||
glBegin(GL_TRIANGLES);
|
glBegin(GL_TRIANGLES);
|
||||||
}
|
}
|
||||||
|
|
||||||
void glxFillMesh(RgbColor specColor, SMesh *m, uint32_t h, uint32_t s1, uint32_t s2)
|
void ssglFillMesh(RgbColor specColor, SMesh *m, uint32_t h, uint32_t s1, uint32_t s2)
|
||||||
{
|
{
|
||||||
RgbColor rgbHovered = Style::Color(Style::HOVERED),
|
RgbColor rgbHovered = Style::Color(Style::HOVERED),
|
||||||
rgbSelected = Style::Color(Style::SELECTED);
|
rgbSelected = Style::Color(Style::SELECTED);
|
||||||
|
@ -278,19 +278,19 @@ void glxFillMesh(RgbColor specColor, SMesh *m, uint32_t h, uint32_t s1, uint32_t
|
||||||
// Compute the normal from the vertices
|
// Compute the normal from the vertices
|
||||||
Vector n = tr->Normal();
|
Vector n = tr->Normal();
|
||||||
glNormal3d(n.x, n.y, n.z);
|
glNormal3d(n.x, n.y, n.z);
|
||||||
glxVertex3v(tr->a);
|
ssglVertex3v(tr->a);
|
||||||
glxVertex3v(tr->b);
|
ssglVertex3v(tr->b);
|
||||||
glxVertex3v(tr->c);
|
ssglVertex3v(tr->c);
|
||||||
} else {
|
} else {
|
||||||
// Use the exact normals that are specified
|
// Use the exact normals that are specified
|
||||||
glNormal3d((tr->an).x, (tr->an).y, (tr->an).z);
|
glNormal3d((tr->an).x, (tr->an).y, (tr->an).z);
|
||||||
glxVertex3v(tr->a);
|
ssglVertex3v(tr->a);
|
||||||
|
|
||||||
glNormal3d((tr->bn).x, (tr->bn).y, (tr->bn).z);
|
glNormal3d((tr->bn).x, (tr->bn).y, (tr->bn).z);
|
||||||
glxVertex3v(tr->b);
|
ssglVertex3v(tr->b);
|
||||||
|
|
||||||
glNormal3d((tr->cn).x, (tr->cn).y, (tr->cn).z);
|
glNormal3d((tr->cn).x, (tr->cn).y, (tr->cn).z);
|
||||||
glxVertex3v(tr->c);
|
ssglVertex3v(tr->c);
|
||||||
}
|
}
|
||||||
|
|
||||||
if((s1 != 0 && tr->meta.face == s1) ||
|
if((s1 != 0 && tr->meta.face == s1) ||
|
||||||
|
@ -305,24 +305,24 @@ void glxFillMesh(RgbColor specColor, SMesh *m, uint32_t h, uint32_t s1, uint32_t
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GLX_CALLBACK Vertex(Vector *p)
|
static void SSGL_CALLBACK Vertex(Vector *p)
|
||||||
{
|
{
|
||||||
glxVertex3v(*p);
|
ssglVertex3v(*p);
|
||||||
}
|
}
|
||||||
void glxFillPolygon(SPolygon *p)
|
void ssglFillPolygon(SPolygon *p)
|
||||||
{
|
{
|
||||||
GLUtesselator *gt = gluNewTess();
|
GLUtesselator *gt = gluNewTess();
|
||||||
gluTessCallback(gt, GLU_TESS_BEGIN, (glxCallbackFptr *)glBegin);
|
gluTessCallback(gt, GLU_TESS_BEGIN, (ssglCallbackFptr *)glBegin);
|
||||||
gluTessCallback(gt, GLU_TESS_END, (glxCallbackFptr *)glEnd);
|
gluTessCallback(gt, GLU_TESS_END, (ssglCallbackFptr *)glEnd);
|
||||||
gluTessCallback(gt, GLU_TESS_VERTEX, (glxCallbackFptr *)Vertex);
|
gluTessCallback(gt, GLU_TESS_VERTEX, (ssglCallbackFptr *)Vertex);
|
||||||
|
|
||||||
glxTesselatePolygon(gt, p);
|
ssglTesselatePolygon(gt, p);
|
||||||
|
|
||||||
gluDeleteTess(gt);
|
gluDeleteTess(gt);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GLX_CALLBACK Combine(double coords[3], void *vertexData[4],
|
static void SSGL_CALLBACK Combine(double coords[3], void *vertexData[4],
|
||||||
float weight[4], void **outData)
|
float weight[4], void **outData)
|
||||||
{
|
{
|
||||||
Vector *n = (Vector *)AllocTemporary(sizeof(Vector));
|
Vector *n = (Vector *)AllocTemporary(sizeof(Vector));
|
||||||
n->x = coords[0];
|
n->x = coords[0];
|
||||||
|
@ -331,11 +331,11 @@ static void GLX_CALLBACK Combine(double coords[3], void *vertexData[4],
|
||||||
|
|
||||||
*outData = n;
|
*outData = n;
|
||||||
}
|
}
|
||||||
void glxTesselatePolygon(GLUtesselator *gt, SPolygon *p)
|
void ssglTesselatePolygon(GLUtesselator *gt, SPolygon *p)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
gluTessCallback(gt, GLU_TESS_COMBINE, (glxCallbackFptr *)Combine);
|
gluTessCallback(gt, GLU_TESS_COMBINE, (ssglCallbackFptr *)Combine);
|
||||||
gluTessProperty(gt, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_ODD);
|
gluTessProperty(gt, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_ODD);
|
||||||
|
|
||||||
Vector normal = p->normal;
|
Vector normal = p->normal;
|
||||||
|
@ -359,7 +359,7 @@ void glxTesselatePolygon(GLUtesselator *gt, SPolygon *p)
|
||||||
gluTessEndPolygon(gt);
|
gluTessEndPolygon(gt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void glxDebugPolygon(SPolygon *p)
|
void ssglDebugPolygon(SPolygon *p)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
glLineWidth(2);
|
glLineWidth(2);
|
||||||
|
@ -371,28 +371,28 @@ void glxDebugPolygon(SPolygon *p)
|
||||||
Vector a = (sc->l.elem[j]).p;
|
Vector a = (sc->l.elem[j]).p;
|
||||||
Vector b = (sc->l.elem[j+1]).p;
|
Vector b = (sc->l.elem[j+1]).p;
|
||||||
|
|
||||||
glxLockColorTo(RGB(0, 0, 255));
|
ssglLockColorTo(RGB(0, 0, 255));
|
||||||
Vector d = (a.Minus(b)).WithMagnitude(-0);
|
Vector d = (a.Minus(b)).WithMagnitude(-0);
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
glxVertex3v(a.Plus(d));
|
ssglVertex3v(a.Plus(d));
|
||||||
glxVertex3v(b.Minus(d));
|
ssglVertex3v(b.Minus(d));
|
||||||
glEnd();
|
glEnd();
|
||||||
glxLockColorTo(RGB(255, 0, 0));
|
ssglLockColorTo(RGB(255, 0, 0));
|
||||||
glBegin(GL_POINTS);
|
glBegin(GL_POINTS);
|
||||||
glxVertex3v(a.Plus(d));
|
ssglVertex3v(a.Plus(d));
|
||||||
glxVertex3v(b.Minus(d));
|
ssglVertex3v(b.Minus(d));
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void glxDrawEdges(SEdgeList *el, bool endpointsToo)
|
void ssglDrawEdges(SEdgeList *el, bool endpointsToo)
|
||||||
{
|
{
|
||||||
SEdge *se;
|
SEdge *se;
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
for(se = el->l.First(); se; se = el->l.NextAfter(se)) {
|
for(se = el->l.First(); se; se = el->l.NextAfter(se)) {
|
||||||
glxVertex3v(se->a);
|
ssglVertex3v(se->a);
|
||||||
glxVertex3v(se->b);
|
ssglVertex3v(se->b);
|
||||||
}
|
}
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
|
@ -400,37 +400,37 @@ void glxDrawEdges(SEdgeList *el, bool endpointsToo)
|
||||||
glPointSize(12);
|
glPointSize(12);
|
||||||
glBegin(GL_POINTS);
|
glBegin(GL_POINTS);
|
||||||
for(se = el->l.First(); se; se = el->l.NextAfter(se)) {
|
for(se = el->l.First(); se; se = el->l.NextAfter(se)) {
|
||||||
glxVertex3v(se->a);
|
ssglVertex3v(se->a);
|
||||||
glxVertex3v(se->b);
|
ssglVertex3v(se->b);
|
||||||
}
|
}
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void glxDebugMesh(SMesh *m)
|
void ssglDebugMesh(SMesh *m)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
glLineWidth(1);
|
glLineWidth(1);
|
||||||
glPointSize(7);
|
glPointSize(7);
|
||||||
glxDepthRangeOffset(1);
|
ssglDepthRangeOffset(1);
|
||||||
glxUnlockColor();
|
ssglUnlockColor();
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||||
glxColorRGBa(RGB(0, 255, 0), 1.0);
|
ssglColorRGBa(RGB(0, 255, 0), 1.0);
|
||||||
glBegin(GL_TRIANGLES);
|
glBegin(GL_TRIANGLES);
|
||||||
for(i = 0; i < m->l.n; i++) {
|
for(i = 0; i < m->l.n; i++) {
|
||||||
STriangle *t = &(m->l.elem[i]);
|
STriangle *t = &(m->l.elem[i]);
|
||||||
if(t->tag) continue;
|
if(t->tag) continue;
|
||||||
|
|
||||||
glxVertex3v(t->a);
|
ssglVertex3v(t->a);
|
||||||
glxVertex3v(t->b);
|
ssglVertex3v(t->b);
|
||||||
glxVertex3v(t->c);
|
ssglVertex3v(t->c);
|
||||||
}
|
}
|
||||||
glEnd();
|
glEnd();
|
||||||
glxDepthRangeOffset(0);
|
ssglDepthRangeOffset(0);
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void glxMarkPolygonNormal(SPolygon *p)
|
void ssglMarkPolygonNormal(SPolygon *p)
|
||||||
{
|
{
|
||||||
Vector tail = Vector::From(0, 0, 0);
|
Vector tail = Vector::From(0, 0, 0);
|
||||||
int i, j, cnt = 0;
|
int i, j, cnt = 0;
|
||||||
|
@ -452,17 +452,17 @@ void glxMarkPolygonNormal(SPolygon *p)
|
||||||
|
|
||||||
glColor3d(1, 1, 0);
|
glColor3d(1, 1, 0);
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
glxVertex3v(tail);
|
ssglVertex3v(tail);
|
||||||
glxVertex3v(tip);
|
ssglVertex3v(tip);
|
||||||
glxVertex3v(tip);
|
ssglVertex3v(tip);
|
||||||
glxVertex3v(tip.Minus(arrow.RotatedAbout(gn, 0.6)));
|
ssglVertex3v(tip.Minus(arrow.RotatedAbout(gn, 0.6)));
|
||||||
glxVertex3v(tip);
|
ssglVertex3v(tip);
|
||||||
glxVertex3v(tip.Minus(arrow.RotatedAbout(gn, -0.6)));
|
ssglVertex3v(tip.Minus(arrow.RotatedAbout(gn, -0.6)));
|
||||||
glEnd();
|
glEnd();
|
||||||
glEnable(GL_LIGHTING);
|
glEnable(GL_LIGHTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
void glxDepthRangeOffset(int units)
|
void ssglDepthRangeOffset(int units)
|
||||||
{
|
{
|
||||||
if(!DepthOffsetLocked) {
|
if(!DepthOffsetLocked) {
|
||||||
// The size of this step depends on the resolution of the Z buffer; for
|
// The size of this step depends on the resolution of the Z buffer; for
|
||||||
|
@ -472,18 +472,18 @@ void glxDepthRangeOffset(int units)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void glxDepthRangeLockToFront(bool yes)
|
void ssglDepthRangeLockToFront(bool yes)
|
||||||
{
|
{
|
||||||
if(yes) {
|
if(yes) {
|
||||||
DepthOffsetLocked = true;
|
DepthOffsetLocked = true;
|
||||||
glDepthRange(0, 0);
|
glDepthRange(0, 0);
|
||||||
} else {
|
} else {
|
||||||
DepthOffsetLocked = false;
|
DepthOffsetLocked = false;
|
||||||
glxDepthRangeOffset(0);
|
ssglDepthRangeOffset(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void glxCreateBitmapFont(void)
|
void ssglCreateBitmapFont(void)
|
||||||
{
|
{
|
||||||
// Place the font in our texture in a two-dimensional grid; 1d would
|
// Place the font in our texture in a two-dimensional grid; 1d would
|
||||||
// be simpler, but long skinny textures (256*16 = 4096 pixels wide)
|
// be simpler, but long skinny textures (256*16 = 4096 pixels wide)
|
||||||
|
@ -513,7 +513,7 @@ void glxCreateBitmapFont(void)
|
||||||
MappedTexture);
|
MappedTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
void glxBitmapCharQuad(char c, double x, double y)
|
void ssglBitmapCharQuad(char c, double x, double y)
|
||||||
{
|
{
|
||||||
uint8_t b = (uint8_t)c;
|
uint8_t b = (uint8_t)c;
|
||||||
int w, h;
|
int w, h;
|
||||||
|
@ -549,12 +549,12 @@ void glxBitmapCharQuad(char c, double x, double y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void glxBitmapText(const char *str, Vector p)
|
void ssglBitmapText(const char *str, Vector p)
|
||||||
{
|
{
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
while(*str) {
|
while(*str) {
|
||||||
glxBitmapCharQuad(*str, p.x, p.y);
|
ssglBitmapCharQuad(*str, p.x, p.y);
|
||||||
|
|
||||||
str++;
|
str++;
|
||||||
p.x += SS.TW.CHAR_WIDTH;
|
p.x += SS.TW.CHAR_WIDTH;
|
||||||
|
@ -563,7 +563,7 @@ void glxBitmapText(const char *str, Vector p)
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
}
|
}
|
||||||
|
|
||||||
void glxDrawPixelsWithTexture(uint8_t *data, int w, int h)
|
void ssglDrawPixelsWithTexture(uint8_t *data, int w, int h)
|
||||||
{
|
{
|
||||||
#define MAX_DIM 32
|
#define MAX_DIM 32
|
||||||
static uint8_t Texture[MAX_DIM*MAX_DIM*3];
|
static uint8_t Texture[MAX_DIM*MAX_DIM*3];
|
||||||
|
|
|
@ -459,17 +459,17 @@ void Group::DrawDisplayItems(int t) {
|
||||||
|
|
||||||
if(SS.GW.showShaded) {
|
if(SS.GW.showShaded) {
|
||||||
glEnable(GL_LIGHTING);
|
glEnable(GL_LIGHTING);
|
||||||
glxFillMesh(specColor, &displayMesh, mh, ms1, ms2);
|
ssglFillMesh(specColor, &displayMesh, mh, ms1, ms2);
|
||||||
glDisable(GL_LIGHTING);
|
glDisable(GL_LIGHTING);
|
||||||
}
|
}
|
||||||
if(SS.GW.showEdges) {
|
if(SS.GW.showEdges) {
|
||||||
glxDepthRangeOffset(2);
|
ssglDepthRangeOffset(2);
|
||||||
glxColorRGB(Style::Color(Style::SOLID_EDGE));
|
ssglColorRGB(Style::Color(Style::SOLID_EDGE));
|
||||||
glLineWidth(Style::Width(Style::SOLID_EDGE));
|
glLineWidth(Style::Width(Style::SOLID_EDGE));
|
||||||
glxDrawEdges(&displayEdges, false);
|
ssglDrawEdges(&displayEdges, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SS.GW.showMesh) glxDebugMesh(&displayMesh);
|
if(SS.GW.showMesh) ssglDebugMesh(&displayMesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Group::Draw(void) {
|
void Group::Draw(void) {
|
||||||
|
@ -489,14 +489,14 @@ void Group::Draw(void) {
|
||||||
// it's just a nuisance.
|
// it's just a nuisance.
|
||||||
if(type == DRAWING_WORKPLANE) {
|
if(type == DRAWING_WORKPLANE) {
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
glxColorRGBa(Style::Color(Style::DRAW_ERROR), 0.2);
|
ssglColorRGBa(Style::Color(Style::DRAW_ERROR), 0.2);
|
||||||
glLineWidth (Style::Width(Style::DRAW_ERROR));
|
glLineWidth (Style::Width(Style::DRAW_ERROR));
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
glxVertex3v(polyError.notClosedAt.a);
|
ssglVertex3v(polyError.notClosedAt.a);
|
||||||
glxVertex3v(polyError.notClosedAt.b);
|
ssglVertex3v(polyError.notClosedAt.b);
|
||||||
glEnd();
|
glEnd();
|
||||||
glxColorRGB(Style::Color(Style::DRAW_ERROR));
|
ssglColorRGB(Style::Color(Style::DRAW_ERROR));
|
||||||
glxWriteText("not closed contour, or not all same style!",
|
ssglWriteText("not closed contour, or not all same style!",
|
||||||
DEFAULT_TEXT_HEIGHT,
|
DEFAULT_TEXT_HEIGHT,
|
||||||
polyError.notClosedAt.b, SS.GW.projRight, SS.GW.projUp,
|
polyError.notClosedAt.b, SS.GW.projRight, SS.GW.projUp,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
|
@ -509,7 +509,7 @@ void Group::Draw(void) {
|
||||||
// These errors occur at points, not lines
|
// These errors occur at points, not lines
|
||||||
if(type == DRAWING_WORKPLANE) {
|
if(type == DRAWING_WORKPLANE) {
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
glxColorRGB(Style::Color(Style::DRAW_ERROR));
|
ssglColorRGB(Style::Color(Style::DRAW_ERROR));
|
||||||
const char *msg;
|
const char *msg;
|
||||||
if(polyError.how == POLY_NOT_COPLANAR) {
|
if(polyError.how == POLY_NOT_COPLANAR) {
|
||||||
msg = "points not all coplanar!";
|
msg = "points not all coplanar!";
|
||||||
|
@ -518,7 +518,7 @@ void Group::Draw(void) {
|
||||||
} else {
|
} else {
|
||||||
msg = "zero-length edge!";
|
msg = "zero-length edge!";
|
||||||
}
|
}
|
||||||
glxWriteText(msg, DEFAULT_TEXT_HEIGHT,
|
ssglWriteText(msg, DEFAULT_TEXT_HEIGHT,
|
||||||
polyError.errorPointAt, SS.GW.projRight, SS.GW.projUp,
|
polyError.errorPointAt, SS.GW.projRight, SS.GW.projUp,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
@ -532,9 +532,9 @@ void Group::FillLoopSetAsPolygon(SBezierLoopSet *sbls) {
|
||||||
SPolygon sp;
|
SPolygon sp;
|
||||||
ZERO(&sp);
|
ZERO(&sp);
|
||||||
sbls->MakePwlInto(&sp);
|
sbls->MakePwlInto(&sp);
|
||||||
glxDepthRangeOffset(1);
|
ssglDepthRangeOffset(1);
|
||||||
glxFillPolygon(&sp);
|
ssglFillPolygon(&sp);
|
||||||
glxDepthRangeOffset(0);
|
ssglDepthRangeOffset(0);
|
||||||
sp.Clear();
|
sp.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -550,7 +550,7 @@ void Group::DrawFilledPaths(void) {
|
||||||
Style *s = Style::Get(hs);
|
Style *s = Style::Get(hs);
|
||||||
if(s->filled) {
|
if(s->filled) {
|
||||||
// This is a filled loop, where the user specified a fill color.
|
// This is a filled loop, where the user specified a fill color.
|
||||||
glxColorRGBa(s->fillColor, 1);
|
ssglColorRGBa(s->fillColor, 1);
|
||||||
FillLoopSetAsPolygon(sbls);
|
FillLoopSetAsPolygon(sbls);
|
||||||
} else {
|
} else {
|
||||||
if(h.v == SS.GW.activeGroup.v && SS.checkClosedContour &&
|
if(h.v == SS.GW.activeGroup.v && SS.checkClosedContour &&
|
||||||
|
@ -559,10 +559,10 @@ void Group::DrawFilledPaths(void) {
|
||||||
// If this is the active group, and we are supposed to check
|
// If this is the active group, and we are supposed to check
|
||||||
// for closed contours, and we do indeed have a closed and
|
// for closed contours, and we do indeed have a closed and
|
||||||
// non-intersecting contour, then fill it dimly.
|
// non-intersecting contour, then fill it dimly.
|
||||||
glxColorRGBa(Style::Color(Style::CONTOUR_FILL), 0.5);
|
ssglColorRGBa(Style::Color(Style::CONTOUR_FILL), 0.5);
|
||||||
glxDepthRangeOffset(1);
|
ssglDepthRangeOffset(1);
|
||||||
FillLoopSetAsPolygon(sbls);
|
FillLoopSetAsPolygon(sbls);
|
||||||
glxDepthRangeOffset(0);
|
ssglDepthRangeOffset(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
60
solvespace.h
60
solvespace.h
|
@ -228,37 +228,37 @@ typedef IdList<Param,hParam> ParamList;
|
||||||
|
|
||||||
|
|
||||||
// Utility functions that are provided in the platform-independent code.
|
// Utility functions that are provided in the platform-independent code.
|
||||||
void glxVertex3v(Vector u);
|
void ssglVertex3v(Vector u);
|
||||||
void glxAxisAlignedQuad(double l, double r, double t, double b, bool lone = true);
|
void ssglAxisAlignedQuad(double l, double r, double t, double b, bool lone = true);
|
||||||
void glxAxisAlignedLineLoop(double l, double r, double t, double b);
|
void ssglAxisAlignedLineLoop(double l, double r, double t, double b);
|
||||||
#define DEFAULT_TEXT_HEIGHT (11.5)
|
#define DEFAULT_TEXT_HEIGHT (11.5)
|
||||||
#define GLX_CALLBACK __stdcall
|
#define SSGL_CALLBACK __stdcall
|
||||||
typedef void GLX_CALLBACK glxCallbackFptr(void);
|
typedef void SSGL_CALLBACK ssglCallbackFptr(void);
|
||||||
void glxTesselatePolygon(GLUtesselator *gt, SPolygon *p);
|
void ssglTesselatePolygon(GLUtesselator *gt, SPolygon *p);
|
||||||
void glxFillPolygon(SPolygon *p);
|
void ssglFillPolygon(SPolygon *p);
|
||||||
void glxFillMesh(RgbColor color, SMesh *m, uint32_t h, uint32_t s1, uint32_t s2);
|
void ssglFillMesh(RgbColor color, SMesh *m, uint32_t h, uint32_t s1, uint32_t s2);
|
||||||
void glxDebugPolygon(SPolygon *p);
|
void ssglDebugPolygon(SPolygon *p);
|
||||||
void glxDrawEdges(SEdgeList *l, bool endpointsToo);
|
void ssglDrawEdges(SEdgeList *l, bool endpointsToo);
|
||||||
void glxDebugMesh(SMesh *m);
|
void ssglDebugMesh(SMesh *m);
|
||||||
void glxMarkPolygonNormal(SPolygon *p);
|
void ssglMarkPolygonNormal(SPolygon *p);
|
||||||
typedef void glxLineFn(void *data, Vector a, Vector b);
|
typedef void ssglLineFn(void *data, Vector a, Vector b);
|
||||||
void glxWriteText(const char *str, double h, Vector t, Vector u, Vector v,
|
void ssglWriteText(const char *str, double h, Vector t, Vector u, Vector v,
|
||||||
glxLineFn *fn, void *fndata);
|
ssglLineFn *fn, void *fndata);
|
||||||
void glxWriteTextRefCenter(const char *str, double h, Vector t, Vector u, Vector v,
|
void ssglWriteTextRefCenter(const char *str, double h, Vector t, Vector u, Vector v,
|
||||||
glxLineFn *fn, void *fndata);
|
ssglLineFn *fn, void *fndata);
|
||||||
double glxStrWidth(const char *str, double h);
|
double ssglStrWidth(const char *str, double h);
|
||||||
double glxStrHeight(double h);
|
double ssglStrHeight(double h);
|
||||||
void glxLockColorTo(RgbColor rgb);
|
void ssglLockColorTo(RgbColor rgb);
|
||||||
void glxFatLine(Vector a, Vector b, double width);
|
void ssglFatLine(Vector a, Vector b, double width);
|
||||||
void glxUnlockColor(void);
|
void ssglUnlockColor(void);
|
||||||
void glxColorRGB(RgbColor rgb);
|
void ssglColorRGB(RgbColor rgb);
|
||||||
void glxColorRGBa(RgbColor rgb, double a);
|
void ssglColorRGBa(RgbColor rgb, double a);
|
||||||
void glxDepthRangeOffset(int units);
|
void ssglDepthRangeOffset(int units);
|
||||||
void glxDepthRangeLockToFront(bool yes);
|
void ssglDepthRangeLockToFront(bool yes);
|
||||||
void glxDrawPixelsWithTexture(uint8_t *data, int w, int h);
|
void ssglDrawPixelsWithTexture(uint8_t *data, int w, int h);
|
||||||
void glxCreateBitmapFont(void);
|
void ssglCreateBitmapFont(void);
|
||||||
void glxBitmapText(const char *str, Vector p);
|
void ssglBitmapText(const char *str, Vector p);
|
||||||
void glxBitmapCharQuad(char c, double x, double y);
|
void ssglBitmapCharQuad(char c, double x, double y);
|
||||||
#define TEXTURE_BACKGROUND_IMG 10
|
#define TEXTURE_BACKGROUND_IMG 10
|
||||||
#define TEXTURE_BITMAP_FONT 20
|
#define TEXTURE_BITMAP_FONT 20
|
||||||
#define TEXTURE_DRAW_PIXELS 30
|
#define TEXTURE_DRAW_PIXELS 30
|
||||||
|
|
32
textwin.cpp
32
textwin.cpp
|
@ -350,7 +350,7 @@ void TextWindow::DrawOrHitTestIcons(int how, double mx, double my)
|
||||||
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);
|
||||||
glxAxisAlignedQuad(0, width, top, bot);
|
ssglAxisAlignedQuad(0, width, top, bot);
|
||||||
|
|
||||||
HideShowIcon *oldHovered = hoveredIcon;
|
HideShowIcon *oldHovered = hoveredIcon;
|
||||||
if(how != PAINT) {
|
if(how != PAINT) {
|
||||||
|
@ -365,7 +365,7 @@ void TextWindow::DrawOrHitTestIcons(int how, double mx, double my)
|
||||||
int l = x, r = l + 4,
|
int l = x, r = l + 4,
|
||||||
t = y, b = t - 24;
|
t = y, b = t - 24;
|
||||||
glColor4d(0.17, 0.17, 0.17, 1);
|
glColor4d(0.17, 0.17, 0.17, 1);
|
||||||
glxAxisAlignedQuad(l, r, t, b);
|
ssglAxisAlignedQuad(l, r, t, b);
|
||||||
}
|
}
|
||||||
x += 12;
|
x += 12;
|
||||||
continue;
|
continue;
|
||||||
|
@ -377,12 +377,12 @@ void TextWindow::DrawOrHitTestIcons(int how, double mx, double my)
|
||||||
// Only thing that matters about the color is the alpha,
|
// Only thing that matters about the color is the alpha,
|
||||||
// should be one for no transparency
|
// should be one for no transparency
|
||||||
glColor3d(0, 0, 0);
|
glColor3d(0, 0, 0);
|
||||||
glxDrawPixelsWithTexture(hsi->icon, 24, 24);
|
ssglDrawPixelsWithTexture(hsi->icon, 24, 24);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
if(hsi == hoveredIcon) {
|
if(hsi == hoveredIcon) {
|
||||||
glColor4d(1, 1, 0, 0.3);
|
glColor4d(1, 1, 0, 0.3);
|
||||||
glxAxisAlignedQuad(x - 2, x + 26, y + 2, y - 26);
|
ssglAxisAlignedQuad(x - 2, x + 26, y + 2, y - 26);
|
||||||
}
|
}
|
||||||
if(!*(hsi->var)) {
|
if(!*(hsi->var)) {
|
||||||
glColor4d(1, 0, 0, 0.6);
|
glColor4d(1, 0, 0, 0.6);
|
||||||
|
@ -443,15 +443,15 @@ void TextWindow::DrawOrHitTestIcons(int how, double mx, double my)
|
||||||
ox = min(ox, (width - 25) - tw);
|
ox = min(ox, (width - 25) - tw);
|
||||||
oy = max(oy, 5);
|
oy = max(oy, 5);
|
||||||
|
|
||||||
glxCreateBitmapFont();
|
ssglCreateBitmapFont();
|
||||||
glLineWidth(1);
|
glLineWidth(1);
|
||||||
glColor4d(1.0, 1.0, 0.6, 1.0);
|
glColor4d(1.0, 1.0, 0.6, 1.0);
|
||||||
glxAxisAlignedQuad(ox, ox+tw, oy, oy+LINE_HEIGHT);
|
ssglAxisAlignedQuad(ox, ox+tw, oy, oy+LINE_HEIGHT);
|
||||||
glColor4d(0.0, 0.0, 0.0, 1.0);
|
glColor4d(0.0, 0.0, 0.0, 1.0);
|
||||||
glxAxisAlignedLineLoop(ox, ox+tw, oy, oy+LINE_HEIGHT);
|
ssglAxisAlignedLineLoop(ox, ox+tw, oy, oy+LINE_HEIGHT);
|
||||||
|
|
||||||
glColor4d(0, 0, 0, 1);
|
glColor4d(0, 0, 0, 1);
|
||||||
glxBitmapText(str, Vector::From(ox+5, oy-3+LINE_HEIGHT, 0));
|
ssglBitmapText(str, Vector::From(ox+5, oy-3+LINE_HEIGHT, 0));
|
||||||
} else {
|
} else {
|
||||||
if(!hoveredIcon ||
|
if(!hoveredIcon ||
|
||||||
(hoveredIcon != tooltippedIcon))
|
(hoveredIcon != tooltippedIcon))
|
||||||
|
@ -593,9 +593,9 @@ bool TextWindow::DrawOrHitTestColorPicker(int how, bool leftDown,
|
||||||
int bw = 6;
|
int bw = 6;
|
||||||
if(how == PAINT) {
|
if(how == PAINT) {
|
||||||
glColor4d(0.2, 0.2, 0.2, 1);
|
glColor4d(0.2, 0.2, 0.2, 1);
|
||||||
glxAxisAlignedQuad(px, pxm+bw, py, pym+bw);
|
ssglAxisAlignedQuad(px, pxm+bw, py, pym+bw);
|
||||||
glColor4d(0.0, 0.0, 0.0, 1);
|
glColor4d(0.0, 0.0, 0.0, 1);
|
||||||
glxAxisAlignedQuad(px+(bw/2), pxm+(bw/2), py+(bw/2), pym+(bw/2));
|
ssglAxisAlignedQuad(px+(bw/2), pxm+(bw/2), py+(bw/2), pym+(bw/2));
|
||||||
} else {
|
} else {
|
||||||
if(x < px || x > pxm+(bw/2) ||
|
if(x < px || x > pxm+(bw/2) ||
|
||||||
y < py || y > pym+(bw/2))
|
y < py || y > pym+(bw/2))
|
||||||
|
@ -635,7 +635,7 @@ bool TextWindow::DrawOrHitTestColorPicker(int how, bool leftDown,
|
||||||
|
|
||||||
if(how == PAINT) {
|
if(how == PAINT) {
|
||||||
glColor4d(CO(rgb), 1);
|
glColor4d(CO(rgb), 1);
|
||||||
glxAxisAlignedQuad(sx, sx+SIZE, sy, sy+SIZE);
|
ssglAxisAlignedQuad(sx, sx+SIZE, sy, sy+SIZE);
|
||||||
} else if(how == CLICK) {
|
} else if(how == CLICK) {
|
||||||
if(x >= sx && x <= sx+SIZE && y >= sy && y <= sy+SIZE) {
|
if(x >= sx && x <= sx+SIZE && y >= sy && y <= sy+SIZE) {
|
||||||
editControl.colorPicker.rgb = RGBf(rgb.x, rgb.y, rgb.z);
|
editControl.colorPicker.rgb = RGBf(rgb.x, rgb.y, rgb.z);
|
||||||
|
@ -654,8 +654,8 @@ bool TextWindow::DrawOrHitTestColorPicker(int how, bool leftDown,
|
||||||
hxm = hx + PITCH*7 + SIZE;
|
hxm = hx + PITCH*7 + SIZE;
|
||||||
hym = hy + PITCH*2 + SIZE;
|
hym = hy + PITCH*2 + SIZE;
|
||||||
if(how == PAINT) {
|
if(how == PAINT) {
|
||||||
glxColorRGB(editControl.colorPicker.rgb);
|
ssglColorRGB(editControl.colorPicker.rgb);
|
||||||
glxAxisAlignedQuad(hx, hxm, hy, hym);
|
ssglAxisAlignedQuad(hx, hxm, hy, hym);
|
||||||
} else if(how == CLICK) {
|
} else if(how == CLICK) {
|
||||||
if(x >= hx && x <= hxm && y >= hy && y <= hym) {
|
if(x >= hx && x <= hxm && y >= hy && y <= hym) {
|
||||||
ColorPickerDone();
|
ColorPickerDone();
|
||||||
|
@ -827,7 +827,7 @@ void TextWindow::Paint(void) {
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
} else if(a == 1) {
|
} else if(a == 1) {
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
glxCreateBitmapFont();
|
ssglCreateBitmapFont();
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -860,12 +860,12 @@ void TextWindow::Paint(void) {
|
||||||
// Move the quad down a bit, so that the descenders
|
// Move the quad down a bit, so that the descenders
|
||||||
// still have the correct background.
|
// still have the correct background.
|
||||||
y += adj;
|
y += adj;
|
||||||
glxAxisAlignedQuad(x, x + CHAR_WIDTH, y, y + bh, false);
|
ssglAxisAlignedQuad(x, x + CHAR_WIDTH, y, y + bh, false);
|
||||||
y -= adj;
|
y -= adj;
|
||||||
}
|
}
|
||||||
} else if(a == 1) {
|
} else if(a == 1) {
|
||||||
glColor3fv(&(fgColorTable[fg*3]));
|
glColor3fv(&(fgColorTable[fg*3]));
|
||||||
glxBitmapCharQuad(text[r][c], x, y + CHAR_HEIGHT);
|
ssglBitmapCharQuad(text[r][c], x, y + CHAR_HEIGHT);
|
||||||
|
|
||||||
// If this is a link and it's hovered, then draw the
|
// If this is a link and it's hovered, then draw the
|
||||||
// underline
|
// underline
|
||||||
|
|
16
toolbar.cpp
16
toolbar.cpp
|
@ -132,7 +132,7 @@ bool GraphicsWindow::ToolbarDrawOrHitTest(int mx, int my,
|
||||||
|
|
||||||
double c = 30.0/255;
|
double c = 30.0/255;
|
||||||
glColor4d(c, c, c, 1.0);
|
glColor4d(c, c, c, 1.0);
|
||||||
glxAxisAlignedQuad(aleft, aright, atop, abot);
|
ssglAxisAlignedQuad(aleft, aright, atop, abot);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
@ -156,7 +156,7 @@ bool GraphicsWindow::ToolbarDrawOrHitTest(int mx, int my,
|
||||||
glColor4d(0.17, 0.17, 0.17, 1);
|
glColor4d(0.17, 0.17, 0.17, 1);
|
||||||
x += 16;
|
x += 16;
|
||||||
y += 24;
|
y += 24;
|
||||||
glxAxisAlignedQuad(x+divw, x-divw, y+divh, y-divh);
|
ssglAxisAlignedQuad(x+divw, x-divw, y+divh, y-divh);
|
||||||
x -= 16;
|
x -= 16;
|
||||||
y -= 24;
|
y -= 24;
|
||||||
}
|
}
|
||||||
|
@ -172,7 +172,7 @@ bool GraphicsWindow::ToolbarDrawOrHitTest(int mx, int my,
|
||||||
// Highlight the hovered or pending item.
|
// Highlight the hovered or pending item.
|
||||||
glColor4d(1, 1, 0, 0.3);
|
glColor4d(1, 1, 0, 0.3);
|
||||||
int boxhw = 15;
|
int boxhw = 15;
|
||||||
glxAxisAlignedQuad(x+boxhw, x-boxhw, y+boxhw, y-boxhw);
|
ssglAxisAlignedQuad(x+boxhw, x-boxhw, y+boxhw, y-boxhw);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(toolbarTooltipped == Toolbar[i].menu) {
|
if(toolbarTooltipped == Toolbar[i].menu) {
|
||||||
|
@ -204,7 +204,7 @@ bool GraphicsWindow::ToolbarDrawOrHitTest(int mx, int my,
|
||||||
if(paint) {
|
if(paint) {
|
||||||
// Do this last so that nothing can draw over it.
|
// Do this last so that nothing can draw over it.
|
||||||
if(toolTip.show) {
|
if(toolTip.show) {
|
||||||
glxCreateBitmapFont();
|
ssglCreateBitmapFont();
|
||||||
char str[1024];
|
char str[1024];
|
||||||
if(strlen(toolTip.str) >= 200) oops();
|
if(strlen(toolTip.str) >= 200) oops();
|
||||||
strcpy(str, toolTip.str);
|
strcpy(str, toolTip.str);
|
||||||
|
@ -225,18 +225,18 @@ bool GraphicsWindow::ToolbarDrawOrHitTest(int mx, int my,
|
||||||
double ox = toolbarMouseX + 3, oy = toolbarMouseY + 3;
|
double ox = toolbarMouseX + 3, oy = toolbarMouseY + 3;
|
||||||
glLineWidth(1);
|
glLineWidth(1);
|
||||||
glColor4d(1.0, 1.0, 0.6, 1.0);
|
glColor4d(1.0, 1.0, 0.6, 1.0);
|
||||||
glxAxisAlignedQuad(ox, ox+tw, oy, oy+th);
|
ssglAxisAlignedQuad(ox, ox+tw, oy, oy+th);
|
||||||
glColor4d(0.0, 0.0, 0.0, 1.0);
|
glColor4d(0.0, 0.0, 0.0, 1.0);
|
||||||
glxAxisAlignedLineLoop(ox, ox+tw, oy, oy+th);
|
ssglAxisAlignedLineLoop(ox, ox+tw, oy, oy+th);
|
||||||
|
|
||||||
glColor4d(0, 0, 0, 1);
|
glColor4d(0, 0, 0, 1);
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslated(ox+5, oy+3, 0);
|
glTranslated(ox+5, oy+3, 0);
|
||||||
glScaled(1, -1, 1);
|
glScaled(1, -1, 1);
|
||||||
glxBitmapText(str, Vector::From(0, 0, 0));
|
ssglBitmapText(str, Vector::From(0, 0, 0));
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
glxDepthRangeLockToFront(false);
|
ssglDepthRangeLockToFront(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return withinToolbar;
|
return withinToolbar;
|
||||||
|
|
Loading…
Reference in New Issue