Control - Run guard

This commit is contained in:
Emmanuel BENOîT 2017-11-14 17:46:45 +01:00
parent d5d463fd2c
commit 8a0afc345f

22
ops.cc
View file

@ -242,6 +242,26 @@ T_OpContext::T_OpContext(
}
}
namespace {
struct T_RunGuard
{
T_OpContext& context;
T_RunGuard( T_OpContext& ctx ) noexcept : context( ctx ) {}
~T_RunGuard( )
{
while ( !context.profiling.empty( ) ) {
Globals::Profiler( ).end( context.profiling.last( ) );
context.profiling.removeLast( );
}
glUseProgram( 0 );
glBindProgramPipeline( 0 );
glBindFramebuffer( GL_FRAMEBUFFER , 0 );
Globals::Textures( ).reset( );
}
};
}
void T_OpContext::run(
const E_RunTarget target ,
const float time ,
@ -249,6 +269,8 @@ void T_OpContext::run(
const float height )
{
assert( !aborted );
T_RunGuard rg( *this );
x87sp = 0;
instrPtr = program.ops.firstOf( target == R_INIT ? program.init : program.frame );
values[ 0 ] = time;