Jump to content
  • Advertisement


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


Easy DirectDraw Questions

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

1. Can you load more then one bitmap to a surface in DirectDraw? Or do you need to have a surface for each bitmap? 2. Can you draw half sprites? If a sprite leavs the screen it disappears just as the first pixel leaves.

Share this post

Link to post
Share on other sites
1. Yes. While sprites usually are on their own small surfaces, many different sprites are being blitted to the Primarary Surface each frame.

2. Yes. There is a clipper object you can use (I forget its syntrax), or you can write your own clipping code, only blitting the part of the sprite that is on the screen.

Share this post

Link to post
Share on other sites
1. You can load more than 1 bitmap to a surface at once. If you have a bitmap that is 10x10 and another that is 10x10, just make a surface of 20x10. Then load one bitmap at ''x'', and the other at ''x''+10. This works for as many pictures as you want, since surfaces can be as big as memory on the vid card.

2. You of course can draw half-sprites. Or 1/4 sprites...etc. It''s called clipping and I''m not affluent with it in DirectDraw, but you can attach clipping rectangles (RECTs) to objects and it will draw only what''s inside those. It won''t delete the object from the screen, it will only draw what''s inside of the rectangle.

Share this post

Link to post
Share on other sites
Hello there.

1). It looks like Sponge99 and CTRL_ALT_DELETE know about this one already. However, I too, am wondering which method, if either, is more efficient: creating one surface for each bitmap; or using one big surface to contain all the bitmaps?

2). I can help with using a clipper. :-)

* Use this code as a base for creating one:


//create the clipper object
lpDD->CreateClipper(0, &lpClipper, NULL);

//set the clipper to your application's hwnd
lpClipper->SetHWnd(0, hwnd);

//assign the clipper to your back buffer (and/or any other

* When you're done with the clipper:
if (lpClipper) {
lpClipper = NULL;

* When you blit to a surface with a clipper attached to it, you must use Blt instead of BltFast. Try both to see what I mean. :-)

That's about it.
Hope it helps

Edited by - Zir0 on August 7, 2001 11:05:04 AM

Edited by - Zir0 on August 7, 2001 11:09:42 AM

Share this post

Link to post
Share on other sites
What function do you use to load more then one bitmap to a surface? I use CreateSurfaceFromBitmap() when I load just one bitmap. I don''t know any other function.

I would really like to see the source from an easy DirectDraw 7 game (preferably a RPG).

Thanks for the clipping help.

Share this post

Link to post
Share on other sites
Sorry dude direct X does not have a build in bitmap loader ur going to have to write ur own or u can use mine(it loads bitmaps
from bitmap resources included in your resource file but it can be modified to load bitmaps from disk):

LPDIRECTDRAWSURFACE7 LoadBitResource( int id, HINSTANCE hinstance)
HDC srcDC;
HDC destDC;
HBITMAP hbitmap;
int h, w;
srcDC = CreateCompatibleDC(NULL);
SelectObject(srcDC, hbitmap);
GetObject(hbitmap, sizeof(BITMAP), &bmp);
h = bmp.bmHeight;
w = bmp.bmWidth;
ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
ddsd.dwSize = sizeof(DDSURFACEDESC2);
ddsd.dwHeight = (DWORD)h;
ddsd.dwWidth = (DWORD)w;
lpDD->CreateSurface(&ddsd, &lpRB, NULL);
BitBlt(destDC, 0, 0, w, h, srcDC, 0, 0, SRCCOPY);
return lpRB;

I know it''s hard to be a directx newbie!

Share this post

Link to post
Share on other sites
I used the DDUtil.cpp and its header file that come with the DirectX SDK. It has support for loading bitmaps.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!