2009-11-04 21:16:50 +00:00
|
|
|
#include "quakedef.h"
|
|
|
|
#ifndef SERVERONLY
|
|
|
|
#include "shader.h"
|
|
|
|
#include "gl_draw.h"
|
|
|
|
|
|
|
|
texid_t missing_texture;
|
2012-11-27 03:23:19 +00:00
|
|
|
texid_t missing_texture_gloss;
|
2011-03-31 11:00:23 +00:00
|
|
|
|
|
|
|
texid_t translate_texture;
|
|
|
|
shader_t *translate_shader;
|
|
|
|
|
2011-03-31 19:46:26 +00:00
|
|
|
texid_t ch_int_texture;
|
|
|
|
vec3_t ch_color;
|
|
|
|
shader_t *shader_crosshair;
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
static mpic_t *conback;
|
|
|
|
static mpic_t *draw_backtile;
|
2011-03-12 13:51:40 +00:00
|
|
|
static shader_t *shader_draw_fill, *shader_draw_fill_trans;
|
2009-11-04 21:16:50 +00:00
|
|
|
mpic_t *draw_disc;
|
|
|
|
|
2012-11-27 03:23:19 +00:00
|
|
|
shader_t *shader_contrastup;
|
|
|
|
shader_t *shader_contrastdown;
|
|
|
|
shader_t *shader_brightness;
|
2010-05-01 22:47:47 +00:00
|
|
|
shader_t *shader_polyblend;
|
2011-03-12 13:51:40 +00:00
|
|
|
shader_t *shader_menutint;
|
2010-05-01 22:47:47 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
static mesh_t draw_mesh;
|
|
|
|
static vecV_t draw_mesh_xyz[4];
|
2010-12-18 17:02:47 +00:00
|
|
|
vec2_t draw_mesh_st[4];
|
2009-11-04 21:16:50 +00:00
|
|
|
static avec4_t draw_mesh_colors[4];
|
2010-05-01 22:47:47 +00:00
|
|
|
index_t r_quad_indexes[6] = {0, 1, 2, 2, 3, 0};
|
2011-04-20 23:34:13 +00:00
|
|
|
unsigned int r2d_be_flags;
|
2009-11-04 21:16:50 +00:00
|
|
|
|
|
|
|
extern cvar_t scr_conalpha;
|
|
|
|
extern cvar_t gl_conback;
|
|
|
|
extern cvar_t gl_font;
|
2012-11-27 03:23:19 +00:00
|
|
|
extern cvar_t gl_contrast, gl_brightness;
|
2011-02-25 04:22:14 +00:00
|
|
|
extern cvar_t gl_screenangle;
|
2010-07-11 02:22:39 +00:00
|
|
|
extern cvar_t vid_conautoscale;
|
2010-11-22 02:03:28 +00:00
|
|
|
extern cvar_t vid_conheight;
|
|
|
|
extern cvar_t vid_conwidth;
|
2010-11-02 23:17:25 +00:00
|
|
|
void R2D_Font_Callback(struct cvar_s *var, char *oldvalue);
|
2010-11-22 02:03:28 +00:00
|
|
|
void R2D_Conautoscale_Callback(struct cvar_s *var, char *oldvalue);
|
2011-02-25 04:22:14 +00:00
|
|
|
void R2D_ScreenAngle_Callback(struct cvar_s *var, char *oldvalue);
|
2010-11-22 02:03:28 +00:00
|
|
|
void R2D_Conheight_Callback(struct cvar_s *var, char *oldvalue);
|
|
|
|
void R2D_Conwidth_Callback(struct cvar_s *var, char *oldvalue);
|
2009-11-04 21:16:50 +00:00
|
|
|
|
2011-03-31 19:46:26 +00:00
|
|
|
extern cvar_t crosshair;
|
|
|
|
extern cvar_t crosshaircolor;
|
|
|
|
extern cvar_t crosshairsize;
|
|
|
|
extern cvar_t crosshairimage;
|
|
|
|
extern cvar_t crosshairalpha;
|
|
|
|
void R2D_Crosshair_Callback(struct cvar_s *var, char *oldvalue);
|
|
|
|
void R2D_CrosshairImage_Callback(struct cvar_s *var, char *oldvalue);
|
|
|
|
void R2D_CrosshairColor_Callback(struct cvar_s *var, char *oldvalue);
|
|
|
|
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
//We need this for minor things though, so we'll just use the slow accurate method.
|
2011-05-29 04:26:29 +00:00
|
|
|
//this is unlikly to be called too often.
|
2009-11-04 21:16:50 +00:00
|
|
|
qbyte GetPaletteIndex(int red, int green, int blue)
|
|
|
|
{
|
|
|
|
//slow, horrible method.
|
|
|
|
{
|
|
|
|
int i, best=15;
|
|
|
|
int bestdif=256*256*256, curdif;
|
|
|
|
extern qbyte *host_basepal;
|
|
|
|
qbyte *pa;
|
|
|
|
|
|
|
|
#define _abs(x) ((x)*(x))
|
|
|
|
|
|
|
|
pa = host_basepal;
|
|
|
|
for (i = 0; i < 256; i++, pa+=3)
|
|
|
|
{
|
|
|
|
curdif = _abs(red - pa[0]) + _abs(green - pa[1]) + _abs(blue - pa[2]);
|
|
|
|
if (curdif < bestdif)
|
|
|
|
{
|
|
|
|
if (curdif<1)
|
|
|
|
return i;
|
|
|
|
bestdif = curdif;
|
|
|
|
best = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return best;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-05 19:42:36 +00:00
|
|
|
void R2D_Shutdown(void)
|
|
|
|
{
|
|
|
|
Cvar_Unhook(&gl_font);
|
|
|
|
Cvar_Unhook(&vid_conautoscale);
|
|
|
|
Cvar_Unhook(&gl_screenangle);
|
|
|
|
Cvar_Unhook(&vid_conheight);
|
|
|
|
Cvar_Unhook(&vid_conwidth);
|
|
|
|
|
|
|
|
Cvar_Unhook(&crosshair);
|
|
|
|
Cvar_Unhook(&crosshairimage);
|
|
|
|
Cvar_Unhook(&crosshaircolor);
|
Android: fat presses, vibrator, onscreen keyboard, keep-screen-on, console scaling, touch-based console scrolling, additional bindables.
Some memory leaks fixed.
latency with the nq protocol over loopback is much reduced.
Terrain: now mostly a property of a (q1 for now) bsp map, file format changed, glsl now built in, terrain editor builtin improved/changed, holes supported.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4067 fc73d0e0-1445-4013-8a0c-d673dee63da5
2012-07-14 16:25:18 +00:00
|
|
|
|
|
|
|
BZ_Free(cl_stris);
|
|
|
|
cl_stris = NULL;
|
|
|
|
BZ_Free(cl_strisvertv);
|
|
|
|
cl_strisvertv = NULL;
|
|
|
|
BZ_Free(cl_strisvertc);
|
|
|
|
cl_strisvertc = NULL;
|
|
|
|
BZ_Free(cl_strisvertt);
|
|
|
|
cl_strisvertt = NULL;
|
|
|
|
BZ_Free(cl_strisidx);
|
|
|
|
cl_strisidx = NULL;
|
|
|
|
cl_numstrisidx = 0;
|
|
|
|
cl_maxstrisidx = 0;
|
|
|
|
cl_numstrisvert = 0;
|
|
|
|
cl_maxstrisvert = 0;
|
|
|
|
cl_numstris = 0;
|
|
|
|
cl_maxstris = 0;
|
2012-09-30 05:52:03 +00:00
|
|
|
|
|
|
|
if (font_conchar)
|
|
|
|
Font_Free(font_conchar);
|
|
|
|
font_conchar = NULL;
|
|
|
|
if (font_tiny)
|
|
|
|
Font_Free(font_tiny);
|
|
|
|
font_tiny = NULL;
|
2012-07-05 19:42:36 +00:00
|
|
|
}
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
/*
|
|
|
|
Iniitalise the 2d rendering functions (including font).
|
|
|
|
Image loading code must be ready for use at this point.
|
|
|
|
*/
|
|
|
|
void R2D_Init(void)
|
|
|
|
{
|
2012-11-27 03:23:19 +00:00
|
|
|
unsigned int nogloss[4*4];
|
|
|
|
int i;
|
2012-12-04 19:37:57 +00:00
|
|
|
unsigned int glossval;
|
|
|
|
extern cvar_t gl_specular_fallback;
|
2010-07-11 02:22:39 +00:00
|
|
|
conback = NULL;
|
|
|
|
|
2010-05-01 22:47:47 +00:00
|
|
|
Shader_Init();
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
BE_Init();
|
2010-05-01 22:47:47 +00:00
|
|
|
draw_mesh.istrifan = true;
|
2009-11-04 21:16:50 +00:00
|
|
|
draw_mesh.numvertexes = 4;
|
|
|
|
draw_mesh.numindexes = 6;
|
|
|
|
draw_mesh.xyz_array = draw_mesh_xyz;
|
|
|
|
draw_mesh.st_array = draw_mesh_st;
|
|
|
|
draw_mesh.colors4f_array = draw_mesh_colors;
|
|
|
|
draw_mesh.indexes = r_quad_indexes;
|
|
|
|
|
|
|
|
|
|
|
|
Font_Init();
|
|
|
|
|
2011-10-27 15:46:36 +00:00
|
|
|
#ifdef warningmsg
|
|
|
|
#pragma warningmsg("Fixme: move conwidth handling into here")
|
2011-05-29 04:26:29 +00:00
|
|
|
#endif
|
2009-11-04 21:16:50 +00:00
|
|
|
|
2012-12-04 19:37:57 +00:00
|
|
|
glossval = min(gl_specular_fallback.value*255, 255);
|
|
|
|
glossval *= 0x10101;
|
|
|
|
glossval |= 0xff000000;
|
|
|
|
glossval = LittleLong(glossval);
|
2012-11-27 03:23:19 +00:00
|
|
|
for (i = 0; i < 4*4; i++)
|
2012-12-04 19:37:57 +00:00
|
|
|
nogloss[i] = glossval;
|
2009-11-04 21:16:50 +00:00
|
|
|
missing_texture = R_LoadTexture8("no_texture", 16, 16, (unsigned char*)r_notexture_mip + r_notexture_mip->offsets[0], IF_NOALPHA|IF_NOGAMMA, 0);
|
2012-11-27 03:23:19 +00:00
|
|
|
missing_texture_gloss = R_LoadTexture("no_texture_gloss", 4, 4, TF_RGBA32, (unsigned char*)nogloss, IF_NOGAMMA);
|
2011-03-31 11:00:23 +00:00
|
|
|
translate_texture = r_nulltex;
|
2011-03-31 19:46:26 +00:00
|
|
|
ch_int_texture = r_nulltex;
|
2009-11-04 21:16:50 +00:00
|
|
|
|
2011-03-31 02:32:32 +00:00
|
|
|
draw_backtile = R_RegisterShader("gfx/backtile.lmp",
|
|
|
|
"{\n"
|
2011-05-20 04:10:46 +00:00
|
|
|
"if $nofixed\n"
|
|
|
|
"[\n"
|
|
|
|
"program default2d\n"
|
|
|
|
"]\n"
|
2011-03-31 02:32:32 +00:00
|
|
|
"nomipmaps\n"
|
|
|
|
"{\n"
|
|
|
|
"map $diffuse\n"
|
|
|
|
"}\n"
|
|
|
|
"}\n");
|
|
|
|
if (!TEXVALID(draw_backtile->defaulttextures.base))
|
|
|
|
draw_backtile->defaulttextures.base = R_LoadHiResTexture("gfx/backtile", NULL, IF_NOPICMIP|IF_NOMIPMAP);
|
|
|
|
if (!TEXVALID(draw_backtile->defaulttextures.base))
|
|
|
|
draw_backtile->defaulttextures.base = R_LoadHiResTexture("gfx/menu/backtile", NULL, IF_NOPICMIP|IF_NOMIPMAP);
|
2009-11-04 21:16:50 +00:00
|
|
|
|
2011-03-12 13:51:40 +00:00
|
|
|
shader_draw_fill = R_RegisterShader("fill_opaque",
|
2010-02-06 01:25:04 +00:00
|
|
|
"{\n"
|
2011-06-05 23:53:33 +00:00
|
|
|
"program defaultfill\n"
|
2010-02-06 01:25:04 +00:00
|
|
|
"{\n"
|
|
|
|
"map $whiteimage\n"
|
|
|
|
"rgbgen vertex\n"
|
|
|
|
"}\n"
|
|
|
|
"}\n");
|
2011-03-12 13:51:40 +00:00
|
|
|
shader_draw_fill_trans = R_RegisterShader("fill_trans",
|
2010-02-06 01:25:04 +00:00
|
|
|
"{\n"
|
2011-06-05 23:53:33 +00:00
|
|
|
"program defaultfill\n"
|
2010-02-06 01:25:04 +00:00
|
|
|
"{\n"
|
|
|
|
"map $whiteimage\n"
|
|
|
|
"rgbgen vertex\n"
|
|
|
|
"alphagen vertex\n"
|
|
|
|
"blendfunc blend\n"
|
|
|
|
"}\n"
|
|
|
|
"}\n");
|
2012-11-27 03:23:19 +00:00
|
|
|
shader_contrastup = R_RegisterShader("constrastupshader",
|
2010-05-01 22:47:47 +00:00
|
|
|
"{\n"
|
2011-06-05 23:53:33 +00:00
|
|
|
"program defaultfill\n"
|
2010-05-01 22:47:47 +00:00
|
|
|
"{\n"
|
2012-11-27 03:23:19 +00:00
|
|
|
"nodepthtest\n"
|
2010-05-01 22:47:47 +00:00
|
|
|
"map $whiteimage\n"
|
|
|
|
"blendfunc gl_dst_color gl_one\n"
|
|
|
|
"rgbgen vertex\n"
|
|
|
|
"alphagen vertex\n"
|
|
|
|
"}\n"
|
|
|
|
"}\n"
|
|
|
|
);
|
2012-11-27 03:23:19 +00:00
|
|
|
shader_contrastdown = R_RegisterShader("constrastdownshader",
|
|
|
|
"{\n"
|
|
|
|
"program defaultfill\n"
|
|
|
|
"{\n"
|
|
|
|
"nodepthtest\n"
|
|
|
|
"map $whiteimage\n"
|
|
|
|
"blendfunc gl_dst_color gl_zero\n"
|
|
|
|
"rgbgen vertex\n"
|
|
|
|
"alphagen vertex\n"
|
|
|
|
"}\n"
|
|
|
|
"}\n"
|
|
|
|
);
|
|
|
|
shader_brightness = R_RegisterShader("brightnessshader",
|
|
|
|
"{\n"
|
|
|
|
"program defaultfill\n"
|
|
|
|
"{\n"
|
|
|
|
"nodepthtest\n"
|
|
|
|
"map $whiteimage\n"
|
|
|
|
"blendfunc gl_one gl_one\n"
|
|
|
|
"rgbgen vertex\n"
|
|
|
|
"alphagen vertex\n"
|
|
|
|
"}\n"
|
|
|
|
"}\n"
|
|
|
|
);
|
2010-05-01 22:47:47 +00:00
|
|
|
shader_polyblend = R_RegisterShader("polyblendshader",
|
|
|
|
"{\n"
|
2011-06-05 23:53:33 +00:00
|
|
|
"program defaultfill\n"
|
2010-05-01 22:47:47 +00:00
|
|
|
"{\n"
|
|
|
|
"map $whiteimage\n"
|
|
|
|
"blendfunc gl_src_alpha gl_one_minus_src_alpha\n"
|
|
|
|
"rgbgen vertex\n"
|
|
|
|
"alphagen vertex\n"
|
|
|
|
"}\n"
|
|
|
|
"}\n"
|
|
|
|
);
|
2011-03-12 13:51:40 +00:00
|
|
|
shader_menutint = R_RegisterShader("menutint_glsl",
|
|
|
|
"{\n"
|
|
|
|
"if $glsl && gl_menutint_shader != 0\n"
|
|
|
|
"[\n"
|
|
|
|
"glslprogram\n"
|
|
|
|
"{\n"
|
|
|
|
"#ifdef VERTEX_SHADER\n"
|
|
|
|
"\
|
2011-03-31 02:32:32 +00:00
|
|
|
attribute vec2 v_texcoord;\
|
2011-03-12 13:51:40 +00:00
|
|
|
varying vec2 texcoord;\
|
|
|
|
uniform vec3 rendertexturescale;\
|
|
|
|
void main(void)\
|
|
|
|
{\
|
2011-03-31 02:32:32 +00:00
|
|
|
texcoord.x = v_texcoord.x*rendertexturescale.x;\
|
|
|
|
texcoord.y = (1.0-v_texcoord.y)*rendertexturescale.y;\
|
2011-06-05 23:53:33 +00:00
|
|
|
gl_Position = ftetransform();\
|
2011-03-12 13:51:40 +00:00
|
|
|
}\
|
|
|
|
\n"
|
|
|
|
"#endif\n"
|
|
|
|
"#ifdef FRAGMENT_SHADER\n"
|
|
|
|
"\
|
|
|
|
varying vec2 texcoord;\
|
|
|
|
uniform vec3 colorparam;\
|
2011-03-31 02:32:32 +00:00
|
|
|
uniform sampler2D s_t0;\
|
2011-03-12 13:51:40 +00:00
|
|
|
uniform int invert;\
|
|
|
|
const vec3 lumfactors = vec3(0.299, 0.587, 0.114);\
|
|
|
|
const vec3 invertvec = vec3(1.0, 1.0, 1.0);\
|
|
|
|
void main(void)\
|
|
|
|
{\
|
2011-03-31 02:32:32 +00:00
|
|
|
vec3 texcolor = texture2D(s_t0, texcoord).rgb;\
|
2011-03-12 13:51:40 +00:00
|
|
|
float luminance = dot(lumfactors, texcolor);\
|
|
|
|
texcolor = vec3(luminance, luminance, luminance);\
|
|
|
|
texcolor *= colorparam;\
|
|
|
|
texcolor = (invert > 0) ? (invertvec - texcolor) : texcolor;\
|
|
|
|
gl_FragColor = vec4(texcolor, 1.0);\
|
|
|
|
}\n"
|
|
|
|
"#endif\n"
|
|
|
|
"}\n"
|
|
|
|
"param cvari r_menutint_inverse invert\n"
|
|
|
|
"param cvar3f r_menutint colorparam\n"
|
|
|
|
"param rendertexturescale rendertexturescale\n"
|
|
|
|
|
|
|
|
"{\n"
|
|
|
|
"map $currentrender\n"
|
|
|
|
"}\n"
|
|
|
|
"][\n"
|
|
|
|
"{\n"
|
2011-10-27 15:46:36 +00:00
|
|
|
"map $whiteimage\n"
|
2011-03-12 13:51:40 +00:00
|
|
|
"blendfunc gl_dst_color gl_zero\n"
|
|
|
|
"rgbgen const $r_menutint\n"
|
|
|
|
"}\n"
|
|
|
|
"]\n"
|
|
|
|
"}\n"
|
|
|
|
);
|
2011-03-31 19:46:26 +00:00
|
|
|
shader_crosshair = R_RegisterShader("crosshairshader",
|
|
|
|
"{\n"
|
2011-05-20 04:10:46 +00:00
|
|
|
"if $nofixed\n"
|
|
|
|
"[\n"
|
|
|
|
"program default2d\n"
|
|
|
|
"]\n"
|
2011-03-31 19:46:26 +00:00
|
|
|
"nomipmaps\n"
|
|
|
|
"{\n"
|
|
|
|
"map $diffuse\n"
|
|
|
|
"blendfunc blend\n"
|
|
|
|
"rgbgen vertex\n"
|
|
|
|
"alphagen vertex\n"
|
|
|
|
"}\n"
|
|
|
|
"}\n"
|
|
|
|
);
|
|
|
|
|
2010-02-06 01:25:04 +00:00
|
|
|
|
2010-11-02 23:17:25 +00:00
|
|
|
Cvar_Hook(&gl_font, R2D_Font_Callback);
|
2010-11-22 02:03:28 +00:00
|
|
|
Cvar_Hook(&vid_conautoscale, R2D_Conautoscale_Callback);
|
2011-02-25 04:22:14 +00:00
|
|
|
Cvar_Hook(&gl_screenangle, R2D_ScreenAngle_Callback);
|
2010-11-22 02:03:28 +00:00
|
|
|
Cvar_Hook(&vid_conheight, R2D_Conheight_Callback);
|
|
|
|
Cvar_Hook(&vid_conwidth, R2D_Conwidth_Callback);
|
2010-11-02 23:17:25 +00:00
|
|
|
|
2011-03-31 19:46:26 +00:00
|
|
|
Cvar_Hook(&crosshair, R2D_Crosshair_Callback);
|
|
|
|
Cvar_Hook(&crosshairimage, R2D_CrosshairImage_Callback);
|
|
|
|
Cvar_Hook(&crosshaircolor, R2D_CrosshairColor_Callback);
|
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
Cvar_ForceCallback(&gl_conback);
|
|
|
|
Cvar_ForceCallback(&vid_conautoscale);
|
|
|
|
Cvar_ForceCallback(&gl_font);
|
2011-03-31 19:46:26 +00:00
|
|
|
|
|
|
|
Cvar_ForceCallback(&crosshair);
|
|
|
|
Cvar_ForceCallback(&crosshaircolor);
|
2011-05-26 16:46:43 +00:00
|
|
|
|
|
|
|
#ifdef PLUGINS
|
|
|
|
Plug_DrawReloadImages();
|
|
|
|
#endif
|
2009-11-04 21:16:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mpic_t *R2D_SafeCachePic (char *path)
|
|
|
|
{
|
2011-04-23 20:37:20 +00:00
|
|
|
shader_t *s;
|
|
|
|
if (!qrenderer)
|
|
|
|
return NULL;
|
|
|
|
s = R_RegisterPic(path);
|
2011-05-20 04:10:46 +00:00
|
|
|
if (s->flags & SHADER_NOIMAGE)
|
|
|
|
return NULL;
|
|
|
|
return s;
|
2009-11-04 21:16:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
char *failedpic; //easier this way
|
|
|
|
mpic_t *R2D_SafePicFromWad (char *name)
|
|
|
|
{
|
2012-01-17 07:57:46 +00:00
|
|
|
char newnamewad[32];
|
|
|
|
char newnamegfx[32];
|
2009-11-04 21:16:50 +00:00
|
|
|
shader_t *s;
|
2012-01-17 07:57:46 +00:00
|
|
|
|
|
|
|
snprintf(newnamewad, sizeof(newnamewad), "wad/%s.lmp", name);
|
|
|
|
snprintf(newnamegfx, sizeof(newnamegfx), "gfx/%s.lmp", name);
|
|
|
|
|
|
|
|
s = R_RegisterPic(newnamewad);
|
|
|
|
if (!(s->flags & SHADER_NOIMAGE))
|
|
|
|
return s;
|
|
|
|
|
|
|
|
s = R_RegisterPic(newnamegfx);
|
2011-05-20 04:10:46 +00:00
|
|
|
if (!(s->flags & SHADER_NOIMAGE))
|
2009-11-04 21:16:50 +00:00
|
|
|
return s;
|
2012-01-17 07:57:46 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
failedpic = name;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void R2D_ImageColours(float r, float g, float b, float a)
|
|
|
|
{
|
|
|
|
draw_mesh_colors[0][0] = r;
|
|
|
|
draw_mesh_colors[0][1] = g;
|
|
|
|
draw_mesh_colors[0][2] = b;
|
|
|
|
draw_mesh_colors[0][3] = a;
|
|
|
|
Vector4Copy(draw_mesh_colors[0], draw_mesh_colors[1]);
|
|
|
|
Vector4Copy(draw_mesh_colors[0], draw_mesh_colors[2]);
|
|
|
|
Vector4Copy(draw_mesh_colors[0], draw_mesh_colors[3]);
|
|
|
|
}
|
2010-02-06 01:25:04 +00:00
|
|
|
void R2D_ImagePaletteColour(unsigned int i, float a)
|
|
|
|
{
|
2011-03-30 17:34:37 +00:00
|
|
|
draw_mesh_colors[0][0] = host_basepal[i*3+0]/255.0;
|
|
|
|
draw_mesh_colors[0][1] = host_basepal[i*3+1]/255.0;
|
|
|
|
draw_mesh_colors[0][2] = host_basepal[i*3+2]/255.0;
|
2010-02-06 01:25:04 +00:00
|
|
|
draw_mesh_colors[0][3] = a;
|
|
|
|
Vector4Copy(draw_mesh_colors[0], draw_mesh_colors[1]);
|
|
|
|
Vector4Copy(draw_mesh_colors[0], draw_mesh_colors[2]);
|
|
|
|
Vector4Copy(draw_mesh_colors[0], draw_mesh_colors[3]);
|
|
|
|
}
|
2009-11-04 21:16:50 +00:00
|
|
|
|
|
|
|
//awkward and weird to use
|
|
|
|
void R2D_Image(float x, float y, float w, float h, float s1, float t1, float s2, float t2, mpic_t *pic)
|
|
|
|
{
|
|
|
|
if (!pic)
|
|
|
|
return;
|
|
|
|
/*
|
|
|
|
if (w == 0 && h == 0)
|
|
|
|
{
|
|
|
|
w = pic->width;
|
|
|
|
h = pic->height;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
draw_mesh_xyz[0][0] = x;
|
|
|
|
draw_mesh_xyz[0][1] = y;
|
|
|
|
draw_mesh_st[0][0] = s1;
|
|
|
|
draw_mesh_st[0][1] = t1;
|
|
|
|
|
|
|
|
draw_mesh_xyz[1][0] = x+w;
|
|
|
|
draw_mesh_xyz[1][1] = y;
|
|
|
|
draw_mesh_st[1][0] = s2;
|
|
|
|
draw_mesh_st[1][1] = t1;
|
|
|
|
|
|
|
|
draw_mesh_xyz[2][0] = x+w;
|
|
|
|
draw_mesh_xyz[2][1] = y+h;
|
|
|
|
draw_mesh_st[2][0] = s2;
|
|
|
|
draw_mesh_st[2][1] = t2;
|
|
|
|
|
|
|
|
draw_mesh_xyz[3][0] = x;
|
|
|
|
draw_mesh_xyz[3][1] = y+h;
|
|
|
|
draw_mesh_st[3][0] = s1;
|
|
|
|
draw_mesh_st[3][1] = t2;
|
|
|
|
|
2011-04-20 23:34:13 +00:00
|
|
|
BE_DrawMesh_Single(pic, &draw_mesh, NULL, &pic->defaulttextures, r2d_be_flags);
|
2009-11-04 21:16:50 +00:00
|
|
|
}
|
|
|
|
|
2010-02-06 01:25:04 +00:00
|
|
|
/*draws a block of the current colour on the screen*/
|
|
|
|
void R2D_FillBlock(int x, int y, int w, int h)
|
|
|
|
{
|
|
|
|
draw_mesh_xyz[0][0] = x;
|
|
|
|
draw_mesh_xyz[0][1] = y;
|
|
|
|
|
|
|
|
draw_mesh_xyz[1][0] = x+w;
|
|
|
|
draw_mesh_xyz[1][1] = y;
|
|
|
|
|
|
|
|
draw_mesh_xyz[2][0] = x+w;
|
|
|
|
draw_mesh_xyz[2][1] = y+h;
|
|
|
|
|
|
|
|
draw_mesh_xyz[3][0] = x;
|
|
|
|
draw_mesh_xyz[3][1] = y+h;
|
|
|
|
|
|
|
|
if (draw_mesh_colors[0][3] != 1)
|
2011-04-20 23:34:13 +00:00
|
|
|
BE_DrawMesh_Single(shader_draw_fill_trans, &draw_mesh, NULL, &shader_draw_fill_trans->defaulttextures, r2d_be_flags);
|
2010-02-06 01:25:04 +00:00
|
|
|
else
|
2011-04-20 23:34:13 +00:00
|
|
|
BE_DrawMesh_Single(shader_draw_fill, &draw_mesh, NULL, &shader_draw_fill->defaulttextures, r2d_be_flags);
|
2010-02-06 01:25:04 +00:00
|
|
|
}
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
void R2D_ScalePic (int x, int y, int width, int height, mpic_t *pic)
|
|
|
|
{
|
|
|
|
R2D_Image(x, y, width, height, 0, 0, 1, 1, pic);
|
|
|
|
}
|
|
|
|
|
|
|
|
void R2D_SubPic(int x, int y, int width, int height, mpic_t *pic, int srcx, int srcy, int srcwidth, int srcheight)
|
|
|
|
{
|
|
|
|
float newsl, newtl, newsh, newth;
|
|
|
|
|
|
|
|
newsl = (srcx)/(float)srcwidth;
|
|
|
|
newsh = newsl + (width)/(float)srcwidth;
|
|
|
|
|
|
|
|
newtl = (srcy)/(float)srcheight;
|
|
|
|
newth = newtl + (height)/(float)srcheight;
|
|
|
|
|
|
|
|
R2D_Image(x, y, width, height, newsl, newtl, newsh, newth, pic);
|
|
|
|
}
|
|
|
|
|
2011-03-31 11:00:23 +00:00
|
|
|
/* this is an ugly special case drawing func that's only used for the player color selection menu */
|
|
|
|
void R2D_TransPicTranslate (int x, int y, int width, int height, qbyte *pic, qbyte *translation)
|
|
|
|
{
|
|
|
|
int v, u, c;
|
|
|
|
unsigned trans[64*64], *dest;
|
|
|
|
qbyte *src;
|
|
|
|
int p;
|
|
|
|
|
|
|
|
c = width * height;
|
|
|
|
|
|
|
|
dest = trans;
|
|
|
|
for (v=0 ; v<64 ; v++, dest += 64)
|
|
|
|
{
|
|
|
|
src = &pic[ ((v*height)>>6) *width];
|
|
|
|
for (u=0 ; u<64 ; u++)
|
|
|
|
{
|
|
|
|
p = src[(u*width)>>6];
|
|
|
|
if (p == 255)
|
|
|
|
dest[u] = 0x0;
|
|
|
|
else
|
|
|
|
dest[u] = d_8to24rgbtable[translation[p]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!TEXVALID(translate_texture))
|
|
|
|
{
|
2012-09-30 05:52:03 +00:00
|
|
|
translate_texture = R_AllocNewTexture("***translatedpic***", 64, 64, 0);
|
2011-03-31 11:00:23 +00:00
|
|
|
translate_shader = R_RegisterShader("translatedpic", "{\n"
|
2011-05-20 04:10:46 +00:00
|
|
|
"if $nofixed\n"
|
|
|
|
"[\n"
|
|
|
|
"program default2d\n"
|
|
|
|
"]\n"
|
2011-03-31 11:00:23 +00:00
|
|
|
"nomipmaps\n"
|
|
|
|
"{\n"
|
|
|
|
"map $diffuse\n"
|
|
|
|
"blendfunc blend\n"
|
|
|
|
"}\n"
|
|
|
|
"}\n");
|
|
|
|
translate_shader->defaulttextures.base = translate_texture;
|
|
|
|
}
|
|
|
|
/* could avoid reuploading already translated textures but this func really isn't used enough anyway */
|
|
|
|
R_Upload(translate_texture, NULL, TF_RGBA32, trans, NULL, 64, 64, IF_NOMIPMAP|IF_NOGAMMA);
|
|
|
|
R2D_ScalePic(x, y, width, height, translate_shader);
|
|
|
|
}
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
/*
|
|
|
|
================
|
|
|
|
Draw_ConsoleBackground
|
|
|
|
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void R2D_ConsoleBackground (int firstline, int lastline, qboolean forceopaque)
|
|
|
|
{
|
|
|
|
float a;
|
|
|
|
int w, h;
|
|
|
|
if (!conback)
|
|
|
|
return;
|
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
w = vid.width;
|
|
|
|
h = vid.height;
|
2009-11-04 21:16:50 +00:00
|
|
|
|
|
|
|
if (forceopaque)
|
|
|
|
{
|
|
|
|
a = 1; // console background is necessary
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!scr_conalpha.value)
|
2011-05-29 04:26:29 +00:00
|
|
|
return;
|
2009-11-04 21:16:50 +00:00
|
|
|
|
|
|
|
a = scr_conalpha.value;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (scr_chatmode == 2)
|
|
|
|
{
|
|
|
|
h>>=1;
|
|
|
|
w>>=1;
|
|
|
|
}
|
|
|
|
if (a >= 1)
|
|
|
|
{
|
|
|
|
R2D_ImageColours(1, 1, 1, 1);
|
2010-07-11 02:22:39 +00:00
|
|
|
R2D_ScalePic(0, lastline-(int)vid.height, w, h, conback);
|
2009-11-04 21:16:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
R2D_ImageColours(1, 1, 1, a);
|
2010-07-11 02:22:39 +00:00
|
|
|
R2D_ScalePic (0, lastline - (int)vid.height, w, h, conback);
|
2009-11-04 21:16:50 +00:00
|
|
|
R2D_ImageColours(1, 1, 1, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void R2D_EditorBackground (void)
|
|
|
|
{
|
2012-11-27 03:23:19 +00:00
|
|
|
R2D_ImageColours(0, 0, 0, 1);
|
|
|
|
R2D_FillBlock(0, 0, vid.width, vid.height);
|
|
|
|
// R2D_ScalePic(0, 0, vid.width, vid.height, conback);
|
2009-11-04 21:16:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=============
|
|
|
|
Draw_TileClear
|
|
|
|
|
|
|
|
This repeats a 64*64 tile graphic to fill the screen around a sized down
|
|
|
|
refresh window.
|
|
|
|
=============
|
|
|
|
*/
|
|
|
|
void R2D_TileClear (int x, int y, int w, int h)
|
|
|
|
{
|
|
|
|
float newsl, newsh, newtl, newth;
|
|
|
|
newsl = (x)/(float)64;
|
|
|
|
newsh = newsl + (w)/(float)64;
|
|
|
|
|
|
|
|
newtl = (y)/(float)64;
|
|
|
|
newth = newtl + (h)/(float)64;
|
|
|
|
|
|
|
|
R2D_ImageColours(1,1,1,1);
|
|
|
|
|
|
|
|
draw_mesh_xyz[0][0] = x;
|
|
|
|
draw_mesh_xyz[0][1] = y;
|
|
|
|
draw_mesh_st[0][0] = newsl;
|
|
|
|
draw_mesh_st[0][1] = newtl;
|
|
|
|
|
|
|
|
draw_mesh_xyz[1][0] = x+w;
|
|
|
|
draw_mesh_xyz[1][1] = y;
|
|
|
|
draw_mesh_st[1][0] = newsh;
|
|
|
|
draw_mesh_st[1][1] = newtl;
|
|
|
|
|
|
|
|
draw_mesh_xyz[2][0] = x+w;
|
|
|
|
draw_mesh_xyz[2][1] = y+h;
|
|
|
|
draw_mesh_st[2][0] = newsh;
|
|
|
|
draw_mesh_st[2][1] = newth;
|
|
|
|
|
|
|
|
draw_mesh_xyz[3][0] = x;
|
|
|
|
draw_mesh_xyz[3][1] = y+h;
|
|
|
|
draw_mesh_st[3][0] = newsl;
|
|
|
|
draw_mesh_st[3][1] = newth;
|
|
|
|
|
2011-04-20 23:34:13 +00:00
|
|
|
BE_DrawMesh_Single(draw_backtile, &draw_mesh, NULL, &draw_backtile->defaulttextures, r2d_be_flags);
|
2009-11-04 21:16:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void R2D_Conback_Callback(struct cvar_s *var, char *oldvalue)
|
|
|
|
{
|
Fixes, workarounds, and breakages. Hexen2 should work much better (-hexen2 says no mission pack, -portals says h2mp). Started working on splitting bigcoords per client, far too much work still to go on that. Removed gl_ztrick entirely. Enabled csprogs download by default. Added client support for fitzquake's 666 protocol, needs testing, some cleanup for dp protocols too, no server support, couldn't selectively enable it anyway. Now attempting to cache shadow meshes for explosions and stuff. Played with lightmaps a little, should potentially run a little faster on certain (intel?) cards. Tweeked npfte a little to try to avoid deadlocks and crashes. Fixed sky worldspawn parsing. Added h2mp's model format. Fixed baseline issue in q2 client, made servers generate q2 baselines. MOVETYPE_PUSH will not rotate extra if rotation is forced. Made status command show allowed client types. Changed lighting on weapons - should now be shaded.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3572 fc73d0e0-1445-4013-8a0c-d673dee63da5
2010-08-11 03:36:31 +00:00
|
|
|
if (qrenderer == QR_NONE)
|
|
|
|
{
|
|
|
|
conback = NULL;
|
|
|
|
return;
|
|
|
|
}
|
2011-03-31 11:00:23 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
if (*var->string)
|
|
|
|
conback = R_RegisterPic(var->string);
|
2011-06-16 02:03:57 +00:00
|
|
|
if (!conback || conback->flags & SHADER_NOIMAGE)
|
2010-07-11 02:22:39 +00:00
|
|
|
{
|
2009-11-04 21:16:50 +00:00
|
|
|
conback = R_RegisterCustom("console", NULL, NULL);
|
2011-06-16 02:03:57 +00:00
|
|
|
if (!conback || conback->flags & SHADER_NOIMAGE)
|
2010-07-11 02:22:39 +00:00
|
|
|
{
|
Fixes, workarounds, and breakages. Hexen2 should work much better (-hexen2 says no mission pack, -portals says h2mp). Started working on splitting bigcoords per client, far too much work still to go on that. Removed gl_ztrick entirely. Enabled csprogs download by default. Added client support for fitzquake's 666 protocol, needs testing, some cleanup for dp protocols too, no server support, couldn't selectively enable it anyway. Now attempting to cache shadow meshes for explosions and stuff. Played with lightmaps a little, should potentially run a little faster on certain (intel?) cards. Tweeked npfte a little to try to avoid deadlocks and crashes. Fixed sky worldspawn parsing. Added h2mp's model format. Fixed baseline issue in q2 client, made servers generate q2 baselines. MOVETYPE_PUSH will not rotate extra if rotation is forced. Made status command show allowed client types. Changed lighting on weapons - should now be shaded.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3572 fc73d0e0-1445-4013-8a0c-d673dee63da5
2010-08-11 03:36:31 +00:00
|
|
|
if (M_GameType() == MGT_HEXEN2)
|
|
|
|
conback = R_RegisterPic("gfx/menu/conback.lmp");
|
|
|
|
else if (M_GameType() == MGT_QUAKE2)
|
2010-07-11 02:22:39 +00:00
|
|
|
conback = R_RegisterPic("pics/conback.pcx");
|
|
|
|
else
|
|
|
|
conback = R_RegisterPic("gfx/conback.lmp");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void R2D_Font_Callback(struct cvar_s *var, char *oldvalue)
|
|
|
|
{
|
|
|
|
if (font_conchar)
|
|
|
|
Font_Free(font_conchar);
|
Fixes, workarounds, and breakages. Hexen2 should work much better (-hexen2 says no mission pack, -portals says h2mp). Started working on splitting bigcoords per client, far too much work still to go on that. Removed gl_ztrick entirely. Enabled csprogs download by default. Added client support for fitzquake's 666 protocol, needs testing, some cleanup for dp protocols too, no server support, couldn't selectively enable it anyway. Now attempting to cache shadow meshes for explosions and stuff. Played with lightmaps a little, should potentially run a little faster on certain (intel?) cards. Tweeked npfte a little to try to avoid deadlocks and crashes. Fixed sky worldspawn parsing. Added h2mp's model format. Fixed baseline issue in q2 client, made servers generate q2 baselines. MOVETYPE_PUSH will not rotate extra if rotation is forced. Made status command show allowed client types. Changed lighting on weapons - should now be shaded.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3572 fc73d0e0-1445-4013-8a0c-d673dee63da5
2010-08-11 03:36:31 +00:00
|
|
|
|
|
|
|
if (qrenderer == QR_NONE)
|
|
|
|
{
|
|
|
|
font_conchar = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-02-25 04:22:14 +00:00
|
|
|
font_conchar = Font_LoadFont(8*vid.rotpixelheight/vid.height, var->string);
|
2010-07-11 02:22:39 +00:00
|
|
|
if (!font_conchar && *var->string)
|
2011-02-25 04:22:14 +00:00
|
|
|
font_conchar = Font_LoadFont(8*vid.rotpixelheight/vid.height, "");
|
2009-11-04 21:16:50 +00:00
|
|
|
}
|
|
|
|
|
2010-11-22 02:03:28 +00:00
|
|
|
// console size manipulation callbacks
|
|
|
|
void R2D_Console_Resize(void)
|
|
|
|
{
|
|
|
|
extern cvar_t gl_font;
|
|
|
|
extern cvar_t vid_conwidth, vid_conheight;
|
|
|
|
int cwidth, cheight;
|
|
|
|
float xratio;
|
|
|
|
float yratio=0;
|
2011-02-25 04:22:14 +00:00
|
|
|
float ang, rad;
|
|
|
|
extern cvar_t gl_screenangle;
|
|
|
|
|
|
|
|
ang = (gl_screenangle.value>0?(gl_screenangle.value+45):(gl_screenangle.value-45))/90;
|
|
|
|
ang = (int)ang * 90;
|
|
|
|
if (ang)
|
|
|
|
{
|
|
|
|
rad = (ang * M_PI) / 180;
|
|
|
|
vid.rotpixelwidth = fabs(cos(rad)) * (vid.pixelwidth) + fabs(sin(rad)) * (vid.pixelheight);
|
|
|
|
vid.rotpixelheight = fabs(sin(rad)) * (vid.pixelwidth) + fabs(cos(rad)) * (vid.pixelheight);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
vid.rotpixelwidth = vid.pixelwidth;
|
|
|
|
vid.rotpixelheight = vid.pixelheight;
|
|
|
|
}
|
|
|
|
|
2010-11-22 02:03:28 +00:00
|
|
|
cwidth = vid_conwidth.value;
|
|
|
|
cheight = vid_conheight.value;
|
|
|
|
|
|
|
|
xratio = vid_conautoscale.value;
|
|
|
|
if (xratio > 0)
|
|
|
|
{
|
|
|
|
char *s = strchr(vid_conautoscale.string, ' ');
|
|
|
|
if (s)
|
|
|
|
yratio = atof(s + 1);
|
2011-05-29 04:26:29 +00:00
|
|
|
|
2010-11-22 02:03:28 +00:00
|
|
|
if (yratio <= 0)
|
|
|
|
yratio = xratio;
|
|
|
|
|
|
|
|
xratio = 1 / xratio;
|
|
|
|
yratio = 1 / yratio;
|
|
|
|
|
|
|
|
//autoscale overrides conwidth/height (without actually changing them)
|
2011-02-25 04:22:14 +00:00
|
|
|
cwidth = vid.rotpixelwidth;
|
|
|
|
cheight = vid.rotpixelheight;
|
2010-11-22 02:03:28 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xratio = 1;
|
|
|
|
yratio = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!cwidth)
|
2011-02-25 04:22:14 +00:00
|
|
|
cwidth = vid.rotpixelwidth;
|
2010-11-22 02:03:28 +00:00
|
|
|
if (!cheight)
|
2011-02-25 04:22:14 +00:00
|
|
|
cheight = vid.rotpixelheight;
|
2010-11-22 02:03:28 +00:00
|
|
|
|
|
|
|
cwidth*=xratio;
|
|
|
|
cheight*=yratio;
|
|
|
|
|
|
|
|
if (cwidth < 320)
|
|
|
|
cwidth = 320;
|
|
|
|
if (cheight < 200)
|
|
|
|
cheight = 200;
|
|
|
|
|
|
|
|
vid.width = cwidth;
|
|
|
|
vid.height = cheight;
|
|
|
|
|
|
|
|
vid.recalc_refdef = true;
|
|
|
|
|
|
|
|
if (font_tiny)
|
|
|
|
Font_Free(font_tiny);
|
|
|
|
font_tiny = NULL;
|
|
|
|
if (font_conchar)
|
|
|
|
Font_Free(font_conchar);
|
|
|
|
font_conchar = NULL;
|
|
|
|
|
|
|
|
Cvar_ForceCallback(&gl_font);
|
|
|
|
|
|
|
|
#ifdef PLUGINS
|
|
|
|
Plug_ResChanged();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void R2D_Conheight_Callback(struct cvar_s *var, char *oldvalue)
|
|
|
|
{
|
|
|
|
if (var->value > 1536) //anything higher is unreadable.
|
|
|
|
{
|
|
|
|
Cvar_ForceSet(var, "1536");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (var->value < 200 && var->value) //lower would be wrong
|
|
|
|
{
|
|
|
|
Cvar_ForceSet(var, "200");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
R2D_Console_Resize();
|
|
|
|
}
|
|
|
|
|
|
|
|
void R2D_Conwidth_Callback(struct cvar_s *var, char *oldvalue)
|
|
|
|
{
|
|
|
|
//let let the user be too crazy
|
|
|
|
if (var->value > 2048) //anything higher is unreadable.
|
|
|
|
{
|
|
|
|
Cvar_ForceSet(var, "2048");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (var->value < 320 && var->value) //lower would be wrong
|
|
|
|
{
|
|
|
|
Cvar_ForceSet(var, "320");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
R2D_Console_Resize();
|
|
|
|
}
|
|
|
|
|
|
|
|
void R2D_Conautoscale_Callback(struct cvar_s *var, char *oldvalue)
|
|
|
|
{
|
|
|
|
R2D_Console_Resize();
|
|
|
|
}
|
|
|
|
|
2011-02-25 04:22:14 +00:00
|
|
|
void R2D_ScreenAngle_Callback(struct cvar_s *var, char *oldvalue)
|
|
|
|
{
|
|
|
|
R2D_Console_Resize();
|
|
|
|
}
|
|
|
|
|
2010-05-01 22:47:47 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
============
|
|
|
|
R_PolyBlend
|
|
|
|
============
|
|
|
|
*/
|
2012-01-17 07:57:46 +00:00
|
|
|
//bright flashes and stuff, game only, doesn't touch sbar
|
2010-05-01 22:47:47 +00:00
|
|
|
void R2D_PolyBlend (void)
|
|
|
|
{
|
|
|
|
if (!sw_blend[3])
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (r_refdef.flags & Q2RDF_NOWORLDMODEL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
R2D_ImageColours (sw_blend[0], sw_blend[1], sw_blend[2], sw_blend[3]);
|
2012-01-17 07:57:46 +00:00
|
|
|
R2D_ScalePic(r_refdef.vrect.x, r_refdef.vrect.y, r_refdef.vrect.width, r_refdef.vrect.height, shader_polyblend);
|
2010-08-16 02:03:02 +00:00
|
|
|
R2D_ImageColours (1, 1, 1, 1);
|
2010-05-01 22:47:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//for lack of hardware gamma
|
|
|
|
void R2D_BrightenScreen (void)
|
|
|
|
{
|
|
|
|
float f;
|
|
|
|
|
|
|
|
RSpeedMark();
|
|
|
|
|
2012-11-27 23:50:58 +00:00
|
|
|
if (gl_contrast.value == 1.0 && gl_brightness.value == 0)
|
2010-05-01 22:47:47 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (r_refdef.flags & Q2RDF_NOWORLDMODEL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
f = gl_contrast.value;
|
|
|
|
f = min (f, 3);
|
|
|
|
|
|
|
|
while (f > 1)
|
|
|
|
{
|
|
|
|
if (f >= 2)
|
2012-11-27 03:23:19 +00:00
|
|
|
{
|
2010-05-01 22:47:47 +00:00
|
|
|
R2D_ImageColours (1, 1, 1, 1);
|
2012-11-27 03:23:19 +00:00
|
|
|
f *= 0.5;
|
|
|
|
}
|
2010-05-01 22:47:47 +00:00
|
|
|
else
|
2012-11-27 03:23:19 +00:00
|
|
|
{
|
2010-05-01 22:47:47 +00:00
|
|
|
R2D_ImageColours (f - 1, f - 1, f - 1, 1);
|
2012-11-27 03:23:19 +00:00
|
|
|
f = 1;
|
|
|
|
}
|
|
|
|
R2D_ScalePic(0, 0, vid.width, vid.height, shader_contrastup);
|
|
|
|
}
|
|
|
|
if (f < 1)
|
|
|
|
{
|
|
|
|
R2D_ImageColours (f, f, f, 1);
|
|
|
|
R2D_ScalePic(0, 0, vid.width, vid.height, shader_contrastdown);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gl_brightness.value)
|
|
|
|
{
|
|
|
|
R2D_ImageColours (gl_brightness.value, gl_brightness.value, gl_brightness.value, 1);
|
|
|
|
R2D_ScalePic(0, 0, vid.width, vid.height, shader_brightness);
|
2010-05-01 22:47:47 +00:00
|
|
|
}
|
2010-08-16 02:03:02 +00:00
|
|
|
R2D_ImageColours (1, 1, 1, 1);
|
2010-05-01 22:47:47 +00:00
|
|
|
|
2012-01-17 07:57:46 +00:00
|
|
|
/*make sure the hud is drawn if needed*/
|
|
|
|
Sbar_Changed();
|
|
|
|
|
2010-05-01 22:47:47 +00:00
|
|
|
RSpeedEnd(RSPEED_PALETTEFLASHES);
|
|
|
|
}
|
2011-03-12 13:51:40 +00:00
|
|
|
|
|
|
|
//for menus
|
|
|
|
void R2D_FadeScreen (void)
|
|
|
|
{
|
|
|
|
R2D_ScalePic(0, 0, vid.width, vid.height, shader_menutint);
|
|
|
|
|
|
|
|
Sbar_Changed();
|
|
|
|
}
|
|
|
|
|
2011-03-31 19:46:26 +00:00
|
|
|
//crosshairs
|
|
|
|
#define CS_HEIGHT 8
|
|
|
|
#define CS_WIDTH 8
|
|
|
|
unsigned char crosshair_pixels[] =
|
|
|
|
{
|
|
|
|
// 2 + (spaced)
|
|
|
|
0x08,
|
|
|
|
0x00,
|
|
|
|
0x08,
|
|
|
|
0x55,
|
|
|
|
0x08,
|
|
|
|
0x00,
|
|
|
|
0x08,
|
|
|
|
0x00,
|
|
|
|
// 3 +
|
|
|
|
0x00,
|
|
|
|
0x08,
|
|
|
|
0x08,
|
|
|
|
0x36,
|
|
|
|
0x08,
|
|
|
|
0x08,
|
|
|
|
0x00,
|
|
|
|
0x00,
|
|
|
|
// 4 X
|
|
|
|
0x00,
|
|
|
|
0x22,
|
|
|
|
0x14,
|
|
|
|
0x00,
|
|
|
|
0x14,
|
|
|
|
0x22,
|
|
|
|
0x00,
|
|
|
|
0x00,
|
|
|
|
// 5 X (spaced)
|
|
|
|
0x41,
|
|
|
|
0x00,
|
|
|
|
0x14,
|
|
|
|
0x00,
|
|
|
|
0x14,
|
|
|
|
0x00,
|
|
|
|
0x41,
|
|
|
|
0x00,
|
|
|
|
// 6 diamond (unconnected)
|
|
|
|
0x00,
|
|
|
|
0x14,
|
|
|
|
0x22,
|
|
|
|
0x00,
|
|
|
|
0x22,
|
|
|
|
0x14,
|
|
|
|
0x00,
|
|
|
|
0x00,
|
|
|
|
// 7 diamond
|
|
|
|
0x00,
|
|
|
|
0x08,
|
|
|
|
0x14,
|
|
|
|
0x22,
|
|
|
|
0x14,
|
|
|
|
0x08,
|
|
|
|
0x00,
|
|
|
|
0x00,
|
|
|
|
// 8 four points
|
|
|
|
0x00,
|
|
|
|
0x08,
|
|
|
|
0x00,
|
|
|
|
0x22,
|
|
|
|
0x00,
|
|
|
|
0x08,
|
|
|
|
0x00,
|
|
|
|
0x00,
|
|
|
|
// 9 three points
|
|
|
|
0x00,
|
|
|
|
0x00,
|
|
|
|
0x08,
|
|
|
|
0x00,
|
|
|
|
0x22,
|
|
|
|
0x00,
|
|
|
|
0x00,
|
|
|
|
0x00,
|
|
|
|
// 10
|
|
|
|
0x08,
|
|
|
|
0x2a,
|
|
|
|
0x00,
|
|
|
|
0x63,
|
|
|
|
0x00,
|
|
|
|
0x2a,
|
|
|
|
0x08,
|
|
|
|
0x00,
|
|
|
|
// 11
|
|
|
|
0x49,
|
|
|
|
0x2a,
|
|
|
|
0x00,
|
|
|
|
0x63,
|
|
|
|
0x00,
|
|
|
|
0x2a,
|
|
|
|
0x49,
|
|
|
|
0x00,
|
|
|
|
// 12 horizontal line
|
|
|
|
0x00,
|
|
|
|
0x00,
|
|
|
|
0x00,
|
|
|
|
0x77,
|
|
|
|
0x00,
|
|
|
|
0x00,
|
|
|
|
0x00,
|
|
|
|
0x00,
|
|
|
|
// 13 vertical line
|
|
|
|
0x08,
|
|
|
|
0x08,
|
|
|
|
0x08,
|
|
|
|
0x00,
|
|
|
|
0x08,
|
|
|
|
0x08,
|
|
|
|
0x08,
|
|
|
|
0x00,
|
|
|
|
// 14 larger +
|
|
|
|
0x08,
|
|
|
|
0x08,
|
|
|
|
0x08,
|
|
|
|
0x77,
|
|
|
|
0x08,
|
|
|
|
0x08,
|
|
|
|
0x08,
|
|
|
|
0x00,
|
|
|
|
// 15 angle
|
|
|
|
0x00,
|
|
|
|
0x00,
|
|
|
|
0x00,
|
|
|
|
0x70,
|
|
|
|
0x08,
|
|
|
|
0x08,
|
|
|
|
0x08,
|
|
|
|
0x00,
|
|
|
|
// 16 dot
|
|
|
|
0x00,
|
|
|
|
0x00,
|
|
|
|
0x00,
|
|
|
|
0x08,
|
|
|
|
0x00,
|
|
|
|
0x00,
|
|
|
|
0x00,
|
|
|
|
0x00,
|
|
|
|
// 17 weird angle thing
|
|
|
|
0x00,
|
|
|
|
0x00,
|
|
|
|
0x00,
|
|
|
|
0x38,
|
|
|
|
0x48,
|
|
|
|
0x08,
|
|
|
|
0x10,
|
|
|
|
0x00,
|
|
|
|
// 18 circle w/ dot
|
|
|
|
0x00,
|
|
|
|
0x00,
|
|
|
|
0x00,
|
|
|
|
0x6b,
|
|
|
|
0x41,
|
|
|
|
0x63,
|
|
|
|
0x3e,
|
|
|
|
0x08,
|
|
|
|
// 19 tripoint
|
|
|
|
0x08,
|
|
|
|
0x08,
|
|
|
|
0x08,
|
|
|
|
0x00,
|
|
|
|
0x14,
|
|
|
|
0x22,
|
|
|
|
0x41,
|
|
|
|
0x00,
|
|
|
|
};
|
|
|
|
|
|
|
|
void R2D_Crosshair_Update(void)
|
|
|
|
{
|
|
|
|
int crossdata[CS_WIDTH*CS_HEIGHT];
|
|
|
|
int c;
|
|
|
|
int w, h;
|
|
|
|
unsigned char *x;
|
|
|
|
|
|
|
|
c = crosshair.ival;
|
2011-04-30 17:21:10 +00:00
|
|
|
if (!crosshairimage.string)
|
|
|
|
return;
|
|
|
|
else if (crosshairimage.string[0] && c == 1)
|
2011-03-31 19:46:26 +00:00
|
|
|
{
|
|
|
|
shader_crosshair->defaulttextures.base = R_LoadHiResTexture (crosshairimage.string, "crosshairs", IF_NOMIPMAP|IF_NOGAMMA);
|
|
|
|
if (TEXVALID(shader_crosshair->defaulttextures.base))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (c <= 1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
c -= 2;
|
|
|
|
c = c % (sizeof(crosshair_pixels) / (CS_HEIGHT*sizeof(*crosshair_pixels)));
|
|
|
|
|
|
|
|
if (!TEXVALID(ch_int_texture))
|
2012-09-30 05:52:03 +00:00
|
|
|
ch_int_texture = R_AllocNewTexture("***crosshair***", CS_WIDTH, CS_HEIGHT, 0);
|
2011-03-31 19:46:26 +00:00
|
|
|
shader_crosshair->defaulttextures.base = ch_int_texture;
|
|
|
|
|
|
|
|
Q_memset(crossdata, 0, sizeof(crossdata));
|
|
|
|
|
|
|
|
x = crosshair_pixels + (CS_HEIGHT * c);
|
|
|
|
for (h = 0; h < CS_HEIGHT; h++)
|
|
|
|
{
|
|
|
|
int pix = x[h];
|
|
|
|
for (w = 0; w < CS_WIDTH; w++)
|
|
|
|
{
|
|
|
|
if (pix & 0x1)
|
|
|
|
crossdata[CS_WIDTH * h + w] = 0xffffffff;
|
|
|
|
pix >>= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
R_Upload(ch_int_texture, NULL, TF_RGBA32, crossdata, NULL, CS_WIDTH, CS_HEIGHT, IF_NOMIPMAP|IF_NOGAMMA);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void R2D_CrosshairImage_Callback(struct cvar_s *var, char *oldvalue)
|
|
|
|
{
|
|
|
|
R2D_Crosshair_Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
void R2D_Crosshair_Callback(struct cvar_s *var, char *oldvalue)
|
|
|
|
{
|
|
|
|
R2D_Crosshair_Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
void R2D_CrosshairColor_Callback(struct cvar_s *var, char *oldvalue)
|
|
|
|
{
|
|
|
|
SCR_StringToRGB(var->string, ch_color, 255);
|
|
|
|
|
|
|
|
ch_color[0] = bound(0, ch_color[0], 1);
|
|
|
|
ch_color[1] = bound(0, ch_color[1], 1);
|
|
|
|
ch_color[2] = bound(0, ch_color[2], 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void R2D_DrawCrosshair(void)
|
|
|
|
{
|
|
|
|
int x, y;
|
|
|
|
int sc;
|
|
|
|
float sx, sy, sizex, sizey;
|
|
|
|
|
|
|
|
float size, chc;
|
|
|
|
|
|
|
|
if (crosshair.ival < 1)
|
|
|
|
return;
|
|
|
|
|
2011-05-29 04:26:29 +00:00
|
|
|
// old style
|
2011-03-31 19:46:26 +00:00
|
|
|
if (crosshair.ival == 1 && !crosshairimage.string[0])
|
|
|
|
{
|
2011-06-24 01:05:43 +00:00
|
|
|
// adjust console crosshair scale to match default
|
|
|
|
size = crosshairsize.value / 8;
|
|
|
|
if (size == 0)
|
|
|
|
size = 8;
|
|
|
|
else if (size < 0)
|
|
|
|
size = -size;
|
2011-03-31 19:46:26 +00:00
|
|
|
for (sc = 0; sc < cl.splitclients; sc++)
|
|
|
|
{
|
|
|
|
SCR_CrosshairPosition(sc, &x, &y);
|
2011-06-24 01:05:43 +00:00
|
|
|
Font_BeginScaledString(font_conchar, x, y, &sx, &sy);
|
|
|
|
sizex = Font_CharWidth('+' | 0xe000 | CON_WHITEMASK) * size;
|
|
|
|
sizey = Font_CharHeight() * size;
|
|
|
|
sx -= sizex/2;
|
|
|
|
sy -= sizey/2;
|
2011-03-31 19:46:26 +00:00
|
|
|
Font_ForceColour(ch_color[0], ch_color[1], ch_color[2], crosshairalpha.value);
|
2011-06-24 01:05:43 +00:00
|
|
|
Font_DrawScaleChar(sx, sy, sizex, sizey, '+' | 0xe000 | CON_WHITEMASK);
|
2011-03-31 19:46:26 +00:00
|
|
|
Font_InvalidateColour();
|
|
|
|
Font_EndString(font_conchar);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
size = crosshairsize.value;
|
|
|
|
|
|
|
|
if (size < 0)
|
|
|
|
{
|
|
|
|
size = -size;
|
|
|
|
sizex = size;
|
|
|
|
sizey = size;
|
|
|
|
chc = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sizex = (size*vid.rotpixelwidth) / (float)vid.width;
|
|
|
|
sizey = (size*vid.rotpixelheight) / (float)vid.height;
|
2011-03-31 23:05:19 +00:00
|
|
|
chc = size / 16.0;
|
2011-03-31 19:46:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sizex = (int)sizex;
|
|
|
|
sizex = ((sizex)*(int)vid.width) / (float)vid.rotpixelwidth;
|
|
|
|
|
|
|
|
sizey = (int)sizey;
|
|
|
|
sizey = ((sizey)*(int)vid.height) / (float)vid.rotpixelheight;
|
|
|
|
|
|
|
|
R2D_ImageColours(ch_color[0], ch_color[1], ch_color[2], crosshairalpha.value);
|
|
|
|
for (sc = 0; sc < cl.splitclients; sc++)
|
|
|
|
{
|
|
|
|
SCR_CrosshairPosition(sc, &x, &y);
|
|
|
|
|
|
|
|
//translate to pixel coord, for rounding
|
|
|
|
x = ((x-sizex-chc)*vid.rotpixelwidth) / (float)vid.width;
|
|
|
|
y = ((y-sizey-chc)*vid.rotpixelheight) / (float)vid.height;
|
|
|
|
|
|
|
|
//translate to screen coords
|
|
|
|
sx = ((x)*(int)vid.width) / (float)vid.rotpixelwidth;
|
|
|
|
sy = ((y)*(int)vid.height) / (float)vid.rotpixelheight;
|
|
|
|
|
|
|
|
R2D_Image(sx, sy, sizex*2, sizey*2, 0, 0, 1, 1, shader_crosshair);
|
|
|
|
}
|
|
|
|
R2D_ImageColours(1, 1, 1, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
#endif
|