My game is seperated into game states, as seen in Chingu or benko's shooter example game. One of them is a menu with a background (Z_MENU_BG) and two buttons (Z_MENU_BUTTONS). Now I want to draw a dialog on top of that which has a background and buttons itself, drawn with the same Z values. To be sure that Gosu doesn't first draw both background, then both buttons, I need to flush/separate the Z ordering between drawing both things. Which is exactly what this new method will do in 0.7.23.
I run into lots of little things that I need lately, like this tiny method. At the same time I am concerned that Gosu's interface will get all wobbly and bloaty until I am done.
Any other suggestions for the name, or any other ideas so I don't have to add *yet another method* which is going to be called only a dozen times in Gosu's existence? ;) Does flushZ()/flush_z make it more clear?
A small question: does this flushing mean that you can't 'draw below stuff that's already drawn' anymore?
Precisely. The way it is now, Gosu actually maintains a priority queue of drawing operations, and when you call a drawing method, it's inserted into the queue sorted by Z order. After your Window#draw method returns, then all the drawing is done from back to front.
flush goes ahead and draws everything so that you can draw, say, a second layer on top of your game without worrying about making sure your Z indices are higher than anything else that you've drawn.
This is good news. Now I can get rid of the Z option for my ring menu and just make it flush the draw op queue after drawing the previous state. :)
flush makes perfect sense for me too, I have been (ab)using
beginGL(); endGL(); to do exactly the same for quite a time now :)
Hah, clever—I never thought of doing that.
Well, flush_z or reset_z or anything like that seems to be fine.
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill