83 lines
1.8 KiB
C++
83 lines
1.8 KiB
C++
#include "externals.hh"
|
|
#include "demo.hh"
|
|
|
|
|
|
T_Demo::T_Demo( __rd__ const uint32_t width ,
|
|
__rd__ const uint32_t height )
|
|
: width( width ) , height( height )
|
|
{ }
|
|
|
|
|
|
bool T_Demo::initialise( )
|
|
{
|
|
raymarcher = std::make_unique< T_Raymarcher >(
|
|
width , height );
|
|
dof = std::make_unique< T_DoFPass >(
|
|
raymarcher->output( ) , raymarcher->depth( ) );
|
|
bloom = std::make_unique< T_BloomPass >(
|
|
raymarcher->output( ) );
|
|
combine = std::make_unique< T_CombinePass >(
|
|
dof->output( ) , bloom->output( ) );
|
|
fxaa = std::make_unique< T_FXAAPass >(
|
|
combine->output( ) );
|
|
return true;
|
|
}
|
|
|
|
void T_Demo::makeUI( )
|
|
{
|
|
auto const& dspSize( ImGui::GetIO( ).DisplaySize );
|
|
ImGui::SetNextWindowSize( ImVec2( 300 , dspSize.y - 300 ) ,
|
|
ImGuiSetCond_Once );
|
|
ImGui::SetNextWindowPos( ImVec2( 0 , 150 ) ,
|
|
ImGuiSetCond_Once );
|
|
ImGui::Begin( "Demo controls" );
|
|
|
|
raymarcher->makeUI( );
|
|
dof->makeUI( );
|
|
bloom->makeUI( );
|
|
combine->makeUI( );
|
|
fxaa->makeUI( );
|
|
|
|
ImGui::End( );
|
|
}
|
|
|
|
void T_Demo::render( )
|
|
{
|
|
if ( playing ) {
|
|
const float time = SDL_GetTicks( ) * 1e-3;
|
|
if ( playingPrevious ) {
|
|
const float adv = time - lastFrame;
|
|
position = std::min( adv + position , sync.duration( ) );
|
|
if ( position >= sync.duration( ) ) {
|
|
playing = false;
|
|
}
|
|
}
|
|
lastFrame = time;
|
|
}
|
|
playingPrevious = playing;
|
|
|
|
raymarcher->render( );
|
|
dof->render( position , sync );
|
|
bloom->render( );
|
|
combine->render( );
|
|
fxaa->render( );
|
|
}
|
|
|
|
void T_Demo::handleDND(
|
|
__rd__ ImVec2 const& move ,
|
|
__rd__ const bool hasCtrl ,
|
|
__rd__ const bool hasShift ,
|
|
__rd__ const bool lmb // Left mouse button
|
|
)
|
|
{
|
|
raymarcher->camera( ).handleDND( move , hasCtrl , hasShift , lmb );
|
|
}
|
|
|
|
void T_Demo::handleWheel(
|
|
__rd__ const float wheel ,
|
|
__rd__ const bool hasCtrl ,
|
|
__rd__ const bool hasShift
|
|
)
|
|
{
|
|
raymarcher->camera( ).handleWheel( wheel , hasCtrl , hasShift );
|
|
}
|