Archived

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

cb007sax

DirectDraw Blitting

Recommended Posts

I''m trying to blit using a direct draw surface, and everything is great, but whenever the image is just barely off the surface, it won''t blit the image at all. So if even a pixel of the blit is off, nothing shows up, but if it''s on teh surface it''s fine. I''m using BltFast, and like this: backSurface->BltFast(x,y,ball,NULL,DDBLTFAST_WAIT | DDBLTFAST_SRCCOLORKEY); and then i''m flipping the surfaces with while(result == DDERR_WASSTILLDRAWING) result = primarySurface->Flip(NULL, DDFLIP_WAIT); if anyone can help, ill be very appriciative

Share this post


Link to post
Share on other sites
BltFast doesn''t handle clipping. You can either make sure the BltFast stuff doesn''t ever go off the screen (a few if... statements will do the trick) or you can attach an IDirectDrawClipper and use Blt instead of BltFast.

Share this post


Link to post
Share on other sites
Can you still use Bltfast after attaching a clipper? or is it impossible?

I''d like to use Bltfast to blit my background image, because it might be just that little bit faster. but it doesn''t work at all :/

It''''s nice to be important, but it''''s more important to be nice.

Share this post


Link to post
Share on other sites
quote:
Original post by Bad_Maniac
Can you still use Bltfast after attaching a clipper? or is it impossible?

BltFast reference says...

quote:
This method works only on display memory surfaces and cannot clip when blitting. If you use this method on a surface with an attached clipper, the call fails, and the method returns DDERR_UNSUPPORTED.


quote:
Original post by Bad_Maniac
I'd like to use Bltfast to blit my background image, because it might be just that little bit faster. but it doesn't work at all :/


...and the survey says...

quote:
The software implementation of IDirectDrawSurface7::BltFast is 10 percent faster than the IDirectDrawSurface7::Blt method. However, there is no speed difference between the two if display hardware is used.


(Note: I don't know the effect that a clipper has in terms of speed. I'd be surprised if it made a significant difference, though.)

[edited by - Alimonster on October 19, 2002 8:20:29 PM]

Share this post


Link to post
Share on other sites
You can do your own clipping by adjusting the SrcRect in the BltFast parameters.


    
// sX,sY = sprite pos

// sWidth,sHeight = sprite size

//


RECT srect = { 0, 0, sWidth, sHeight };
int dX = sX, dY = sY;

// Adjust right/bottom

if ( sX + sWidth > SCREEN_WIDTH )
srect.right = SCREEN_WIDTH - sX;

if ( sY + sHeight > SCREEN_HEIGHT )
srect.bottom = SCREEN_HEIGHT - sY;

// Adjust top/left

if ( sX < 0 ) srect.left = - sX;
if ( sY < 0 ) srect.top = - sY;

if ( dX < 0 ) dX = 0;
if ( dY < 0 ) dY = 0;

lpDDSBack->BltFast( dX, dY, lpDDSGfx, &srect, 0);



Edit: added some code



[edited by - Prototype on October 19, 2002 9:16:24 PM]

Share this post


Link to post
Share on other sites