2017-10-02 13:51:08 +02:00
|
|
|
#include "externals.hh"
|
|
|
|
#include "demo.hh"
|
2017-10-30 18:29:52 +01:00
|
|
|
#include "sync.hh"
|
2017-11-14 22:04:00 +01:00
|
|
|
#include "rendertarget.hh"
|
2017-10-30 18:29:52 +01:00
|
|
|
#include "globals.hh"
|
2017-11-15 23:09:52 +01:00
|
|
|
#include "ops.hh"
|
2017-11-15 18:58:37 +01:00
|
|
|
#include "opcomp.hh"
|
2017-11-14 22:04:00 +01:00
|
|
|
#include <ebcl/Files.hh>
|
|
|
|
#include <ebcl/SRDText.hh>
|
2017-10-02 13:51:08 +02:00
|
|
|
|
2017-11-16 12:20:21 +01:00
|
|
|
#warning remove this later
|
|
|
|
#include "syncoverrides.hh"
|
|
|
|
|
2017-10-02 13:51:08 +02:00
|
|
|
|
2017-11-15 23:09:52 +01:00
|
|
|
bool T_Demo::initialise(
|
|
|
|
const uint32_t w ,
|
|
|
|
const uint32_t h )
|
2017-10-02 13:51:08 +02:00
|
|
|
{
|
2017-11-15 23:09:52 +01:00
|
|
|
width = w;
|
|
|
|
height = h;
|
|
|
|
return program && runInit( *program );
|
2017-10-02 13:51:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void T_Demo::render( )
|
|
|
|
{
|
2017-11-15 23:09:52 +01:00
|
|
|
if ( Globals::Ops( ).hasNewProgram( ) ) {
|
|
|
|
auto nProgram{ Globals::Ops( ).program( ) };
|
|
|
|
if ( runInit( *nProgram ) ) {
|
|
|
|
program = std::move( nProgram );
|
|
|
|
}
|
2017-11-14 22:04:00 +01:00
|
|
|
}
|
|
|
|
|
2017-10-30 18:29:52 +01:00
|
|
|
auto& sync( Globals::Sync( ) );
|
2017-10-07 17:39:38 +02:00
|
|
|
if ( playing ) {
|
|
|
|
const float time = SDL_GetTicks( ) * 1e-3;
|
|
|
|
if ( playingPrevious ) {
|
2017-10-30 18:29:52 +01:00
|
|
|
sync.timeDelta( time - lastFrame );
|
|
|
|
playing = !sync.finished( );
|
2017-10-07 17:39:38 +02:00
|
|
|
}
|
|
|
|
lastFrame = time;
|
|
|
|
}
|
|
|
|
playingPrevious = playing;
|
|
|
|
|
2017-11-14 23:44:13 +01:00
|
|
|
if ( context && !context->aborted ) {
|
|
|
|
try {
|
|
|
|
context->run( ops::T_OpContext::R_RENDER , sync.time( ) , width , height );
|
|
|
|
} catch ( ops::X_OpFailure const& fail ) {
|
|
|
|
printf( "FAILED TO RUN FRAME!\n\t%s\n" , fail.what( ) );
|
|
|
|
context->aborted = true;
|
|
|
|
}
|
|
|
|
}
|
2017-10-02 13:51:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void T_Demo::handleDND(
|
2017-11-14 22:04:00 +01:00
|
|
|
ImVec2 const& move ,
|
|
|
|
const bool hasCtrl ,
|
|
|
|
const bool hasShift ,
|
|
|
|
const bool lmb // Left mouse button
|
2017-10-02 13:51:08 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void T_Demo::handleWheel(
|
2017-11-14 22:04:00 +01:00
|
|
|
const float wheel ,
|
|
|
|
const bool hasCtrl ,
|
|
|
|
const bool hasShift
|
2017-10-02 13:51:08 +02:00
|
|
|
)
|
|
|
|
{
|
2017-11-14 22:04:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-15 23:09:52 +01:00
|
|
|
bool T_Demo::runInit(
|
|
|
|
ops::T_OpProgram& p )
|
2017-11-14 22:04:00 +01:00
|
|
|
{
|
2017-11-15 23:09:52 +01:00
|
|
|
auto nContext{ NewOwned< ops::T_OpContext >( p ) };
|
2017-11-14 22:04:00 +01:00
|
|
|
try {
|
2017-11-15 23:09:52 +01:00
|
|
|
nContext->run( ops::T_OpContext::R_INIT , 0 , width , height );
|
2017-11-14 22:04:00 +01:00
|
|
|
} catch ( ops::X_OpFailure const& fail ) {
|
|
|
|
printf( "FAILED TO RUN INIT!\n\t%s\n" , fail.what( ) );
|
2017-11-15 23:09:52 +01:00
|
|
|
nContext.clear( );
|
2017-11-14 22:04:00 +01:00
|
|
|
}
|
2017-11-15 23:09:52 +01:00
|
|
|
if ( !nContext ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
context = std::move( nContext );
|
2017-11-14 23:44:13 +01:00
|
|
|
|
|
|
|
Globals::Sync( ).clearInputs( );
|
|
|
|
const auto n( context->initialInputs.size( ) );
|
2017-11-15 23:09:52 +01:00
|
|
|
assert( n == p.inputs.size( ) );
|
2017-11-14 23:44:13 +01:00
|
|
|
for ( auto i = 0u ; i < n ; i ++ ) {
|
2017-11-15 23:09:52 +01:00
|
|
|
Globals::Sync( ).addInput( p.inputs[ i ] ,
|
2017-11-14 23:44:13 +01:00
|
|
|
context->initialInputs[ i ] );
|
2017-11-15 09:46:07 +01:00
|
|
|
#ifdef INVASIVE_TRACES
|
2017-11-15 23:09:52 +01:00
|
|
|
printf( "#%d %s pos %d\n" , i , p.inputs[ i ].toOSString( ).data( ) ,
|
|
|
|
Globals::Sync( ).inputPos( p.inputs[ i ] ) );
|
2017-11-15 09:46:07 +01:00
|
|
|
#endif //INVASIVE_TRACES
|
2017-11-14 23:44:13 +01:00
|
|
|
}
|
|
|
|
Globals::Sync( ).updateCurveCaches( );
|
2017-11-15 23:09:52 +01:00
|
|
|
|
2017-11-16 12:20:21 +01:00
|
|
|
#warning silly test here
|
|
|
|
T_OwnPtr< sov::T_Float > ov{ NewOwned< sov::T_Float >(
|
|
|
|
"dof-sharp-distance" , "Sharp distance" ) };
|
|
|
|
ov->setMin( 0 );
|
|
|
|
ov->setMax( 1000 );
|
|
|
|
ov->setStep( .1 );
|
2017-11-16 23:15:44 +01:00
|
|
|
// ov->setSlider( true );
|
2017-11-16 12:20:21 +01:00
|
|
|
ov->setup( );
|
|
|
|
|
|
|
|
T_SyncOverrideSection sos( "" );
|
|
|
|
sos.subsections.add( NewOwned< T_SyncOverrideSection >( "Testing" ) );
|
|
|
|
sos.subsections[ 0 ]->subsections.add( NewOwned< T_SyncOverrideSection >( "Yeah really" ) );
|
|
|
|
sos.subsections[ 0 ]->subsections[ 0 ]->overrides.add( std::move( ov ) );
|
2017-11-16 23:15:44 +01:00
|
|
|
|
|
|
|
auto ov2{ NewOwned< sov::T_Float4 >(
|
|
|
|
"bloom-bw0" , "bloom-bw1" , "bloom-bw2" , "bloom-bw3" ,
|
|
|
|
"Blur weights" ) };
|
|
|
|
ov2->setMax( 1 );
|
|
|
|
ov2->setSlider( );
|
|
|
|
ov2->setup( );
|
|
|
|
sos.subsections[ 0 ]->overrides.add( std::move( ov2 ) );
|
|
|
|
|
2017-11-16 12:20:21 +01:00
|
|
|
Globals::Sync( ).mergeOverrides( sos );
|
|
|
|
|
2017-11-15 23:09:52 +01:00
|
|
|
return true;
|
2017-10-02 13:51:08 +02:00
|
|
|
}
|