66 lines
2.1 KiB
C
66 lines
2.1 KiB
C
/*
|
|
Copyright (c) 2021-2022 jdeokkim
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
in the Software without restriction, including without limitation the rights
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
copies or substantial portions of the Software.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
SOFTWARE.
|
|
*/
|
|
|
|
#include "ferox.h"
|
|
|
|
/* | `timer` λͺ¨λ 맀ν¬λ‘ μ μ... | */
|
|
|
|
#if defined(_WIN32)
|
|
#define NOGDI
|
|
#define NOUSER
|
|
#endif
|
|
|
|
#define SOKOL_TIME_IMPL
|
|
#include "sokol_time.h"
|
|
|
|
/* | `timer` λͺ¨λ λ³μ... | */
|
|
|
|
/* λ¨μ‘° μκ³μ μ΄κΈ°ν μ¬λΆλ₯Ό λνλ΄λ λ³μ. */
|
|
static bool initialized = false;
|
|
|
|
/* | `timer` λͺ¨λ ν¨μ... | */
|
|
|
|
/* λ¨μ‘° μκ³λ₯Ό μ΄κΈ°ννλ€. */
|
|
void frInitClock(void) {
|
|
if (!initialized) {
|
|
initialized = true;
|
|
stm_setup();
|
|
}
|
|
}
|
|
|
|
/* λ¨μ‘° μκ³μ νμ¬ μκ° (λ¨μ: ms)μ λ°ννλ€. */
|
|
double frGetCurrentTime(void) {
|
|
if (!initialized) frInitClock();
|
|
|
|
return stm_ms(stm_now());
|
|
}
|
|
|
|
/* λ¨μ‘° μκ³μ μκ° `newTime`κ³Ό `oldTime`μ μ°¨μ΄λ₯Ό λ°ννλ€. */
|
|
double frGetTimeDifference(double newTime, double oldTime) {
|
|
return newTime - oldTime;
|
|
}
|
|
|
|
/* λ¨μ‘° μκ³μ νμ¬ μκ°κ³Ό `old_time`κ³Όμ μ°¨μ΄λ₯Ό λ°ννλ€. */
|
|
double frGetTimeSince(double oldTime) {
|
|
return frGetTimeDifference(frGetCurrentTime(), oldTime);
|
|
}
|