Open SomeGuyWhoLovesCoding opened 8 months ago
As I understand it, all Stage 3D code is required to remain in the main thread (and that is not considered a bug). You can use threads for other things, though.
toTexture method costs almost nothing, for thread-safety you should run this method in the main thread. OpenGL is single thread supported, so you can't make gl calls in another thread.
Describe the bug So, someone helped me with how I would reduce memory usage when loading an image by converting it to a texture, simply with this function:
(All the classes were imported for this btw) And then, when I tried it out while also threading, it silent crashes the game. I was so shocked that it happened. I did make the thread handler function safer by adding a mutex which acquires before the call, and releases the mutex after that.
OpenFL and Lime versions: Latest
To Reproduce Steps to reproduce the behavior:
class Main extends openfl.display.Sprite { public function new():Void { super(); new sys.thread.FixedThreadPool(1).run(function() { var img:Image = toTexture(Image.fromBitmapData(BitmapData.fromFile('image.png'))); }); }
}