Not logged inGosu Forums
Forum back to Help Search Register Login
Up Topic Gosu / Gosu Exchange / Batch image draws
- - By Omegas7 Date 2012-07-30 21:34
In cocos2d-iPhone, we had Sprites, and each would make a "draw call" (forgot how it was called XD). When you had lots of sprites that use the same texture, we had the SpriteBatchNode. Basically, you had your sprites inside this batchNode and then this batchNode will "draw all your sprites with one single call". Which was very efficient and saved resources.

Is there some kind of equivalent to that in Gosu-ruby? In my game, when I have multiple sprites using the same texture, the only kind of optimization I have is that all those sprites reference the same Image instance - but still I have to make multiple draw calls instead of just one.
Parent - - By Spooner Date 2012-07-30 23:05
Yes, it is Window#record, which is often used in this way:

    def draw
      @recording ||= $window.record 1, 1 do
        10000.times { draw something }
      @recording.draw 0, 0, 0

The values passed to record are the effective width and height of the recorded area. They only make a difference if you want to use center_x/center_y or rotation on the recording. I generally don't so 1, 1 suffices :)

This puts all the sprite draws into a vertex array, so they can be drawn incredibly fast (at least 100x faster than they would drawn manually).
Parent - By jlnr (dev) Date 2012-07-31 15:44
The downside is that things inside the recorded block cannot be moved individually later on. If you want to move everything around (game objects), you still have to call draw() on each of them.
Parent - - By Omegas7 Date 2012-08-04 18:57
Seems awesome, thanks! By the way, is there a limit to the dimensions of a Gosu::Image object?
Parent - By Spooner Date 2012-08-04 19:02
No limit at all (though if the image > 1022x1022 then it is actually split up onto multiple openGL textures and also TexPlay won't be able to work with it).
Up Topic Gosu / Gosu Exchange / Batch image draws

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill