[SDL] Game event loop and input
Gabriel Gambetta
mystml at adinet.com.uy
Sun Feb 10 09:59:38 PST 2008
On Feb 10, 2008 3:01 PM, Martin <wtxnh-sdl at yahoo.com.au> wrote:
> This is exactly what I am looking for.
> One thing that puzzles me is order of drawing. Suppose you have stack (man
> menu, game screen, dialog). When dialog has to be drawn it is drawn and
> PASS_DRAW to game screen. When game screen is drawn will it not overdraw
> (hide) dialog? I thing that game screen should be drawn first, then dialog
> while processing input and update should remain as it is. Am I wrong?
No, you're right. Drawing is done bottom to top to avoid the use of the
zbuffer (my framework has software(SDL), Direct3D and OpenGL renderers), in
a painter's algorithm of sorts since the modes are few and you have them
ordered in a stack (keeping the drawing order of the images of a single mode
is a different matter). So what I do is to start from the top of the stack
and go down until I find a mode that does NOT have PASS_DRAW set. That's the
last mode that will be drawn - everything beneath it will be hidden. I then
draw from that mode to the top of the stack.
For example if the stack looks like this :
Options Dialog (PASS_DRAW)
Game HUD (PASS_DRAW)
Game Screen (-)
Menu Screen (-)
my code goes down until it reaches Game Screen, then draws Game Screen, then
Game HUD, and finally Options Dialog.
Since I am not experienced programmer I am still looking for some example
> code that has similar functionality as Gabriel and Scott described. Is there
> any available?
>
Mine isn't, but I don't think it would do you any good - this mechanism is
so generic and high level that any particular implementation probably won't
fit your particular needs. On the other hand, adding it to your framework
should be quite easy.
--Gabriel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20080210/31af007d/attachment.html
More information about the SDL
mailing list