Archived

This topic is now archived and is closed to further replies.

rocknroll60s

Quake3 BSP Lightmaps

Recommended Posts

Here's my code to load Q3A lightmaps:


    

for(int i=0;i < numlightmaps;i++)
{
D3DLOCKED_RECT lr;

D3DXCreateTexture(d3ddevice,128,128,1,0,D3DFMT_A8R8G8B8,D3DPOOL_MANAGED,&lightmaptextures[i])
lightmaptextures[i]->LockRect(0,&lr,NULL,0);

for(int j=0;j < 128*128;j++)
{
//swap the bytes to the way D3D likes it

((unsigned char*)lr.pBits)[j*4+0] = lightmapdata[128*128*3*i+j*3+2];
((unsigned char*)lr.pBits)[j*4+1] = lightmapdata[128*128*3*i+j*3+1];
((unsigned char*)lr.pBits)[j*4+2] = lightmapdata[128*128*3*i+j*3+0];
((unsigned char*)lr.pBits)[j*4+3] = 255;

}
lightmaptextures[i]->UnlockRect(0);
}

I gave you the whole source cause there are some subtleties.

If you ever release your source, let me know. I'm collecting links to Q3A BSP renders.

[edited by - RollingRock on December 23, 2002 11:54:28 PM]

Share this post


Link to post
Share on other sites