remove last bits of immediate-mode usage

master
Lee Salzman 2013-03-01 05:41:16 +02:00
parent 6769c44a33
commit c65e62159c
5 changed files with 51 additions and 38 deletions

View File

@ -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();

View File

@ -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)

View File

@ -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)

View File

@ -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"

View File

@ -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)