Direct3D for 2D animation

Started by
1 comment, last by MasterWorks 23 years, 10 months ago
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
Advertisement
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
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.

GDNet+. It's only $5 a month. You know you want it.

This topic is closed to new replies.

Advertisement