Archived

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

Direct3D for 2D animation

This topic is 6391 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

Hello everyone, I''m a fairly experienced VB programmer, who has until know relied on the VBDX type libraries for DirectX programming. Now I''m working on a new project. (our first game, Flux, has gone commercial and is available at www.planetflux.com) VB specific responses are not required, as I''m sure the implentation I''m looking for is similar to the C++ version. I''m looking to do another 2D puzzle game but using D3D for alpha blended sprites. This appears to be fairly simple, just by using a DirectDraw surface with an alpha channel as a rectangular texture. There are several examples of how to do this. The problem I''m having is getting new information into the alpha channel. Specifically, I want to blit a grayscale surface (?) onto the alpha channel of ANOTHER surface. How can this be done? Please, no DDS! I want to use separate BMP/JPG files for the sprites and their alpha masks, because I need to assign different sprites new masks at run-time. Is this possible? How can I load into only the alpha channel of a 32-bit surface? PLEASE HELP!! Anything at all is appreciated! Best, Jay Wheeler President, MasterWorks Software

Share this post


Link to post
Share on other sites
Oye! That's a tough one.

In 32 bits your surface is set up in a ARGB format, correct?

Presumably what you could do is lock both the surfaces and just copy data from the grayscale image into every 4th byte. A bit of a pain, but it's probably your only option.


--TheGoop

Edited by - TheGoop on June 13, 2000 7:55:19 PM

Share this post


Link to post
Share on other sites
Sounds like you need to check out the Fireworks sample program in the DX7 SDK. I''m also a VB user, and I can tell you that it IS possible to do what you''re asking, but I don''t know how. Oddly enough, I''m trying to do the same thing you are right now, so this post was a boon to me.

To use an alpha bitmap, you enable alpha-blending like normal, set your bitamp as your D3DDevice''s texture, and apply a material. This is what Microsoft did in the Fireworks example. It creates an alpha blended texture with the material''s color and light settings. You can create all kinds of neat effects with this, and it may be all you need.

However, if you still want to add a texture to the alpha surface, it should be possible with multiple textures. I don''t know how to do this, but I''ll eventually need to figure it out. If you would like to swap ideas, e-mail me.

It should be possible to do what you''re asking using multiple textures. There''s another sample in the DX7 SDK called Multi-texture. It''s a C++ sample, but if you understand C++ then you shouldn''t have any trouble converting it to VB.

Share this post


Link to post
Share on other sites