Work around poor line rendering with Intel Mesa-based drivers.
However, don't use ssglLineWidth for UI drawing operations. These only draw horizontal or vertical lines that don't need to be antialiased, and thus don't require the workaround. In fact the workaround would make them thicker than needed.pull/3/head
parent
13afcb310e
commit
14690e6e42
|
@ -667,7 +667,7 @@ void SBsp2::DebugDraw(Vector n, double d) {
|
|||
if(fabs((edge.a).Dot(n) - d) > LENGTH_EPS) oops();
|
||||
if(fabs((edge.b).Dot(n) - d) > LENGTH_EPS) oops();
|
||||
|
||||
glLineWidth(10);
|
||||
ssglLineWidth(10);
|
||||
glBegin(GL_LINES);
|
||||
ssglVertex3v(edge.a);
|
||||
ssglVertex3v(edge.b);
|
||||
|
@ -675,6 +675,6 @@ void SBsp2::DebugDraw(Vector n, double d) {
|
|||
pos->DebugDraw(n, d);
|
||||
neg->DebugDraw(n, d);
|
||||
more->DebugDraw(n, d);
|
||||
glLineWidth(1);
|
||||
ssglLineWidth(1);
|
||||
}
|
||||
|
||||
|
|
16
src/draw.cpp
16
src/draw.cpp
|
@ -60,14 +60,14 @@ void GraphicsWindow::Selection::Draw(void) {
|
|||
topLeft = topLeft.Plus(SS.GW.projUp.ScaledBy(SS.GW.height*s));
|
||||
topLeft = topLeft.Minus(SS.GW.offset);
|
||||
|
||||
glLineWidth(40);
|
||||
ssglLineWidth(40);
|
||||
RgbColor rgb = Style::Color(Style::HOVERED);
|
||||
glColor4d(rgb.redF(), rgb.greenF(), rgb.blueF(), 0.2);
|
||||
glBegin(GL_LINES);
|
||||
ssglVertex3v(topLeft);
|
||||
ssglVertex3v(refp);
|
||||
glEnd();
|
||||
glLineWidth(1);
|
||||
ssglLineWidth(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -673,7 +673,7 @@ void GraphicsWindow::Paint(void) {
|
|||
if(i0 > i1 || i1 - i0 > 400) goto nogrid;
|
||||
if(j0 > j1 || j1 - j0 > 400) goto nogrid;
|
||||
|
||||
glLineWidth(1);
|
||||
ssglLineWidth(1);
|
||||
ssglColorRGBa(Style::Color(Style::DATUM), 0.3);
|
||||
glBegin(GL_LINES);
|
||||
for(i = i0 + 1; i < i1; i++) {
|
||||
|
@ -717,7 +717,7 @@ nogrid:;
|
|||
}
|
||||
|
||||
// Draw the traced path, if one exists
|
||||
glLineWidth(Style::Width(Style::ANALYZE));
|
||||
ssglLineWidth(Style::Width(Style::ANALYZE));
|
||||
ssglColorRGB(Style::Color(Style::ANALYZE));
|
||||
SContour *sc = &(SS.traced.path);
|
||||
glBegin(GL_LINE_STRIP);
|
||||
|
@ -727,7 +727,7 @@ nogrid:;
|
|||
glEnd();
|
||||
|
||||
// And the naked edges, if the user did Analyze -> Show Naked Edges.
|
||||
glLineWidth(Style::Width(Style::DRAW_ERROR));
|
||||
ssglLineWidth(Style::Width(Style::DRAW_ERROR));
|
||||
ssglColorRGB(Style::Color(Style::DRAW_ERROR));
|
||||
ssglDrawEdges(&(SS.nakedEdges), true);
|
||||
|
||||
|
@ -758,7 +758,7 @@ nogrid:;
|
|||
br = UnProjectPoint(Point2d::From(xmax, ymax)),
|
||||
bl = UnProjectPoint(Point2d::From(xmin, ymax));
|
||||
|
||||
glLineWidth((GLfloat)1.3);
|
||||
ssglLineWidth((GLfloat)1.3);
|
||||
ssglColorRGB(Style::Color(Style::HOVERED));
|
||||
glBegin(GL_LINE_LOOP);
|
||||
ssglVertex3v(tl);
|
||||
|
@ -778,7 +778,7 @@ nogrid:;
|
|||
// An extra line, used to indicate the origin when rotating within the
|
||||
// plane of the monitor.
|
||||
if(SS.extraLine.draw) {
|
||||
glLineWidth(1);
|
||||
ssglLineWidth(1);
|
||||
ssglLockColorTo(Style::Color(Style::DATUM));
|
||||
glBegin(GL_LINES);
|
||||
ssglVertex3v(SS.extraLine.ptA);
|
||||
|
@ -793,7 +793,7 @@ nogrid:;
|
|||
u = SS.justExportedInfo.u,
|
||||
v = SS.justExportedInfo.v;
|
||||
|
||||
glLineWidth(1.5);
|
||||
ssglLineWidth(1.5);
|
||||
glBegin(GL_LINES);
|
||||
ssglVertex3v(p.Plus(u.WithMagnitude(-15/scale)));
|
||||
ssglVertex3v(p.Plus(u.WithMagnitude(30/scale)));
|
||||
|
|
|
@ -1030,7 +1030,7 @@ s:
|
|||
|
||||
case COMMENT: {
|
||||
if(disp.style.v) {
|
||||
glLineWidth(Style::Width(disp.style));
|
||||
ssglLineWidth(Style::Width(disp.style));
|
||||
ssglColorRGB(Style::Color(disp.style));
|
||||
}
|
||||
Vector u, v;
|
||||
|
@ -1054,7 +1054,7 @@ void Constraint::Draw(void) {
|
|||
dogd.drawing = true;
|
||||
dogd.sel = NULL;
|
||||
|
||||
glLineWidth(Style::Width(Style::CONSTRAINT));
|
||||
ssglLineWidth(Style::Width(Style::CONSTRAINT));
|
||||
ssglColorRGB(Style::Color(Style::CONSTRAINT));
|
||||
|
||||
DrawOrGetDistance(NULL);
|
||||
|
|
|
@ -114,7 +114,7 @@ void Entity::DrawAll(void) {
|
|||
void Entity::Draw(void) {
|
||||
hStyle hs = Style::ForEntity(h);
|
||||
dogd.lineWidth = Style::Width(hs);
|
||||
glLineWidth((float)dogd.lineWidth);
|
||||
ssglLineWidth((float)dogd.lineWidth);
|
||||
ssglColorRGB(Style::Color(hs));
|
||||
|
||||
dogd.drawing = true;
|
||||
|
@ -534,7 +534,7 @@ void Entity::DrawOrGetDistance(void) {
|
|||
Vector tail;
|
||||
if(i == 0) {
|
||||
tail = SK.GetEntity(point[0])->PointGetNum();
|
||||
glLineWidth(1);
|
||||
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.
|
||||
|
@ -545,7 +545,7 @@ void Entity::DrawOrGetDistance(void) {
|
|||
tail = SS.GW.projRight.ScaledBy(w/s).Plus(
|
||||
SS.GW.projUp. ScaledBy(h/s)).Minus(SS.GW.offset);
|
||||
ssglDepthRangeLockToFront(true);
|
||||
glLineWidth(2);
|
||||
ssglLineWidth(2);
|
||||
}
|
||||
|
||||
Vector v = (q.RotationN()).WithMagnitude(50/SS.GW.scale);
|
||||
|
@ -583,7 +583,7 @@ void Entity::DrawOrGetDistance(void) {
|
|||
Vector mm = p.Minus(us).Minus(vs), mm2 = mm;
|
||||
Vector mp = p.Minus(us).Plus (vs);
|
||||
|
||||
glLineWidth(1);
|
||||
ssglLineWidth(1);
|
||||
ssglColorRGB(Style::Color(Style::NORMALS));
|
||||
glEnable(GL_LINE_STIPPLE);
|
||||
glLineStipple(3, 0x1111);
|
||||
|
|
|
@ -209,7 +209,7 @@ void SolveSpace::GenerateAll(int first, int last, bool andFindFree) {
|
|||
double left = 80, top = -20, width = 240, height = 24;
|
||||
glColor3d(0.9, 0.8, 0.8);
|
||||
ssglAxisAlignedQuad(left, left+width, top, top-height);
|
||||
glLineWidth(1);
|
||||
ssglLineWidth(1);
|
||||
glColor3d(0.0, 0.0, 0.0);
|
||||
ssglAxisAlignedLineLoop(left, left+width, top, top-height);
|
||||
|
||||
|
|
|
@ -52,9 +52,27 @@ void ssglWriteTextRefCenter(const char *str, double h, Vector t, Vector u, Vecto
|
|||
ssglWriteText(str, h, t, u, v, fn, fndata);
|
||||
}
|
||||
|
||||
void ssglLineWidth(GLfloat width) {
|
||||
// Intel GPUs with Mesa on *nix render thin lines poorly.
|
||||
static bool workaroundChecked, workaroundEnabled;
|
||||
if(!workaroundChecked) {
|
||||
// ssglLineWidth can be called before GL is initialized
|
||||
if(glGetString(GL_VENDOR)) {
|
||||
workaroundChecked = true;
|
||||
if(!strcmp((char*)glGetString(GL_VENDOR), "Intel Open Source Technology Center"))
|
||||
workaroundEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(workaroundEnabled && width < 1.6)
|
||||
width = 1.6;
|
||||
|
||||
glLineWidth(width);
|
||||
}
|
||||
|
||||
static void LineDrawCallback(void *fndata, Vector a, Vector b)
|
||||
{
|
||||
glLineWidth(1);
|
||||
ssglLineWidth(1);
|
||||
glBegin(GL_LINES);
|
||||
ssglVertex3v(a);
|
||||
ssglVertex3v(b);
|
||||
|
@ -362,7 +380,7 @@ void ssglTesselatePolygon(GLUtesselator *gt, SPolygon *p)
|
|||
void ssglDebugPolygon(SPolygon *p)
|
||||
{
|
||||
int i, j;
|
||||
glLineWidth(2);
|
||||
ssglLineWidth(2);
|
||||
glPointSize(7);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
for(i = 0; i < p->l.n; i++) {
|
||||
|
@ -410,7 +428,7 @@ void ssglDrawEdges(SEdgeList *el, bool endpointsToo)
|
|||
void ssglDebugMesh(SMesh *m)
|
||||
{
|
||||
int i;
|
||||
glLineWidth(1);
|
||||
ssglLineWidth(1);
|
||||
glPointSize(7);
|
||||
ssglDepthRangeOffset(1);
|
||||
ssglUnlockColor();
|
||||
|
|
|
@ -465,7 +465,7 @@ void Group::DrawDisplayItems(int t) {
|
|||
if(SS.GW.showEdges) {
|
||||
ssglDepthRangeOffset(2);
|
||||
ssglColorRGB(Style::Color(Style::SOLID_EDGE));
|
||||
glLineWidth(Style::Width(Style::SOLID_EDGE));
|
||||
ssglLineWidth(Style::Width(Style::SOLID_EDGE));
|
||||
ssglDrawEdges(&displayEdges, false);
|
||||
}
|
||||
|
||||
|
@ -490,7 +490,7 @@ void Group::Draw(void) {
|
|||
if(type == DRAWING_WORKPLANE) {
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
ssglColorRGBa(Style::Color(Style::DRAW_ERROR), 0.2);
|
||||
glLineWidth (Style::Width(Style::DRAW_ERROR));
|
||||
ssglLineWidth (Style::Width(Style::DRAW_ERROR));
|
||||
glBegin(GL_LINES);
|
||||
ssglVertex3v(polyError.notClosedAt.a);
|
||||
ssglVertex3v(polyError.notClosedAt.b);
|
||||
|
|
|
@ -273,6 +273,7 @@ typedef IdList<Param,hParam> ParamList;
|
|||
|
||||
|
||||
// Utility functions that are provided in the platform-independent code.
|
||||
void ssglLineWidth(GLfloat width);
|
||||
void ssglVertex3v(Vector u);
|
||||
void ssglAxisAlignedQuad(double l, double r, double t, double b, bool lone = true);
|
||||
void ssglAxisAlignedLineLoop(double l, double r, double t, double b);
|
||||
|
|
|
@ -259,7 +259,7 @@ float Style::Width(hStyle h) {
|
|||
} else if(s->widthAs == UNITS_AS_PIXELS) {
|
||||
r = s->width;
|
||||
}
|
||||
// This returns a float because glLineWidth expects a float, avoid casts.
|
||||
// This returns a float because ssglLineWidth expects a float, avoid casts.
|
||||
return (float)r;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue