Closed konsnos closed 10 years ago
Yes - this should be working without you having to do anything (at least it used to). Probably related to https://github.com/StarlingGraphics/Starling-Extension-Graphics/issues/99
You might get some milage with the 'fix' in there, though though the fix will cause a performance problem if you're clearing/drawing every Graphics API object each frame.
Not sure when I'll get round to taking a look.
yes, changing the releaseProgram3D method back to
public static function releaseProgram3D( program3D:Program3D ):void
{
if ( !numReferencesByProgramTable[program3D] )
{
throw( new Error( "Program3D is not in cache" ) );
return;
}
numReferencesByProgramTable[program3D]--;
flush();
}
fixes the issue here.
However, that kills the benefit of the Lazy Cache. I can look into something for this briefly, but I need a second pair of eyes before I dare committing anything.
Well, the simplest solution seems to be to re-write releaseProgram3D like this:
public static function releaseProgram3D( program3D:Program3D, forceFlush:Boolean = false ):void
{
if ( !numReferencesByProgramTable[program3D] )
{
throw( new Error( "Program3D is not in cache" ) );
return;
}
numReferencesByProgramTable[program3D]--;
if ( forceFlush )
flush();
}
and set the forceFlush variable to "true" only in restoreOnLostContext() in StandardMaterial, in the call:
Program3DCache.releaseProgram3D(program, true);
that seems to keep the program from being flushed on dispose() and other similar methods, while still being able to recreate it properly after a lost Context.
Let me know what you think, @jonathanrpace. I can check in the fix if you think it seems reasonable.
Nice - makes sense to me. Check it in!
Ok, I have checked in the fix, it seems to work in the few test cases I have run it through.
Indeed it works. Thank you!
I've created a simple app whith one shape.
Then Ctrl+Alt+Delete, and the shape is gone. I've set Starling.handleLostContext to true before I start Starling. Is there a way for the Shapes to handle this by themselves?