diff --git a/src/engine/3dgui.cpp b/src/engine/3dgui.cpp index 0421512..a347c1b 100644 --- a/src/engine/3dgui.cpp +++ b/src/engine/3dgui.cpp @@ -983,7 +983,6 @@ struct gui : g3d_gui void draw() { cb->gui(*this, layoutpass); - varray::disable(); } }; @@ -1224,6 +1223,8 @@ void g3d_render() loopvrev(guis2d) guis2d[i].draw(); glDisable(GL_BLEND); + + varray::disable(); } flusheditors(); diff --git a/src/engine/rendergl.cpp b/src/engine/rendergl.cpp index 9c0ea4e..c1a9efe 100644 --- a/src/engine/rendergl.cpp +++ b/src/engine/rendergl.cpp @@ -1702,7 +1702,6 @@ void hudquad(float x, float y, float w, float h, float tx, float ty, float tw, f varray::attribf(x, y+h); varray::attribf(tx, ty + th); varray::attribf(x+w, y+h); varray::attribf(tx + tw, ty + th); varray::end(); - varray::disable(); } void debugquad(float x, float y, float w, float h, float tx, float ty, float tw, float th) @@ -2394,11 +2393,7 @@ void drawdamagecompass(int w, int h) scale -= float(curtime)/damagecompassfade; damagedirs[i] = scale > 0 ? (pow(logscale, scale) - 1) / (logscale - 1) : 0; } - if(dirs) - { - varray::end(); - varray::disable(); - } + if(dirs) varray::end(); } int damageblendmillis = 0; @@ -2694,6 +2689,8 @@ void gl_drawhud(int w, int h) drawcrosshair(w, h); + varray::disable(); + glDisable(GL_BLEND); if(frametimer) diff --git a/src/fpsgame/capture.h b/src/fpsgame/capture.h index f3cf773..44dd943 100644 --- a/src/fpsgame/capture.h +++ b/src/fpsgame/capture.h @@ -440,16 +440,21 @@ struct captureclientmode : clientmode } else { - if(!blips) glBegin(GL_QUADS); + if(!blips) + { + varray::defvertex(2); + varray::deftexcoord0(); + varray::begin(GL_QUADS); + } float x = 0.5f*(dir.x*fw/blipsize - fw), y = 0.5f*(dir.y*fh/blipsize - fh); - glTexCoord2f(0.0f, 0.0f); glVertex2f(x, y); - glTexCoord2f(1.0f, 0.0f); glVertex2f(x+fw, y); - glTexCoord2f(1.0f, 1.0f); glVertex2f(x+fw, y+fh); - glTexCoord2f(0.0f, 1.0f); glVertex2f(x, y+fh); + varray::attribf(x, y); varray::attribf(0, 0); + varray::attribf(x+fw, y); varray::attribf(1, 0); + varray::attribf(x+fw, y+fh); varray::attribf(1, 1); + varray::attribf(x, y+fh); varray::attribf(0, 1); } blips++; } - if(blips && !basenumbers) glEnd(); + if(blips && !basenumbers) varray::end(); } int respawnwait(fpsent *d) diff --git a/src/fpsgame/client.cpp b/src/fpsgame/client.cpp index cd22006..d025198 100644 --- a/src/fpsgame/client.cpp +++ b/src/fpsgame/client.cpp @@ -17,25 +17,29 @@ namespace game vec pos = vec(d->o).sub(minimapcenter).mul(minimapscale).add(0.5f), dir; vecfromyawpitch(camera1->yaw, 0, 1, 0, dir); float scale = calcradarscale(); - glBegin(GL_TRIANGLE_FAN); + varray::defvertex(2); + varray::deftexcoord0(); + varray::begin(GL_TRIANGLE_FAN); loopi(16) { - vec tc = vec(dir).rotate_around_z(i/16.0f*2*M_PI); - glTexCoord2f(1.0f - (pos.x + tc.x*scale*minimapscale.x), pos.y + tc.y*scale*minimapscale.y); vec v = vec(0, -1, 0).rotate_around_z(i/16.0f*2*M_PI); - glVertex2f(x + 0.5f*s*(1.0f + v.x), y + 0.5f*s*(1.0f + v.y)); + varray::attribf(x + 0.5f*s*(1.0f + v.x), y + 0.5f*s*(1.0f + v.y)); + vec tc = vec(dir).rotate_around_z(i/16.0f*2*M_PI); + varray::attribf(1.0f - (pos.x + tc.x*scale*minimapscale.x), pos.y + tc.y*scale*minimapscale.y); } - glEnd(); + varray::end(); } void drawradar(float x, float y, float s) { - glBegin(GL_TRIANGLE_STRIP); - glTexCoord2f(0.0f, 0.0f); glVertex2f(x, y); - glTexCoord2f(1.0f, 0.0f); glVertex2f(x+s, y); - glTexCoord2f(0.0f, 1.0f); glVertex2f(x, y+s); - glTexCoord2f(1.0f, 1.0f); glVertex2f(x+s, y+s); - glEnd(); + varray::defvertex(2); + varray::deftexcoord0(); + varray::begin(GL_TRIANGLE_STRIP); + varray::attribf(x, y); varray::attribf(0, 0); + varray::attribf(x+s, y); varray::attribf(1, 0); + varray::attribf(x, y+s); varray::attribf(0, 1); + varray::attribf(x+s, y+s); varray::attribf(1, 1); + varray::end(); } void drawteammate(fpsent *d, float x, float y, float s, fpsent *o, float scale) @@ -50,10 +54,10 @@ namespace game by = y + s*0.5f*(1.0f + dir.y); vec v(-0.5f, -0.5f, 0); v.rotate_around_z((90+o->yaw-camera1->yaw)*RAD); - glTexCoord2f(0.0f, 0.0f); glVertex2f(bx + bs*v.x, by + bs*v.y); - glTexCoord2f(1.0f, 0.0f); glVertex2f(bx + bs*v.y, by - bs*v.x); - glTexCoord2f(1.0f, 1.0f); glVertex2f(bx - bs*v.x, by - bs*v.y); - glTexCoord2f(0.0f, 1.0f); glVertex2f(bx - bs*v.y, by + bs*v.x); + varray::attribf(bx + bs*v.x, by + bs*v.y); varray::attribf(0, 0); + varray::attribf(bx + bs*v.y, by - bs*v.x); varray::attribf(1, 0); + varray::attribf(bx - bs*v.x, by - bs*v.y); varray::attribf(1, 1); + varray::attribf(bx - bs*v.y, by + bs*v.x); varray::attribf(0, 1); } void drawteammates(fpsent *d, float x, float y, float s) @@ -69,12 +73,14 @@ namespace game if(!alive++) { settexture(isteam(d->team, player1->team) ? "packages/hud/blip_blue_alive.png" : "packages/hud/blip_red_alive.png"); - glBegin(GL_QUADS); + varray::defvertex(2); + varray::deftexcoord0(); + varray::begin(GL_QUADS); } drawteammate(d, x, y, s, o, scale); } } - if(alive) glEnd(); + if(alive) varray::end(); loopv(players) { fpsent *o = players[i]; @@ -83,12 +89,14 @@ namespace game if(!dead++) { settexture(isteam(d->team, player1->team) ? "packages/hud/blip_blue_dead.png" : "packages/hud/blip_red_dead.png"); - glBegin(GL_QUADS); + varray::defvertex(2); + varray::deftexcoord0(); + varray::begin(GL_QUADS); } drawteammate(d, x, y, s, o, scale); } } - if(dead) glEnd(); + if(dead) varray::end(); } #include "capture.h" diff --git a/src/fpsgame/fps.cpp b/src/fpsgame/fps.cpp index 93e3633..7586bdf 100644 --- a/src/fpsgame/fps.cpp +++ b/src/fpsgame/fps.cpp @@ -664,13 +664,15 @@ namespace game void drawicon(int icon, float x, float y, float sz) { settexture("packages/hud/items.png"); - glBegin(GL_TRIANGLE_STRIP); float tsz = 0.25f, tx = tsz*(icon%4), ty = tsz*(icon/4); - glTexCoord2f(tx, ty); glVertex2f(x, y); - glTexCoord2f(tx+tsz, ty); glVertex2f(x+sz, y); - glTexCoord2f(tx, ty+tsz); glVertex2f(x, y+sz); - glTexCoord2f(tx+tsz, ty+tsz); glVertex2f(x+sz, y+sz); - glEnd(); + varray::defvertex(2); + varray::deftexcoord0(); + varray::begin(GL_TRIANGLE_STRIP); + varray::attribf(x, y); varray::attribf(tx, ty); + varray::attribf(x+sz, y); varray::attribf(tx+tsz, ty); + varray::attribf(x, y+sz); varray::attribf(tx, ty+tsz); + varray::attribf(x+sz, y+sz); varray::attribf(tx+tsz, ty+tsz); + varray::end(); } float abovegameplayhud(int w, int h)