Archived

This topic is now archived and is closed to further replies.

honds

DirectDraw - 24 bit color and transparencies

Recommended Posts

Hello, I haven't posted here at all yet, even though I have been a member for a while. However, I just started trying to learn DirectDraw since the 2d graphics meathod I used/wrote was too slow. I have run into a few problems though. Maybe some one can shine some light on them? First... In the color depth parimeter in SetDisplayMode() if I specify anything higher than 8 bit it does't return DD_OK. And 8 bit color looks bad for practicaly any type of application or game. My video card supports up to 32 bit so I can't figure out why I can't set it higher than 8. Second... DDSetColorKey() does not seem to work. I have tried doing it to both buffers and the sprite surface, nothing works. I have tried it with RGB(255,0,255) (fushia) and RGB(255,255,255). I can see how fushia might not be in the pallete (although that is what I usualy use because it is rarely used in images) but white definately should be in there. Obviously I need to figure this out because it really stresses my creativity to have all the sprites entitely rectangle shaped. Thanks in advance for any help. - Andrew G. Curioso - AKA honds Edited by - honds on June 10, 2001 1:22:31 AM

Share this post


Link to post
Share on other sites
Try the following:

1) Try using the DirectX7 SDK if you are not using it already. It contains many DirectDraw sample applications running in 16Bit mode so all you have to do is copy the initialization routine, and it is more compatible with the majority of video cards out there.

2) Try downloading and installing the latest drivers for your video card.

3) If your video card is very old, i.e. S3 Trio, it may be time to upgrade to a better one, GeForce256 cards are still a very good card and they are less than $100 now


As for DDSetColorKey(), are you sure the RGB values match the color you use for colorkeying in the bitmaps?
I use 100% black (RGB(0,0,0)) mainly because ive had RGB problems with some programs such as mspaint related to bright colors.
Again, check out the DDSetColorKey routine in DDUtil.c file from the DX SDK.
Remember to use the flag DDBLT_CLRKEY (check the spelling) when you call DDSurface->Blt().






Demo Download: www.angelfire.com/realm/zeroone

Share this post


Link to post
Share on other sites
Colour Keys depend on what colour mode you are in, and since you are using 8 bit (I assume at least), then the value you need to set it to could be anything depending on where it ends up on the pallette.

Try enumerating all the video modes, the SDK has a good example, and I''m sure there would be others available. Then, pick one of the modes there that has >8 bit and use that. If none of them are >8 bit, then you will have problems

But don''t diss 8 bit, Starcraft uses it, and so do a lot of other games, and you can do some cool things with it because it uses palletes (and I realise that I''ve spelt palette differently all 3 times I typed it... I figure one of them must be right ).

Trying is the first step towards failure.

Share this post


Link to post
Share on other sites
I have Starcraft and the graphics I end up getting suck compaired to the graphics I get . Maybe they just have a better pallete, I should try to make a new one.
I have the DirectX 8 SDK but I am a Borland C++ Builder user and it takes some effort to get some of the sample to work properly, but I will look into it.
Also, I get an "undefined symbol" error for DDBLT_CLRKEY.

Thanks for you help, I will try looking more into the sample.

Share this post


Link to post
Share on other sites
Why don''t you capture the HRESULT that is returned from the call and find out why it is failing. It''s probably as easy as your video card doesn''t support the resolution.

Share this post


Link to post
Share on other sites
My video card should support higher. I run Genesis3D and Morfit with higher resolutions than 8-bit.

I looked in the DX8 SDK samples. I saw a few that use 16 bit, but they use a stange CDisplay class that appears in a different version of ddutil. I would see if I can use the different ddutil.h and .cpp but I am not sure if it will mess up my sprite system because it appears to use a completely different system than what I was using. The CDDisplay object seams to take over everything (surfaces, blitting, text, ect). I''m a control freak, I like to be able to have direct access to all that stuff .
But, since I haven''t done much learning yet when it comes to DirectDraw (a day or so) I might give that a try if I can''t get my own routines to work.
I also noticed that in the ddutil I found, when they call SetCooperativeLevel() it has two extra parimeters. I tried using the two extra parimeters in my application but I get a compilation error. I still can''t get anything higher than 8 bit to work, but I guess if I customize my pallete enough it will work.

Anyway I got transparency working. I made a very stupid mistake. My pellete had (255,255,253) for white instead of all 255.
I''m using Corel now to make a custom pallete for the type of game I want so I don''t make that mistake again.

Share this post


Link to post
Share on other sites