9031
Graphics / Re: RenderTextures and dynamic memory
« on: January 13, 2013, 01:21:40 am »
Could you please provide complete and minimal example?
Because from the text and the posted source it's not clear when the RenderTexture gets deleted.
Also could you specify what you mean by "the screen is never cleared, and nothing ever renders"?
Why do you have to allocate the render texture dynamically?
Have you ever considered using a smart pointer/RAII over manual calling delete? For instance if the posted code failt to create the texture, but the render texture got created, the the render texture will never get deleted, since you directly return with -1 and thus you create a memory leak. Maybe you could talk a look at this discussion.
(Disclaimer: It doesn't mean it would fix the problem, but it would just make your code safer.)
Because from the text and the posted source it's not clear when the RenderTexture gets deleted.
Also could you specify what you mean by "the screen is never cleared, and nothing ever renders"?
Why do you have to allocate the render texture dynamically?
Have you ever considered using a smart pointer/RAII over manual calling delete? For instance if the posted code failt to create the texture, but the render texture got created, the the render texture will never get deleted, since you directly return with -1 and thus you create a memory leak. Maybe you could talk a look at this discussion.
(Disclaimer: It doesn't mean it would fix the problem, but it would just make your code safer.)