0
votes

For a small 2D mobile game, I'm planning on make the main character texture be decided by player (combine outfit, color, hair,..). First I though in use multiple textures (each with some outfits, hairs,..), load the required and render the character in multiple passes (e.g. front => back hair, body+cloth, head, hair, hair complements, more hair), but as that calls to many times the texture, I don't like this approach.

Instead, I was thinking on doing something similar, but rendering the full character texture (clothes, poses,..) into a framebuffer and use it as a texture (more work than doing it for only the current pose, but only done one time). What I don't know is what is the lifetime of the content of a framebuffer? Does its content remains until the context is deleted, it's cleared at each draw, ..?

Thanks

1

1 Answers

0
votes

What content does the frame buffer have that can be cleared? It is the render buffer or a texture that have the drawable content and can be cleared. Those two may be attached or detached from the frame buffer which is in this case more like a wrapper of other buffers.

So none, a render buffer nor a texture will clear its content unless so specified. None of them will be deleted unless again so specified. And if the owner context is deleted then all its elements are gone as well.

I do not completely believe your solution is appropriate but if I understand what you are trying to do is create a FBO (frame buffer object) with attached texture. Use the frame buffer to draw to the texture and then preserve the texture. This is all good. You may still delete the FBO after the drawing is done and the texture is usable. You could even reattach it to another FBO later on if you needed to redraw it for instance.

Also "cleared at each draw" seems a bit off. If you mean after each draw call to the fame buffer then definitely not, clearing after every shape is drawn would make it impossible to draw a scene. Or rather if you mean drawing to the screen which is usually called presenting then again no, many application use accumulation such as to draw to canvas with your finger and the buffer must not be cleared. But then again you will not even be presenting the buffer so this event never occurs.