From 0e52f84a7018a16f78167202c9a3707c899040ce Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Mon, 15 Mar 2010 18:34:43 +0000 Subject: [PATCH] removing some GL_QUADS usage git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@4790 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/menus.cpp | 4 ++-- source/src/rendergl.cpp | 20 +++++++++----------- source/src/renderhud.cpp | 14 +++++++------- source/src/shadow.cpp | 2 +- source/src/texture.cpp | 2 +- 5 files changed, 20 insertions(+), 22 deletions(-) diff --git a/source/src/menus.cpp b/source/src/menus.cpp index 2dd5ce13..c3184c9b 100644 --- a/source/src/menus.cpp +++ b/source/src/menus.cpp @@ -249,7 +249,7 @@ struct mitemimagemanual : mitemmanual glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor3f(1, 1, 1); xs = (FONTH*image->xs)/image->ys; - glBegin(GL_QUADS); + glBegin(GL_TRIANGLE_FAN); glTexCoord2f(0, 0); glVertex2f(x, y); glTexCoord2f(1, 0); glVertex2f(x+xs, y); glTexCoord2f(1, 1); glVertex2f(x+xs, y+FONTH); @@ -281,7 +281,7 @@ struct mitemimagemanual : mitemmanual glBindTexture(GL_TEXTURE_2D, image->id); // I just copy&pasted this... glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // could pls someone with actual OpenGL-knowledge check this? glColor3f(1, 1, 1); - glBegin(GL_QUADS); + glBegin(GL_TRIANGLE_FAN); glTexCoord2f(0, 0); glVertex2f(x, y); glTexCoord2f(1, 0); glVertex2f(x+xs, y); glTexCoord2f(1, 1); glVertex2f(x+xs, y+ys); diff --git a/source/src/rendergl.cpp b/source/src/rendergl.cpp index 4da6de8c..0c1cf16a 100644 --- a/source/src/rendergl.cpp +++ b/source/src/rendergl.cpp @@ -176,7 +176,7 @@ void disablepolygonoffset(GLenum type, bool restore) void line(int x1, int y1, float z1, int x2, int y2, float z2) { - glBegin(GL_QUADS); + glBegin(GL_TRIANGLE_FAN); glVertex3f((float)x1, (float)y1, z1); glVertex3f((float)x1, y1+0.01f, z1); glVertex3f((float)x2, y2+0.01f, z2); @@ -205,7 +205,7 @@ void linestyle(float width, int r, int g, int b) void box(block &b, float z1, float z2, float z3, float z4) { - glBegin(GL_QUADS); + glBegin(GL_TRIANGLE_FAN); glVertex3f((float)b.x, (float)b.y, z1); glVertex3f((float)b.x+b.xs, (float)b.y, z2); glVertex3f((float)b.x+b.xs, (float)b.y+b.ys, z3); @@ -218,7 +218,7 @@ void quad(GLuint tex, float x, float y, float s, float tx, float ty, float tsx, { if(!tsy) tsy = tsx; glBindTexture(GL_TEXTURE_2D, tex); - glBegin(GL_QUADS); + glBegin(GL_TRIANGLE_FAN); glTexCoord2f(tx, ty); glVertex2f(x, y); glTexCoord2f(tx+tsx, ty); glVertex2f(x+s, y); glTexCoord2f(tx+tsx, ty+tsy); glVertex2f(x+s, y+s); @@ -231,7 +231,7 @@ void quad(GLuint tex, const vec &c1, const vec &c2, float tx, float ty, float ts { if(!tsy) tsy = tsx; glBindTexture(GL_TEXTURE_2D, tex); - glBegin(GL_QUADS); + glBegin(GL_TRIANGLE_FAN); glTexCoord2f(tx, ty); glVertex3f(c1.x, c1.y, c1.z); glTexCoord2f(tx+tsx, ty); glVertex3f(c2.x, c1.y, c1.z); glTexCoord2f(tx+tsx, ty+tsy); glVertex3f(c2.x, c2.y, c2.z); @@ -259,7 +259,7 @@ void circle(GLuint tex, float x, float y, float r, float tx, float ty, float tr, void dot(int x, int y, float z) { const float DOF = 0.1f; - glBegin(GL_QUADS); + glBegin(GL_TRIANGLE_FAN); glVertex3f(x-DOF, y-DOF, z); glVertex3f(x+DOF, y-DOF, z); glVertex3f(x+DOF, y+DOF, z); @@ -311,7 +311,7 @@ void blendbox(int x1, int y1, int x2, int y2, bool border, int tex, color *c) xtexcut = (float)(((i+1)*texw)-(x2-x1))/texw; } - glBegin(GL_QUADS); + glBegin(GL_TRIANGLE_FAN); glTexCoord2f(0, 0); glVertex2f((float)x1+texw*i, (float)y1+texh*j); glTexCoord2f(1-xtexcut, 0); glVertex2f(x1+texw*(i+1)-xboxcut, (float)y1+texh*j); glTexCoord2f(1-xtexcut, 1-ytexcut); glVertex2f(x1+texw*(i+1)-xboxcut, (float)y1+texh*(j+1)-yboxcut); @@ -337,7 +337,7 @@ void blendbox(int x1, int y1, int x2, int y2, bool border, int tex, color *c) glColor3f(0.5f, 0.5f, 0.5f); } - glBegin(GL_QUADS); + glBegin(GL_TRIANGLE_FAN); glTexCoord2f(0, 0); glVertex2f(x1, y1); glTexCoord2f(1, 0); glVertex2f(x2, y1); glTexCoord2f(1, 1); glVertex2f(x2, y2); @@ -350,15 +350,13 @@ void blendbox(int x1, int y1, int x2, int y2, bool border, int tex, color *c) { glDisable(GL_BLEND); if(tex>=0) glDisable(GL_TEXTURE_2D); - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - glBegin(GL_QUADS); glColor3f(0.6f, 0.6f, 0.6f); + glBegin(GL_LINE_LOOP); glVertex2f(x1, y1); glVertex2f(x2, y1); glVertex2f(x2, y2); glVertex2f(x1, y2); glEnd(); - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glEnable(GL_BLEND); } @@ -681,7 +679,7 @@ void drawreflection(float hf, int w, int h, float changelod, bool refract) glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4ubv(hdr.watercolor); - glBegin(GL_QUADS); + glBegin(GL_TRIANGLE_FAN); glVertex2f(0, 1); glVertex2f(1, 1); glVertex2f(1, 0); diff --git a/source/src/renderhud.cpp b/source/src/renderhud.cpp index d2ec9569..26d9928e 100644 --- a/source/src/renderhud.cpp +++ b/source/src/renderhud.cpp @@ -95,8 +95,8 @@ void drawscope() x2 = VIRTW/2 + w/2; float s1 = VIRTW/16, s2 = VIRTH/24; glDisable(GL_BLEND); - glBegin(GL_QUADS); - glColor3ub( 0, 0, 0); + glColor3ub(0, 0, 0); + glBegin(GL_TRIANGLE_FAN); glVertex2f( 0, 0); glVertex2f(VIRTW, 0); glVertex2f(VIRTW, 4*s2); glVertex2f( 0, 4*s2); glVertex2f( 0, 4*s2); glVertex2f( 3*s1, 4*s2); glVertex2f( 3*s1, 20*s2); glVertex2f( 0, 20*s2); glVertex2f( 0, 20*s2); glVertex2f(VIRTW, 20*s2); glVertex2f(VIRTW, VIRTH); glVertex2f( 0, VIRTH); @@ -111,8 +111,8 @@ void drawscope() glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBindTexture(GL_TEXTURE_2D, scopetex->id); - glBegin(GL_QUADS); - glColor3ub(255,255,255); + glColor3ub(255, 255, 255); + glBegin(GL_TRIANGLE_FAN); glTexCoord2f(0, 0); glVertex2f(x1, 0); glTexCoord2f(1, 0); glVertex2f(x2, 0); glTexCoord2f(1, 1); glVertex2f(x2, VIRTH); @@ -170,7 +170,7 @@ void drawcrosshair(playerent *p, int n, color *c, float size) } float s = size>0 ? size : (float)crosshairsize; float chsize = s * (p->weaponsel->type==GUN_ASSAULT && p->weaponsel->shots > 3 ? 1.4f : 1.0f) * (n==CROSSHAIR_TEAMMATE ? 2.0f : 1.0f); - glBegin(GL_QUADS); + glBegin(GL_TRIANGLE_FAN); glTexCoord2f(0, 0); glVertex2f(VIRTW/2 - chsize, VIRTH/2 - chsize); glTexCoord2f(1, 0); glVertex2f(VIRTW/2 + chsize, VIRTH/2 - chsize); glTexCoord2f(1, 1); glVertex2f(VIRTW/2 + chsize, VIRTH/2 + chsize); @@ -510,7 +510,7 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4ub(hdr.watercolor[0], hdr.watercolor[1], hdr.watercolor[2], 102); - glBegin(GL_QUADS); + glBegin(GL_TRIANGLE_FAN); glVertex2f(0, 0); glVertex2f(VIRTW, 0); glVertex2f(VIRTW, VIRTH); @@ -531,7 +531,7 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat fade *= float(damageblendmillis - lastmillis)/damagescreenfade; glColor4f(fade, fade, fade, fade); - glBegin(GL_QUADS); + glBegin(GL_TRIANGLE_FAN); glTexCoord2f(0, 0); glVertex2f(0, 0); glTexCoord2f(1, 0); glVertex2f(VIRTW, 0); glTexCoord2f(1, 1); glVertex2f(VIRTW, VIRTH); diff --git a/source/src/shadow.cpp b/source/src/shadow.cpp index 44a9afd8..58e74cef 100644 --- a/source/src/shadow.cpp +++ b/source/src/shadow.cpp @@ -271,7 +271,7 @@ static void rendershadowtiles() if(!shadowtile) { - glBegin(GL_QUADS); + glBegin(GL_TRIANGLE_FAN); glVertex2f(clipy1, clipx1); glVertex2f(clipy1, clipx2); glVertex2f(clipy2, clipx2); diff --git a/source/src/texture.cpp b/source/src/texture.cpp index e9bcc3f6..e7ac7af0 100644 --- a/source/src/texture.cpp +++ b/source/src/texture.cpp @@ -481,7 +481,7 @@ void draw_envbox_face(float s0, float t0, float x0, float y0, float z0, Texture *tex) { glBindTexture(GL_TEXTURE_2D, tex->id); - glBegin(GL_QUADS); + glBegin(GL_TRIANGLE_FAN); glTexCoord2f(s3, t3); glVertex3f(x3, y3, z3); glTexCoord2f(s2, t2); glVertex3f(x2, y2, z2); glTexCoord2f(s1, t1); glVertex3f(x1, y1, z1);