Time value, play button, playing
This commit is contained in:
parent
d61158fa9e
commit
58e3c35ea4
5 changed files with 45 additions and 3 deletions
13
demo.cc
13
demo.cc
|
@ -43,6 +43,19 @@ void T_Demo::makeUI( )
|
||||||
|
|
||||||
void T_Demo::render( )
|
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( );
|
raymarcher->render( );
|
||||||
dof->render( );
|
dof->render( );
|
||||||
bloom->render( );
|
bloom->render( );
|
||||||
|
|
9
demo.hh
9
demo.hh
|
@ -6,6 +6,7 @@
|
||||||
#include "combine.hh"
|
#include "combine.hh"
|
||||||
#include "fxaa.hh"
|
#include "fxaa.hh"
|
||||||
#include "profiling.hh"
|
#include "profiling.hh"
|
||||||
|
#include "sync.hh"
|
||||||
|
|
||||||
|
|
||||||
struct T_Demo
|
struct T_Demo
|
||||||
|
@ -40,9 +41,17 @@ struct T_Demo
|
||||||
const uint32_t width;
|
const uint32_t width;
|
||||||
const uint32_t height;
|
const uint32_t height;
|
||||||
|
|
||||||
|
T_SyncData sync;
|
||||||
|
float position = 0;
|
||||||
|
bool playing = false;
|
||||||
|
|
||||||
std::unique_ptr< T_Raymarcher > raymarcher;
|
std::unique_ptr< T_Raymarcher > raymarcher;
|
||||||
std::unique_ptr< T_DoFPass > dof;
|
std::unique_ptr< T_DoFPass > dof;
|
||||||
std::unique_ptr< T_BloomPass > bloom;
|
std::unique_ptr< T_BloomPass > bloom;
|
||||||
std::unique_ptr< T_CombinePass > combine;
|
std::unique_ptr< T_CombinePass > combine;
|
||||||
std::unique_ptr< T_FXAAPass > fxaa;
|
std::unique_ptr< T_FXAAPass > fxaa;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool playingPrevious = false;
|
||||||
|
float lastFrame;
|
||||||
};
|
};
|
||||||
|
|
18
main.cc
18
main.cc
|
@ -29,7 +29,7 @@ struct T_Main
|
||||||
uint32_t stopResize = 0;
|
uint32_t stopResize = 0;
|
||||||
ImVec2 prevSize;
|
ImVec2 prevSize;
|
||||||
|
|
||||||
bool demoCtrl_ = true;
|
bool demoCtrl_ = false;
|
||||||
std::unique_ptr< T_Demo > demo;
|
std::unique_ptr< T_Demo > demo;
|
||||||
|
|
||||||
void initDemo( );
|
void initDemo( );
|
||||||
|
@ -176,10 +176,24 @@ void T_Main::makeUI( )
|
||||||
ImGui::Begin( "Tools" );
|
ImGui::Begin( "Tools" );
|
||||||
|
|
||||||
ImGui::Checkbox( "Demo controls" , &demoCtrl_ );
|
ImGui::Checkbox( "Demo controls" , &demoCtrl_ );
|
||||||
ImGui::Checkbox( "Profiler" , &Globals::Profiler( ).uiEnabled( ) );
|
|
||||||
ImGui::Checkbox( "Output debugger" , &Globals::ODbg( ).uiEnabled( ) );
|
ImGui::Checkbox( "Output debugger" , &Globals::ODbg( ).uiEnabled( ) );
|
||||||
|
ImGui::Checkbox( "Profiler" , &Globals::Profiler( ).uiEnabled( ) );
|
||||||
ImGui::Checkbox( "Shaders" , &Globals::Shaders( ).uiEnabled( ) );
|
ImGui::Checkbox( "Shaders" , &Globals::Shaders( ).uiEnabled( ) );
|
||||||
|
|
||||||
|
if ( demo ) {
|
||||||
|
ImGui::Separator( );
|
||||||
|
const float duration( demo->sync.duration( ) );
|
||||||
|
if ( ImGui::SliderFloat( "" , &demo->position , 0 , duration , "%.1fs" )
|
||||||
|
&& demo->position > duration ) {
|
||||||
|
demo->position = duration;
|
||||||
|
demo->playing = false;
|
||||||
|
}
|
||||||
|
ImGui::SameLine( );
|
||||||
|
if ( ImGui::Button( demo->playing ? "Stop" : "Play" ) ) {
|
||||||
|
demo->playing = !demo->playing;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::End( );
|
ImGui::End( );
|
||||||
|
|
||||||
if ( demo && demoCtrl_ ) {
|
if ( demo && demoCtrl_ ) {
|
||||||
|
|
3
sync.cc
3
sync.cc
|
@ -4,6 +4,9 @@
|
||||||
|
|
||||||
const T_SyncVariable T_SyncData::MissingVariable_{ };
|
const T_SyncVariable T_SyncData::MissingVariable_{ };
|
||||||
|
|
||||||
|
T_SyncData::T_SyncData( )
|
||||||
|
: T_SyncData( 60 * 60 , 1. / 60 )
|
||||||
|
{ }
|
||||||
|
|
||||||
T_SyncData::T_SyncData(
|
T_SyncData::T_SyncData(
|
||||||
__rd__ const uint32_t duration ,
|
__rd__ const uint32_t duration ,
|
||||||
|
|
5
sync.hh
5
sync.hh
|
@ -25,11 +25,14 @@ using T_SyncVariable = std::vector< T_SyncSegment >;
|
||||||
|
|
||||||
struct T_SyncData
|
struct T_SyncData
|
||||||
{
|
{
|
||||||
T_SyncData( ) = delete;
|
T_SyncData( );
|
||||||
T_SyncData(
|
T_SyncData(
|
||||||
__rd__ const uint32_t duration ,
|
__rd__ const uint32_t duration ,
|
||||||
__rd__ const float units ) noexcept;
|
__rd__ const float units ) noexcept;
|
||||||
|
|
||||||
|
float duration( ) const noexcept
|
||||||
|
{ return duration_ * units_; }
|
||||||
|
|
||||||
void setSyncVariable(
|
void setSyncVariable(
|
||||||
__rd__ std::string const& name ,
|
__rd__ std::string const& name ,
|
||||||
__rw__ T_SyncVariable&& variable ) noexcept;
|
__rw__ T_SyncVariable&& variable ) noexcept;
|
||||||
|
|
Loading…
Reference in a new issue