Archived

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

transparent 2d bitmaps in Direct3D?

This topic is 4943 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m making a 2d game in direct3d. I don''t know how to do transparency. If someone could tell me how to do this that would be great. I''m using the function IDirect3DSurface9::StretchRect I need to know how to set the color key and everything.

Share this post


Link to post
Share on other sites
I don''t know how you would get transparence using strechrect, but I would recommend switching to textures instead. They are much easier to work with and you get all sorts of funky features.

If you do want the traditional 2D then you may as well use DDraw.

Share this post


Link to post
Share on other sites
You can''t use IDirect3DDevice9::StrectRect() to do transparency, the texturefilter parameter is how you want Direct3D to ''fix'' pixelloss or pixelgain (blitting to other sizes).

I''d recommend using textures too, only because there are much more resources about them.

--
You''re Welcome,
Rick Wong
- Google | Google for GameDev.net | GameDev.net''s DirectX FAQ. (not as cool as the Graphics and Theory FAQ)

Share this post


Link to post
Share on other sites
This is annoying.
I bought the book Beginning DirectX 9 by Wendy Jones.
She explains how to do 2d programming in one of the
chapters and she uses StretchRect. It works in the
sample program because the bitmaps have black in the
background and the screen used is all black. I
think this is a major flaw in the book. Transparency
is very important . I thought I had 2d graphics figured
out, now I have to go back to the beginning again.
Luckily, she explains how to do textures, but unfortunately
not for 2d games.
I guess I''ll have to go back to the beginning again.
BTW, does anyone have a bad book buying curse? It seems
like every time I buy a game programming book there''s some
kind of glitch in it that keeps me from doing what I want
to do. I''m quite disappointed, if you can''t tell.

Share this post


Link to post
Share on other sites
jimiwa, I did the same thing myself. Different book, same mistake. Setting up 2d through textures is very easy though. The book I recommend on the topic is "Focus on 2D in Direct3D". There are also some tutorials on using textured quads in DxGraphics in the articles section here on GDNet.


[edited by - stro on May 30, 2004 3:57:09 PM]

Share this post


Link to post
Share on other sites
The problem with Focus on 2d in Direct3D is it''s written
for DirectX 8 ( I have the book )

Fortunately, the book I got shows how to do textures.
It just doesn''t describe how to do them in 2d. But I''m
assuming that if I figure them out in 3d I will easily
be able to apply it to 2D
basically I''m wondering this:
Will I need to create a bunch of rectangles, one for each bitmap,
or can I load multiple textures from bitmaps all onto one
rectangle?

I just talked to someone who programs a lot, and he said that
I''m basically at par with learning dirextx. He said it takes
most people a year or two to learn, and I''ve been working on this
for about that long. Looking for information any way I can,
through the net and through books. It''s hard to find exactly what
you''re looking for.
Even on GameDev.net I think there''s a problem with the articles.
They too often are outdated or incomplete, at least from my
experience with working with them. These articles really need
to be updated.

It''s interesting that stro said use direct draw. Basically,
it seems like half of the people say direct draw is obsolete
and you should program even your 2d games in direct3d. The other
half say use direct draw for 2d games. I personally would use
direct draw if I had a book that showed how to do it, but my
best book, the one I just got, is on direct3d - so I''m learning
that.

Share this post


Link to post
Share on other sites