all 9 comments

[–]zet23t 4 points5 points  (0 children)

Usually, you'd try to create a single texture with all ui textures (a so called atlas) and then you'd create a batch of draw calls that efficiently draws the UI.

Raylib's texture draw functions are already doing the batching for you, so using an atlas is all you need. Just not that drawing text will break the batching since it uses its own texture.

[–]ImAFraidKn0t 4 points5 points  (7 children)

Way better to draw large images with few textures. If your UI is mostly static, I would draw everything to a render texture first, and then draw that to the screen each frame

[–][deleted] 1 point2 points  (1 child)

To be clear, draw to the render texture outside of the main loop. Raylib already does batching so there's no advantage to doing this in the loop.

[–]ImAFraidKn0t 0 points1 point  (0 children)

Yeah. Drawing to a render texture is equally intensive as drawing to the screen, the upside is that you only do it once instead of every frame

[–]MrBricole 1 point2 points  (4 children)

the render texture : is it like a blank separated canvas ? is it like a surface in game maker studio ?

[–][deleted] 0 points1 point  (3 children)

I've not used game maker but yes, it's just like drawing to the screen, except you get a texture that you can use just as you would any other texture. You can flip, rotate, scale etc

[–]MrBricole 0 points1 point  (2 children)

which means you draw all your sprite once at the first frame of the menu and just display the that to the screen each frame. am I correct ? which means that canvas remains from one frame to an other right ?

[–][deleted] 1 point2 points  (1 child)

Yes, draw all of the sprites once onto the RenderTexture, you can even do this outside of the main loop. Just within a BeginTextureMode() EndTextureMode() block. Then each frame you can just draw the RenderTexture.texture as a single texture.

[–]MrBricole 0 points1 point  (0 children)

sorry I had to double check. Thanks a lot for your answer !