1
0
Fork 0
forked from fte/fteqw
fteqw/engine/sw/sw_image.c
Spoike c4d3497054 some Q2 compat tweaks. moved all q2 temp-ents to particle scripts.
PF_VarString can now shortcircuit, directly returning the first argument (which also bypasses related length limitations). this required const correctness fixes.
r_showshaders cvar reports the wall texture being pointed at.
improve dp compat in a number of areas, should now mostly be able to run xonotic 0.8.2, but will need some more extra cvars/defaults/stuff.
fix q3bsp loader race condition.
fix dpm loader multi-surface issue.
remove limit on stringbuffer count.
don't poll xinput (because its disturbingly slow), instead wait for some window message before re-checking.
fixed splitscreen saved games.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5140 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-08-14 16:38:44 +00:00

114 lines
2.2 KiB
C

#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 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;
//ensure we reject any s3tc encodings
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;
}
// 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