fteqw/engine/sw/sw_image.c

115 lines
2.2 KiB
C
Raw Normal View History

#include "quakedef.h"
#ifdef SWQUAKE
#include "sw.h"
void SW_NukeAlpha(swimage_t *img)
{
int x, y;
unsigned int *d = img->data;
for (y = 0; y < img->pheight; y++)
{
for (x = 0; x < img->pwidth; x++)
{
d[x] |= 0xff000000;
}
d += img->pitch;
}
}
void SW_DestroyTexture(texid_t tex)
{
swimage_t *img = tex->ptr;
tex->ptr = NULL;
/*make sure its not in use by the renderer*/
SWRast_Sync(&commandqueue);
/*okay, it can be killed*/
BZ_Free(img);
}
void SW_UpdateFiltering (image_t *imagelist, int filtermip[3], int filterpic[3], int mipcap[2], float lodbias, float anis)
{
//always nearest...
}
qboolean SW_LoadTextureMips (texid_t tex, const struct pendingtextureinfo *mips)
{
swimage_t *img;
int i;
int nw = mips->mip[0].width;
int nh = mips->mip[0].height;
qbyte *indata = mips->mip[0].data;
qbyte *imgdata;
if (mips->type != PTI_2D)
return false;
//only accept formats that actually make sense here.
switch(mips->encoding)
{
case PTI_RGBA8:
case PTI_RGBX8:
case PTI_BGRA8:
case PTI_BGRX8:
break;
default:
return false;
}
img = BZ_Malloc(sizeof(*img) - sizeof(img->data) + (nw * nh * 4));
imgdata = (qbyte*)(img+1) - sizeof(img->data);
tex->ptr = img;
img->pwidth = nw;
img->pheight = nh;
img->pitch = nw;
//precalculated
img->pwidthmask = nw-1;
img->pheightmask = nh-1;
if (mips->encoding == PTI_RGBA8 || mips->encoding == PTI_RGBX8)
{ //assuming PC hardware is bgr
if (mips->encoding == PTI_RGBX8)
{
for (i = 0; i < nw*nh*4; i+=4)
{
imgdata[i+0] = indata[i+2];
imgdata[i+1] = indata[i+1];
imgdata[i+2] = indata[i+0];
imgdata[i+3] = 255;
}
}
else
{
for (i = 0; i < nw*nh*4; i+=4)
{
imgdata[i+0] = indata[i+2];
imgdata[i+1] = indata[i+1];
imgdata[i+2] = indata[i+0];
imgdata[i+3] = indata[i+3];
}
}
}
else
{
memcpy(imgdata, indata, (nw * nh * 4));
if (mips->encoding == PTI_BGRX8)
for (i = 0; i < nw*nh*4; i+=4)
imgdata[i+3] = 255;
}
mvd: cl_autotrack_team cvar locks autotrack to a specific team. getting the team name to match can still be problematic when it contains non-ascii chars however. qw: fix recording mid-map. q2: add support for recording demos on q2 servers. q: fix setattachment not using the correct orientations. q2: now supports splitscreen, as well as increased model and sound limits. cl: fix crosshair not appearing in splitscreen. cl: splitscreen clients now get their own colour tints (like the bf command) snd: tweak audio to be a bit more usable in splitscreen by default. cl: added con_logcenterprint cvar, for shoving a copy of centerprints onto the console. by default only appears in single player. qc: add checkbuiltin builtin. for all those #0 builtins without their own extension name. gl: fix r_dynamic -1 bug that was painfully visible in AD. mdl: validate per-frame bounds of mdl files (stuff that would crash software renderers). sv: fix -port or +sv_port commandline args to override the port correctly. win: attempt to cope with windows symlinks enumerating with the wrong filesizes. gl: fix skyboxes not appearing properly. gl: fix sprite alpha/edge issue resulting in some invisible sprites in AD. gl: fix screenshot_mega, in combination with r_projection. yay for HUGE panoramic screenshots. q2: fix replacement textures issue. qw: fix download demonum/X issue, both in client and server. qw: fix multicast dimensions not always being honoured properly. nq: fix starting angles sometimes being wrong. menusys: I'm finally uploading my menusys library, plus example mod, which I'll now be providing like csaddon is. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4997 fc73d0e0-1445-4013-8a0c-d673dee63da5
2016-01-18 05:22:07 +00:00
// for (i = 0; i < mips->mipcount; i++)
// if (mips->mip[i].needfree)
// Z_Free(mips->mip[i].data);
// if (mips->extrafree)
// Z_Free(mips->extrafree);
return true;
}
#endif