EngoEngine / engo

Engo is an open-source 2D game engine written in Go.
https://engoengine.github.io
MIT License
1.74k stars 136 forks source link

Utilize a Sprite Atlas #707

Closed Noofbiz closed 4 years ago

Noofbiz commented 4 years ago

Now that batch rendering is complete (thanks to everyone for all the help there!) the next step for picking up speed is utilizing a sprite atlas. This reduces texture switching, which reduces draw calls even further! My two cents is we should have a function common.LoadToFontAtlas(urls ...string) error that appends the files in the url to a texture which would be our font atlas. It would basically be a common.SpriteSheet except rather than use a map[int]Texture it would have a map[string]Texture where the string would be the url. It would re-use the atlas, so if another call is made to common.LoadToFontAtlas(url) it would append the new sprites to the current atlas. It would also be a slice rather than single, that way if the textures get bigger than 2048x2048 (or whatever multiple of 2 OpenGL will allow :P) we can start a second one.