Thread: DirectX 8 Transparent Textures

  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    35

    DirectX 8 Transparent Textures

    hi all,
    can any 1 help me on this .i cant seem to get a texture to b transparent i have been al over google and various websites but nothing im using windows xp dev-c++ 4.9.8.0 and dx8.1 sdk the code compiles fine but i cant get it transparent wether theres something i missed out or its the bmp or what i dunn0 i spent like 2 days messing with alpha blending and alpha channels etc.. is that the right approach to it or is it rong and if so what can i do to correct it or can u give me a link or tutorial for this.......

    PLEASE HELP ME!!

    lol
    if u want ne more info just ask me
    Last edited by poopy_pants2; 04-06-2003 at 08:29 PM.
    Theres a sucker born every minute, but a swallower is harder to find

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Make sure you have the memory specified as D3DPOOL_MANAGED. If that doesn't fix it post the code and I will try to help you.

  3. #3
    Are you creating your textures using D3DXCreateTextureFromFileEx()? If so, pass the color you wish to be transparent to the Colorkey parameter.

  4. #4
    Registered User
    Join Date
    Jul 2002
    Posts
    35
    yes im doing what french fry said and i have set the color but it just goes black
    Theres a sucker born every minute, but a swallower is harder to find

  5. #5
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Post your code. Without looking at it , its rather hard to say. Make sure you are setting the texture for your device and setting the color operations.

  6. #6
    Registered User
    Join Date
    Jul 2002
    Posts
    35
    i cant post it now i will upload my project when i get back if u pm me ur email
    Theres a sucker born every minute, but a swallower is harder to find

  7. #7
    Registered User
    Join Date
    Jul 2002
    Posts
    35
    ok i sent it to ur email thx for any help
    Theres a sucker born every minute, but a swallower is harder to find

  8. #8
    Registered User Coder's Avatar
    Join Date
    Aug 2001
    Location
    Cairo, Egypt
    Posts
    128
    If the color you want to be transparent is black, make sure you supply 0xff000000 as the color key, not 0x00000000.
    The latter disables color-keying.

    Generally, color key should be 0xffrrggbb

  9. #9
    Registered User
    Join Date
    Jul 2002
    Posts
    35

    Question

    what i never said that, the color that i have set to be transparent turns black, the color i have used for transparentcy is 0xFFFF00FF

  10. #10
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    I've been pretty busy but the semester is almost over. I think I'll have some time this week to look at it.

  11. #11
    do this in your initialization function:

    Code:
    	D3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,  TRUE);
    	D3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
    	D3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
    	D3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);

  12. #12
    Registered User
    Join Date
    Jul 2002
    Posts
    35
    i already have :/
    Theres a sucker born every minute, but a swallower is harder to find

  13. #13
    Registered User Coder's Avatar
    Join Date
    Aug 2001
    Location
    Cairo, Egypt
    Posts
    128
    1. Enable alpha testing

    2. Run your sample/app using the REFerence rasterizer (D3DDEVTYPE_REF). If the problem persists, then you're definitely doing something wrong.

    If it doesn't, then either you're:
    - Doing something not supported by the card
    - Not setting all the render states required (don't rely on default values)
    - Driver bug (I've seen such alpha blending bugs with unsigned drivers for s3's old cards)

    3. Create a texture filled with your 0xffff00ff color (Using any image processing tool).
    Load the texture, lock it, and loop through it yourself.
    Using the debugger, step into this loop. You'll be able to verify whether the color got replaced with transparent black or not.

  14. #14
    What screen format are you using? You need at least 1 alpha bit to do alpha stuff (for example: D3DFORMAT_A1R5G5B5 or D3DFORMAT_A8R8G8B8)

  15. #15
    Registered User
    Join Date
    Jul 2002
    Posts
    35
    im using A8R8B8G8 thx i will try it and also my grfx is radeon 9000 pro 128 ddr w/ ATi catalyst 3.2 should be very capable of running alpha blending :P
    Theres a sucker born every minute, but a swallower is harder to find

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Transparent panels overlapped
    By AtomRiot in forum C# Programming
    Replies: 3
    Last Post: 04-21-2007, 09:16 PM
  2. Isometric Tile Engine using DirectX
    By Wraithan in forum Game Programming
    Replies: 3
    Last Post: 07-17-2006, 12:16 PM
  3. DirectSound header issues
    By dxfoo in forum C++ Programming
    Replies: 0
    Last Post: 03-19-2006, 07:16 PM
  4. DirectX - Starting Guide?
    By Zeusbwr in forum Game Programming
    Replies: 13
    Last Post: 11-25-2004, 12:49 AM
  5. the effects of textures on my frame rate
    By DavidP in forum Game Programming
    Replies: 37
    Last Post: 10-03-2003, 11:24 AM