clean up texture boxes in menus
too many copies of the same few lines...
This commit is contained in:
+5
-46
@@ -313,17 +313,8 @@ struct mitemimagemanual : mitemmanual
|
||||
int xs = 0;
|
||||
if(image)
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, image->id);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glColor3f(1, 1, 1);
|
||||
xs = (FONTH*image->xs)/image->ys;
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
glTexCoord2f(0, 0); glVertex2f(x, y);
|
||||
glTexCoord2f(1, 0); glVertex2f(x+xs, y);
|
||||
glTexCoord2f(0, 1); glVertex2f(x, y+FONTH);
|
||||
glTexCoord2f(1, 1); glVertex2f(x+xs, y+FONTH);
|
||||
glEnd();
|
||||
xtraverts += 4;
|
||||
framedquadtexture(image->id, x, y, xs, FONTH, 0, 255, true);
|
||||
}
|
||||
draw_text(text, !image || *text == '\t' ? x : x+xs + FONTH/2, y);
|
||||
if(altfont && strchr(text, '\a'))
|
||||
@@ -345,17 +336,7 @@ struct mitemimagemanual : mitemmanual
|
||||
w += FONTH;
|
||||
int xs = (2 * VIRTW - w) / 5, ys = (xs * image->ys) / image->xs;
|
||||
x = (6 * VIRTW + w - 2 * xs) / 4; y = VIRTH - ys / 2;
|
||||
blendbox(x - FONTH, y - FONTH, x + xs + FONTH, y + ys + FONTH, false);
|
||||
glBindTexture(GL_TEXTURE_2D, image->id);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glColor3f(1, 1, 1);
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
glTexCoord2f(0, 0); glVertex2f(x, y);
|
||||
glTexCoord2f(1, 0); glVertex2f(x+xs, y);
|
||||
glTexCoord2f(0, 1); glVertex2f(x, y+ys);
|
||||
glTexCoord2f(1, 1); glVertex2f(x+xs, y+ys);
|
||||
glEnd();
|
||||
xtraverts += 4;
|
||||
framedquadtexture(image->id, x, y, xs, ys, FONTH);
|
||||
}
|
||||
}
|
||||
else mitemmanual::render(x, y, w);
|
||||
@@ -438,19 +419,7 @@ struct mitemmaploadmanual : mitemmanual
|
||||
w += FONTH;
|
||||
int xs = (2 * VIRTW - w) / 5, ys = (xs * image->ys) / image->xs;
|
||||
x = (6 * VIRTW + w - 2 * xs) / 4; y = VIRTH - ys / 2;
|
||||
|
||||
blendbox(x - FONTH, y - FONTH, x + xs + FONTH, y + ys + FONTH, false);
|
||||
glBindTexture(GL_TEXTURE_2D, image->id); // I just copy&pasted this...
|
||||
glDisable(GL_BLEND);
|
||||
glColor3f(1, 1, 1);
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
glTexCoord2f(0, 0); glVertex2f(x, y);
|
||||
glTexCoord2f(1, 0); glVertex2f(x+xs, y);
|
||||
glTexCoord2f(0, 1); glVertex2f(x, y+ys);
|
||||
glTexCoord2f(1, 1); glVertex2f(x+xs, y+ys);
|
||||
glEnd();
|
||||
xtraverts += 4;
|
||||
glEnable(GL_BLEND);
|
||||
framedquadtexture(image->id, x, y, xs, ys, FONTH);
|
||||
if(maptitle[0])
|
||||
{
|
||||
filtertext(maptitle, maptitle, FTXT__MAPMSG);
|
||||
@@ -1342,18 +1311,8 @@ void rendermenutexturepreview(char *previewtexture, int w)
|
||||
int xs = (VIRTW * menutexturesize) / 4, ys = (xs * pt->ys) / pt->xs, ysmax = (3 * VIRTH) / 2;
|
||||
if(ys > ysmax) ys = ysmax, xs = (ys * pt->xs) / pt->ys;
|
||||
int x = (6 * VIRTW + w - 2 * xs) / 4, y = VIRTH - ys / 2 - 2 * FONTH;
|
||||
blendbox(x - FONTH/2, y - FONTH/2, x + xs + FONTH/2, y + ys + FONTH/2, false);
|
||||
glBindTexture(GL_TEXTURE_2D, pt->id);
|
||||
glDisable(GL_BLEND);
|
||||
glColor3f(1, 1, 1);
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
glTexCoord2f(0, 0); glVertex2f(x, y);
|
||||
glTexCoord2f(1, 0); glVertex2f(x+xs, y);
|
||||
glTexCoord2f(0, 1); glVertex2f(x, y+ys);
|
||||
glTexCoord2f(1, 1); glVertex2f(x+xs, y+ys);
|
||||
glEnd();
|
||||
xtraverts += 4;
|
||||
glEnable(GL_BLEND);
|
||||
extern int fullbrightlevel;
|
||||
framedquadtexture(pt->id, x, y, xs, ys, FONTH / 2, fullbrightlevel);
|
||||
defformatstring(res)("%dx%d", pt->xs, pt->ys);
|
||||
draw_text(res, x, y + ys + 2 * FONTH);
|
||||
}
|
||||
|
||||
@@ -260,12 +260,14 @@ extern void disablepolygonoffset(GLenum type, bool restore = true);
|
||||
extern void line(int x1, int y1, float z1, int x2, int y2, float z2);
|
||||
extern void line(int x1, int y1, int x2, int y2, color *c = NULL);
|
||||
extern void box(block &b, float z1, float z2, float z3, float z4);
|
||||
extern void box2d(int x1, int y1, int x2, int y2, int gray);
|
||||
extern void dot(int x, int y, float z);
|
||||
extern void linestyle(float width, int r, int g, int b);
|
||||
extern void blendbox(int x1, int y1, int x2, int y2, bool border, int tex = -1, color *c = NULL);
|
||||
extern void quad(GLuint tex, float x, float y, float s, float tx, float ty, float tsx, float tsy = 0);
|
||||
extern void quad(GLuint tex, vec &c1, vec &c2, float tx, float ty, float tsx, float tsy);
|
||||
extern void circle(GLuint tex, float x, float y, float r, float tx, float ty, float tr, int subdiv = 32);
|
||||
extern void framedquadtexture(GLuint tex, int x, int y, int xs, int ys, int border = 0, int backlight = 255, bool blend = false);
|
||||
extern void setperspective(float fovy, float aspect, float nearplane, float farplane);
|
||||
extern void sethudgunperspective(bool on);
|
||||
extern void gl_drawframe(int w, int h, float changelod, float curfps);
|
||||
|
||||
+29
-7
@@ -235,6 +235,17 @@ void box(block &b, float z1, float z2, float z3, float z4)
|
||||
xtraverts += 4;
|
||||
}
|
||||
|
||||
void box2d(int x1, int y1, int x2, int y2, int gray)
|
||||
{
|
||||
glColor3ub(gray, gray, gray);
|
||||
glBegin(GL_LINE_LOOP);
|
||||
glVertex2f(x1, y1);
|
||||
glVertex2f(x2, y1);
|
||||
glVertex2f(x2, y2);
|
||||
glVertex2f(x1, y2);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
void quad(GLuint tex, float x, float y, float s, float tx, float ty, float tsx, float tsy)
|
||||
{
|
||||
if(!tsy) tsy = tsx;
|
||||
@@ -371,13 +382,7 @@ 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);
|
||||
glColor3f(0.6f, 0.6f, 0.6f);
|
||||
glBegin(GL_LINE_LOOP);
|
||||
glVertex2f(x1, y1);
|
||||
glVertex2f(x2, y1);
|
||||
glVertex2f(x2, y2);
|
||||
glVertex2f(x1, y2);
|
||||
glEnd();
|
||||
box2d(x1, y1, x2, y2, 155);
|
||||
glEnable(GL_BLEND);
|
||||
}
|
||||
|
||||
@@ -385,6 +390,23 @@ void blendbox(int x1, int y1, int x2, int y2, bool border, int tex, color *c)
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
|
||||
void framedquadtexture(GLuint tex, int x, int y, int xs, int ys, int border, int backlight, bool blend)
|
||||
{
|
||||
if(border) blendbox(x - border, y - border, x + xs + border, y + ys + border, false);
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
if(blend) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
else glDisable(GL_BLEND);
|
||||
glColor3ub(backlight, backlight, backlight);
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
glTexCoord2f(0, 0); glVertex2f(x, y);
|
||||
glTexCoord2f(1, 0); glVertex2f(x + xs, y);
|
||||
glTexCoord2f(0, 1); glVertex2f(x, y + ys);
|
||||
glTexCoord2f(1, 1); glVertex2f(x + xs, y + ys);
|
||||
glEnd();
|
||||
xtraverts += 4;
|
||||
if(!blend) glEnable(GL_BLEND);
|
||||
}
|
||||
|
||||
VARP(aboveheadiconsize, 0, 50, 1000);
|
||||
VARP(aboveheadiconfadetime, 1, 2000, 10000);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user