From f2a9b616839c4befde8f4f59da6b06ecdf2a47fd Mon Sep 17 00:00:00 2001 From: Lucas GAUTHERON Date: Sun, 30 Dec 2012 20:40:41 +0000 Subject: [PATCH] drawzone: allow multiple zones to be drawn at once git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@7013 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/clientgame.cpp | 2 +- source/src/protos.h | 4 +++- source/src/rendergl.cpp | 36 ++++++++++++++++++++---------------- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index d4ba1e24..b82b801f 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -1095,7 +1095,7 @@ COMMAND(gamemodedesc, "is"); void resetmap(bool mrproper) { resetsleep(); - resetzone(); + resetzones(); clearminimap(); cleardynlights(); pruneundos(); diff --git a/source/src/protos.h b/source/src/protos.h index 1c51fba4..3480edf2 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -259,7 +259,7 @@ extern void setperspective(float fovy, float aspect, float nearplane, float farp extern void sethudgunperspective(bool on); extern void gl_drawframe(int w, int h, float changelod, float curfps); extern void clearminimap(); -extern void resetzone(); +extern void resetzones(); extern void rendercursor(int x, int y, int w); extern void renderaboveheadicon(playerent *p); extern void drawscope(bool preload = false); @@ -321,6 +321,8 @@ extern void scaletmu(int n, int rgbscale, int alphascale = 0); extern void colortmu(int n, float r = 0, float g = 0, float b = 0, float a = 0); extern void setuptmu(int n, const char *rgbfunc = NULL, const char *alphafunc = NULL); +struct zone { int x1, x2, y1, y2, color; }; // zones (drawn on the minimap) + // rendercubes extern void mipstats(int a, int b, int c); extern void render_flat(int tex, int x, int y, int size, int h, sqr *l1, sqr *l2, sqr *l3, sqr *l4, bool isceil); diff --git a/source/src/rendergl.cpp b/source/src/rendergl.cpp index 5543ea60..3678341f 100644 --- a/source/src/rendergl.cpp +++ b/source/src/rendergl.cpp @@ -748,20 +748,23 @@ bool minimap = false, minimapdirty = true; int minimaplastsize = 0; GLuint minimaptex = 0; -int zonex1 = -1, zoney1 = -1, zonex2 = -1, zoney2 = -1, zonecolor = 0; +vector zones; -void renderzone(float z) +void renderzones(float z) { - glColor4f(((zonecolor>>16)&0xFF)/255.0f, ((zonecolor>>8)&0xFF)/255.0f, (zonecolor&0xFF)/255.0f, 0.3f); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDisable(GL_TEXTURE_2D); - glBegin(GL_QUADS); - glVertex3f(zonex1, zoney1, z); - glVertex3f(zonex2, zoney1, z); - glVertex3f(zonex2, zoney2, z); - glVertex3f(zonex1, zoney2, z); - glEnd(); + loopv(zones) + { + glColor4f(((zones[i].color>>16)&0xFF)/255.0f, ((zones[i].color>>8)&0xFF)/255.0f, (zones[i].color&0xFF)/255.0f, 0.3f); + glBegin(GL_QUADS); + glVertex3f(zones[i].x1, zones[i].y1, z); + glVertex3f(zones[i].x2, zones[i].y1, z); + glVertex3f(zones[i].x2, zones[i].y2, z); + glVertex3f(zones[i].x1, zones[i].y2, z); + glEnd(); + } glDisable(GL_BLEND); glEnable(GL_TEXTURE_2D); } @@ -833,7 +836,7 @@ void drawminimap(int w, int h) renderstrips(); glDepthFunc(GL_LESS); rendermapmodels(); - renderzone(mapdims[7]); + renderzones(mapdims[7]); //renderentities();// IMHO better done by radar itself, if at all resettmu(0); float hf = hdr.waterlevel-0.3f; @@ -877,18 +880,19 @@ void cleanupgl() void drawzone(int *x1, int *x2, int *y1, int *y2, int *color) { - zonex1 = *x1; zoney1 = *y1; - zonex2 = *x2; zoney2 = *y2; - if(*color) zonecolor = *color; - else zonecolor = 0x00FF00; + zone &newzone = zones.add(); + newzone.x1 = *x1; newzone.x2 = *x2; + newzone.y1 = *y1; newzone.y2 = *y2; + newzone.color = *color ? *color : 0x00FF00; clearminimap(); } COMMAND(drawzone, "iiiii"); -void resetzone() +void resetzones() { - zonex1 = zoney1 = zonex2 = zoney2 = 0; + zones.shrink(0); } +COMMAND(resetzones, ""); int xtraverts;