mirror of
https://github.com/Clortox/dashboard.git
synced 2024-12-29 14:38:00 +00:00
Add panel incrmementing
This commit is contained in:
parent
38dfa2a8b6
commit
282edfc7aa
@ -31,6 +31,10 @@ up to you to call this, to give you the option of lazy loading it.
|
||||
because SDL will not be setup when your constructor is called, and therefore
|
||||
will not be able to properly create the texture for the renderer.
|
||||
|
||||
The *_time_on_screen* value is in milliseconds, and will be the amount of time
|
||||
the board will display the panel before transitioning. This value can be
|
||||
modified at runtime if needed (ie displaying a dynamic length video).
|
||||
|
||||
The provided memory api stores textures (SDL_Texture), fonts (TTF_Font), and
|
||||
strings (SDL_Texture). Both static values can be added that will exist for the
|
||||
lifetime of the program, as well as dynamic versions that will be stored in a
|
||||
|
@ -346,13 +346,23 @@ void board::start(){
|
||||
//frame counter
|
||||
static unsigned long long int fcount = 0;
|
||||
|
||||
//time since last panel
|
||||
auto last_panel = start;
|
||||
|
||||
SDL_Log("Starting main loop...\n");
|
||||
for(;;){
|
||||
start = std::chrono::high_resolution_clock::now();
|
||||
fcount++;
|
||||
|
||||
//check if its time to increment the panel
|
||||
if(std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
start - last_panel).count() >= PANELS[i]->_time_on_screen){
|
||||
i++;
|
||||
last_panel = start;
|
||||
}
|
||||
|
||||
//check if we can loop back over
|
||||
if(i > PANELS_LENGTH)
|
||||
if(i >= PANELS_LENGTH)
|
||||
i = 0;
|
||||
|
||||
SDL_RenderClear(_renderer);
|
||||
|
@ -25,6 +25,7 @@ namespace dashboard::panel {
|
||||
|
||||
virtual void draw() = 0;
|
||||
|
||||
//in milliseconds
|
||||
size_t _time_on_screen = 0;
|
||||
|
||||
protected:
|
||||
|
Loading…
Reference in New Issue
Block a user