HOWTO: Texture Rendered Upside Down in Direct3D Retained Mode

ID: Q175543


The information in this article applies to:


SUMMARY

In DirectX 3, a texture loaded from a .bmp file with the IDirect3DRM::LoadTexture method is rendered upside down. In DirectX version 5.0, you can use the new IDirect3DRM2 interface to load a .bmp file and have it displayed right side up.


MORE INFORMATION

This behavior in DirectX 3 needed to be preserved in DirectX 5.0 (in IDirect3DRM) for backward compatibility with older applications. In DirectX 5.0, you can call IDirect3DRM2::LoadTexture to load a .bmp file and have it rendered right side up.

If you are writing a DirectX 5.0 (or later) application that uses the IDirect3DRM interface, then you should call QueryInterface on IDirect3DRM to obtain the IDirect3DRM2 interface if you would like your .bmp files loaded with LoadTexture() to be displayed right side up. The texture must be placed in a DIRECT3DRMTEXTURE2 object. Here is an example in "C" which demonstrates this process:


   LPDIRECT3DRM2 lpD3DRM2;
   LPDIRECT3DRMTEXTURE2 tex = NULL;

   // Query the IDirect3DRM2 interface off of Direct3DRM.
   rval = lpD3DRM->lpVtbl->QueryInterface(lpD3DRM,
                &IID_IDirect3DRM2,(LPVOID*)&lpD3DRM2);
   if (rval != D3DRM_OK)
   {
      Msg("Failed to obtain the IDirect3DRM2 interface.\n");
      goto ret_with_error;
   }

   // Load the texture with the new interface
   rval = lpD3DRM2->lpVtbl->LoadTexture(lpD3DRM2, "test.bmp", &tex);
   if (rval != D3DRM_OK)
   {
      Msg("Failed to load test.bmp.\n");
      goto ret_with_error;
   }

   // Release the IDirect3DRM2 interface
   lpD3DRM2->lpVtbl->Release(lpD3DRM2); 

Additional query words:


Keywords          : KbDirectX500 kbSDKWin32 
Version           : WINDOWS:5.0
Platform          : WINDOWS 
Issue type        : kbhowto 

Last Reviewed: June 17, 1999