Skip to main content
GameDev.net gamedev.net
🔒 Locked

Sloowww bitmap engine... please help.

Started by Gf11speed Nov 25, 2001 at 12:02 PM 3 replies 200+ views
Original Post
Gf11speed
Gf11speed
I am having complaints of my bitmap loading/displaying engine being very slow. I'm not sure what is making it slow... if anybody could look at my code, I would appreciate it. I think the problem lies within the drawing part: int DDDrawSprite( DDSPRITE sprite ){ RECT DestRect,SourceRect; DestRect.left=sprite.x; DestRect.top=sprite.y; DestRect.right=sprite.x + sprite.width; DestRect.bottom=sprite.y + sprite.height; SourceRect.left=1; SourceRect.top=1; SourceRect.right=sprite.width; SourceRect.bottom=sprite.height; if(lpddsback->Blt(&DestRect, sprite.images[ sprite.curr_frame ], NULL,DDBLT_WAIT | DDBLT_KEYSRC, NULL!=DD_OK)) return 0; return 1; } // End DDDrawSprite(); Is there anything wrong with this??? Let me know if you need me to post the creating/loading routines. THANKS a lot! I am using DirectX 5 for the engine, for compatibility on older systems. *==================* www.syntasoft.com *==================* Edited by - Gf11speed on November 25, 2001 1:03:18 PM
Greg FieldsSyntasoft Gameswww.syntasoft.comPost-Time Horse Racing (Available Now)
EbonySeraph
EbonySeraph
I just made a program that draws a bitmap to the screen too and it was sloooow...make sure you are not loading the bitmap to the surface every single frame.
"Ogun's Laughter Is No Joke!!!" - Ogun Kills On The Right, A Nigerian Poem.
Gf11speed
Gf11speed
What would

SourceRect.left/right = 0, as compared to 1 do ?

Edited by - Gf11speed on November 26, 2001 1:53:59 PM
Greg FieldsSyntasoft Gameswww.syntasoft.comPost-Time Horse Racing (Available Now)
GuyJohnston
GuyJohnston

Generally it''s best to have your source rect, and destination
rect the same size. In this way, Direct X doesn''t have to resize
the image when it does the Blt.

Let''s give some values to your rects.

sprite.x = 0;
sprite.y = 0;
sprite.width = 32;
sprite.height = 32;

This would make you destination rect from 0,0 to 32, 32.
You source rect would be 1, 1, to 32, 32.

So your source rect is smaller then your destination rect.
Direct X now has to worry about resizing the image to fit
the destination rect. This would slow down the Blt.

Also, I like using values of 8, 16, 32, 64 etc when I can.

btw My sprite library as it stands has the stretching problem
as well. This thread brought it to my attention. Now I think
I''ll go and fix it.

Guy
Adulthood is the vehicle for making you childhood dreams come true.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.