2011-12-23 03:19:50 +00:00
|
|
|
/*
|
|
|
|
glsl_draw.c
|
|
|
|
|
|
|
|
2D drawing support for GLSL
|
|
|
|
|
|
|
|
Copyright (C) 2011 Bill Currie <bill@taniwha.org>
|
|
|
|
|
|
|
|
Author: Bill Currie <bill@taniwha.org>
|
|
|
|
Date: 2011/12/23
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static __attribute__ ((used)) const char rcsid[] = "$Id$";
|
|
|
|
|
2012-02-22 07:32:34 +00:00
|
|
|
#define NH_DEFINE
|
|
|
|
#include "namehack.h"
|
|
|
|
|
2011-12-26 11:33:40 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# include <string.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
|
|
|
|
2011-12-27 08:59:58 +00:00
|
|
|
#include "QF/cvar.h"
|
2011-12-23 03:19:50 +00:00
|
|
|
#include "QF/draw.h"
|
2011-12-25 10:42:39 +00:00
|
|
|
#include "QF/dstring.h"
|
2011-12-31 11:36:24 +00:00
|
|
|
#include "QF/hash.h"
|
2011-12-26 11:33:40 +00:00
|
|
|
#include "QF/quakefs.h"
|
2011-12-25 10:42:39 +00:00
|
|
|
#include "QF/sys.h"
|
2011-12-25 23:12:05 +00:00
|
|
|
#include "QF/vid.h"
|
2011-12-25 10:42:39 +00:00
|
|
|
|
2011-12-26 07:08:55 +00:00
|
|
|
#include "QF/GLSL/defines.h"
|
|
|
|
#include "QF/GLSL/funcs.h"
|
2011-12-26 09:34:51 +00:00
|
|
|
#include "QF/GLSL/qf_textures.h"
|
2011-12-26 07:08:55 +00:00
|
|
|
#include "QF/GLSL/qf_vid.h"
|
2011-12-25 10:42:39 +00:00
|
|
|
|
|
|
|
#include "gl_draw.h"
|
2012-02-14 08:28:09 +00:00
|
|
|
#include "r_internal.h"
|
2011-12-23 03:19:50 +00:00
|
|
|
|
2011-12-26 11:33:40 +00:00
|
|
|
typedef struct {
|
|
|
|
int texnum;
|
|
|
|
} glpic_t;
|
|
|
|
|
2011-12-31 11:36:24 +00:00
|
|
|
typedef struct cachepic_s {
|
|
|
|
struct cachepic_s *next;
|
|
|
|
char *name;
|
|
|
|
qpic_t *pic;
|
|
|
|
} cachepic_t;
|
2011-12-26 11:33:40 +00:00
|
|
|
|
|
|
|
static const char quakeicon_vert[] =
|
|
|
|
#include "quakeico.vc"
|
|
|
|
;
|
|
|
|
|
2011-12-25 06:53:12 +00:00
|
|
|
static const char quaketext_vert[] =
|
|
|
|
#include "quaketxt.vc"
|
|
|
|
;
|
|
|
|
|
2011-12-26 08:09:09 +00:00
|
|
|
static const char quake2d_frag[] =
|
|
|
|
#include "quake2d.fc"
|
2011-12-25 06:53:12 +00:00
|
|
|
;
|
|
|
|
|
2011-12-26 08:42:23 +00:00
|
|
|
static float proj_matrix[16];
|
|
|
|
|
|
|
|
static struct {
|
|
|
|
int program;
|
|
|
|
shaderparam_t charmap;
|
|
|
|
shaderparam_t palette;
|
|
|
|
shaderparam_t matrix;
|
|
|
|
shaderparam_t vertex;
|
2011-12-28 00:04:26 +00:00
|
|
|
shaderparam_t color;
|
2011-12-26 08:42:23 +00:00
|
|
|
shaderparam_t dchar;
|
|
|
|
} quake_text = {
|
|
|
|
0,
|
|
|
|
{"texture", 1},
|
|
|
|
{"palette", 1},
|
|
|
|
{"mvp_mat", 1},
|
|
|
|
{"vertex", 0},
|
2011-12-28 00:04:26 +00:00
|
|
|
{"vcolor", 0},
|
2011-12-26 08:42:23 +00:00
|
|
|
{"char", 0},
|
|
|
|
};
|
|
|
|
|
2011-12-26 11:33:40 +00:00
|
|
|
static struct {
|
|
|
|
int program;
|
|
|
|
shaderparam_t icon;
|
|
|
|
shaderparam_t palette;
|
|
|
|
shaderparam_t matrix;
|
|
|
|
shaderparam_t vertex;
|
2011-12-28 00:04:26 +00:00
|
|
|
shaderparam_t color;
|
2011-12-26 11:33:40 +00:00
|
|
|
} quake_icon = {
|
|
|
|
0,
|
|
|
|
{"texture", 1},
|
|
|
|
{"palette", 1},
|
|
|
|
{"mvp_mat", 1},
|
|
|
|
{"vertex", 0},
|
2011-12-28 00:04:26 +00:00
|
|
|
{"vcolor", 0},
|
2011-12-26 11:33:40 +00:00
|
|
|
};
|
|
|
|
|
2011-12-29 02:25:27 +00:00
|
|
|
static byte white_block[8 * 8];
|
2011-12-25 10:42:39 +00:00
|
|
|
static dstring_t *char_queue;
|
|
|
|
static int char_texture;
|
2011-12-26 11:33:40 +00:00
|
|
|
static int conback_texture;
|
2011-12-27 08:59:58 +00:00
|
|
|
static qpic_t *crosshair_pic;
|
2011-12-29 02:25:27 +00:00
|
|
|
static qpic_t *white_pic;
|
2011-12-29 09:15:15 +00:00
|
|
|
static qpic_t *backtile_pic;
|
2011-12-31 11:36:24 +00:00
|
|
|
static hashtab_t *pic_cache;
|
2011-12-26 11:33:40 +00:00
|
|
|
|
|
|
|
static qpic_t *
|
|
|
|
make_glpic (const char *name, qpic_t *p)
|
|
|
|
{
|
|
|
|
qpic_t *pic = 0;
|
|
|
|
glpic_t *gl;
|
|
|
|
|
|
|
|
if (p) {
|
|
|
|
// FIXME is alignment ok?
|
|
|
|
pic = malloc (sizeof (qpic_t) + sizeof (glpic_t));
|
|
|
|
*pic = *p;
|
|
|
|
gl = (glpic_t *) pic->data;
|
2012-02-17 09:57:13 +00:00
|
|
|
gl->texnum = GLSL_LoadQuakeTexture (name, p->width, p->height,
|
|
|
|
p->data);
|
2011-12-26 11:33:40 +00:00
|
|
|
}
|
|
|
|
return pic;
|
|
|
|
}
|
|
|
|
|
2011-12-31 11:36:24 +00:00
|
|
|
static void
|
|
|
|
pic_free (qpic_t *pic)
|
|
|
|
{
|
|
|
|
glpic_t *gl = (glpic_t *) pic->data;
|
|
|
|
|
2012-02-17 09:57:13 +00:00
|
|
|
GLSL_ReleaseTexture (gl->texnum);
|
2011-12-31 11:36:24 +00:00
|
|
|
free (pic);
|
|
|
|
}
|
|
|
|
|
|
|
|
//FIXME nicer allocator
|
|
|
|
static cachepic_t *
|
|
|
|
new_cachepic (const char *name, qpic_t *pic)
|
|
|
|
{
|
|
|
|
cachepic_t *cp;
|
|
|
|
|
|
|
|
cp = malloc (sizeof (cachepic_t));
|
|
|
|
cp->name = strdup (name);
|
|
|
|
cp->pic = pic;
|
|
|
|
return cp;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
cachepic_getkey (void *_cp, void *unused)
|
|
|
|
{
|
|
|
|
return ((cachepic_t *) _cp)->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cachepic_free (void *_cp, void *unused)
|
|
|
|
{
|
|
|
|
cachepic_t *cp = (cachepic_t *) _cp;
|
|
|
|
pic_free (cp->pic);
|
|
|
|
free (cp->name);
|
|
|
|
free (cp);
|
|
|
|
}
|
|
|
|
|
2011-12-29 02:25:27 +00:00
|
|
|
static qpic_t *
|
|
|
|
pic_data (const char *name, int w, int h, const byte *data)
|
|
|
|
{
|
|
|
|
qpic_t *pic;
|
|
|
|
qpic_t *glpic;
|
|
|
|
|
|
|
|
pic = malloc (field_offset (qpic_t, data[w * h]));
|
|
|
|
pic->width = w;
|
|
|
|
pic->height = h;
|
|
|
|
memcpy (pic->data, data, pic->width * pic->height);
|
|
|
|
glpic = make_glpic (name, pic);
|
|
|
|
free (pic);
|
|
|
|
return glpic;
|
|
|
|
}
|
|
|
|
|
2011-12-26 11:33:40 +00:00
|
|
|
static void
|
2012-02-06 10:32:30 +00:00
|
|
|
make_quad (qpic_t *pic, float x, float y, int w, int h,
|
2011-12-29 02:25:27 +00:00
|
|
|
int srcx, int srcy, int srcw, int srch, float verts[6][4])
|
2011-12-26 11:33:40 +00:00
|
|
|
{
|
|
|
|
float sl, sh, tl, th;
|
|
|
|
|
|
|
|
sl = (float) srcx / (float) pic->width;
|
2011-12-29 02:25:27 +00:00
|
|
|
sh = sl + (float) srcw / (float) pic->width;
|
2011-12-26 11:33:40 +00:00
|
|
|
tl = (float) srcy / (float) pic->height;
|
2011-12-29 02:25:27 +00:00
|
|
|
th = tl + (float) srch / (float) pic->height;
|
2011-12-26 11:33:40 +00:00
|
|
|
|
|
|
|
verts[0][0] = x;
|
|
|
|
verts[0][1] = y;
|
|
|
|
verts[0][2] = sl;
|
|
|
|
verts[0][3] = tl;
|
|
|
|
|
2011-12-29 02:25:27 +00:00
|
|
|
verts[1][0] = x + w;
|
2011-12-26 11:33:40 +00:00
|
|
|
verts[1][1] = y;
|
|
|
|
verts[1][2] = sh;
|
|
|
|
verts[1][3] = tl;
|
|
|
|
|
2011-12-29 02:25:27 +00:00
|
|
|
verts[2][0] = x + w;
|
|
|
|
verts[2][1] = y + h;
|
2011-12-26 11:33:40 +00:00
|
|
|
verts[2][2] = sh;
|
|
|
|
verts[2][3] = th;
|
|
|
|
|
|
|
|
verts[3][0] = x;
|
|
|
|
verts[3][1] = y;
|
|
|
|
verts[3][2] = sl;
|
|
|
|
verts[3][3] = tl;
|
|
|
|
|
2011-12-29 02:25:27 +00:00
|
|
|
verts[4][0] = x + w;
|
|
|
|
verts[4][1] = y + h;
|
2011-12-26 11:33:40 +00:00
|
|
|
verts[4][2] = sh;
|
|
|
|
verts[4][3] = th;
|
|
|
|
|
|
|
|
verts[5][0] = x;
|
2011-12-29 02:25:27 +00:00
|
|
|
verts[5][1] = y + h;
|
2011-12-26 11:33:40 +00:00
|
|
|
verts[5][2] = sl;
|
|
|
|
verts[5][3] = th;
|
|
|
|
}
|
2011-12-23 03:19:50 +00:00
|
|
|
|
2011-12-27 08:59:58 +00:00
|
|
|
static void
|
2012-02-06 10:32:30 +00:00
|
|
|
draw_pic (float x, float y, int w, int h, qpic_t *pic,
|
2011-12-29 02:25:27 +00:00
|
|
|
int srcx, int srcy, int srcw, int srch,
|
2011-12-28 00:04:26 +00:00
|
|
|
float *color)
|
2011-12-27 08:59:58 +00:00
|
|
|
{
|
|
|
|
glpic_t *gl;
|
|
|
|
float verts[6][4];
|
|
|
|
|
2011-12-29 02:25:27 +00:00
|
|
|
make_quad (pic, x, y, w, h, srcx, srcy, srcw, srch, verts);
|
2011-12-27 08:59:58 +00:00
|
|
|
gl = (glpic_t *) pic->data;
|
|
|
|
|
|
|
|
qfglUseProgram (quake_icon.program);
|
|
|
|
qfglEnableVertexAttribArray (quake_icon.vertex.location);
|
|
|
|
|
|
|
|
qfglUniformMatrix4fv (quake_icon.matrix.location, 1, false, proj_matrix);
|
|
|
|
|
|
|
|
qfglUniform1i (quake_icon.icon.location, 0);
|
|
|
|
qfglActiveTexture (GL_TEXTURE0 + 0);
|
|
|
|
qfglEnable (GL_TEXTURE_2D);
|
|
|
|
qfglBindTexture (GL_TEXTURE_2D, gl->texnum);
|
|
|
|
|
|
|
|
qfglUniform1i (quake_icon.palette.location, 1);
|
|
|
|
qfglActiveTexture (GL_TEXTURE0 + 1);
|
|
|
|
qfglEnable (GL_TEXTURE_2D);
|
|
|
|
qfglBindTexture (GL_TEXTURE_2D, glsl_palette);
|
|
|
|
|
2011-12-28 00:04:26 +00:00
|
|
|
qfglVertexAttrib4fv (quake_icon.color.location, color);
|
|
|
|
|
2011-12-27 08:59:58 +00:00
|
|
|
qfglVertexAttribPointer (quake_icon.vertex.location, 4, GL_FLOAT,
|
|
|
|
0, 0, verts);
|
|
|
|
|
|
|
|
qfglDrawArrays (GL_TRIANGLES, 0, 6);
|
|
|
|
|
|
|
|
qfglDisableVertexAttribArray (quake_icon.vertex.location);
|
|
|
|
}
|
|
|
|
|
2012-02-18 13:28:42 +00:00
|
|
|
qpic_t *
|
2012-02-22 07:32:34 +00:00
|
|
|
glsl_Draw_MakePic (int width, int height, const byte *data)
|
2012-02-01 08:46:15 +00:00
|
|
|
{
|
|
|
|
return pic_data (0, width, height, data);
|
|
|
|
}
|
|
|
|
|
2012-02-18 13:28:42 +00:00
|
|
|
void
|
2012-02-22 07:32:34 +00:00
|
|
|
glsl_Draw_DestroyPic (qpic_t *pic)
|
2012-02-01 08:46:15 +00:00
|
|
|
{
|
|
|
|
pic_free (pic);
|
|
|
|
}
|
|
|
|
|
2012-02-18 13:28:42 +00:00
|
|
|
qpic_t *
|
2012-02-22 07:32:34 +00:00
|
|
|
glsl_Draw_PicFromWad (const char *name)
|
2011-12-23 03:19:50 +00:00
|
|
|
{
|
2011-12-26 11:33:40 +00:00
|
|
|
return make_glpic (name, W_GetLumpName (name));
|
2011-12-23 03:19:50 +00:00
|
|
|
}
|
|
|
|
|
2012-02-18 13:28:42 +00:00
|
|
|
qpic_t *
|
2012-02-22 07:32:34 +00:00
|
|
|
glsl_Draw_CachePic (const char *path, qboolean alpha)
|
2011-12-23 03:19:50 +00:00
|
|
|
{
|
2011-12-26 11:33:40 +00:00
|
|
|
qpic_t *p, *pic;
|
2011-12-31 11:36:24 +00:00
|
|
|
cachepic_t *cpic;
|
2011-12-26 11:33:40 +00:00
|
|
|
|
2011-12-31 11:36:24 +00:00
|
|
|
if ((cpic = Hash_Find (pic_cache, path)))
|
|
|
|
return cpic->pic;
|
2011-12-26 11:33:40 +00:00
|
|
|
if (strlen (path) < 4 || strcmp (path + strlen (path) - 4, ".lmp")
|
|
|
|
|| !(p = (qpic_t *) QFS_LoadFile (path, 0))) {
|
|
|
|
//FIXME load a null texture
|
|
|
|
Sys_Error ("Draw_CachePic: failed to load %s", path);
|
|
|
|
}
|
|
|
|
|
|
|
|
pic = make_glpic (path, p);
|
|
|
|
free (p);
|
2011-12-31 11:36:24 +00:00
|
|
|
cpic = new_cachepic (path, pic);
|
|
|
|
Hash_Add (pic_cache, cpic);
|
2011-12-26 11:33:40 +00:00
|
|
|
return pic;
|
2011-12-23 03:19:50 +00:00
|
|
|
}
|
|
|
|
|
2012-02-18 13:28:42 +00:00
|
|
|
void
|
2012-02-22 07:32:34 +00:00
|
|
|
glsl_Draw_UncachePic (const char *path)
|
2012-02-01 07:55:35 +00:00
|
|
|
{
|
|
|
|
Hash_Free (pic_cache, Hash_Del (pic_cache, path));
|
|
|
|
}
|
|
|
|
|
2012-02-18 13:28:42 +00:00
|
|
|
void
|
2012-02-22 07:32:34 +00:00
|
|
|
glsl_Draw_TextBox (int x, int y, int width, int lines, byte alpha)
|
2011-12-23 03:19:50 +00:00
|
|
|
{
|
2011-12-29 08:51:31 +00:00
|
|
|
static quat_t color = { 1, 1, 1, 0 };
|
|
|
|
qpic_t *p;
|
|
|
|
int cx, cy, n;
|
|
|
|
#define draw(px,py,pp) \
|
|
|
|
draw_pic (px, py, pp->width, pp->height, pp, \
|
|
|
|
0, 0, pp->width, pp->height, color)
|
|
|
|
|
|
|
|
color[3] = alpha / 255.0;
|
|
|
|
// draw left side
|
|
|
|
cx = x;
|
|
|
|
cy = y;
|
2012-02-22 07:32:34 +00:00
|
|
|
p = glsl_Draw_CachePic ("gfx/box_tl.lmp", true);
|
2011-12-29 08:51:31 +00:00
|
|
|
draw (cx, cy, p);
|
2012-02-22 07:32:34 +00:00
|
|
|
p = glsl_Draw_CachePic ("gfx/box_ml.lmp", true);
|
2011-12-29 08:51:31 +00:00
|
|
|
for (n = 0; n < lines; n++) {
|
|
|
|
cy += 8;
|
|
|
|
draw (cx, cy, p);
|
|
|
|
}
|
2012-02-22 07:32:34 +00:00
|
|
|
p = glsl_Draw_CachePic ("gfx/box_bl.lmp", true);
|
2011-12-29 08:51:31 +00:00
|
|
|
draw (cx, cy + 8, p);
|
|
|
|
|
|
|
|
// draw middle
|
|
|
|
cx += 8;
|
|
|
|
while (width > 0) {
|
|
|
|
cy = y;
|
2012-02-22 07:32:34 +00:00
|
|
|
p = glsl_Draw_CachePic ("gfx/box_tm.lmp", true);
|
2011-12-29 08:51:31 +00:00
|
|
|
draw (cx, cy, p);
|
2012-02-22 07:32:34 +00:00
|
|
|
p = glsl_Draw_CachePic ("gfx/box_mm.lmp", true);
|
2011-12-29 08:51:31 +00:00
|
|
|
for (n = 0; n < lines; n++) {
|
|
|
|
cy += 8;
|
|
|
|
if (n == 1)
|
2012-02-22 07:32:34 +00:00
|
|
|
p = glsl_Draw_CachePic ("gfx/box_mm2.lmp", true);
|
2011-12-29 08:51:31 +00:00
|
|
|
draw (cx, cy, p);
|
|
|
|
}
|
2012-02-22 07:32:34 +00:00
|
|
|
p = glsl_Draw_CachePic ("gfx/box_bm.lmp", true);
|
2011-12-29 08:51:31 +00:00
|
|
|
draw (cx, cy + 8, p);
|
|
|
|
width -= 2;
|
|
|
|
cx += 16;
|
|
|
|
}
|
|
|
|
|
|
|
|
// draw right side
|
|
|
|
cy = y;
|
2012-02-22 07:32:34 +00:00
|
|
|
p = glsl_Draw_CachePic ("gfx/box_tr.lmp", true);
|
2011-12-29 08:51:31 +00:00
|
|
|
draw (cx, cy, p);
|
2012-02-22 07:32:34 +00:00
|
|
|
p = glsl_Draw_CachePic ("gfx/box_mr.lmp", true);
|
2011-12-29 08:51:31 +00:00
|
|
|
for (n = 0; n < lines; n++) {
|
|
|
|
cy += 8;
|
|
|
|
draw (cx, cy, p);
|
|
|
|
}
|
2012-02-22 07:32:34 +00:00
|
|
|
p = glsl_Draw_CachePic ("gfx/box_br.lmp", true);
|
2011-12-29 08:51:31 +00:00
|
|
|
draw (cx, cy + 8, p);
|
|
|
|
#undef draw
|
2011-12-23 03:19:50 +00:00
|
|
|
}
|
|
|
|
|
2011-12-31 11:36:24 +00:00
|
|
|
static void
|
|
|
|
Draw_ClearCache (int phase)
|
|
|
|
{
|
|
|
|
if (phase)
|
|
|
|
return;
|
|
|
|
Hash_FlushTable (pic_cache);
|
|
|
|
}
|
|
|
|
|
2012-02-18 13:28:42 +00:00
|
|
|
void
|
2012-02-22 07:32:34 +00:00
|
|
|
glsl_Draw_Init (void)
|
2011-12-23 03:19:50 +00:00
|
|
|
{
|
2011-12-25 10:42:39 +00:00
|
|
|
int i;
|
2011-12-26 08:42:23 +00:00
|
|
|
int frag, vert;
|
2011-12-26 11:33:40 +00:00
|
|
|
qpic_t *pic;
|
2012-01-07 14:11:56 +00:00
|
|
|
glpic_t *gl;
|
2011-12-25 10:42:39 +00:00
|
|
|
|
2011-12-31 11:36:24 +00:00
|
|
|
pic_cache = Hash_NewTable (127, cachepic_getkey, cachepic_free, 0);
|
|
|
|
QFS_GamedirCallback (Draw_ClearCache);
|
2011-12-28 12:45:20 +00:00
|
|
|
//FIXME temporary work around for the timing of cvar creation and palette
|
|
|
|
//loading
|
|
|
|
crosshaircolor->callback (crosshaircolor);
|
|
|
|
|
2011-12-25 10:42:39 +00:00
|
|
|
char_queue = dstring_new ();
|
2012-02-17 09:57:13 +00:00
|
|
|
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,
|
|
|
|
GL_VERTEX_SHADER);
|
|
|
|
quake_icon.program = GLSL_LinkProgram ("quakeico", vert, frag);
|
|
|
|
GLSL_ResolveShaderParam (quake_icon.program, &quake_icon.icon);
|
|
|
|
GLSL_ResolveShaderParam (quake_icon.program, &quake_icon.palette);
|
|
|
|
GLSL_ResolveShaderParam (quake_icon.program, &quake_icon.matrix);
|
|
|
|
GLSL_ResolveShaderParam (quake_icon.program, &quake_icon.vertex);
|
|
|
|
GLSL_ResolveShaderParam (quake_icon.program, &quake_icon.color);
|
2011-12-26 11:33:40 +00:00
|
|
|
|
2011-12-25 10:42:39 +00:00
|
|
|
draw_chars = W_GetLumpName ("conchars");
|
|
|
|
for (i = 0; i < 256 * 64; i++)
|
|
|
|
if (draw_chars[i] == 0)
|
|
|
|
draw_chars[i] = 255; // proper transparent color
|
|
|
|
|
2012-02-17 09:57:13 +00:00
|
|
|
char_texture = GLSL_LoadQuakeTexture ("conchars", 128, 128, draw_chars);
|
2011-12-26 11:33:40 +00:00
|
|
|
|
|
|
|
pic = (qpic_t *) QFS_LoadFile ("gfx/conback.lmp", 0);
|
|
|
|
if (pic) {
|
|
|
|
SwapPic (pic);
|
2012-02-17 09:57:13 +00:00
|
|
|
conback_texture = GLSL_LoadQuakeTexture ("conback",
|
2011-12-26 11:33:40 +00:00
|
|
|
pic->width, pic->height,
|
|
|
|
pic->data);
|
|
|
|
free (pic);
|
|
|
|
}
|
2011-12-27 08:59:58 +00:00
|
|
|
|
|
|
|
pic = Draw_CrosshairPic ();
|
|
|
|
crosshair_pic = make_glpic ("crosshair", pic);
|
|
|
|
free (pic);
|
2011-12-29 02:25:27 +00:00
|
|
|
|
|
|
|
memset (white_block, 0xfe, sizeof (white_block));
|
|
|
|
white_pic = pic_data ("white_block", 8, 8, white_block);
|
2011-12-29 09:15:15 +00:00
|
|
|
|
2012-02-22 07:32:34 +00:00
|
|
|
backtile_pic = glsl_Draw_PicFromWad ("backtile");
|
2012-01-07 14:11:56 +00:00
|
|
|
gl = (glpic_t *) backtile_pic->data;
|
|
|
|
qfglBindTexture (GL_TEXTURE_2D, gl->texnum);
|
2011-12-29 09:15:15 +00:00
|
|
|
qfglTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
|
|
|
qfglTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
2011-12-25 10:42:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
queue_character (int x, int y, byte chr)
|
|
|
|
{
|
2011-12-25 23:12:05 +00:00
|
|
|
unsigned short *v;
|
2011-12-26 01:16:16 +00:00
|
|
|
unsigned i, c;
|
2011-12-26 07:08:55 +00:00
|
|
|
const int size = 5 * 2 * 6;
|
2011-12-25 10:42:39 +00:00
|
|
|
|
2011-12-25 23:12:05 +00:00
|
|
|
char_queue->size += size;
|
2011-12-25 10:42:39 +00:00
|
|
|
dstring_adjust (char_queue);
|
2011-12-25 23:12:05 +00:00
|
|
|
v = (unsigned short *) (char_queue->str + char_queue->size - size);
|
2011-12-26 07:08:55 +00:00
|
|
|
c = 0x738;
|
|
|
|
for (i = 0; i < 6; i++, c >>= 2) {
|
2011-12-25 10:42:39 +00:00
|
|
|
*v++ = x;
|
|
|
|
*v++ = y;
|
2011-12-26 01:16:16 +00:00
|
|
|
*v++ = c & 1;
|
|
|
|
*v++ = (c >> 1) & 1;
|
2011-12-25 10:42:39 +00:00
|
|
|
*v++ = chr;
|
|
|
|
}
|
2011-12-23 03:19:50 +00:00
|
|
|
}
|
|
|
|
|
2011-12-25 23:12:05 +00:00
|
|
|
static void
|
|
|
|
flush_text (void)
|
|
|
|
{
|
2011-12-26 08:42:23 +00:00
|
|
|
qfglUseProgram (quake_text.program);
|
|
|
|
qfglEnableVertexAttribArray (quake_text.vertex.location);
|
|
|
|
qfglEnableVertexAttribArray (quake_text.dchar.location);
|
2011-12-25 23:12:05 +00:00
|
|
|
|
2011-12-26 08:42:23 +00:00
|
|
|
qfglUniformMatrix4fv (quake_text.matrix.location, 1, false, proj_matrix);
|
2011-12-26 01:16:16 +00:00
|
|
|
|
2011-12-26 08:42:23 +00:00
|
|
|
qfglUniform1i (quake_text.charmap.location, 0);
|
2011-12-26 07:08:55 +00:00
|
|
|
qfglActiveTexture (GL_TEXTURE0 + 0);
|
2011-12-26 01:16:16 +00:00
|
|
|
qfglEnable (GL_TEXTURE_2D);
|
2011-12-26 07:08:55 +00:00
|
|
|
qfglBindTexture (GL_TEXTURE_2D, char_texture);
|
2011-12-25 23:12:05 +00:00
|
|
|
|
2011-12-26 08:42:23 +00:00
|
|
|
qfglUniform1i (quake_text.palette.location, 1);
|
2011-12-26 07:08:55 +00:00
|
|
|
qfglActiveTexture (GL_TEXTURE0 + 1);
|
2011-12-26 01:16:16 +00:00
|
|
|
qfglEnable (GL_TEXTURE_2D);
|
2011-12-26 07:08:55 +00:00
|
|
|
qfglBindTexture (GL_TEXTURE_2D, glsl_palette);
|
2011-12-25 23:12:05 +00:00
|
|
|
|
2011-12-28 00:04:26 +00:00
|
|
|
qfglVertexAttrib4f (quake_text.color.location, 1, 1, 1, 1);
|
|
|
|
|
2011-12-26 08:42:23 +00:00
|
|
|
qfglVertexAttribPointer (quake_text.vertex.location, 4, GL_UNSIGNED_SHORT,
|
|
|
|
0, 10, char_queue->str);
|
|
|
|
qfglVertexAttribPointer (quake_text.dchar.location, 1, GL_UNSIGNED_SHORT,
|
|
|
|
0, 10, char_queue->str + 8);
|
2011-12-25 23:12:05 +00:00
|
|
|
|
2011-12-26 07:08:55 +00:00
|
|
|
qfglDrawArrays (GL_TRIANGLES, 0, char_queue->size / 10);
|
2011-12-25 23:12:05 +00:00
|
|
|
|
2011-12-26 08:42:23 +00:00
|
|
|
qfglDisableVertexAttribArray (quake_text.dchar.location);
|
|
|
|
qfglDisableVertexAttribArray (quake_text.vertex.location);
|
2011-12-25 23:12:05 +00:00
|
|
|
char_queue->size = 0;
|
|
|
|
}
|
|
|
|
|
2012-02-18 13:28:42 +00:00
|
|
|
void
|
2012-02-22 07:32:34 +00:00
|
|
|
glsl_Draw_Character (int x, int y, unsigned int chr)
|
2011-12-23 03:19:50 +00:00
|
|
|
{
|
2011-12-25 23:12:05 +00:00
|
|
|
chr &= 255;
|
|
|
|
|
|
|
|
if (chr == 32)
|
|
|
|
return; // space
|
|
|
|
if (y <= -8)
|
|
|
|
return; // totally off screen
|
|
|
|
|
|
|
|
queue_character (x, y, chr);
|
2011-12-23 03:19:50 +00:00
|
|
|
}
|
|
|
|
|
2012-02-18 13:28:42 +00:00
|
|
|
void
|
2012-02-22 07:32:34 +00:00
|
|
|
glsl_Draw_String (int x, int y, const char *str)
|
2011-12-23 03:19:50 +00:00
|
|
|
{
|
2011-12-25 23:12:05 +00:00
|
|
|
byte chr;
|
|
|
|
|
|
|
|
if (!str || !str[0])
|
|
|
|
return; // totally off screen
|
|
|
|
if (y <= -8)
|
|
|
|
return; // totally off screen
|
|
|
|
|
|
|
|
while (*str) {
|
|
|
|
if ((chr = *str++) != 32)
|
|
|
|
queue_character (x, y, chr);
|
|
|
|
x += 8;
|
|
|
|
}
|
2011-12-23 03:19:50 +00:00
|
|
|
}
|
|
|
|
|
2012-02-18 13:28:42 +00:00
|
|
|
void
|
2012-02-22 07:32:34 +00:00
|
|
|
glsl_Draw_nString (int x, int y, const char *str, int count)
|
2011-12-23 03:19:50 +00:00
|
|
|
{
|
2011-12-25 23:12:05 +00:00
|
|
|
byte chr;
|
|
|
|
|
|
|
|
if (!str || !str[0])
|
|
|
|
return; // totally off screen
|
|
|
|
if (y <= -8)
|
|
|
|
return; // totally off screen
|
|
|
|
|
|
|
|
while (count-- && *str) {
|
|
|
|
if ((chr = *str++) != 32)
|
|
|
|
queue_character (x, y, chr);
|
|
|
|
x += 8;
|
|
|
|
}
|
2011-12-23 03:19:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-02-22 07:32:34 +00:00
|
|
|
glsl_Draw_AltString (int x, int y, const char *str)
|
2011-12-23 03:19:50 +00:00
|
|
|
{
|
2011-12-26 11:33:40 +00:00
|
|
|
byte chr;
|
|
|
|
|
|
|
|
if (!str || !str[0])
|
|
|
|
return;
|
|
|
|
if (y <= -8)
|
|
|
|
return; // totally off screen
|
|
|
|
|
|
|
|
while (*str) {
|
|
|
|
if ((chr = *str++ | 0x80) != (0x80 | 32)) { // Don't render spaces
|
|
|
|
queue_character (x, y, chr);
|
|
|
|
}
|
|
|
|
x += 8;
|
|
|
|
}
|
2011-12-23 03:19:50 +00:00
|
|
|
}
|
|
|
|
|
2011-12-27 08:59:58 +00:00
|
|
|
static void
|
|
|
|
crosshair_1 (int x, int y)
|
2011-12-23 03:19:50 +00:00
|
|
|
{
|
2012-02-22 07:32:34 +00:00
|
|
|
glsl_Draw_Character (x - 4, y - 4, '+');
|
2011-12-23 03:19:50 +00:00
|
|
|
}
|
|
|
|
|
2011-12-27 08:59:58 +00:00
|
|
|
//FIXME these should use an index to select the region.
|
|
|
|
static void
|
|
|
|
crosshair_2 (int x, int y)
|
2011-12-23 03:19:50 +00:00
|
|
|
{
|
2011-12-29 02:25:27 +00:00
|
|
|
draw_pic (x, y, CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT, crosshair_pic,
|
2011-12-28 00:04:26 +00:00
|
|
|
0, 0, CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT, crosshair_color);
|
2011-12-23 03:19:50 +00:00
|
|
|
}
|
|
|
|
|
2011-12-26 11:33:40 +00:00
|
|
|
static void
|
2011-12-27 08:59:58 +00:00
|
|
|
crosshair_3 (int x, int y)
|
2011-12-26 11:33:40 +00:00
|
|
|
{
|
2011-12-29 02:25:27 +00:00
|
|
|
draw_pic (x, y, CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT, crosshair_pic,
|
2011-12-27 08:59:58 +00:00
|
|
|
CROSSHAIR_WIDTH, 0,
|
2011-12-28 00:04:26 +00:00
|
|
|
CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT, crosshair_color);
|
2011-12-27 08:59:58 +00:00
|
|
|
}
|
2011-12-26 11:33:40 +00:00
|
|
|
|
2011-12-27 08:59:58 +00:00
|
|
|
static void
|
|
|
|
crosshair_4 (int x, int y)
|
|
|
|
{
|
2011-12-29 02:25:27 +00:00
|
|
|
draw_pic (x, y, CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT, crosshair_pic,
|
2011-12-27 08:59:58 +00:00
|
|
|
0, CROSSHAIR_HEIGHT,
|
2011-12-28 00:04:26 +00:00
|
|
|
CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT, crosshair_color);
|
2011-12-27 08:59:58 +00:00
|
|
|
}
|
2011-12-26 11:33:40 +00:00
|
|
|
|
2011-12-27 08:59:58 +00:00
|
|
|
static void
|
|
|
|
crosshair_5 (int x, int y)
|
|
|
|
{
|
2011-12-29 02:25:27 +00:00
|
|
|
draw_pic (x, y, CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT, crosshair_pic,
|
2011-12-27 08:59:58 +00:00
|
|
|
CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT,
|
2011-12-28 00:04:26 +00:00
|
|
|
CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT, crosshair_color);
|
2011-12-27 08:59:58 +00:00
|
|
|
}
|
2011-12-26 11:33:40 +00:00
|
|
|
|
2011-12-27 08:59:58 +00:00
|
|
|
static void (*crosshair_func[]) (int x, int y) = {
|
|
|
|
crosshair_1,
|
|
|
|
crosshair_2,
|
|
|
|
crosshair_3,
|
|
|
|
crosshair_4,
|
|
|
|
crosshair_5,
|
|
|
|
};
|
2011-12-26 11:33:40 +00:00
|
|
|
|
2012-02-18 13:28:42 +00:00
|
|
|
void
|
2012-02-22 07:32:34 +00:00
|
|
|
glsl_Draw_Crosshair (void)
|
2011-12-27 08:59:58 +00:00
|
|
|
{
|
|
|
|
int x, y;
|
|
|
|
size_t ch;
|
2011-12-26 11:33:40 +00:00
|
|
|
|
2011-12-27 08:59:58 +00:00
|
|
|
ch = crosshair->int_val - 1;
|
|
|
|
if (ch >= sizeof (crosshair_func) / sizeof (crosshair_func[0]))
|
|
|
|
return;
|
2011-12-26 11:33:40 +00:00
|
|
|
|
2011-12-27 08:59:58 +00:00
|
|
|
x = vid.conwidth / 2 + cl_crossx->int_val;
|
|
|
|
y = vid.conheight / 2 + cl_crossy->int_val;
|
2011-12-26 11:33:40 +00:00
|
|
|
|
2011-12-27 08:59:58 +00:00
|
|
|
crosshair_func[ch] (x, y);
|
|
|
|
}
|
2011-12-26 11:33:40 +00:00
|
|
|
|
2011-12-27 08:59:58 +00:00
|
|
|
void
|
2012-02-22 07:32:34 +00:00
|
|
|
glsl_Draw_CrosshairAt (int ch, int x, int y)
|
2011-12-27 08:59:58 +00:00
|
|
|
{
|
|
|
|
unsigned c = ch - 1;
|
|
|
|
|
|
|
|
if (c >= sizeof (crosshair_func) / sizeof (crosshair_func[0]))
|
|
|
|
return;
|
|
|
|
|
|
|
|
crosshair_func[c] (x, y);
|
2011-12-26 11:33:40 +00:00
|
|
|
}
|
|
|
|
|
2012-02-18 13:28:42 +00:00
|
|
|
void
|
2012-02-22 07:32:34 +00:00
|
|
|
glsl_Draw_Pic (int x, int y, qpic_t *pic)
|
2011-12-23 03:19:50 +00:00
|
|
|
{
|
2011-12-28 00:04:26 +00:00
|
|
|
static quat_t color = { 1, 1, 1, 1};
|
2011-12-29 02:25:27 +00:00
|
|
|
draw_pic (x, y, pic->width, pic->height, pic,
|
|
|
|
0, 0, pic->width, pic->height, color);
|
2011-12-23 03:19:50 +00:00
|
|
|
}
|
|
|
|
|
2012-02-18 13:28:42 +00:00
|
|
|
void
|
2012-02-22 07:32:34 +00:00
|
|
|
glsl_Draw_Picf (float x, float y, qpic_t *pic)
|
2012-02-06 10:32:30 +00:00
|
|
|
{
|
|
|
|
static quat_t color = { 1, 1, 1, 1};
|
|
|
|
draw_pic (x, y, pic->width, pic->height, pic,
|
|
|
|
0, 0, pic->width, pic->height, color);
|
|
|
|
}
|
|
|
|
|
2012-02-18 13:28:42 +00:00
|
|
|
void
|
2012-02-22 07:32:34 +00:00
|
|
|
glsl_Draw_SubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width,
|
|
|
|
int height)
|
2011-12-23 03:19:50 +00:00
|
|
|
{
|
2011-12-28 00:04:26 +00:00
|
|
|
static quat_t color = { 1, 1, 1, 1};
|
2011-12-29 02:25:27 +00:00
|
|
|
draw_pic (x, y, width, height, pic, srcx, srcy, width, height, color);
|
2011-12-23 03:19:50 +00:00
|
|
|
}
|
|
|
|
|
2012-02-18 13:28:42 +00:00
|
|
|
void
|
2012-02-22 07:32:34 +00:00
|
|
|
glsl_Draw_ConsoleBackground (int lines, byte alpha)
|
2011-12-23 03:19:50 +00:00
|
|
|
{
|
2011-12-26 11:33:40 +00:00
|
|
|
float ofs = (vid.conheight - lines) / (float) vid.conheight;
|
|
|
|
float verts[][4] = {
|
|
|
|
{ 0, 0, 0, ofs},
|
|
|
|
{vid.conwidth, 0, 1, ofs},
|
|
|
|
{vid.conwidth, lines, 1, 1},
|
|
|
|
{ 0, 0, 0, ofs},
|
|
|
|
{vid.conwidth, lines, 1, 1},
|
|
|
|
{ 0, lines, 0, 1},
|
|
|
|
};
|
|
|
|
|
2011-12-29 09:23:09 +00:00
|
|
|
GL_FlushText (); // Flush text that should be rendered before the console
|
|
|
|
|
2011-12-26 11:33:40 +00:00
|
|
|
qfglUseProgram (quake_icon.program);
|
|
|
|
qfglEnableVertexAttribArray (quake_icon.vertex.location);
|
|
|
|
|
|
|
|
qfglUniformMatrix4fv (quake_icon.matrix.location, 1, false, proj_matrix);
|
|
|
|
|
|
|
|
qfglUniform1i (quake_icon.icon.location, 0);
|
|
|
|
qfglActiveTexture (GL_TEXTURE0 + 0);
|
|
|
|
qfglEnable (GL_TEXTURE_2D);
|
|
|
|
qfglBindTexture (GL_TEXTURE_2D, conback_texture);
|
|
|
|
|
|
|
|
qfglUniform1i (quake_icon.palette.location, 1);
|
|
|
|
qfglActiveTexture (GL_TEXTURE0 + 1);
|
|
|
|
qfglEnable (GL_TEXTURE_2D);
|
|
|
|
qfglBindTexture (GL_TEXTURE_2D, glsl_palette);
|
|
|
|
|
2011-12-28 00:04:26 +00:00
|
|
|
qfglVertexAttrib4f (quake_icon.color.location,
|
|
|
|
1, 1, 1, bound (0, alpha, 255) / 255.0);
|
|
|
|
|
2011-12-26 11:33:40 +00:00
|
|
|
qfglVertexAttribPointer (quake_icon.vertex.location, 4, GL_FLOAT,
|
|
|
|
0, 0, verts);
|
|
|
|
|
|
|
|
qfglDrawArrays (GL_TRIANGLES, 0, 6);
|
|
|
|
|
|
|
|
qfglDisableVertexAttribArray (quake_icon.vertex.location);
|
2011-12-23 03:19:50 +00:00
|
|
|
}
|
|
|
|
|
2012-02-18 13:28:42 +00:00
|
|
|
void
|
2012-02-22 07:32:34 +00:00
|
|
|
glsl_Draw_TileClear (int x, int y, int w, int h)
|
2011-12-23 03:19:50 +00:00
|
|
|
{
|
2011-12-29 09:15:15 +00:00
|
|
|
static quat_t color = { 1, 1, 1, 1 };
|
2012-01-13 10:47:16 +00:00
|
|
|
draw_pic (x, y, w, h, backtile_pic, 0, 0, w, h, color);
|
2011-12-23 03:19:50 +00:00
|
|
|
}
|
|
|
|
|
2012-02-18 13:28:42 +00:00
|
|
|
void
|
2012-02-22 07:32:34 +00:00
|
|
|
glsl_Draw_Fill (int x, int y, int w, int h, int c)
|
2011-12-23 03:19:50 +00:00
|
|
|
{
|
2011-12-29 02:25:27 +00:00
|
|
|
quat_t color;
|
|
|
|
|
|
|
|
VectorScale (vid.palette + c * 3, 1.0f/255.0f, color);
|
|
|
|
color[3] = 1.0;
|
|
|
|
draw_pic (x, y, w, h, white_pic, 0, 0, 8, 8, color);
|
2011-12-23 03:19:50 +00:00
|
|
|
}
|
|
|
|
|
2012-01-28 11:45:14 +00:00
|
|
|
static inline void
|
|
|
|
draw_blendscreen (quat_t color)
|
|
|
|
{
|
|
|
|
draw_pic (0, 0, vid.conwidth, vid.conheight, white_pic, 0, 0, 8, 8, color);
|
|
|
|
}
|
|
|
|
|
2012-02-18 13:28:42 +00:00
|
|
|
void
|
2012-02-22 07:32:34 +00:00
|
|
|
glsl_Draw_FadeScreen (void)
|
2011-12-23 03:19:50 +00:00
|
|
|
{
|
2011-12-29 08:51:31 +00:00
|
|
|
static quat_t color = { 0, 0, 0, 0.7 };
|
|
|
|
|
2011-12-29 09:23:09 +00:00
|
|
|
GL_FlushText (); // Flush text that should be rendered before the menu
|
2012-01-28 11:45:14 +00:00
|
|
|
draw_blendscreen (color);
|
2011-12-23 03:19:50 +00:00
|
|
|
}
|
2011-12-25 10:42:39 +00:00
|
|
|
|
2011-12-25 23:12:05 +00:00
|
|
|
static void
|
|
|
|
ortho_mat (float *proj, float xmin, float xmax, float ymin, float ymax,
|
|
|
|
float znear, float zfar)
|
|
|
|
{
|
2012-01-13 10:46:52 +00:00
|
|
|
proj[0] = 2 / (xmax - xmin);
|
2011-12-25 23:12:05 +00:00
|
|
|
proj[4] = 0;
|
|
|
|
proj[8] = 0;
|
2012-01-13 10:46:52 +00:00
|
|
|
proj[12] = -(xmax + xmin) / (xmax - xmin);
|
2011-12-25 23:12:05 +00:00
|
|
|
|
|
|
|
proj[1] = 0;
|
2012-01-13 10:46:52 +00:00
|
|
|
proj[5] = 2 / (ymax - ymin);
|
2011-12-25 23:12:05 +00:00
|
|
|
proj[9] = 0;
|
2012-01-13 10:46:52 +00:00
|
|
|
proj[13] = -(ymax + ymin) / (ymax - ymin);
|
2011-12-25 23:12:05 +00:00
|
|
|
|
|
|
|
proj[2] = 0;
|
|
|
|
proj[6] = 0;
|
2012-01-13 10:46:52 +00:00
|
|
|
proj[10] = -2 / (zfar - znear);
|
|
|
|
proj[14] = -(zfar + znear) / (zfar - znear);
|
2011-12-25 23:12:05 +00:00
|
|
|
|
|
|
|
proj[3] = 0;
|
|
|
|
proj[7] = 0;
|
|
|
|
proj[11] = 0;
|
|
|
|
proj[15] = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
set_2d (int width, int height)
|
|
|
|
{
|
|
|
|
qfglViewport (0, 0, vid.width, vid.height);
|
|
|
|
|
|
|
|
qfglDisable (GL_DEPTH_TEST);
|
|
|
|
qfglDisable (GL_CULL_FACE);
|
|
|
|
|
|
|
|
ortho_mat (proj_matrix, 0, width, height, 0, -99999, 99999);
|
|
|
|
}
|
|
|
|
|
2011-12-25 10:42:39 +00:00
|
|
|
void
|
2011-12-25 22:59:36 +00:00
|
|
|
GL_Set2D (void)
|
|
|
|
{
|
2011-12-25 23:12:05 +00:00
|
|
|
set_2d (vid.width, vid.height);
|
2011-12-25 22:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GL_Set2DScaled (void)
|
|
|
|
{
|
2011-12-25 23:12:05 +00:00
|
|
|
set_2d (vid.conwidth, vid.conheight);
|
2011-12-25 22:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GL_DrawReset (void)
|
2011-12-25 10:42:39 +00:00
|
|
|
{
|
|
|
|
char_queue->size = 0;
|
|
|
|
}
|
2011-12-25 22:59:36 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
GL_FlushText (void)
|
|
|
|
{
|
2011-12-25 23:12:05 +00:00
|
|
|
if (char_queue->size)
|
|
|
|
flush_text ();
|
2011-12-25 22:59:36 +00:00
|
|
|
}
|
2012-01-28 11:45:14 +00:00
|
|
|
|
|
|
|
void
|
2012-02-22 07:32:34 +00:00
|
|
|
glsl_Draw_BlendScreen (quat_t color)
|
2012-01-28 11:45:14 +00:00
|
|
|
{
|
|
|
|
if (!color[3])
|
|
|
|
return;
|
|
|
|
draw_blendscreen (color);
|
|
|
|
}
|