Loading TBitmap onto a DirectX Surface

This is a discussion on Loading TBitmap onto a DirectX Surface within the Game Programming forums, part of the General Programming Boards category; Has anyone had any experiance loading a BCB6 TBitmap onto a DirectDraw Surface? At the moment, I'm just grabing the ...

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    180

    Loading TBitmap onto a DirectX Surface

    Has anyone had any experiance loading a BCB6 TBitmap onto a DirectDraw Surface? At the moment, I'm just grabing the TBitmap's HDC, then blting it onto the surface, but nothing is actually copied...any ideas?

    DW

  2. #2
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    Yeah don't use it.

    Use the D3DX library for DirectX 9.0 to load the bitmap. DirectDraw is deprecated and as such you should not use it. Direct3D and DirectDraw have been merged into DirectGraphics.

    Here is a simple texture loader in DirectX 9.0.

    Code:
    #include "d3dx9.h"
     
    void LoadTexture(IDirect3DDevice9 *_Device,std::string _File,IDirect3DTexture9 *_Texture)
    {
      if (D3DXCreateTextureFromFile(_Device,_File,&_Texture)))
      {
    	::MessageBox(0,"Failed to load texture",0,0);
      }
    }
    This function natively supports several popular image formats as well as DDS files.

  3. #3
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Bubba is correct. D3DX is a good library for loading bitmaps.

    Just one change though:
    Code:
      if (D3DXCreateTextureFromFile(_Device,_File.c_str(),&_Texture)))
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    LOL. oops.

    I really shouldn't compose code here.


  5. #5
    Registered User
    Join Date
    Mar 2004
    Posts
    180
    any way to get this to work with DirectDraw?

  6. #6
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    The way you are doing it works does it not. Get a pointer to the surface, retrieve the data from TBitmap, copy the data to the surface via the pointer.

    1. Retrieve from TBitmap, or get a pointer to TBitmap surface/data.
    2. Lock DirectDraw surfaceand get pointer to surface.
    3. Read from TBitmap, write to surface.

  7. #7
    Registered User
    Join Date
    Mar 2004
    Posts
    180
    I tried that...didn't work to well...Noting gets copied.

    I got the hDC for the DD7 surface, blted the bitmap to the DD7 surface, but nothing got coppied....Just gave up on it now, and will try somthing else

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Cargo loading system
    By kyle rull in forum C Programming
    Replies: 1
    Last Post: 04-20-2009, 12:16 PM
  2. Please help with my game
    By jjj93421 in forum Game Programming
    Replies: 10
    Last Post: 04-12-2004, 11:38 PM
  3. Game update...
    By jdinger in forum Game Programming
    Replies: 14
    Last Post: 11-08-2002, 06:10 AM
  4. Loading X Files with DirectX 8 ??
    By MrWizard in forum Game Programming
    Replies: 2
    Last Post: 07-24-2002, 02:48 AM
  5. DirectX surface question
    By Magos in forum C++ Programming
    Replies: 2
    Last Post: 06-03-2002, 10:15 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21