HOWTO: Texture Rendered Upside Down in Direct3D Retained Mode

Last reviewed: October 24, 1997
Article ID: Q175543
The information in this article applies to:
  • Microsoft DirectX 5 Software Development Kit, version 5.0

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);

Keywords          : GdiDirect3D
Version           : WINDOWS:5.0
Platform          : WINDOWS
Issue type        : kbhowto


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: October 24, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.