Not logged inGosu Forums
Forum back to Help Search Register Login
Up Topic Gosu / Gosu Exchange / Technical question
- - By lol_o2 Date 2014-07-11 12:53
I'm making a method that pre-loads all resources for game. While it is easy with sound and music, there is a problem with images. An image can be loaded as image or as tiles and I want everything to be automated.
Se here's the question: does loading tiles from image make any performance differences? I can load tiles from file, but without pre-loading, this may cause a lag. And I don't want to write down how to load each tiles individually. But I can pre-load image and then load tiles from it instead from a file. Does it speed anything?

And if not, would it be maybe better to use .subimage method instead of loading tiles or is it too slow?
Parent - - By arrow Date 2014-07-11 15:07
I'm not exactly sure what you are asking but as long as you preload the images I don't think you should worry about performance. You can wait with figuring out how to make your game faster until it becomes a problem that it's too slow.
Parent - By lol_o2 Date 2014-07-11 18:42
I've meant, that when you load images in-game, you get a small lag, when loading file. So you can pre-load image to avoid this. But you can't do this automatically for tiles, because most of images are loaded with different tile sizes. But instead of loading from file, you can load tiles from image stored in memory and I'm wondering if it is any faster.
Parent - - By jlnr (dev) Date 2014-07-12 09:02 Edited 2014-07-12 13:26
You could use a texture packer and then load all images using Image#subimage, see

This would be the ultimate in performance, as Gosu does not have to do any atlas-building during runtime. :) subimage is perfectly portable. Just make sure that the tile atlases are 1024x1024 and loaded with tileable: true, so they end up on their own OpenGL texture.
Parent - - By lol_o2 Date 2014-07-12 12:53
I don't mean to make ultimate performance that much :)
I just want to know if loading tiles from Gosu::Image is faster than from file.
Parent - By jlnr (dev) Date 2014-07-12 13:29
Should be, because no file I/O is involved, but I don't think the difference will be dramatic (unlike subimage, which is almost a no-op). Only benchmarks know the truth, though. ;)
Up Topic Gosu / Gosu Exchange / Technical question

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill