Refactoring structs Part 1
This commit is contained in:
26
src/epoch/epoch.c
Normal file
26
src/epoch/epoch.c
Normal file
@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "epoch.h"
|
||||
|
||||
void epochInit(epoch_t *epoch) {
|
||||
epoch->delta = EPOCH_FIXED_STEP;
|
||||
epoch->last = EPOCH_FIXED_STEP;
|
||||
epoch->current = EPOCH_FIXED_STEP + EPOCH_FIXED_STEP;
|
||||
}
|
||||
|
||||
void epochUpdate(epoch_t *epoch, float platformDelta) {
|
||||
platformDelta = mathMax(
|
||||
mathMin(platformDelta, EPOCH_FIXED_STEP),
|
||||
0
|
||||
);
|
||||
|
||||
epoch->last = epoch->current;
|
||||
epoch->current = epoch->current + platformDelta;
|
||||
epoch->delta = epoch->current - epoch->last;
|
||||
epoch->fixedDelta = EPOCH_FIXED_STEP;
|
||||
}
|
24
src/epoch/epoch.h
Normal file
24
src/epoch/epoch.h
Normal file
@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <dawn/dawn.h>
|
||||
|
||||
/**
|
||||
* Initializes the epoch time tracking.
|
||||
*
|
||||
* @param epoch Epoch to initialize.
|
||||
*/
|
||||
void epochInit(epoch_t *epoch);
|
||||
|
||||
/**
|
||||
* Ticks the current epoch time.
|
||||
*
|
||||
* @param epoch Epoch to update.
|
||||
* @param platformDelta The delta step between frames from the platform engine.
|
||||
*/
|
||||
void epochUpdate(epoch_t *epoch, float platformDelta);
|
Reference in New Issue
Block a user