Jump to content
  • Advertisement

Archived

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

hajkr

problem with rendering half-life wad-textures

This topic is 5899 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I trie to render half-life wad-file textures that are loaded in memory. And i can't find the mistake that i made, because the texture that is rendered with the code below doesen't really look like the original. Maybe somebody of you can find a problem in this code:
// p3d : direct3d-class
// g_lpTextur: direct3d-texture
// pcxEncode: structure holding informationen of the texture
// lpData: Pointer at Texture-information ( 8bit-values )


// create Directx texture 32 bit ( 8 8 8 8 )
if( FAILED( hr = p3d->m_pd3dDevice->CreateTexture( 
                              pcxEncode.dwWidth, 
                              pcxEncode.dwHeight,
                              1, 0, D3DFMT_A8R8G8B8, 
                              D3DPOOL_MANAGED, &g_lpTextur ) ) )
   {
      MessageBox( NULL, "Could not create wad-texture", "error", MB_OK );
      return MYDIRECT3D_FAILED;
   }


// lock texture to write it
D3DLOCKED_RECT lockedRect;
   if( FAILED( g_lpTextur->LockRect( 0, &lockedRect, NULL, 0 ) ) )
   {
      MessageBox( NULL, "Could not lock wad-texture", "error", MB_OK );
      return MYDIRECT3D_FAILED;
   }


   BYTE* pByte,*pByte2 = NULL;
   pByte = (BYTE*)lockedRect.pBits;
   pByte2 = (BYTE*)lpData;
   BYTE* pB = NULL;


// convert information of wadfile-pointer ( pByte2 ) with the 
// palette to 32 bit and write to texture (pByte)
// Directx: BGRX, ( WAD-File: RGB ??? )
for( int i = 0; i < pcxEncode.dwHeight; i++ )
   {
      for( int c = 0; c < pcxEncode.dwWidth; c++ )
      {
         pB = &pcxEncode.lpPalette[*(pByte2++)];
      
         *pByte++ = *( pB + 2 * sizeof( BYTE ) ); // B
         *pByte++ = *( pB + sizeof( BYTE ) ); // G
         *pByte++ = *pB; // R
         *pByte++ = 0; // X
      }

      pByte += lockedRect.Pitch - pcxEncode.dwWidth * 4;
   }
   
I have read the tutorials on http://folk.uio.no/stefanha/ and had a look at the wad3-source but they didn't help me with this problem. I have made two pictures how the textures look when they are rendered with this code and how they should look: http://heiko.merlin.friedrich.bei.t-online.de/texture1.jpg http://heiko.merlin.friedrich.bei.t-online.de/texture2.jpg [edited by - hajkr on April 29, 2002 4:56:10 PM]

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!