[SDL] Re: Re: Optimized draw policy in the main loop of a game.

Freeman ahk-freeman at webmails.com
Sat Aug 23 10:48:07 PDT 2003


> Welcome!
Thanks !!!!!

 > ....
 >To have a moving background with a selective erasure
 >scheme like above, you'd need to re-blit the screen
 >content to an offset location... if it's a hardware
 >surface one of SDL's blit functions may be able to
 >transfer directly from hardware memory to hardware
 >memory.

What ?, Does a simple call to BlitSurface() with both src and dest
surfaces pointing to the sreeen will do the stuff ??,by the way which
is the fatser :
-1 Redraw an internal surface to the sreeen everytime with a different
offset,
    And then update !
-2 Try to take what's there on the screen and redraw it on the screen with
an offset ,
 And then perform an UpdateRect(screen,0,0,0,0) !!!

I guess the answer is '2' !!!

> Chances are it'll actually be faster as a
 >software surface, in which case you might be able to
 >write a faster move/blit function than the generic
 >one... assuming your screen dosn't move too much (how
 >much will again depend on the system) you could write
 >a single for loop that would do an extra draw in the
 >new 'uncovered' area, but wouldn't have as many
 >comparisons. If you're interested in an example of
 >what I'm talking about let me know. (It might only be
 >worth it for 1 or 2 pixels shift left/right)

Of course I am !!!! thank you in advence !!!!!

 >Also, as a final note: most systems today are fast
 >enough that you may want to postpone optimization
 >until you are fairly close to 'finished' with the game
 >(and by cloes to finished I mean close to
 >releasing/going beta/going past beta). This has the
 >advantage of being able to know how everything is
 >layed out, and hence where exactly you should start
 >optimizing :).

Yes ,but the problem is that I'm designing a 2D game engine,(which
is 100% pure ANSI/ISO C++ ,..I plan to release a beta version with
in a few weeks ....anyway ....), And want it to be general pupose,and do
the right optimization for most of the games.....

 >Geeze I reply too long too much... :)

Yes ,and many thanks to you Mike !!!....
------- End of transmission ----------






More information about the SDL mailing list