Closed benjamin-heasly closed 2 years ago
What did you have in mind for this? I think the functionality of the call is useful and simple - can we just change the back-end of how it is implemented?
I just hit the button too soon, and I'm filling it in now.
I think this is actually resolved with commit 3b377ac26e28b26191f37411d11582afece37a1b.
I just modified mglMetal to process texture create and delete at any time, whether in the drawing tight loop or not.
The new test mglTestTextDraw should show this in action!
In performance-sensitive code, I think we'll still want to create and delete textures outside of the draw loop. We can use mglUpdateTexture to update a texture's buffer contents during the loop. This is demoed in mglTestUpdateTexture.
In MGL v2, mglTextDraw would create a new image array, create a new OpenGL texture with this image, blt this texture, then delete this texture.
I'm not sure if this will be a good fit for v3 with Metal. Since we're sending texture data over the socket, we might want to be more strict about creating and managing texture resources before drawing, and then just blt-ing textures while drawing each frame.
A possible alternative would be to create a texture ahead of time, to hold the text. Then on each frame that we want to update the texture, use mglUpdateTexture to send over new image contents, and then blt the texture. We'd still be sending lots of image data per frame, but we could have the Metal texture to hold the data allocated ahead of time.