davecamp / Render2Texture

A render to texture solution for the BlitzMax language
2 stars 2 forks source link

Error when creating more than one render target #4

Closed davecamp closed 7 years ago

davecamp commented 7 years ago

There's an error when creating more than 1 render target image. This is due to a global variable. When creating a render target the global variable is set to a context value. Any time a render target is created it checks the global and destroys the previous one if there is one. I'm not sure why I have that code in there, but it will be fixed.

GWRon commented 7 years ago

Also make sure it works in threaded builds... Even if brl modules as "pngloader" are not threadsafe too.

Am 19. Oktober 2017 01:05:36 MESZ, schrieb davecamp notifications@github.com:

There's an error when creating more than 1 render target image. This is due to a global variable. When creating a render target the global variable is set to a context value. Any time a render target is created it checks the global and destroys the previous one if there is one. I'm not sure why I have that code in there, but it will be fixed.

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/davecamp/Render2Texture/issues/4

davecamp commented 7 years ago

I've not checked threaded builds just yet. Have you experienced any issues with threaded builds?

davecamp commented 7 years ago

The global that I was referring to in post 1 is the max2d graphics context. I was comparing 2 different variable types which was the cause of the bug.

You've highlighted a possible issue with threading however, thanks! RenderImages should only be called from the render thread. The render thread when using render images for d3d9 needs to be the same thread as the gui thread, in BlitzMax that would be the main thread. I'll make a note of this in the readme file.

GWRon commented 7 years ago

Nope I did not experience trouble yet - as I do not use the r2t feature in my "main project" yet (as I try to be NG compatible, but the SDL, used there, and your r2t are not friends yet).

For me it was obvious to use it in the main thread (opposed to my software render functions ;-)). After having found out that "pngloader" is not threadsafe I wonder what modules else are not threadsafe. And to save you headaches I just did a soft reminder to make you aware of potential problems.

Also check things in "debug builds" as the GC seems to be different in that mode - and so bugs might have other effects there (eg. they show up there :-)).

davecamp commented 7 years ago

Cool :-) Thanks for the heads up !