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?
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.
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.
You could use a texture packer and then load all images using
, see https://github.com/spajus/gosu-texture-packer
This would be the ultimate in performance, as Gosu does not have to do any atlas-building during runtime. :)
is perfectly portable. Just make sure that the tile atlases are 1024x1024 and loaded with
, so they end up on their own OpenGL texture.
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.
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. ;)
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill