d3d8 renderer
(17:08:12) eukara: Let's make one! (17:09:01) eukara: I'd even maintain it! chances are that he'll need to get it working first. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5074 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
a97007ae5a
commit
afa9fce336
3 changed files with 4979 additions and 0 deletions
3469
engine/d3d/d3d8_backend.c
Normal file
3469
engine/d3d/d3d8_backend.c
Normal file
File diff suppressed because it is too large
Load diff
142
engine/d3d/d3d8_image.c
Normal file
142
engine/d3d/d3d8_image.c
Normal file
|
@ -0,0 +1,142 @@
|
|||
#include "quakedef.h"
|
||||
#include "winquake.h"
|
||||
#ifdef D3D8QUAKE
|
||||
#if !defined(HMONITOR_DECLARED) && (WINVER < 0x0500)
|
||||
#define HMONITOR_DECLARED
|
||||
DECLARE_HANDLE(HMONITOR);
|
||||
#endif
|
||||
#include <d3d8.h>
|
||||
extern LPDIRECT3DDEVICE8 pD3DDev8;
|
||||
|
||||
void D3D8_DestroyTexture (texid_t tex)
|
||||
{
|
||||
if (!tex)
|
||||
return;
|
||||
|
||||
if (tex->ptr)
|
||||
IDirect3DTexture8_Release((IDirect3DTexture8*)tex->ptr);
|
||||
tex->ptr = NULL;
|
||||
}
|
||||
|
||||
qboolean D3D8_LoadTextureMips(image_t *tex, struct pendingtextureinfo *mips)
|
||||
{
|
||||
qbyte *fte_restrict out, *fte_restrict in;
|
||||
int x, y, i;
|
||||
D3DLOCKED_RECT lock;
|
||||
D3DFORMAT fmt;
|
||||
D3DSURFACE_DESC desc;
|
||||
IDirect3DTexture8 *dt;
|
||||
qboolean swap = false;
|
||||
unsigned int pixelsize = 4;
|
||||
unsigned int blocksize = 0;
|
||||
|
||||
switch(mips->encoding)
|
||||
{
|
||||
case PTI_RGB565:
|
||||
pixelsize = 2;
|
||||
fmt = D3DFMT_R5G6B5;
|
||||
break;
|
||||
case PTI_RGBA4444://not supported on d3d9
|
||||
return false;
|
||||
case PTI_ARGB4444:
|
||||
pixelsize = 2;
|
||||
fmt = D3DFMT_A4R4G4B4;
|
||||
break;
|
||||
case PTI_RGBA5551://not supported on d3d9
|
||||
return false;
|
||||
case PTI_ARGB1555:
|
||||
pixelsize = 2;
|
||||
fmt = D3DFMT_A1R5G5B5;
|
||||
break;
|
||||
case PTI_RGBA8:
|
||||
// fmt = D3DFMT_A8B8G8R8; /*how do we check
|
||||
fmt = D3DFMT_A8R8G8B8;
|
||||
swap = true;
|
||||
break;
|
||||
case PTI_RGBX8:
|
||||
// fmt = D3DFMT_X8B8G8R8;
|
||||
fmt = D3DFMT_X8R8G8B8;
|
||||
swap = true;
|
||||
break;
|
||||
case PTI_BGRA8:
|
||||
fmt = D3DFMT_A8R8G8B8;
|
||||
break;
|
||||
case PTI_BGRX8:
|
||||
fmt = D3DFMT_X8R8G8B8;
|
||||
break;
|
||||
|
||||
//too lazy to support these for now
|
||||
case PTI_S3RGB1:
|
||||
case PTI_S3RGBA1: //d3d doesn't distinguish between these
|
||||
fmt = D3DFMT_DXT1;
|
||||
blocksize = 8;
|
||||
break;
|
||||
case PTI_S3RGBA3:
|
||||
fmt = D3DFMT_DXT3;
|
||||
blocksize = 16;
|
||||
break;
|
||||
case PTI_S3RGBA5:
|
||||
fmt = D3DFMT_DXT5;
|
||||
blocksize = 16;
|
||||
break;
|
||||
|
||||
default: //no idea
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!pD3DDev8)
|
||||
return false; //can happen on errors
|
||||
if (FAILED(IDirect3DDevice8_CreateTexture(pD3DDev8, mips->mip[0].width, mips->mip[0].height, mips->mipcount, 0, fmt, D3DPOOL_MANAGED, &dt)))
|
||||
return false;
|
||||
|
||||
for (i = 0; i < mips->mipcount; i++)
|
||||
{
|
||||
IDirect3DTexture8_GetLevelDesc(dt, i, &desc);
|
||||
|
||||
if (mips->mip[i].height != desc.Height || mips->mip[i].width != desc.Width)
|
||||
{
|
||||
IDirect3DTexture8_Release(dt);
|
||||
return false;
|
||||
}
|
||||
|
||||
IDirect3DTexture8_LockRect(dt, i, &lock, NULL, D3DLOCK_NOSYSLOCK|D3DLOCK_DISCARD);
|
||||
//can't do it in one go. pitch might contain padding or be upside down.
|
||||
if (!mips->mip[i].data)
|
||||
;
|
||||
else if (blocksize)
|
||||
{
|
||||
if (lock.Pitch == ((mips->mip[i].width+3)/4)*blocksize)
|
||||
//for (y = 0, out = lock.pBits, in = mips->mip[i].data; y < mips->mip[i].height; y++, out += lock.Pitch, in += mips->mip[i].width*pixelsize)
|
||||
memcpy(lock.pBits, mips->mip[i].data, mips->mip[i].datasize);
|
||||
}
|
||||
else if (swap)
|
||||
{
|
||||
for (y = 0, out = lock.pBits, in = mips->mip[i].data; y < mips->mip[i].height; y++, out += lock.Pitch, in += mips->mip[i].width*4)
|
||||
{
|
||||
for (x = 0; x < mips->mip[i].width*4; x+=4)
|
||||
{
|
||||
out[x+0] = in[x+2];
|
||||
out[x+1] = in[x+1];
|
||||
out[x+2] = in[x+0];
|
||||
out[x+3] = in[x+3];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (y = 0, out = lock.pBits, in = mips->mip[i].data; y < mips->mip[i].height; y++, out += lock.Pitch, in += mips->mip[i].width*pixelsize)
|
||||
memcpy(out, in, mips->mip[i].width*pixelsize);
|
||||
}
|
||||
IDirect3DTexture8_UnlockRect(dt, i);
|
||||
}
|
||||
|
||||
D3D8_DestroyTexture(tex);
|
||||
tex->ptr = dt;
|
||||
|
||||
return true;
|
||||
}
|
||||
void D3D8_UploadLightmap(lightmapinfo_t *lm)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
1368
engine/d3d/vid_d3d8.c
Normal file
1368
engine/d3d/vid_d3d8.c
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue