Advertisement

Why won't this code work?

Started by January 23, 2000 11:00 PM
18 comments, last by Bigshot 25 years, 1 month ago
If you read my last post, you know I was trying to copy a background buffer to the back buffer in DirectDraw helluva fast. I finally decided to use a DirectDraw surface for the background buffer but now the code doesn''t work! To copy the background buffer to the back buffer I''m using the following code: // set up a RECT structure for bg buffer based on pan in x-axis RECT bg_rect = {Screen_Pan_X, 0, Screen_Pan_X + 641, 481}; // make the blitter call if(FAILED(lpddsback->BltFast(0,0,bg_surface,&bg_rect,DDBLTFAST_NOCOLORKEY))) return(0); ............................................................ This code should copy the background to the back buffer, but when I try to display it the background doesn''t show up at all. The computer doesn''t crash or anything, but background never gets displayed. I''ve also tried blitting directly to the primary buffer and using the slower Blt instead of BltFast but i get the same results. I think I setup the new surface correctly, but I''m not sure. Could someone please help me out? I''d appreciate it. Thanks, Al
Alexbigshot@austin.rr.comFoolish man give wife grand piano. Wise man give wife upright organ.
What are the sizes of the surfaces involved? If your background surface is bigger than your primary surface, e.g. if your background is 1280x1024 and your screen resolution is 640x480, then you will have to employ clipping to only Blt a subsection of the total background image. You can do this with the DIRECTDRAWCLIPPER interface. Note that once you attach a clipper object to a surface, you cannot use BltFast to display that surface (The BltFast function does not support clipping).
------When thirsty for life, drink whisky. When thirsty for water, add ice.
Advertisement
Does the Blt return an error? If so what is it?

Breakaway Games

Former Microsoft XNA and Xbox MVP | Check out my blog for random ramblings on game development

Well, I don''t know if this would do it, but you should change the 641 to 640 and the 481 to 480. The way you have it set up now is 1 pixel too far in each direction. This could cause the blit to fail.

If that doesn''t work, see if the actual blit call is failing or suceeding. If it''s failing, what is the return value?
Try add this flag: DDBLTFAST_WAIT.

Gandalf the White
Gandalf the Black
Well if the image is surpacing even by 1 pixel of the image wont show. Do you have a clipper attached??
Hardcore Until The End.
Advertisement
I ended up using the normal Blt function instead of BltFast. It''s not helluva fast but I guess it will have to suffice. I suppose it''s better than using memcpy. I don''t understand why it won''t work with bltfast, though... do I really need clipping? All I''m doing is copying a portion of the background buffer to the back buffer. The RECTs are the same size, so why would I need clipping? It should work as is. I already had a clipper attached to the back buffer but it''s really just for sprites. Anyway...Thanks for everyone''s advice.

Al
Alexbigshot@austin.rr.comFoolish man give wife grand piano. Wise man give wife upright organ.
Aw... You know what? I just figured it out. If you know a little about DirectX you should already know what I''m about to say because I mentioned it in my last reply. BltFast won''t work because I have a clipper attached to the back buffer. I took it out and then tried bltfast and it worked... but then my sprites wouldn''t clip anymore. Dammit! I guess I''m stuck with the normal Blt (bacon lettuce and tomatoes) and my game won''t be helluva fast. Oh well... I guess it''s the best i can do.
Alexbigshot@austin.rr.comFoolish man give wife grand piano. Wise man give wife upright organ.
Although I don''t have any direct knowledge that this is true, MOST, if not all, new video cards should perform identically performance-wise with both the Blt and BltFast methods, so you''re not losing anything. I could be wrong though.

www.gameprojects.com - Share Your Games and Other Projects
quote:
Original post by Bigshot

I guess I''m stuck with the normal Blt (bacon lettuce and tomatoes) and my game won''t be helluva fast. Oh well... I guess it''s the best i can do.


Use BltFast() and do your own clipping. It''s quite a bit faster as far as I can tell. I just posted a routine to do this in the Isometric Land forum earlier today.

//TOOM

This topic is closed to new replies.

Advertisement