StarlingGraphics / Starling-Extension-Graphics

flash.display.Graphics style extension for the Starling Flash GPU rendering framework
https://github.com/StarlingGraphics/Starling-Extension-Graphics/wiki
MIT License
285 stars 88 forks source link

flush Program3D in Program3DCache #99

Closed triki999 closed 10 years ago

triki999 commented 10 years ago

Hi. I don't know what exactly is going on but i have a problem when switching contexts and i lose all graphic data. I found a way to resolve the issue but i don't know if is ok.

starling.display.materials.Program3DCache

public static function releaseProgram3D( program3D:Program3D ):void { if ( !numReferencesByProgramTable[program3D] ) { throw( new Error( "Program3D is not in cache" ) ); return; } numReferencesByProgramTable[program3D]--; flush();

        //var numReferences:int = numReferencesByProgramTable[program3D];
        //numReferences--;
    }
IonSwitz commented 10 years ago

I think this is something for @jonathanrpace , he did a re-write of this some time ago.

I feel very unsure of what to do, so I hope he can shed some light on this :)

jonathanrpace commented 10 years ago

Oh dear - god knows why I'm decrementing that value and not re-assigning it back to the value in the table . . .

Your fix for decrementing the table reference is correct. However you shouldn't need to call 'flush()' afterwards (you can see that flush() is called only when trying to increase the number of program3D's past a certain limit).

If it works without the flush(), and the examples still run ok after a context switch - send us over a merge request.

triki999 commented 10 years ago

Doesn't work without flush() I think that a new Program3D has to be recreated from the current context.

IonSwitz commented 10 years ago

I am closing this, see Issue #100