[Add] Using clipping planes on starmap for better results.
This commit is contained in:
parent
b156c96662
commit
35bcabdf16
29
src/map.c
29
src/map.c
@ -163,11 +163,9 @@ static void map_render(double bx, double by, double w, double h) {
|
|||||||
// Draw the system name.
|
// Draw the system name.
|
||||||
tx = x + 7. + sys->pos.x * map_zoom;
|
tx = x + 7. + sys->pos.x * map_zoom;
|
||||||
ty = y - 5. + sys->pos.y * map_zoom;
|
ty = y - 5. + sys->pos.y * map_zoom;
|
||||||
if((map_zoom >= 1.) && // Can't be tiny.
|
gl_print(&gl_smallFont,
|
||||||
((tx > bx) && (ty > by) && (ty < by+h-6.))) // Width checking.
|
tx + gl_screen.w/2., ty + gl_screen.h/2.,
|
||||||
gl_printMax(&gl_smallFont, (bx+w)-(tx),
|
&cWhite, sys->name);
|
||||||
tx + gl_screen.w/2., ty + gl_screen.h/2.,
|
|
||||||
&cWhite, sys->name);
|
|
||||||
|
|
||||||
// Draw the hyperspace paths.
|
// Draw the hyperspace paths.
|
||||||
glShadeModel(GL_SMOOTH);
|
glShadeModel(GL_SMOOTH);
|
||||||
@ -181,20 +179,17 @@ static void map_render(double bx, double by, double w, double h) {
|
|||||||
col = &cRed;
|
col = &cRed;
|
||||||
else col = &cDarkBlue;
|
else col = &cDarkBlue;
|
||||||
glBegin(GL_LINE_STRIP);
|
glBegin(GL_LINE_STRIP);
|
||||||
ACOLOUR(*col, 0.);
|
ACOLOUR(*col, 0.);
|
||||||
tx = x + sys->pos.x * map_zoom;
|
tx = x + sys->pos.x * map_zoom;
|
||||||
ty = y + sys->pos.y * map_zoom;
|
ty = y + sys->pos.y * map_zoom;
|
||||||
if(!((tx < bx) || (tx > bx + w) || (ty < by) || (ty > by+h)))
|
|
||||||
glVertex2d(tx, ty);
|
glVertex2d(tx, ty);
|
||||||
COLOUR(*col);
|
COLOUR(*col);
|
||||||
tx += (systems_stack[sys->jumps[j]].pos.x - sys->pos.x)/2. * map_zoom;
|
tx += (systems_stack[sys->jumps[j]].pos.x - sys->pos.x)/2. * map_zoom;
|
||||||
ty += (systems_stack[sys->jumps[j]].pos.y - sys->pos.y)/2. * map_zoom;
|
ty += (systems_stack[sys->jumps[j]].pos.y - sys->pos.y)/2. * map_zoom;
|
||||||
if(!((tx < bx) || (tx > bx+w) || (ty < by) || (ty > by+h)))
|
|
||||||
glVertex2d(tx, ty);
|
glVertex2d(tx, ty);
|
||||||
ACOLOUR(*col, 0.);
|
ACOLOUR(*col, 0.);
|
||||||
tx = x + systems_stack[sys->jumps[j]].pos.x * map_zoom;
|
tx = x + systems_stack[sys->jumps[j]].pos.x * map_zoom;
|
||||||
ty = y + systems_stack[sys->jumps[j]].pos.y * map_zoom;
|
ty = y + systems_stack[sys->jumps[j]].pos.y * map_zoom;
|
||||||
if(!((tx < bx) || (tx > bx+w) || (ty < by) || (ty > by+h)))
|
|
||||||
glVertex2d(tx, ty);
|
glVertex2d(tx, ty);
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
|
@ -144,6 +144,8 @@ static void toolkit_renderCust(Widget* cst, double bx, double by);
|
|||||||
static void toolkit_renderInput(Widget* inp, double bx, double by);
|
static void toolkit_renderInput(Widget* inp, double bx, double by);
|
||||||
static void toolkit_drawOutline(double x, double y, double w,
|
static void toolkit_drawOutline(double x, double y, double w,
|
||||||
double h, double b, glColour* c, glColour* lc);
|
double h, double b, glColour* c, glColour* lc);
|
||||||
|
static void toolkit_clip(double x, double y, double w, double h);
|
||||||
|
static void toolkit_unclip(void);
|
||||||
static void toolkit_drawRect(double x, double y, double w, double h,
|
static void toolkit_drawRect(double x, double y, double w, double h,
|
||||||
glColour* c, glColour* lc);
|
glColour* c, glColour* lc);
|
||||||
// Dialogues..
|
// Dialogues..
|
||||||
@ -627,6 +629,32 @@ static void toolkit_drawRect(double x, double y, double w, double h,
|
|||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set up 2d clipping planes around a rectangle.
|
||||||
|
static void toolkit_clip(double x, double y, double w, double h) {
|
||||||
|
GLdouble ctop[4] = { 0., 1., 0., -y };
|
||||||
|
GLdouble cbot[4] = { 0., -1., 0., y+h };
|
||||||
|
GLdouble clef[4] = { 1., 0., 0., -x };
|
||||||
|
GLdouble crig[4] = { -1., 0., 0, x+w };
|
||||||
|
|
||||||
|
glClipPlane(GL_CLIP_PLANE0, ctop);
|
||||||
|
glClipPlane(GL_CLIP_PLANE1, cbot);
|
||||||
|
glClipPlane(GL_CLIP_PLANE2, clef);
|
||||||
|
glClipPlane(GL_CLIP_PLANE3, crig);
|
||||||
|
|
||||||
|
glEnable(GL_CLIP_PLANE0);
|
||||||
|
glEnable(GL_CLIP_PLANE1);
|
||||||
|
glEnable(GL_CLIP_PLANE2);
|
||||||
|
glEnable(GL_CLIP_PLANE3);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void toolkit_unclip(void) {
|
||||||
|
glDisable(GL_CLIP_PLANE0);
|
||||||
|
glDisable(GL_CLIP_PLANE1);
|
||||||
|
glDisable(GL_CLIP_PLANE2);
|
||||||
|
glDisable(GL_CLIP_PLANE3);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Render a window.
|
// Render a window.
|
||||||
static void window_render(Window* w) {
|
static void window_render(Window* w) {
|
||||||
int i;
|
int i;
|
||||||
@ -984,7 +1012,10 @@ static void toolkit_renderCust(Widget* cst, double bx, double by) {
|
|||||||
toolkit_drawOutline(x-1, y, cst->w+1, cst->h+1, 1.,
|
toolkit_drawOutline(x-1, y, cst->w+1, cst->h+1, 1.,
|
||||||
toolkit_colDark, NULL);
|
toolkit_colDark, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toolkit_clip(x+1, y+1, cst->w, cst->h);
|
||||||
(*cst->dat.cst.render) (x, y, cst->w, cst->h);
|
(*cst->dat.cst.render) (x, y, cst->w, cst->h);
|
||||||
|
toolkit_unclip();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render an input widget.
|
// Render an input widget.
|
||||||
|
Loading…
Reference in New Issue
Block a user