- Changed true color texture creation to use a newly defined Bitmap class
instead of having the copy functions in the frame buffer class. - Fixed: The WolfSS didn't have its obituary defined. SVN r915 (trunk)
This commit is contained in:
parent
99b2fab410
commit
ce5d4dba02
17 changed files with 648 additions and 505 deletions
210
src/v_video.cpp
210
src/v_video.cpp
|
|
@ -1157,216 +1157,6 @@ void DFrameBuffer::WipeCleanup()
|
|||
wipe_Cleanup();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// multi-format pixel copy with colormap application
|
||||
// requires one of the previously defined conversion classes to work
|
||||
//
|
||||
//===========================================================================
|
||||
template<class T>
|
||||
void iCopyColors(BYTE *pout, const BYTE *pin, int count, int step)
|
||||
{
|
||||
for(int i=0;i<count;i++)
|
||||
{
|
||||
pout[0]=T::B(pin);
|
||||
pout[1]=T::G(pin);
|
||||
pout[2]=T::R(pin);
|
||||
pout[3]=T::A(pin);
|
||||
pout+=4;
|
||||
pin+=step;
|
||||
}
|
||||
}
|
||||
|
||||
typedef void (*CopyFunc)(BYTE *pout, const BYTE *pin, int count, int step);
|
||||
|
||||
static CopyFunc copyfuncs[]={
|
||||
iCopyColors<cRGB>,
|
||||
iCopyColors<cRGBA>,
|
||||
iCopyColors<cIA>,
|
||||
iCopyColors<cCMYK>,
|
||||
iCopyColors<cBGR>,
|
||||
iCopyColors<cBGRA>,
|
||||
iCopyColors<cI16>,
|
||||
iCopyColors<cRGB555>,
|
||||
iCopyColors<cPalEntry>
|
||||
};
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// Clips the copy area for CopyPixelData functions
|
||||
//
|
||||
//===========================================================================
|
||||
bool ClipCopyPixelRect(int texwidth, int texheight, int &originx, int &originy,
|
||||
const BYTE *&patch, int &srcwidth, int &srcheight,
|
||||
int &pstep_x, int &pstep_y, int rotate)
|
||||
{
|
||||
int pixxoffset;
|
||||
int pixyoffset;
|
||||
|
||||
int step_x;
|
||||
int step_y;
|
||||
|
||||
// First adjust the settings for the intended rotation
|
||||
switch (rotate)
|
||||
{
|
||||
default:
|
||||
case 0: // normal
|
||||
pixxoffset = 0;
|
||||
pixyoffset = 0;
|
||||
step_x = pstep_x;
|
||||
step_y = pstep_y;
|
||||
break;
|
||||
|
||||
case 1: // rotate 90° right
|
||||
pixxoffset = 0;
|
||||
pixyoffset = srcheight - 1;
|
||||
step_x = -pstep_y;
|
||||
step_y = pstep_x;
|
||||
break;
|
||||
|
||||
case 2: // rotate 180°
|
||||
pixxoffset = srcwidth - 1;
|
||||
pixyoffset = srcheight - 1;
|
||||
step_x = -pstep_x;
|
||||
step_y = -pstep_y;
|
||||
break;
|
||||
|
||||
case 3: // rotate 90° left
|
||||
pixxoffset = srcwidth - 1;
|
||||
pixyoffset = 0;
|
||||
step_x = pstep_y;
|
||||
step_y = -pstep_x;
|
||||
break;
|
||||
|
||||
case 4: // flip horizontally
|
||||
pixxoffset = srcwidth - 1;
|
||||
pixyoffset = 0;
|
||||
step_x = -pstep_x;
|
||||
step_y = pstep_y;
|
||||
break;
|
||||
|
||||
case 5: // flip horizontally and rotate 90° right
|
||||
pixxoffset = srcwidth - 1;
|
||||
pixyoffset = srcheight - 1;
|
||||
step_x = -pstep_y;
|
||||
step_y = -pstep_x;
|
||||
break;
|
||||
|
||||
case 6: // flip vertically
|
||||
pixxoffset = 0;
|
||||
pixyoffset = srcheight - 1;
|
||||
step_x = pstep_x;
|
||||
step_y = -pstep_y;
|
||||
break;
|
||||
|
||||
case 7: // flip horizontally and rotate 90° left
|
||||
pixxoffset = 0;
|
||||
pixyoffset = 0;
|
||||
step_x = pstep_y;
|
||||
step_y = pstep_x;
|
||||
break;
|
||||
}
|
||||
if (rotate&1)
|
||||
{
|
||||
int v = srcwidth;
|
||||
srcwidth = srcheight;
|
||||
srcheight = v;
|
||||
}
|
||||
|
||||
patch += pixxoffset * pstep_x + pixyoffset * pstep_y;
|
||||
pstep_x = step_x;
|
||||
pstep_y = step_y;
|
||||
|
||||
// clip source rectangle to destination
|
||||
if (originx<0)
|
||||
{
|
||||
srcwidth+=originx;
|
||||
patch-=originx*step_x;
|
||||
originx=0;
|
||||
if (srcwidth<=0) return false;
|
||||
}
|
||||
if (originx+srcwidth>texwidth)
|
||||
{
|
||||
srcwidth=texwidth-originx;
|
||||
if (srcwidth<=0) return false;
|
||||
}
|
||||
|
||||
if (originy<0)
|
||||
{
|
||||
srcheight+=originy;
|
||||
patch-=originy*step_y;
|
||||
originy=0;
|
||||
if (srcheight<=0) return false;
|
||||
}
|
||||
if (originy+srcheight>texheight)
|
||||
{
|
||||
srcheight=texheight-originy;
|
||||
if (srcheight<=0) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// True Color texture copy function
|
||||
//
|
||||
//===========================================================================
|
||||
void DFrameBuffer::CopyPixelDataRGB(BYTE *buffer, int texpitch, int texheight, int originx, int originy,
|
||||
const BYTE *patch, int srcwidth, int srcheight, int step_x, int step_y,
|
||||
int rotate, int ct)
|
||||
{
|
||||
if (ClipCopyPixelRect(texpitch/4, texheight, originx, originy, patch, srcwidth, srcheight, step_x, step_y, rotate))
|
||||
{
|
||||
buffer+=4*originx + texpitch*originy;
|
||||
for (int y=0;y<srcheight;y++)
|
||||
{
|
||||
copyfuncs[ct](&buffer[y*texpitch], &patch[y*step_y], srcwidth, step_x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// Paletted to True Color texture copy function
|
||||
//
|
||||
//===========================================================================
|
||||
void DFrameBuffer::CopyPixelData(BYTE * buffer, int texpitch, int texheight, int originx, int originy,
|
||||
const BYTE * patch, int srcwidth, int srcheight,
|
||||
int step_x, int step_y, int rotate, PalEntry * palette)
|
||||
{
|
||||
int x,y,pos;
|
||||
|
||||
if (ClipCopyPixelRect(texpitch/4, texheight, originx, originy, patch, srcwidth, srcheight, step_x, step_y, rotate))
|
||||
{
|
||||
buffer+=4*originx + texpitch*originy;
|
||||
|
||||
for (y=0;y<srcheight;y++)
|
||||
{
|
||||
pos=y*texpitch;
|
||||
for (x=0;x<srcwidth;x++,pos+=4)
|
||||
{
|
||||
int v=(unsigned char)patch[y*step_y+x*step_x];
|
||||
if (palette[v].a==0)
|
||||
{
|
||||
buffer[pos]=palette[v].b;
|
||||
buffer[pos+1]=palette[v].g;
|
||||
buffer[pos+2]=palette[v].r;
|
||||
buffer[pos+3]=255;
|
||||
}
|
||||
else if (palette[v].a!=255)
|
||||
{
|
||||
// [RH] Err... This can't be right, can it?
|
||||
buffer[pos ] = (buffer[pos ] * palette[v].a + palette[v].b * (1-palette[v].a)) / 255;
|
||||
buffer[pos+1] = (buffer[pos+1] * palette[v].a + palette[v].g * (1-palette[v].a)) / 255;
|
||||
buffer[pos+2] = (buffer[pos+2] * palette[v].a + palette[v].r * (1-palette[v].a)) / 255;
|
||||
buffer[pos+3] = clamp<int>(buffer[pos+3] + (( 255-buffer[pos+3]) * (255-palette[v].a))/255, 0, 255);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// Texture precaching
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue