mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-12 06:51:09 +00:00
Rewrite the 2d code to use a scrap.
This severely reduces the calles to BindTexture, and more importantly, glUseProgram, EnableVertexAttribArray etc. The biggest changes are: o icons and text are all in the one giant texture o icons and text are mixed in the one queue This gave ~9% speedup for bigass1 (159->174fps).
This commit is contained in:
parent
df35b22af4
commit
b25de4d995
3 changed files with 146 additions and 178 deletions
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
void GLSL_Set2D (void);
|
void GLSL_Set2D (void);
|
||||||
void GLSL_Set2DScaled (void);
|
void GLSL_Set2DScaled (void);
|
||||||
|
void GLSL_End2D (void);
|
||||||
void GLSL_DrawReset (void);
|
void GLSL_DrawReset (void);
|
||||||
void GLSL_FlushText (void);
|
void GLSL_FlushText (void);
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@
|
||||||
#include "r_internal.h"
|
#include "r_internal.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int texnum;
|
subpic_t *subpic;
|
||||||
} glpic_t;
|
} glpic_t;
|
||||||
|
|
||||||
typedef struct cachepic_s {
|
typedef struct cachepic_s {
|
||||||
|
@ -67,6 +67,11 @@ typedef struct cachepic_s {
|
||||||
qpic_t *pic;
|
qpic_t *pic;
|
||||||
} cachepic_t;
|
} cachepic_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
float xyst[4];
|
||||||
|
float color[4];
|
||||||
|
} drawvert_t;
|
||||||
|
|
||||||
static const char quakeicon_vert[] =
|
static const char quakeicon_vert[] =
|
||||||
#include "quakeico.vc"
|
#include "quakeico.vc"
|
||||||
;
|
;
|
||||||
|
@ -83,30 +88,12 @@ static float proj_matrix[16];
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
int program;
|
int program;
|
||||||
shaderparam_t charmap;
|
shaderparam_t texture;
|
||||||
shaderparam_t palette;
|
shaderparam_t palette;
|
||||||
shaderparam_t matrix;
|
shaderparam_t matrix;
|
||||||
shaderparam_t vertex;
|
shaderparam_t vertex;
|
||||||
shaderparam_t color;
|
shaderparam_t color;
|
||||||
shaderparam_t dchar;
|
} quake_2d = {
|
||||||
} quake_text = {
|
|
||||||
0,
|
|
||||||
{"texture", 1},
|
|
||||||
{"palette", 1},
|
|
||||||
{"mvp_mat", 1},
|
|
||||||
{"vertex", 0},
|
|
||||||
{"vcolor", 0},
|
|
||||||
{"dchar", 0},
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct {
|
|
||||||
int program;
|
|
||||||
shaderparam_t icon;
|
|
||||||
shaderparam_t palette;
|
|
||||||
shaderparam_t matrix;
|
|
||||||
shaderparam_t vertex;
|
|
||||||
shaderparam_t color;
|
|
||||||
} quake_icon = {
|
|
||||||
0,
|
0,
|
||||||
{"texture", 1},
|
{"texture", 1},
|
||||||
{"palette", 1},
|
{"palette", 1},
|
||||||
|
@ -115,13 +102,14 @@ static struct {
|
||||||
{"vcolor", 0},
|
{"vcolor", 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static scrap_t *draw_scrap; // hold all 2d images
|
||||||
static byte white_block[8 * 8];
|
static byte white_block[8 * 8];
|
||||||
static dstring_t *char_queue;
|
static dstring_t *char_queue;
|
||||||
static int char_texture;
|
static qpic_t *conchars;
|
||||||
static int conback_texture;
|
static int conback_texture;
|
||||||
static qpic_t *crosshair_pic;
|
static qpic_t *crosshair_pic;
|
||||||
static qpic_t *white_pic;
|
static qpic_t *white_pic;
|
||||||
static qpic_t *backtile_pic;
|
//FIXME static qpic_t *backtile_pic;
|
||||||
static hashtab_t *pic_cache;
|
static hashtab_t *pic_cache;
|
||||||
static cvar_t *glsl_conback_texnum;
|
static cvar_t *glsl_conback_texnum;
|
||||||
|
|
||||||
|
@ -134,10 +122,11 @@ make_glpic (const char *name, qpic_t *p)
|
||||||
if (p) {
|
if (p) {
|
||||||
// FIXME is alignment ok?
|
// FIXME is alignment ok?
|
||||||
pic = malloc (sizeof (qpic_t) + sizeof (glpic_t));
|
pic = malloc (sizeof (qpic_t) + sizeof (glpic_t));
|
||||||
*pic = *p;
|
pic->width = p->width;
|
||||||
|
pic->height = p->height;
|
||||||
gl = (glpic_t *) pic->data;
|
gl = (glpic_t *) pic->data;
|
||||||
gl->texnum = GLSL_LoadQuakeTexture (name, p->width, p->height,
|
gl->subpic = GLSL_ScrapSubpic (draw_scrap, pic->width, pic->height);
|
||||||
p->data);
|
GLSL_SubpicUpdate (gl->subpic, p->data, 1);
|
||||||
}
|
}
|
||||||
return pic;
|
return pic;
|
||||||
}
|
}
|
||||||
|
@ -147,7 +136,7 @@ pic_free (qpic_t *pic)
|
||||||
{
|
{
|
||||||
glpic_t *gl = (glpic_t *) pic->data;
|
glpic_t *gl = (glpic_t *) pic->data;
|
||||||
|
|
||||||
GLSL_ReleaseTexture (gl->texnum);
|
GLSL_SubpicDelete (gl->subpic);
|
||||||
free (pic);
|
free (pic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,44 +184,59 @@ pic_data (const char *name, int w, int h, const byte *data)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
make_quad (qpic_t *pic, float x, float y, int w, int h,
|
make_quad (qpic_t *pic, float x, float y, int w, int h,
|
||||||
int srcx, int srcy, int srcw, int srch, float verts[6][4])
|
int srcx, int srcy, int srcw, int srch, drawvert_t verts[6],
|
||||||
|
float *color)
|
||||||
{
|
{
|
||||||
|
glpic_t *gl;
|
||||||
|
subpic_t *sp;
|
||||||
float sl, sh, tl, th;
|
float sl, sh, tl, th;
|
||||||
|
|
||||||
sl = (float) srcx / (float) pic->width;
|
gl = (glpic_t *) pic->data;
|
||||||
sh = sl + (float) srcw / (float) pic->width;
|
sp = gl->subpic;
|
||||||
tl = (float) srcy / (float) pic->height;
|
|
||||||
th = tl + (float) srch / (float) pic->height;
|
|
||||||
|
|
||||||
verts[0][0] = x;
|
srcx += sp->rect->x;
|
||||||
verts[0][1] = y;
|
srcy += sp->rect->y;
|
||||||
verts[0][2] = sl;
|
sl = (srcx + 0.25) * sp->size;
|
||||||
verts[0][3] = tl;
|
sh = sl + (srcw - 0.5) * sp->size;
|
||||||
|
tl = (srcy + 0.25) * sp->size;
|
||||||
|
th = tl + (srch - 0.5) * sp->size;
|
||||||
|
|
||||||
verts[1][0] = x + w;
|
verts[0].xyst[0] = x;
|
||||||
verts[1][1] = y;
|
verts[0].xyst[1] = y;
|
||||||
verts[1][2] = sh;
|
verts[0].xyst[2] = sl;
|
||||||
verts[1][3] = tl;
|
verts[0].xyst[3] = tl;
|
||||||
|
|
||||||
verts[2][0] = x + w;
|
verts[1].xyst[0] = x + w;
|
||||||
verts[2][1] = y + h;
|
verts[1].xyst[1] = y;
|
||||||
verts[2][2] = sh;
|
verts[1].xyst[2] = sh;
|
||||||
verts[2][3] = th;
|
verts[1].xyst[3] = tl;
|
||||||
|
|
||||||
verts[3][0] = x;
|
verts[2].xyst[0] = x + w;
|
||||||
verts[3][1] = y;
|
verts[2].xyst[1] = y + h;
|
||||||
verts[3][2] = sl;
|
verts[2].xyst[2] = sh;
|
||||||
verts[3][3] = tl;
|
verts[2].xyst[3] = th;
|
||||||
|
|
||||||
verts[4][0] = x + w;
|
verts[3].xyst[0] = x;
|
||||||
verts[4][1] = y + h;
|
verts[3].xyst[1] = y;
|
||||||
verts[4][2] = sh;
|
verts[3].xyst[2] = sl;
|
||||||
verts[4][3] = th;
|
verts[3].xyst[3] = tl;
|
||||||
|
|
||||||
verts[5][0] = x;
|
verts[4].xyst[0] = x + w;
|
||||||
verts[5][1] = y + h;
|
verts[4].xyst[1] = y + h;
|
||||||
verts[5][2] = sl;
|
verts[4].xyst[2] = sh;
|
||||||
verts[5][3] = th;
|
verts[4].xyst[3] = th;
|
||||||
|
|
||||||
|
verts[5].xyst[0] = x;
|
||||||
|
verts[5].xyst[1] = y + h;
|
||||||
|
verts[5].xyst[2] = sl;
|
||||||
|
verts[5].xyst[3] = th;
|
||||||
|
|
||||||
|
QuatCopy (color, verts[0].color);
|
||||||
|
QuatCopy (color, verts[1].color);
|
||||||
|
QuatCopy (color, verts[2].color);
|
||||||
|
QuatCopy (color, verts[3].color);
|
||||||
|
QuatCopy (color, verts[4].color);
|
||||||
|
QuatCopy (color, verts[5].color);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -240,35 +244,15 @@ draw_pic (float x, float y, int w, int h, qpic_t *pic,
|
||||||
int srcx, int srcy, int srcw, int srch,
|
int srcx, int srcy, int srcw, int srch,
|
||||||
float *color)
|
float *color)
|
||||||
{
|
{
|
||||||
glpic_t *gl;
|
drawvert_t verts[6];
|
||||||
float verts[6][4];
|
void *v;
|
||||||
|
int size = sizeof (verts);
|
||||||
|
|
||||||
make_quad (pic, x, y, w, h, srcx, srcy, srcw, srch, verts);
|
make_quad (pic, x, y, w, h, srcx, srcy, srcw, srch, verts, color);
|
||||||
gl = (glpic_t *) pic->data;
|
char_queue->size += size;
|
||||||
|
dstring_adjust (char_queue);
|
||||||
qfeglUseProgram (quake_icon.program);
|
v = char_queue->str + char_queue->size - size;
|
||||||
qfeglEnableVertexAttribArray (quake_icon.vertex.location);
|
memcpy (v, verts, size);
|
||||||
|
|
||||||
qfeglUniformMatrix4fv (quake_icon.matrix.location, 1, false, proj_matrix);
|
|
||||||
|
|
||||||
qfeglUniform1i (quake_icon.icon.location, 0);
|
|
||||||
qfeglActiveTexture (GL_TEXTURE0 + 0);
|
|
||||||
qfeglEnable (GL_TEXTURE_2D);
|
|
||||||
qfeglBindTexture (GL_TEXTURE_2D, gl->texnum);
|
|
||||||
|
|
||||||
qfeglUniform1i (quake_icon.palette.location, 1);
|
|
||||||
qfeglActiveTexture (GL_TEXTURE0 + 1);
|
|
||||||
qfeglEnable (GL_TEXTURE_2D);
|
|
||||||
qfeglBindTexture (GL_TEXTURE_2D, glsl_palette);
|
|
||||||
|
|
||||||
qfeglVertexAttrib4fv (quake_icon.color.location, color);
|
|
||||||
|
|
||||||
qfeglVertexAttribPointer (quake_icon.vertex.location, 4, GL_FLOAT,
|
|
||||||
0, 0, verts);
|
|
||||||
|
|
||||||
qfeglDrawArrays (GL_TRIANGLES, 0, 6);
|
|
||||||
|
|
||||||
qfeglDisableVertexAttribArray (quake_icon.vertex.location);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qpic_t *
|
qpic_t *
|
||||||
|
@ -387,7 +371,7 @@ glsl_Draw_Init (void)
|
||||||
int i;
|
int i;
|
||||||
int frag, vert;
|
int frag, vert;
|
||||||
qpic_t *pic;
|
qpic_t *pic;
|
||||||
glpic_t *gl;
|
//FIXME glpic_t *gl;
|
||||||
|
|
||||||
pic_cache = Hash_NewTable (127, cachepic_getkey, cachepic_free, 0);
|
pic_cache = Hash_NewTable (127, cachepic_getkey, cachepic_free, 0);
|
||||||
QFS_GamedirCallback (Draw_ClearCache);
|
QFS_GamedirCallback (Draw_ClearCache);
|
||||||
|
@ -396,33 +380,26 @@ glsl_Draw_Init (void)
|
||||||
crosshaircolor->callback (crosshaircolor);
|
crosshaircolor->callback (crosshaircolor);
|
||||||
|
|
||||||
char_queue = dstring_new ();
|
char_queue = dstring_new ();
|
||||||
vert = GLSL_CompileShader ("quaketxt.vert", quaketext_vert,
|
|
||||||
GL_VERTEX_SHADER);
|
|
||||||
frag = GLSL_CompileShader ("quake2d.frag", quake2d_frag,
|
|
||||||
GL_FRAGMENT_SHADER);
|
|
||||||
quake_text.program = GLSL_LinkProgram ("quaketxt", vert, frag);
|
|
||||||
GLSL_ResolveShaderParam (quake_text.program, &quake_text.charmap);
|
|
||||||
GLSL_ResolveShaderParam (quake_text.program, &quake_text.palette);
|
|
||||||
GLSL_ResolveShaderParam (quake_text.program, &quake_text.matrix);
|
|
||||||
GLSL_ResolveShaderParam (quake_text.program, &quake_text.vertex);
|
|
||||||
GLSL_ResolveShaderParam (quake_text.program, &quake_text.color);
|
|
||||||
GLSL_ResolveShaderParam (quake_text.program, &quake_text.dchar);
|
|
||||||
|
|
||||||
vert = GLSL_CompileShader ("quakeico.vert", quakeicon_vert,
|
vert = GLSL_CompileShader ("quakeico.vert", quakeicon_vert,
|
||||||
GL_VERTEX_SHADER);
|
GL_VERTEX_SHADER);
|
||||||
quake_icon.program = GLSL_LinkProgram ("quakeico", vert, frag);
|
frag = GLSL_CompileShader ("quake2d.frag", quake2d_frag,
|
||||||
GLSL_ResolveShaderParam (quake_icon.program, &quake_icon.icon);
|
GL_FRAGMENT_SHADER);
|
||||||
GLSL_ResolveShaderParam (quake_icon.program, &quake_icon.palette);
|
quake_2d.program = GLSL_LinkProgram ("quake2d", vert, frag);
|
||||||
GLSL_ResolveShaderParam (quake_icon.program, &quake_icon.matrix);
|
GLSL_ResolveShaderParam (quake_2d.program, &quake_2d.texture);
|
||||||
GLSL_ResolveShaderParam (quake_icon.program, &quake_icon.vertex);
|
GLSL_ResolveShaderParam (quake_2d.program, &quake_2d.palette);
|
||||||
GLSL_ResolveShaderParam (quake_icon.program, &quake_icon.color);
|
GLSL_ResolveShaderParam (quake_2d.program, &quake_2d.matrix);
|
||||||
|
GLSL_ResolveShaderParam (quake_2d.program, &quake_2d.vertex);
|
||||||
|
GLSL_ResolveShaderParam (quake_2d.program, &quake_2d.color);
|
||||||
|
|
||||||
|
draw_scrap = GLSL_CreateScrap (2048, GL_LUMINANCE, 0);
|
||||||
|
|
||||||
draw_chars = W_GetLumpName ("conchars");
|
draw_chars = W_GetLumpName ("conchars");
|
||||||
for (i = 0; i < 256 * 64; i++)
|
for (i = 0; i < 256 * 64; i++)
|
||||||
if (draw_chars[i] == 0)
|
if (draw_chars[i] == 0)
|
||||||
draw_chars[i] = 255; // proper transparent color
|
draw_chars[i] = 255; // proper transparent color
|
||||||
|
|
||||||
char_texture = GLSL_LoadQuakeTexture ("conchars", 128, 128, draw_chars);
|
conchars = pic_data ("conchars", 128, 128, draw_chars);
|
||||||
|
|
||||||
pic = (qpic_t *) QFS_LoadFile ("gfx/conback.lmp", 0);
|
pic = (qpic_t *) QFS_LoadFile ("gfx/conback.lmp", 0);
|
||||||
if (pic) {
|
if (pic) {
|
||||||
|
@ -440,11 +417,11 @@ glsl_Draw_Init (void)
|
||||||
memset (white_block, 0xfe, sizeof (white_block));
|
memset (white_block, 0xfe, sizeof (white_block));
|
||||||
white_pic = pic_data ("white_block", 8, 8, white_block);
|
white_pic = pic_data ("white_block", 8, 8, white_block);
|
||||||
|
|
||||||
backtile_pic = glsl_Draw_PicFromWad ("backtile");
|
//FIXME backtile_pic = glsl_Draw_PicFromWad ("backtile");
|
||||||
gl = (glpic_t *) backtile_pic->data;
|
//FIXME gl = (glpic_t *) backtile_pic->data;
|
||||||
qfeglBindTexture (GL_TEXTURE_2D, gl->texnum);
|
//FIXME qfeglBindTexture (GL_TEXTURE_2D, gl->texnum);
|
||||||
qfeglTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
//FIXME qfeglTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
qfeglTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
//FIXME qfeglTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
|
|
||||||
glsl_conback_texnum = Cvar_Get ("glsl_conback_texnum", "0", CVAR_NONE,
|
glsl_conback_texnum = Cvar_Get ("glsl_conback_texnum", "0", CVAR_NONE,
|
||||||
NULL, "bind conback to this texture for "
|
NULL, "bind conback to this texture for "
|
||||||
|
@ -454,53 +431,25 @@ glsl_Draw_Init (void)
|
||||||
static inline void
|
static inline void
|
||||||
queue_character (int x, int y, byte chr)
|
queue_character (int x, int y, byte chr)
|
||||||
{
|
{
|
||||||
unsigned short *v;
|
quat_t color = {1, 1, 1, 1};
|
||||||
unsigned i, c;
|
int cx, cy;
|
||||||
const int size = 5 * 2 * 6;
|
|
||||||
|
|
||||||
char_queue->size += size;
|
cx = chr % 16;
|
||||||
dstring_adjust (char_queue);
|
cy = chr / 16;
|
||||||
v = (unsigned short *) (char_queue->str + char_queue->size - size);
|
draw_pic (x, y, 8, 8, conchars, cx * 8, cy * 8, 8, 8, color);
|
||||||
c = 0x738;
|
|
||||||
for (i = 0; i < 6; i++, c >>= 2) {
|
|
||||||
*v++ = x;
|
|
||||||
*v++ = y;
|
|
||||||
*v++ = c & 1;
|
|
||||||
*v++ = (c >> 1) & 1;
|
|
||||||
*v++ = chr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
flush_text (void)
|
flush_2d (void)
|
||||||
{
|
{
|
||||||
qfeglUseProgram (quake_text.program);
|
GLSL_ScrapFlush (draw_scrap);
|
||||||
qfeglEnableVertexAttribArray (quake_text.vertex.location);
|
qfeglBindTexture (GL_TEXTURE_2D, GLSL_ScrapTexture (draw_scrap));
|
||||||
qfeglEnableVertexAttribArray (quake_text.dchar.location);
|
qfeglVertexAttribPointer (quake_2d.vertex.location, 4, GL_FLOAT,
|
||||||
|
0, 32, char_queue->str);
|
||||||
|
qfeglVertexAttribPointer (quake_2d.color.location, 4, GL_FLOAT,
|
||||||
|
0, 32, char_queue->str + 16);
|
||||||
|
|
||||||
qfeglUniformMatrix4fv (quake_text.matrix.location, 1, false, proj_matrix);
|
qfeglDrawArrays (GL_TRIANGLES, 0, char_queue->size / 32);
|
||||||
|
|
||||||
qfeglUniform1i (quake_text.charmap.location, 0);
|
|
||||||
qfeglActiveTexture (GL_TEXTURE0 + 0);
|
|
||||||
qfeglEnable (GL_TEXTURE_2D);
|
|
||||||
qfeglBindTexture (GL_TEXTURE_2D, char_texture);
|
|
||||||
|
|
||||||
qfeglUniform1i (quake_text.palette.location, 1);
|
|
||||||
qfeglActiveTexture (GL_TEXTURE0 + 1);
|
|
||||||
qfeglEnable (GL_TEXTURE_2D);
|
|
||||||
qfeglBindTexture (GL_TEXTURE_2D, glsl_palette);
|
|
||||||
|
|
||||||
qfeglVertexAttrib4f (quake_text.color.location, 1, 1, 1, 1);
|
|
||||||
|
|
||||||
qfeglVertexAttribPointer (quake_text.vertex.location, 4, GL_UNSIGNED_SHORT,
|
|
||||||
0, 10, char_queue->str);
|
|
||||||
qfeglVertexAttribPointer (quake_text.dchar.location, 1, GL_UNSIGNED_SHORT,
|
|
||||||
0, 10, char_queue->str + 8);
|
|
||||||
|
|
||||||
qfeglDrawArrays (GL_TRIANGLES, 0, char_queue->size / 10);
|
|
||||||
|
|
||||||
qfeglDisableVertexAttribArray (quake_text.dchar.location);
|
|
||||||
qfeglDisableVertexAttribArray (quake_text.vertex.location);
|
|
||||||
char_queue->size = 0;
|
char_queue->size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -670,51 +619,43 @@ void
|
||||||
glsl_Draw_ConsoleBackground (int lines, byte alpha)
|
glsl_Draw_ConsoleBackground (int lines, byte alpha)
|
||||||
{
|
{
|
||||||
float ofs = (vid.conheight - lines) / (float) vid.conheight;
|
float ofs = (vid.conheight - lines) / (float) vid.conheight;
|
||||||
float verts[][4] = {
|
quat_t color = {1, 1, 1, bound (0, alpha, 255) / 255.0};
|
||||||
{ 0, 0, 0, ofs},
|
drawvert_t verts[] = {
|
||||||
{vid.conwidth, 0, 1, ofs},
|
{{ 0, 0, 0, ofs}},
|
||||||
{vid.conwidth, lines, 1, 1},
|
{{vid.conwidth, 0, 1, ofs}},
|
||||||
{ 0, 0, 0, ofs},
|
{{vid.conwidth, lines, 1, 1}},
|
||||||
{vid.conwidth, lines, 1, 1},
|
{{ 0, 0, 0, ofs}},
|
||||||
{ 0, lines, 0, 1},
|
{{vid.conwidth, lines, 1, 1}},
|
||||||
|
{{ 0, lines, 0, 1}},
|
||||||
};
|
};
|
||||||
|
|
||||||
GLSL_FlushText (); // Flush text that should be rendered before the console
|
GLSL_FlushText (); // Flush text that should be rendered before the console
|
||||||
|
|
||||||
qfeglUseProgram (quake_icon.program);
|
QuatCopy (color, verts[0].color);
|
||||||
qfeglEnableVertexAttribArray (quake_icon.vertex.location);
|
QuatCopy (color, verts[1].color);
|
||||||
|
QuatCopy (color, verts[2].color);
|
||||||
|
QuatCopy (color, verts[3].color);
|
||||||
|
QuatCopy (color, verts[4].color);
|
||||||
|
QuatCopy (color, verts[5].color);
|
||||||
|
|
||||||
qfeglUniformMatrix4fv (quake_icon.matrix.location, 1, false, proj_matrix);
|
|
||||||
|
|
||||||
qfeglUniform1i (quake_icon.icon.location, 0);
|
|
||||||
qfeglActiveTexture (GL_TEXTURE0 + 0);
|
|
||||||
qfeglEnable (GL_TEXTURE_2D);
|
|
||||||
if (glsl_conback_texnum->int_val)
|
if (glsl_conback_texnum->int_val)
|
||||||
qfeglBindTexture (GL_TEXTURE_2D, glsl_conback_texnum->int_val);
|
qfeglBindTexture (GL_TEXTURE_2D, glsl_conback_texnum->int_val);
|
||||||
else
|
else
|
||||||
qfeglBindTexture (GL_TEXTURE_2D, conback_texture);
|
qfeglBindTexture (GL_TEXTURE_2D, conback_texture);
|
||||||
|
|
||||||
qfeglUniform1i (quake_icon.palette.location, 1);
|
qfeglVertexAttribPointer (quake_2d.vertex.location, 4, GL_FLOAT,
|
||||||
qfeglActiveTexture (GL_TEXTURE0 + 1);
|
0, sizeof (drawvert_t), &verts[0].xyst);
|
||||||
qfeglEnable (GL_TEXTURE_2D);
|
qfeglVertexAttribPointer (quake_2d.color.location, 4, GL_FLOAT,
|
||||||
qfeglBindTexture (GL_TEXTURE_2D, glsl_palette);
|
0, sizeof (drawvert_t), &verts[0].color);
|
||||||
|
|
||||||
qfeglVertexAttrib4f (quake_icon.color.location,
|
|
||||||
1, 1, 1, bound (0, alpha, 255) / 255.0);
|
|
||||||
|
|
||||||
qfeglVertexAttribPointer (quake_icon.vertex.location, 4, GL_FLOAT,
|
|
||||||
0, 0, verts);
|
|
||||||
|
|
||||||
qfeglDrawArrays (GL_TRIANGLES, 0, 6);
|
qfeglDrawArrays (GL_TRIANGLES, 0, 6);
|
||||||
|
|
||||||
qfeglDisableVertexAttribArray (quake_icon.vertex.location);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
glsl_Draw_TileClear (int x, int y, int w, int h)
|
glsl_Draw_TileClear (int x, int y, int w, int h)
|
||||||
{
|
{
|
||||||
static quat_t color = { 1, 1, 1, 1 };
|
//FIXME static quat_t color = { 1, 1, 1, 1 };
|
||||||
draw_pic (x, y, w, h, backtile_pic, 0, 0, w, h, color);
|
//FIXME draw_pic (x, y, w, h, backtile_pic, 0, 0, w, h, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -776,6 +717,24 @@ set_2d (int width, int height)
|
||||||
qfeglDisable (GL_CULL_FACE);
|
qfeglDisable (GL_CULL_FACE);
|
||||||
|
|
||||||
ortho_mat (proj_matrix, 0, width, height, 0, -99999, 99999);
|
ortho_mat (proj_matrix, 0, width, height, 0, -99999, 99999);
|
||||||
|
|
||||||
|
qfeglUseProgram (quake_2d.program);
|
||||||
|
qfeglEnableVertexAttribArray (quake_2d.vertex.location);
|
||||||
|
qfeglEnableVertexAttribArray (quake_2d.color.location);
|
||||||
|
|
||||||
|
qfeglUniformMatrix4fv (quake_2d.matrix.location, 1, false, proj_matrix);
|
||||||
|
|
||||||
|
qfeglUniform1i (quake_2d.palette.location, 1);
|
||||||
|
qfeglActiveTexture (GL_TEXTURE0 + 1);
|
||||||
|
qfeglEnable (GL_TEXTURE_2D);
|
||||||
|
qfeglBindTexture (GL_TEXTURE_2D, glsl_palette);
|
||||||
|
|
||||||
|
qfeglUniform1i (quake_2d.texture.location, 0);
|
||||||
|
qfeglActiveTexture (GL_TEXTURE0 + 0);
|
||||||
|
qfeglEnable (GL_TEXTURE_2D);
|
||||||
|
qfeglBindTexture (GL_TEXTURE_2D, GLSL_ScrapTexture (draw_scrap));
|
||||||
|
|
||||||
|
qfeglVertexAttrib4f (quake_2d.color.location, 1, 1, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -790,6 +749,13 @@ GLSL_Set2DScaled (void)
|
||||||
set_2d (vid.conwidth, vid.conheight);
|
set_2d (vid.conwidth, vid.conheight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
GLSL_End2D (void)
|
||||||
|
{
|
||||||
|
qfeglDisableVertexAttribArray (quake_2d.vertex.location);
|
||||||
|
qfeglDisableVertexAttribArray (quake_2d.color.location);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
GLSL_DrawReset (void)
|
GLSL_DrawReset (void)
|
||||||
{
|
{
|
||||||
|
@ -800,7 +766,7 @@ void
|
||||||
GLSL_FlushText (void)
|
GLSL_FlushText (void)
|
||||||
{
|
{
|
||||||
if (char_queue->size)
|
if (char_queue->size)
|
||||||
flush_text ();
|
flush_2d ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -197,6 +197,7 @@ glsl_SCR_UpdateScreen (double realtime, SCR_Func scr_3dfunc,
|
||||||
scr_funcs++;
|
scr_funcs++;
|
||||||
GLSL_FlushText ();
|
GLSL_FlushText ();
|
||||||
}
|
}
|
||||||
|
GLSL_End2D ();
|
||||||
qfeglFlush ();
|
qfeglFlush ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue