(putting in beta for now, but will open when 1.3 is out)
So I’m planning to implement the atlas trick and wanted to bounce ideas/questions.
I’m thinking the atlas has a single mesh whose texture is an image with all the drawings that this atlas knows how to render. Then addRect/setRect creates the mesh rect. So something like:
-
Atlas:map( name, drawingFunc, width, height) adds a new drawing to the texture. drawingFunc draws a single image which will be rendered to the texture with dimensions (width,height)
-
Atlas:addRect(name, x, y, width, height) adds a new rect to the mesh. Return the index of the rect. width, height are optional
-
Atlas:setRect( index, x, w, width, height) moves an existing rect around
-
Atlas:draw() renders the mesh onto the screen
Does this make sense?
A couple of questions
-
@Simon said there’s a limit on the size of mesh textures. Does this mean that my atlas should have multiple meshes to get around that? If so, then Atlas:draw() will need to draw multiple meshes. And addRect will need to do some house keeping to map from each mesh index to the atlas index.
-
If so, is it worth adding my background image (768x1024) to the atlas? In which case it will take a whole mesh - I might as well just draw the background image outside the atlas no?
-
Edit: the way I’m planning to construct the texture is with setContext. Is that the best way? One problems seems to be that setContext actually limits drawing to the dimensions of the screen (which surprised me). That is I can’t draw onto an image at position say 769x1025 with setContext