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);
|
|||
|
}
|