• Advertisement

Archived

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

please help me with direct draw

This topic is 5027 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 am trying to get a simple animation going. The problem is DDLoadBitmap and DDSetColorKey are not found by my compiler. I need to know how to load a bitmap from a resource and set the color key for transparency so I can do this animation (I.E. using different functions than DDLoadBitmap and DDSetColorKey, I think they''re SetColorKey and LoadSurfaceFromBitmap). If anyone who reads this knows how do do this please reply. I need some explaination, please give me an example of how this is done and how to set up the parameters I need to do this

Share this post


Link to post
Share on other sites
Advertisement
Heya, hope this helps.

First off you should declare your transparencies when creating the surface, its a lot safer to do than afterwards. Check out my Direct Draw wrapper class function here. I declare the transparencies in the ddsd_a structure. This is also know as a "Direct Draw Surface Description" structure.


void CGfxEngine::CreateOffScreenSurface(int iWidth, int iHeight, LPDIRECTDRAWSURFACE7 & lpDDS7)
{
DDRAW_INIT_STRUCT(this->ddsd_a);

this->ddsd_a.dwFlags = DDSD_HEIGHT | DDSD_WIDTH | DDSD_CAPS | DDSD_CKSRCBLT;
this->ddsd_a.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
this->ddsd_a.dwHeight = iHeight;
this->ddsd_a.dwWidth = iWidth;
this->ddsd_a.ddckCKSrcBlt.dwColorSpaceLowValue = 0;
this->ddsd_a.ddckCKSrcBlt.dwColorSpaceHighValue = 0;

if (FAILED(this->lpDD->CreateSurface(&this->ddsd_a, &lpDDS7, NULL)))
{
this->oReporter.ReportGenError(ET_INIT,
"UNABLE TO CREATE OFSCREEN SURFACE",
"CGFXENGINE::CREATEOFFSCREENSURFACE",
ER_FATAL);
}
}// END CREATEOFFSCREENSURFACE()



and for getting a bitmap to load to a surface, check out this article here on gamedev

Best of luck!

edit: fixed code alignment, stupid copy-paste from VS.net

[edited by - etherstar on April 14, 2004 1:54:34 PM]

Share this post


Link to post
Share on other sites
DDLoadBitmap and DDSetColorKey are part of ddutil.cpp .h found here (it was included in DirectX 6.1 SDK which is what I''m using)

ddutil.h | ddutil.cpp

However, the functions here use DirectDraw 1.0 which is what I''m using for a full side-scroller/platformer. You can convert these to DirectDraw 7 by changing the variables (IDirectDraw7 instead of IDirectDraw, etc). I use straight C calls to DirectDraw, no classes.

See my demos for how to load from a resource, to do this with DirectDraw you can include ddutil.h .cpp above and use DDLoadBitmap and DDSetColorKey. Probably the least amount of code required if you''re gonna use DDraw. You''ll also need your own .h and your own .rc (plain text files containing references to your .bmp and/or .wav files you wanna use).

VazGames.com

Phil P

Share this post


Link to post
Share on other sites

  • Advertisement