attempt implement d3d and gl es getrgbinfo, fix typos/commit with crosshair
git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3766 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
0a1b14b202
commit
52fd75801c
8 changed files with 84 additions and 184 deletions
|
@ -1003,7 +1003,7 @@ void R2D_DrawCrosshair(void)
|
|||
{
|
||||
sizex = (size*vid.rotpixelwidth) / (float)vid.width;
|
||||
sizey = (size*vid.rotpixelheight) / (float)vid.height;
|
||||
chc = size * chc;
|
||||
chc = size / 16.0;
|
||||
}
|
||||
|
||||
sizex = (int)sizex;
|
||||
|
|
|
@ -4336,8 +4336,8 @@ char *version_string(void)
|
|||
#define STRINGIFY2(arg) #arg
|
||||
#define STRINGIFY(arg) STRINGIFY2(arg)
|
||||
Q_snprintfz(s, sizeof(s), "%s SVN %s", DISTRIBUTION, STRINGIFY(SVNREVISION));
|
||||
#undef STRINGIFY2
|
||||
#undef STRINGIFY
|
||||
#undef STRINGIFY2
|
||||
#else
|
||||
Q_snprintfz(s, sizeof(s), "%s build %s", DISTRIBUTION, __DATE__);
|
||||
#endif
|
||||
|
|
|
@ -798,7 +798,64 @@ static void (D3D9_VID_ShiftPalette) (unsigned char *palette)
|
|||
}
|
||||
static char *(D3D9_VID_GetRGBInfo) (int prepad, int *truevidwidth, int *truevidheight)
|
||||
{
|
||||
return NULL;
|
||||
IDirect3DSurface9 *surf;
|
||||
D3DLOCKED_RECT rect;
|
||||
extern qboolean gammaworks;
|
||||
int i, j, c;
|
||||
qbyte *ret = BZ_Malloc(prepad + vid.pixelwidth*vid.pixelheight*3);
|
||||
qbyte *p;
|
||||
HRESULT res;
|
||||
|
||||
// TODO: this captures the entire screen on windowed display..
|
||||
// also might break on multi-monitor
|
||||
IDirect3DDevice9_CreateOffscreenPlainSurface(pD3DDev9,
|
||||
GetSystemMetrics(SM_CXSCREEN),
|
||||
GetSystemMetrics(SM_CYSCREEN),
|
||||
D3DFMT_A8R8G8B8,
|
||||
D3DPOOL_SYSTEMMEM,
|
||||
&surf,
|
||||
NULL);
|
||||
IDirect3DDevice9_GetFrontBufferData(pD3DDev9, 0, surf);
|
||||
IDirect3DSurface9_LockRect(surf, &rect, NULL, D3DLOCK_NO_DIRTY_UPDATE|D3DLOCK_READONLY|D3DLOCK_NOSYSLOCK);
|
||||
|
||||
// read surface rect and convert 32 bgra to 24 rgb and flip
|
||||
c = prepad+vid.pixelwidth*vid.pixelheight*3;
|
||||
p = (qbyte *)rect.pBits;
|
||||
|
||||
if (gammaworks)
|
||||
{
|
||||
extern qbyte gammatable[256];
|
||||
for (i=c-(3*vid.pixelwidth); i>=prepad; i-=(3*vid.pixelwidth))
|
||||
{
|
||||
for (j=0; j<vid.pixelwidth; j++)
|
||||
{
|
||||
ret[i+j*3+0] = gammatable[p[j*4+2]];
|
||||
ret[i+j*3+1] = gammatable[p[j*4+1]];
|
||||
ret[i+j*3+2] = gammatable[p[j*4+0]];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i=c-(3*vid.pixelwidth); i>=prepad; i-=(3*vid.pixelwidth))
|
||||
{
|
||||
for (j=0; j<vid.pixelwidth; j++)
|
||||
{
|
||||
ret[i+j*3+0] = p[j*4+2];
|
||||
ret[i+j*3+1] = p[j*4+1];
|
||||
ret[i+j*3+2] = p[j*4+0];
|
||||
}
|
||||
p += rect.Pitch;
|
||||
}
|
||||
}
|
||||
|
||||
*truevidwidth = vid.pixelwidth;
|
||||
*truevidheight = vid.pixelheight;
|
||||
|
||||
IDirect3DSurface9_UnlockRect(surf);
|
||||
IDirect3DSurface9_Release(surf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
static void (D3D9_VID_SetWindowCaption) (char *msg)
|
||||
{
|
||||
|
@ -1035,9 +1092,6 @@ static void (D3D9_Draw_Init) (void)
|
|||
static void (D3D9_Draw_ReInit) (void)
|
||||
{
|
||||
}
|
||||
static void (D3D9_Draw_Crosshair) (void)
|
||||
{
|
||||
}
|
||||
|
||||
static void (D3D9_R_Init) (void)
|
||||
{
|
||||
|
@ -1165,7 +1219,6 @@ rendererinfo_t d3drendererinfo =
|
|||
|
||||
D3D9_Draw_Init,
|
||||
D3D9_Draw_ReInit,
|
||||
D3D9_Draw_Crosshair,
|
||||
|
||||
D3D9_LoadTexture,
|
||||
D3D9_LoadTexture8Pal24,
|
||||
|
|
|
@ -135,7 +135,6 @@ extern qbyte gammatable[256];
|
|||
unsigned char *d_15to8table;
|
||||
qboolean inited15to8;
|
||||
#endif
|
||||
extern cvar_t crosshair, crosshairimage, crosshairalpha, cl_crossx, cl_crossy, crosshaircolor, crosshairsize;
|
||||
|
||||
static texid_t filmtexture;
|
||||
|
||||
|
@ -151,11 +150,6 @@ extern cvar_t gl_savecompressedtex;
|
|||
|
||||
texid_t missing_texture; //texture used when one is missing.
|
||||
|
||||
texid_t cs_texture; // crosshair texture
|
||||
shader_t *crosshair_shader;
|
||||
|
||||
static unsigned cs_data[16*16];
|
||||
static texid_t externalhair;
|
||||
int gl_anisotropy_factor;
|
||||
|
||||
mpic_t *conback;
|
||||
|
@ -373,17 +367,6 @@ TRACE(("dbg: GLDraw_ReInit: Allocating upload buffers\n"));
|
|||
GL_EndRendering ();
|
||||
GL_DoSwap();
|
||||
|
||||
cs_texture = GL_AllocNewTexture(16, 16);
|
||||
|
||||
crosshair_shader = R_RegisterShader("crosshairshader",
|
||||
"{\n"
|
||||
"{\n"
|
||||
"map $diffuse\n"
|
||||
"blendfunc blend\n"
|
||||
"}\n"
|
||||
"}\n"
|
||||
);
|
||||
|
||||
GL_SetupSceneProcessingTextures();
|
||||
|
||||
//
|
||||
|
@ -450,153 +433,6 @@ void GLDraw_DeInit (void)
|
|||
|
||||
}
|
||||
|
||||
#include "crosshairs.dat"
|
||||
vec3_t chcolor;
|
||||
|
||||
void GLCrosshairimage_Callback(struct cvar_s *var, char *oldvalue)
|
||||
{
|
||||
if (*(var->string))
|
||||
externalhair = R_LoadHiResTexture (var->string, "crosshairs", IF_NOMIPMAP);
|
||||
}
|
||||
|
||||
void GLCrosshair_Callback(struct cvar_s *var, char *oldvalue)
|
||||
{
|
||||
unsigned int c, c2;
|
||||
|
||||
if (!var->value)
|
||||
return;
|
||||
|
||||
c = (unsigned int)(chcolor[0] * 255) | // red
|
||||
((unsigned int)(chcolor[1] * 255) << 8) | // green
|
||||
((unsigned int)(chcolor[2] * 255) << 16) | // blue
|
||||
0xff000000; // alpha
|
||||
c2 = c;
|
||||
|
||||
#define Pix(x,y,c) { \
|
||||
if (y+8<0)c=0; \
|
||||
if (y+8>=16)c=0; \
|
||||
if (x+8<0)c=0; \
|
||||
if (x+8>=16)c=0; \
|
||||
\
|
||||
cs_data[(y+8)*16+(x+8)] = c; \
|
||||
}
|
||||
memset(cs_data, 0, sizeof(cs_data));
|
||||
switch((int)var->value)
|
||||
{
|
||||
default:
|
||||
#include "crosshairs.dat"
|
||||
}
|
||||
#undef Pix
|
||||
|
||||
R_Upload(cs_texture, NULL, TF_RGBA32, cs_data, NULL, 16, 16, IF_NOMIPMAP|IF_NOGAMMA);
|
||||
|
||||
if (gl_smoothcrosshair.ival)
|
||||
{
|
||||
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
}
|
||||
else
|
||||
{
|
||||
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
}
|
||||
}
|
||||
|
||||
void GLCrosshaircolor_Callback(struct cvar_s *var, char *oldvalue)
|
||||
{
|
||||
SCR_StringToRGB(var->string, chcolor, 255);
|
||||
|
||||
chcolor[0] = bound(0, chcolor[0], 1);
|
||||
chcolor[1] = bound(0, chcolor[1], 1);
|
||||
chcolor[2] = bound(0, chcolor[2], 1);
|
||||
|
||||
GLCrosshair_Callback(&crosshair, "");
|
||||
}
|
||||
|
||||
void GLDraw_Crosshair(void)
|
||||
{
|
||||
int x, y;
|
||||
int sc;
|
||||
float sx, sy, sizex, sizey;
|
||||
|
||||
float size, chc;
|
||||
shader_t *shader;
|
||||
|
||||
qboolean usingimage = false;
|
||||
|
||||
if (crosshair.ival == 1 && !*crosshairimage.string)
|
||||
{
|
||||
for (sc = 0; sc < cl.splitclients; sc++)
|
||||
{
|
||||
SCR_CrosshairPosition(sc, &x, &y);
|
||||
Font_BeginString(font_conchar, x, y, &x, &y);
|
||||
x -= Font_CharWidth('+' | 0xe000 | CON_WHITEMASK)/2;
|
||||
y -= Font_CharHeight()/2;
|
||||
Font_DrawChar(x, y, '+' | 0xe000 | CON_WHITEMASK);
|
||||
Font_EndString(font_conchar);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
shader = crosshair_shader;
|
||||
if (*crosshairimage.string)
|
||||
{
|
||||
usingimage = true;
|
||||
chc = 0;
|
||||
|
||||
shader->defaulttextures.base = externalhair;
|
||||
}
|
||||
else if (crosshair.ival)
|
||||
{
|
||||
chc = 1/16.0;
|
||||
|
||||
// force crosshair refresh with animated crosshairs
|
||||
if (crosshair.ival >= FIRSTANIMATEDCROSHAIR)
|
||||
GLCrosshair_Callback(&crosshair, "");
|
||||
|
||||
shader->defaulttextures.base = cs_texture;
|
||||
}
|
||||
else
|
||||
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;
|
||||
chc = size * chc;
|
||||
}
|
||||
|
||||
sizex = (int)sizex;
|
||||
sizex = ((sizex)*(int)vid.width) / (float)vid.rotpixelwidth;
|
||||
|
||||
sizey = (int)sizey;
|
||||
sizey = ((sizey)*(int)vid.height) / (float)vid.rotpixelheight;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=============================================================================
|
||||
|
|
|
@ -25,7 +25,6 @@ void GLDraw_Init (void);
|
|||
void GLDraw_ReInit (void);
|
||||
void GLDraw_DeInit (void);
|
||||
void Surf_DeInit (void);
|
||||
void GLDraw_Crosshair(void);
|
||||
|
||||
void R2D_Init(void);
|
||||
mpic_t *R2D_SafeCachePic (char *path);
|
||||
|
|
|
@ -451,9 +451,6 @@ extern cvar_t vid_conautoscale, vid_conheight, vid_conwidth;
|
|||
extern cvar_t crosshair, crosshairimage, crosshaircolor, r_skyboxname;
|
||||
extern cvar_t r_floorcolour, r_wallcolour, r_floortexture, r_walltexture;
|
||||
extern cvar_t r_fastskycolour;
|
||||
void GLCrosshairimage_Callback(struct cvar_s *var, char *oldvalue);
|
||||
void GLCrosshair_Callback(struct cvar_s *var, char *oldvalue);
|
||||
void GLCrosshaircolor_Callback(struct cvar_s *var, char *oldvalue);
|
||||
void GLV_Gamma_Callback(struct cvar_s *var, char *oldvalue);
|
||||
|
||||
void GLR_DeInit (void)
|
||||
|
@ -464,9 +461,6 @@ void GLR_DeInit (void)
|
|||
|
||||
Cmd_RemoveCommand ("makewad");
|
||||
|
||||
Cvar_Unhook(&crosshair);
|
||||
Cvar_Unhook(&crosshairimage);
|
||||
Cvar_Unhook(&crosshaircolor);
|
||||
Cvar_Unhook(&r_skyboxname);
|
||||
Cvar_Unhook(&vid_conautoscale);
|
||||
Cvar_Unhook(&vid_conheight);
|
||||
|
@ -495,9 +489,6 @@ void GLR_Init (void)
|
|||
|
||||
// Cmd_AddRemCommand ("makewad", R_MakeTexWad_f);
|
||||
|
||||
Cvar_Hook(&crosshair, GLCrosshair_Callback);
|
||||
Cvar_Hook(&crosshairimage, GLCrosshairimage_Callback);
|
||||
Cvar_Hook(&crosshaircolor, GLCrosshaircolor_Callback);
|
||||
// Cvar_Hook(&r_floorcolour, GLR_Floorcolour_Callback);
|
||||
// Cvar_Hook(&r_fastskycolour, GLR_Fastskycolour_Callback);
|
||||
// Cvar_Hook(&r_wallcolour, GLR_Wallcolour_Callback);
|
||||
|
|
|
@ -221,9 +221,31 @@ char *GLVID_GetRGBInfo(int prepadbytes, int *truewidth, int *trueheight)
|
|||
{ //returns a BZ_Malloced array
|
||||
extern qboolean gammaworks;
|
||||
int i, c;
|
||||
qbyte *ret = BZ_Malloc(prepadbytes + vid.pixelwidth*vid.pixelheight*3);
|
||||
qbyte *ret;
|
||||
|
||||
qglReadPixels (0, 0, vid.pixelwidth, vid.pixelheight, GL_RGB, GL_UNSIGNED_BYTE, ret + prepadbytes);
|
||||
if (gl_config.gles)
|
||||
{
|
||||
qbyte *p;
|
||||
|
||||
// gles only guarantees GL_RGBA/GL_UNSIGNED_BYTE so downconvert and resize
|
||||
ret = BZ_Malloc(prepadbytes + vid.pixelwidth*vid.pixelheight*4);
|
||||
qglReadPixels (0, 0, vid.pixelwidth, vid.pixelheight, GL_RGBA, GL_UNSIGNED_BYTE, ret + prepadbytes);
|
||||
|
||||
c = vid.pixelwidth*vid.pixelheight;
|
||||
p = ret + prepadbytes;
|
||||
for (i = 1; i < c; i++)
|
||||
{
|
||||
p[i*3+0]=p[i*4+0];
|
||||
p[i*3+1]=p[i*4+1];
|
||||
p[i*3+2]=p[i*4+2];
|
||||
}
|
||||
ret = BZ_Realloc(ret, prepadbytes + vid.pixelwidth*vid.pixelheight*3);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = BZ_Malloc(prepadbytes + vid.pixelwidth*vid.pixelheight*3);
|
||||
qglReadPixels (0, 0, vid.pixelwidth, vid.pixelheight, GL_RGB, GL_UNSIGNED_BYTE, ret + prepadbytes);
|
||||
}
|
||||
|
||||
*truewidth = vid.pixelwidth;
|
||||
*trueheight = vid.pixelheight;
|
||||
|
|
|
@ -1067,7 +1067,6 @@ rendererinfo_t openglrendererinfo = {
|
|||
|
||||
GLDraw_Init,
|
||||
GLDraw_ReInit,
|
||||
GLDraw_Crosshair,
|
||||
|
||||
GL_LoadTextureFmt,
|
||||
GL_LoadTexture8Pal24,
|
||||
|
|
Loading…
Reference in a new issue