Texture as Rendertarget

Hi there,

I have a problem. I want to use textures as buffer, but if i use texture.Destroy() they wont be drawn correctly anymore (no matter where i call texture.Destroy, even after renderer.Present()). I dont get the sequence of stuff to do to get this working. If I dont delete the texture it will be drawn fine but then I’ll have a huge memory leak. If graphics are created dynamically, they should be disposed after usage.

Create Texture
Set Texture As Target
Draw Stuff
Set Default Target (Window)
Copy Texture
Delete Texture

Maybe a code example and image will help.
Language: Go


forgive me my english, im german :slight_smile:

I’m not very experienced with Go, but are you creating a texture every frame? If you are, that is very slow, you should create your texture once before the loop and destroy it after the loop for your program anyways.

I know its not good to create the texture every frame. This is just a minimal example for the behaviour and i wont do anything like that in a “real” program, but the problem occured to me and i wanted to write a few lines to demonstrate its core instead of copying a dozen files. How to create -> draw -> present -> delete? a Texture. This is the question.