problem with rendering half-life wad-textures

Started by
0 comments, last by hajkr 21 years, 11 months ago
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]
Advertisement
Nobody???

This topic is closed to new replies.

Advertisement