mirror of
https://github.com/Relintai/sfw.git
synced 2024-11-08 07:52:09 +01:00
Renamed STime to SFWTime.
This commit is contained in:
parent
7df1e7a0f3
commit
71192064e6
@ -41,7 +41,7 @@ ccache g++ -Wall -D_REENTRANT -g -Isfw -c sfw/core/dir_access.cpp -o sfw/core/di
|
||||
ccache g++ -Wall -D_REENTRANT -g -Isfw -c sfw/core/pool_vector.cpp -o sfw/core/pool_vector.o
|
||||
ccache g++ -Wall -D_REENTRANT -g -Isfw -c sfw/core/pool_allocator.cpp -o sfw/core/pool_allocator.o
|
||||
ccache g++ -Wall -D_REENTRANT -g -Isfw -c sfw/core/mutex.cpp -o sfw/core/mutex.o
|
||||
ccache g++ -Wall -D_REENTRANT -g -Isfw -c sfw/core/stime.cpp -o sfw/core/stime.o
|
||||
ccache g++ -Wall -D_REENTRANT -g -Isfw -c sfw/core/sfw_time.cpp -o sfw/core/SFWTime.o
|
||||
|
||||
ccache g++ -Wall -D_REENTRANT -g -Isfw -c sfw/core/sfw_core.cpp -o sfw/core/sfw_core.o
|
||||
|
||||
@ -106,7 +106,7 @@ ccache g++ -Wall -lm -ldl -lpthread -lX11 -D_REENTRANT -g sfw/core/aabb.o sfw/c
|
||||
sfw/core/ustring.o sfw/core/string_name.o \
|
||||
sfw/core/vector2.o sfw/core/vector2i.o sfw/core/vector3.o \
|
||||
sfw/core/vector3i.o sfw/core/vector4.o sfw/core/vector4i.o \
|
||||
sfw/core/pool_vector.o sfw/core/pool_allocator.o sfw/core/mutex.o sfw/core/stime.o \
|
||||
sfw/core/pool_vector.o sfw/core/pool_allocator.o sfw/core/mutex.o sfw/core/SFWTime.o \
|
||||
sfw/core/dir_access.o sfw/core/file_access.o \
|
||||
sfw/core/sfw_core.o \
|
||||
sfw/object/object.o sfw/object/reference.o sfw/object/core_string_names.o \
|
||||
|
@ -41,7 +41,7 @@ ccache g++ -Wall -D_REENTRANT -g -Isfw -c sfw/core/dir_access.cpp -o sfw/core/di
|
||||
ccache g++ -Wall -D_REENTRANT -g -Isfw -c sfw/core/pool_vector.cpp -o sfw/core/pool_vector.o
|
||||
ccache g++ -Wall -D_REENTRANT -g -Isfw -c sfw/core/pool_allocator.cpp -o sfw/core/pool_allocator.o
|
||||
ccache g++ -Wall -D_REENTRANT -g -Isfw -c sfw/core/mutex.cpp -o sfw/core/mutex.o
|
||||
ccache g++ -Wall -D_REENTRANT -g -Isfw -c sfw/core/stime.cpp -o sfw/core/stime.o
|
||||
ccache g++ -Wall -D_REENTRANT -g -Isfw -c sfw/core/sfw_time.cpp -o sfw/core/SFWTime.o
|
||||
|
||||
ccache g++ -Wall -D_REENTRANT -g -Isfw -c sfw/core/sfw_core.cpp -o sfw/core/sfw_core.o
|
||||
|
||||
@ -106,7 +106,7 @@ ccache g++ -Wall -lm -ldl -lpthread -lX11 -D_REENTRANT -g sfw/core/aabb.o sfw/c
|
||||
sfw/core/ustring.o sfw/core/string_name.o \
|
||||
sfw/core/vector2.o sfw/core/vector2i.o sfw/core/vector3.o \
|
||||
sfw/core/vector3i.o sfw/core/vector4.o sfw/core/vector4i.o \
|
||||
sfw/core/pool_vector.o sfw/core/pool_allocator.o sfw/core/mutex.o sfw/core/stime.o \
|
||||
sfw/core/pool_vector.o sfw/core/pool_allocator.o sfw/core/mutex.o sfw/core/SFWTime.o \
|
||||
sfw/core/dir_access.o sfw/core/file_access.o \
|
||||
sfw/core/sfw_core.o \
|
||||
sfw/object/object.o sfw/object/reference.o sfw/object/core_string_names.o \
|
||||
|
@ -6,7 +6,7 @@
|
||||
//--STRIP
|
||||
#include "core/random_pcg.h"
|
||||
|
||||
#include "core/stime.h"
|
||||
#include "core/sfw_time.h"
|
||||
#include "core/error_macros.h"
|
||||
//--STRIP
|
||||
|
||||
@ -17,7 +17,7 @@ RandomPCG::RandomPCG(uint64_t p_seed, uint64_t p_inc) :
|
||||
}
|
||||
|
||||
void RandomPCG::randomize() {
|
||||
seed((STime::date() + STime::time_us()) * pcg.state + PCG_DEFAULT_INC_64);
|
||||
seed((SFWTime::date() + SFWTime::time_us()) * pcg.state + PCG_DEFAULT_INC_64);
|
||||
}
|
||||
|
||||
double RandomPCG::random(double p_from, double p_to) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
// time
|
||||
|
||||
//--STRIP
|
||||
#include "core/stime.h"
|
||||
#include "core/sfw_time.h"
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
@ -11,42 +11,42 @@
|
||||
//--STRIP
|
||||
|
||||
#if 0
|
||||
uint64_t STime::time_gpu() {
|
||||
uint64_t SFWTime::time_gpu() {
|
||||
GLint64 t = 123456789;
|
||||
glGetInteger64v(GL_TIMESTAMP, &t);
|
||||
return (uint64_t)t;
|
||||
}
|
||||
#endif
|
||||
uint64_t STime::date() {
|
||||
uint64_t SFWTime::date() {
|
||||
//time_t epoch = time(0);
|
||||
//struct tm *ti = localtime(&epoch);
|
||||
//return atoi64(va("%04d%02d%02d%02d%02d%02d", ti->tm_year + 1900, ti->tm_mon + 1, ti->tm_mday, ti->tm_hour, ti->tm_min, ti->tm_sec));
|
||||
return 0;
|
||||
}
|
||||
char *STime::date_string() {
|
||||
char *SFWTime::date_string() {
|
||||
//time_t epoch = time(0);
|
||||
//struct tm *ti = localtime(&epoch);
|
||||
//return va("%04d-%02d-%02d %02d:%02d:%02d", ti->tm_year + 1900, ti->tm_mon + 1, ti->tm_mday, ti->tm_hour, ti->tm_min, ti->tm_sec);
|
||||
return 0;
|
||||
}
|
||||
uint64_t STime::date_epoch() {
|
||||
uint64_t SFWTime::date_epoch() {
|
||||
time_t epoch = time(0);
|
||||
return epoch;
|
||||
}
|
||||
#if 0
|
||||
double STime::time_ss() {
|
||||
double SFWTime::time_ss() {
|
||||
return glfwGetTime();
|
||||
}
|
||||
double STime::time_ms() {
|
||||
double SFWTime::time_ms() {
|
||||
return glfwGetTime() * 1000.0;
|
||||
}
|
||||
uint64_t STime::time_us() {
|
||||
uint64_t SFWTime::time_us() {
|
||||
return (uint64_t)(glfwGetTime() * 1000000.0); // @fixme: use a high resolution timer instead, or time_gpu below
|
||||
}
|
||||
uint64_t STime::sleep_us(uint64_t us) { // @fixme: use a high resolution sleeper instead
|
||||
uint64_t SFWTime::sleep_us(uint64_t us) { // @fixme: use a high resolution sleeper instead
|
||||
return sleep_ms( us / 1000.0 );
|
||||
}
|
||||
double STime::sleep_ms(double ms) {
|
||||
double SFWTime::sleep_ms(double ms) {
|
||||
double now = time_ms();
|
||||
if( ms <= 0 ) {
|
||||
#if defined(_WIN64) || defined(_WIN32)
|
||||
@ -113,7 +113,7 @@ static uint64_t nanotimer(uint64_t *out_freq) {
|
||||
#endif
|
||||
}
|
||||
|
||||
uint64_t STime::time_ns() {
|
||||
uint64_t SFWTime::time_ns() {
|
||||
static __thread uint64_t epoch = 0;
|
||||
static __thread uint64_t freq = 0;
|
||||
if (!freq) {
|
||||
@ -130,23 +130,23 @@ uint64_t STime::time_ns() {
|
||||
uint64_t r = a % c;
|
||||
return q * b + r * b / c;
|
||||
}
|
||||
uint64_t STime::time_us() {
|
||||
uint64_t SFWTime::time_us() {
|
||||
return time_ns() / TIMER_E3;
|
||||
}
|
||||
uint64_t STime::time_ms() {
|
||||
uint64_t SFWTime::time_ms() {
|
||||
return time_ns() / TIMER_E6;
|
||||
}
|
||||
double STime::time_ss() {
|
||||
double SFWTime::time_ss() {
|
||||
return time_ns() / 1e9; // TIMER_E9;
|
||||
}
|
||||
double STime::time_mm() {
|
||||
double SFWTime::time_mm() {
|
||||
return time_ss() / 60;
|
||||
}
|
||||
double STime::time_hh() {
|
||||
double SFWTime::time_hh() {
|
||||
return time_mm() / 60;
|
||||
}
|
||||
|
||||
void STime::sleep_ns(double ns) {
|
||||
void SFWTime::sleep_ns(double ns) {
|
||||
#if defined(_WIN64) || defined(_WIN32)
|
||||
if (ns >= 100) {
|
||||
LARGE_INTEGER li; // Windows sleep in 100ns units
|
||||
@ -170,12 +170,12 @@ void STime::sleep_ns(double ns) {
|
||||
#endif
|
||||
}
|
||||
}
|
||||
void STime::sleep_us(double us) {
|
||||
void SFWTime::sleep_us(double us) {
|
||||
sleep_ns(us * 1e3);
|
||||
}
|
||||
void STime::sleep_ms(double ms) {
|
||||
void SFWTime::sleep_ms(double ms) {
|
||||
sleep_ns(ms * 1e6);
|
||||
}
|
||||
void STime::sleep_ss(double ss) {
|
||||
void SFWTime::sleep_ss(double ss) {
|
||||
sleep_ns(ss * 1e9);
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
//--STRIP
|
||||
#ifndef STIME_H
|
||||
#define STIME_H
|
||||
#ifndef SFW_TIME_H
|
||||
#define SFW_TIME_H
|
||||
//--STRIP
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -11,7 +11,7 @@
|
||||
#include "core/int_types.h"
|
||||
//--STRIP
|
||||
|
||||
class STime {
|
||||
class SFWTime {
|
||||
public:
|
||||
static uint64_t date(); // YYYYMMDDhhmmss
|
||||
static uint64_t date_epoch(); // linux epoch
|
@ -2673,7 +2673,7 @@ typedef void (*GLADpostcallback)(void *ret, const char *name, GLADapiproc apipro
|
||||
* khronos_time_ns_t unsigned 64 bit time in nanoseconds
|
||||
* khronos_utime_nanoseconds_t unsigned time interval or absolute time in
|
||||
* nanoseconds
|
||||
* khronos_stime_nanoseconds_t signed time interval in nanoseconds
|
||||
* khronos_SFWTime_nanoseconds_t signed time interval in nanoseconds
|
||||
* khronos_boolean_enum_t enumerated boolean type. This should
|
||||
* only be used as a base type when a client API's boolean type is
|
||||
* an enum. Client APIs which use an integer or other type for
|
||||
@ -2873,7 +2873,7 @@ typedef float khronos_float_t;
|
||||
* may be either signed or unsigned.
|
||||
*/
|
||||
typedef khronos_uint64_t khronos_utime_nanoseconds_t;
|
||||
typedef khronos_int64_t khronos_stime_nanoseconds_t;
|
||||
typedef khronos_int64_t khronos_SFWTime_nanoseconds_t;
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -3961,7 +3961,7 @@ GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow*
|
||||
*
|
||||
* @sa @ref events
|
||||
* @sa @ref glfwWaitEvents
|
||||
* @sa @ref glfwWaitEventsTimeout
|
||||
* @sa @ref glfwWaitEventSFWTimeout
|
||||
*
|
||||
* @since Added in version 1.0.
|
||||
*
|
||||
@ -4006,7 +4006,7 @@ GLFWAPI void glfwPollEvents(void);
|
||||
*
|
||||
* @sa @ref events
|
||||
* @sa @ref glfwPollEvents
|
||||
* @sa @ref glfwWaitEventsTimeout
|
||||
* @sa @ref glfwWaitEventSFWTimeout
|
||||
*
|
||||
* @since Added in version 2.5.
|
||||
*
|
||||
@ -4061,12 +4061,12 @@ GLFWAPI void glfwWaitEvents(void);
|
||||
*
|
||||
* @ingroup window
|
||||
*/
|
||||
GLFWAPI void glfwWaitEventsTimeout(double timeout);
|
||||
GLFWAPI void glfwWaitEventSFWTimeout(double timeout);
|
||||
|
||||
/*! @brief Posts an empty event to the event queue.
|
||||
*
|
||||
* This function posts an empty event from the current thread to the event
|
||||
* queue, causing @ref glfwWaitEvents or @ref glfwWaitEventsTimeout to return.
|
||||
* queue, causing @ref glfwWaitEvents or @ref glfwWaitEventSFWTimeout to return.
|
||||
*
|
||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||
* GLFW_PLATFORM_ERROR.
|
||||
@ -4075,7 +4075,7 @@ GLFWAPI void glfwWaitEventsTimeout(double timeout);
|
||||
*
|
||||
* @sa @ref events
|
||||
* @sa @ref glfwWaitEvents
|
||||
* @sa @ref glfwWaitEventsTimeout
|
||||
* @sa @ref glfwWaitEventSFWTimeout
|
||||
*
|
||||
* @since Added in version 3.1.
|
||||
*
|
||||
@ -9438,7 +9438,7 @@ typedef struct _GLFWwindowX11
|
||||
|
||||
// The time of the last KeyPress event per keycode, for discarding
|
||||
// duplicate key events generated for some keys by ibus
|
||||
Time keyPressTimes[256];
|
||||
Time keyPresSFWTimes[256];
|
||||
} _GLFWwindowX11;
|
||||
|
||||
// X11-specific global data
|
||||
@ -11434,7 +11434,7 @@ void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity);
|
||||
|
||||
void _glfwPlatformPollEvents(void);
|
||||
void _glfwPlatformWaitEvents(void);
|
||||
void _glfwPlatformWaitEventsTimeout(double timeout);
|
||||
void _glfwPlatformWaitEventSFWTimeout(double timeout);
|
||||
void _glfwPlatformPostEmptyEvent(void);
|
||||
|
||||
void _glfwPlatformGetRequiredInstanceExtensions(const char** extensions);
|
||||
@ -18236,7 +18236,7 @@ GLFWAPI void glfwWaitEvents(void)
|
||||
_glfwPlatformWaitEvents();
|
||||
}
|
||||
|
||||
GLFWAPI void glfwWaitEventsTimeout(double timeout)
|
||||
GLFWAPI void glfwWaitEventSFWTimeout(double timeout)
|
||||
{
|
||||
_GLFW_REQUIRE_INIT();
|
||||
assert(timeout == timeout);
|
||||
@ -18249,7 +18249,7 @@ GLFWAPI void glfwWaitEventsTimeout(double timeout)
|
||||
return;
|
||||
}
|
||||
|
||||
_glfwPlatformWaitEventsTimeout(timeout);
|
||||
_glfwPlatformWaitEventSFWTimeout(timeout);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwPostEmptyEvent(void)
|
||||
@ -22497,7 +22497,7 @@ void _glfwPlatformWaitEvents(void)
|
||||
_glfwPlatformPollEvents();
|
||||
}
|
||||
|
||||
void _glfwPlatformWaitEventsTimeout(double timeout)
|
||||
void _glfwPlatformWaitEventSFWTimeout(double timeout)
|
||||
{
|
||||
MsgWaitForMultipleObjects(0, NULL, FALSE, (DWORD) (timeout * 1e3), QS_ALLEVENTS);
|
||||
|
||||
@ -23984,7 +23984,7 @@ void _glfwPlatformWaitEvents(void)
|
||||
{
|
||||
}
|
||||
|
||||
void _glfwPlatformWaitEventsTimeout(double timeout)
|
||||
void _glfwPlatformWaitEventSFWTimeout(double timeout)
|
||||
{
|
||||
}
|
||||
|
||||
@ -27352,13 +27352,13 @@ static void processEvent(XEvent *event)
|
||||
// NOTE: Always allow the first event for each key through
|
||||
// (the server never sends a timestamp of zero)
|
||||
// NOTE: Timestamp difference is compared to handle wrap-around
|
||||
Time diff = event->xkey.time - window->x11.keyPressTimes[keycode];
|
||||
Time diff = event->xkey.time - window->x11.keyPresSFWTimes[keycode];
|
||||
if (diff == event->xkey.time || (diff > 0 && diff < ((Time)1 << 31)))
|
||||
{
|
||||
if (keycode)
|
||||
_glfwInputKey(window, key, keycode, GLFW_PRESS, mods);
|
||||
|
||||
window->x11.keyPressTimes[keycode] = event->xkey.time;
|
||||
window->x11.keyPresSFWTimes[keycode] = event->xkey.time;
|
||||
}
|
||||
|
||||
if (!filtered)
|
||||
@ -28887,7 +28887,7 @@ void _glfwPlatformWaitEvents(void)
|
||||
_glfwPlatformPollEvents();
|
||||
}
|
||||
|
||||
void _glfwPlatformWaitEventsTimeout(double timeout)
|
||||
void _glfwPlatformWaitEventSFWTimeout(double timeout)
|
||||
{
|
||||
waitForAnyEvent(&timeout);
|
||||
_glfwPlatformPollEvents();
|
||||
@ -32923,7 +32923,7 @@ void _glfwPlatformWaitEvents(void)
|
||||
handleEvents(NULL);
|
||||
}
|
||||
|
||||
void _glfwPlatformWaitEventsTimeout(double timeout)
|
||||
void _glfwPlatformWaitEventSFWTimeout(double timeout)
|
||||
{
|
||||
handleEvents(&timeout);
|
||||
}
|
||||
@ -37115,7 +37115,7 @@ void _glfwPlatformWaitEvents(void)
|
||||
} // autoreleasepool
|
||||
}
|
||||
|
||||
void _glfwPlatformWaitEventsTimeout(double timeout)
|
||||
void _glfwPlatformWaitEventSFWTimeout(double timeout)
|
||||
{
|
||||
@autoreleasepool {
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#undef Time
|
||||
|
||||
#include "core/error_macros.h"
|
||||
#include "core/stime.h"
|
||||
#include "core/sfw_time.h"
|
||||
#include "core/ustring.h"
|
||||
#include "core/vector4.h"
|
||||
#include "render_core/application.h"
|
||||
@ -40,11 +40,11 @@ static int fps__timing_thread(void *arg) {
|
||||
while (fps_active) {
|
||||
if (framerate <= 0) {
|
||||
loop_counter = timer_counter = 0;
|
||||
STime::sleep_ms(250);
|
||||
SFWTime::sleep_ms(250);
|
||||
} else {
|
||||
timer_counter++;
|
||||
int64_t tt = (int64_t)(1e9 / (float)framerate) - ns_excess;
|
||||
uint64_t took = -STime::time_ns();
|
||||
uint64_t took = -SFWTime::time_ns();
|
||||
#if is(win32)
|
||||
timeBeginPeriod(1);
|
||||
Sleep(tt > 0 ? tt / 1e6 : 0);
|
||||
@ -84,7 +84,7 @@ static int fps_wait() {
|
||||
// if we throttled too much, cpu idle wait
|
||||
while (fps_active && (loop_counter > timer_counter)) {
|
||||
//thread_yield();
|
||||
STime::sleep_ns(100);
|
||||
SFWTime::sleep_ns(100);
|
||||
}
|
||||
|
||||
// max auto frameskip is 10: ie, even if speed is low paint at least one frame every 10
|
||||
@ -434,7 +434,7 @@ bool AppWindow::create(bool full_Screen, float canvas_scale, unsigned int flags,
|
||||
char *AppWindow::get_stats() {
|
||||
static double num_frames = 0, begin = FLT_MAX, prev_frame = 0;
|
||||
|
||||
double now = STime::time_ss();
|
||||
double now = SFWTime::time_ss();
|
||||
if (boot_time < 0) {
|
||||
boot_time = now;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
#include "core/math_defs.h"
|
||||
|
||||
#include "core/stime.h"
|
||||
#include "core/sfw_time.h"
|
||||
#include "render_core/input.h"
|
||||
#include "render_core/input_map.h"
|
||||
#include "render_core/app_window.h"
|
||||
@ -46,7 +46,7 @@ void Application::start_main_loop() {
|
||||
}
|
||||
|
||||
void Application::main_loop() {
|
||||
uint64_t start = STime::time_us();
|
||||
uint64_t start = SFWTime::time_us();
|
||||
|
||||
AppWindow *w = AppWindow::get_singleton();
|
||||
|
||||
@ -64,7 +64,7 @@ void Application::main_loop() {
|
||||
//render
|
||||
render();
|
||||
|
||||
uint64_t end = STime::time_us();
|
||||
uint64_t end = SFWTime::time_us();
|
||||
|
||||
uint64_t elapsed_us = end - start;
|
||||
|
||||
@ -78,7 +78,7 @@ void Application::main_loop() {
|
||||
if (remaining > 0) {
|
||||
frame_delta = tfps;
|
||||
|
||||
STime::sleep_us((double)SEC_TO_USEC(remaining));
|
||||
SFWTime::sleep_us((double)SEC_TO_USEC(remaining));
|
||||
} else {
|
||||
frame_delta = elapsed_seconds;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "input.h"
|
||||
|
||||
#include "core/logger.h"
|
||||
#include "core/stime.h"
|
||||
#include "core/sfw_time.h"
|
||||
#include "render_core/application.h"
|
||||
#include "render_core/input_map.h"
|
||||
#include "render_core/keyboard.h"
|
||||
@ -578,7 +578,7 @@ void Input::GLFWmousebuttonfunCallback(GLFWwindow *window, int button, int actio
|
||||
mb->set_pressed(pressed);
|
||||
|
||||
if (pressed) {
|
||||
uint64_t diff = STime::time_us() / 1000 - self->last_click_ms;
|
||||
uint64_t diff = SFWTime::time_us() / 1000 - self->last_click_ms;
|
||||
|
||||
if (mb->get_button_index() == self->last_click_button_index) {
|
||||
if (diff < 400 && Point2(self->last_click_pos).distance_to(last_mouse_pos) < 5) {
|
||||
@ -798,7 +798,7 @@ String Input::_hex_str(uint8_t p_byte) {
|
||||
Input *Input::singleton = nullptr;
|
||||
|
||||
void Input::SpeedTrack::update(const Vector2 &p_delta_p) {
|
||||
uint64_t tick = STime::time_us();
|
||||
uint64_t tick = SFWTime::time_us();
|
||||
uint32_t tdiff = tick - last_tick;
|
||||
float delta_t = tdiff / 1000000.0;
|
||||
last_tick = tick;
|
||||
@ -825,7 +825,7 @@ void Input::SpeedTrack::update(const Vector2 &p_delta_p) {
|
||||
}
|
||||
|
||||
void Input::SpeedTrack::reset() {
|
||||
last_tick = STime::time_us();
|
||||
last_tick = SFWTime::time_us();
|
||||
speed = Vector2();
|
||||
accum = Vector2();
|
||||
accum_t = 0;
|
||||
|
@ -6,7 +6,7 @@
|
||||
//--STRIP
|
||||
#include "core/random_pcg.h"
|
||||
|
||||
#include "core/stime.h"
|
||||
#include "core/sfw_time.h"
|
||||
#include "core/error_macros.h"
|
||||
//--STRIP
|
||||
|
||||
@ -17,7 +17,7 @@ RandomPCG::RandomPCG(uint64_t p_seed, uint64_t p_inc) :
|
||||
}
|
||||
|
||||
void RandomPCG::randomize() {
|
||||
seed((STime::date() + STime::time_us()) * pcg.state + PCG_DEFAULT_INC_64);
|
||||
seed((SFWTime::date() + SFWTime::time_us()) * pcg.state + PCG_DEFAULT_INC_64);
|
||||
}
|
||||
|
||||
double RandomPCG::random(double p_from, double p_to) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
// time
|
||||
|
||||
//--STRIP
|
||||
#include "core/stime.h"
|
||||
#include "core/sfw_time.h"
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
@ -11,42 +11,42 @@
|
||||
//--STRIP
|
||||
|
||||
#if 0
|
||||
uint64_t STime::time_gpu() {
|
||||
uint64_t SFWTime::time_gpu() {
|
||||
GLint64 t = 123456789;
|
||||
glGetInteger64v(GL_TIMESTAMP, &t);
|
||||
return (uint64_t)t;
|
||||
}
|
||||
#endif
|
||||
uint64_t STime::date() {
|
||||
uint64_t SFWTime::date() {
|
||||
//time_t epoch = time(0);
|
||||
//struct tm *ti = localtime(&epoch);
|
||||
//return atoi64(va("%04d%02d%02d%02d%02d%02d", ti->tm_year + 1900, ti->tm_mon + 1, ti->tm_mday, ti->tm_hour, ti->tm_min, ti->tm_sec));
|
||||
return 0;
|
||||
}
|
||||
char *STime::date_string() {
|
||||
char *SFWTime::date_string() {
|
||||
//time_t epoch = time(0);
|
||||
//struct tm *ti = localtime(&epoch);
|
||||
//return va("%04d-%02d-%02d %02d:%02d:%02d", ti->tm_year + 1900, ti->tm_mon + 1, ti->tm_mday, ti->tm_hour, ti->tm_min, ti->tm_sec);
|
||||
return 0;
|
||||
}
|
||||
uint64_t STime::date_epoch() {
|
||||
uint64_t SFWTime::date_epoch() {
|
||||
time_t epoch = time(0);
|
||||
return epoch;
|
||||
}
|
||||
#if 0
|
||||
double STime::time_ss() {
|
||||
double SFWTime::time_ss() {
|
||||
return glfwGetTime();
|
||||
}
|
||||
double STime::time_ms() {
|
||||
double SFWTime::time_ms() {
|
||||
return glfwGetTime() * 1000.0;
|
||||
}
|
||||
uint64_t STime::time_us() {
|
||||
uint64_t SFWTime::time_us() {
|
||||
return (uint64_t)(glfwGetTime() * 1000000.0); // @fixme: use a high resolution timer instead, or time_gpu below
|
||||
}
|
||||
uint64_t STime::sleep_us(uint64_t us) { // @fixme: use a high resolution sleeper instead
|
||||
uint64_t SFWTime::sleep_us(uint64_t us) { // @fixme: use a high resolution sleeper instead
|
||||
return sleep_ms( us / 1000.0 );
|
||||
}
|
||||
double STime::sleep_ms(double ms) {
|
||||
double SFWTime::sleep_ms(double ms) {
|
||||
double now = time_ms();
|
||||
if( ms <= 0 ) {
|
||||
#if defined(_WIN64) || defined(_WIN32)
|
||||
@ -113,7 +113,7 @@ static uint64_t nanotimer(uint64_t *out_freq) {
|
||||
#endif
|
||||
}
|
||||
|
||||
uint64_t STime::time_ns() {
|
||||
uint64_t SFWTime::time_ns() {
|
||||
static __thread uint64_t epoch = 0;
|
||||
static __thread uint64_t freq = 0;
|
||||
if (!freq) {
|
||||
@ -130,23 +130,23 @@ uint64_t STime::time_ns() {
|
||||
uint64_t r = a % c;
|
||||
return q * b + r * b / c;
|
||||
}
|
||||
uint64_t STime::time_us() {
|
||||
uint64_t SFWTime::time_us() {
|
||||
return time_ns() / TIMER_E3;
|
||||
}
|
||||
uint64_t STime::time_ms() {
|
||||
uint64_t SFWTime::time_ms() {
|
||||
return time_ns() / TIMER_E6;
|
||||
}
|
||||
double STime::time_ss() {
|
||||
double SFWTime::time_ss() {
|
||||
return time_ns() / 1e9; // TIMER_E9;
|
||||
}
|
||||
double STime::time_mm() {
|
||||
double SFWTime::time_mm() {
|
||||
return time_ss() / 60;
|
||||
}
|
||||
double STime::time_hh() {
|
||||
double SFWTime::time_hh() {
|
||||
return time_mm() / 60;
|
||||
}
|
||||
|
||||
void STime::sleep_ns(double ns) {
|
||||
void SFWTime::sleep_ns(double ns) {
|
||||
#if defined(_WIN64) || defined(_WIN32)
|
||||
if (ns >= 100) {
|
||||
LARGE_INTEGER li; // Windows sleep in 100ns units
|
||||
@ -170,12 +170,12 @@ void STime::sleep_ns(double ns) {
|
||||
#endif
|
||||
}
|
||||
}
|
||||
void STime::sleep_us(double us) {
|
||||
void SFWTime::sleep_us(double us) {
|
||||
sleep_ns(us * 1e3);
|
||||
}
|
||||
void STime::sleep_ms(double ms) {
|
||||
void SFWTime::sleep_ms(double ms) {
|
||||
sleep_ns(ms * 1e6);
|
||||
}
|
||||
void STime::sleep_ss(double ss) {
|
||||
void SFWTime::sleep_ss(double ss) {
|
||||
sleep_ns(ss * 1e9);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef STIME_H
|
||||
#define STIME_H
|
||||
#ifndef SFWTime_H
|
||||
#define SFWTime_H
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// time framework utils
|
||||
@ -9,7 +9,7 @@
|
||||
#include "core/int_types.h"
|
||||
//--STRIP
|
||||
|
||||
class STime {
|
||||
class SFWTime {
|
||||
public:
|
||||
static uint64_t date(); // YYYYMMDDhhmmss
|
||||
static uint64_t date_epoch(); // linux epoch
|
||||
|
@ -663,10 +663,10 @@ Files
|
||||
Time
|
||||
------------------------------------------------------------------
|
||||
|
||||
<a name="CLASS_STime"></a>
|
||||
<details><summary>STime</summary>
|
||||
<a name="CLASS_SFWTime"></a>
|
||||
<details><summary>SFWTime</summary>
|
||||
|
||||
|||CLASS_STime|||
|
||||
|||CLASS_SFWTime|||
|
||||
|
||||
</details>
|
||||
|
||||
|
@ -35,9 +35,9 @@
|
||||
{{FILE:sfw/core/safe_refcount.cpp}}
|
||||
|
||||
//--STRIP
|
||||
//#include "core/stime.h"
|
||||
//#include "core/sfw_time.h"
|
||||
//--STRIP
|
||||
{{FILE:sfw/core/stime.cpp}}
|
||||
{{FILE:sfw/core/sfw_time.cpp}}
|
||||
|
||||
//--STRIP
|
||||
//#include "core/memory.h"
|
||||
@ -62,7 +62,7 @@
|
||||
|
||||
//--STRIP
|
||||
//#include "core/random_pcg.h"
|
||||
//#include "core/stime.h"
|
||||
//#include "core/sfw_time.h"
|
||||
//#include "core/error_macros.h"
|
||||
//--STRIP
|
||||
{{FILE:sfw/core/random_pcg.cpp}}
|
||||
|
@ -47,7 +47,7 @@
|
||||
//--STRIP
|
||||
//#include "core/int_types.h"
|
||||
//--STRIP
|
||||
{{FILE:sfw/core/stime.h}}
|
||||
{{FILE:sfw/core/sfw_time.h}}
|
||||
//--STRIP
|
||||
//#include "core/typedefs.h"
|
||||
//--STRIP
|
||||
|
@ -207,9 +207,9 @@
|
||||
{{FILE:sfw/core/safe_refcount.cpp}}
|
||||
|
||||
//--STRIP
|
||||
//#include "core/stime.h"
|
||||
//#include "core/sfw_time.h"
|
||||
//--STRIP
|
||||
{{FILE:sfw/core/stime.cpp}}
|
||||
{{FILE:sfw/core/sfw_time.cpp}}
|
||||
|
||||
//--STRIP
|
||||
//#include "core/memory.h"
|
||||
@ -234,7 +234,7 @@
|
||||
|
||||
//--STRIP
|
||||
//#include "core/random_pcg.h"
|
||||
//#include "core/stime.h"
|
||||
//#include "core/sfw_time.h"
|
||||
//#include "core/error_macros.h"
|
||||
//--STRIP
|
||||
{{FILE:sfw/core/random_pcg.cpp}}
|
||||
@ -475,7 +475,7 @@
|
||||
//--STRIP
|
||||
//#include "render_core/application.h"
|
||||
//#include "core/math_defs.h"
|
||||
//#include "core/stime.h"
|
||||
//#include "core/sfw_time.h"
|
||||
//#include "render_core/input.h"
|
||||
//#include "render_core/input_map.h"
|
||||
//#include "render_core/app_window.h"
|
||||
@ -578,7 +578,7 @@
|
||||
//#include "render_core/3rd_glad.h"
|
||||
//#include "3rd_glfw3.h"
|
||||
//#include "core/error_macros.h"
|
||||
//#include "core/stime.h"
|
||||
//#include "core/sfw_time.h"
|
||||
//#include "core/ustring.h"
|
||||
//#include "core/vector4.h"
|
||||
//#include "render_core/application.h"
|
||||
@ -603,7 +603,7 @@
|
||||
//--STRIP
|
||||
//#include "input.h"
|
||||
//#include "core/logger.h"
|
||||
//#include "core/stime.h"
|
||||
//#include "core/sfw_time.h"
|
||||
//#include "render_core/application.h"
|
||||
//#include "render_core/input_map.h"
|
||||
//#include "render_core/keyboard.h"
|
||||
|
@ -47,7 +47,7 @@
|
||||
//--STRIP
|
||||
//#include "core/int_types.h"
|
||||
//--STRIP
|
||||
{{FILE:sfw/core/stime.h}}
|
||||
{{FILE:sfw/core/sfw_time.h}}
|
||||
//--STRIP
|
||||
//#include "core/typedefs.h"
|
||||
//--STRIP
|
||||
|
@ -35,9 +35,9 @@
|
||||
{{FILE:sfwl/core/safe_refcount.cpp}}
|
||||
|
||||
//--STRIP
|
||||
//#include "core/stime.h"
|
||||
//#include "core/sfw_time.h"
|
||||
//--STRIP
|
||||
{{FILE:sfwl/core/stime.cpp}}
|
||||
{{FILE:sfwl/core/sfw_time.cpp}}
|
||||
|
||||
//--STRIP
|
||||
//#include "core/memory.h"
|
||||
@ -62,7 +62,7 @@
|
||||
|
||||
//--STRIP
|
||||
//#include "core/random_pcg.h"
|
||||
//#include "core/stime.h"
|
||||
//#include "core/sfw_time.h"
|
||||
//#include "core/error_macros.h"
|
||||
//--STRIP
|
||||
{{FILE:sfwl/core/random_pcg.cpp}}
|
||||
|
@ -40,7 +40,7 @@
|
||||
//--STRIP
|
||||
//#include "core/int_types.h"
|
||||
//--STRIP
|
||||
{{FILE:sfwl/core/stime.h}}
|
||||
{{FILE:sfwl/core/sfw_time.h}}
|
||||
//--STRIP
|
||||
//#include "core/typedefs.h"
|
||||
//--STRIP
|
||||
|
@ -35,9 +35,9 @@
|
||||
{{FILE:sfwl/core/safe_refcount.cpp}}
|
||||
|
||||
//--STRIP
|
||||
//#include "core/stime.h"
|
||||
//#include "core/sfw_time.h"
|
||||
//--STRIP
|
||||
{{FILE:sfwl/core/stime.cpp}}
|
||||
{{FILE:sfwl/core/sfw_time.cpp}}
|
||||
|
||||
//--STRIP
|
||||
//#include "core/memory.h"
|
||||
@ -62,7 +62,7 @@
|
||||
|
||||
//--STRIP
|
||||
//#include "core/random_pcg.h"
|
||||
//#include "core/stime.h"
|
||||
//#include "core/sfw_time.h"
|
||||
//#include "core/error_macros.h"
|
||||
//--STRIP
|
||||
{{FILE:sfwl/core/random_pcg.cpp}}
|
||||
|
@ -40,7 +40,7 @@
|
||||
//--STRIP
|
||||
//#include "core/int_types.h"
|
||||
//--STRIP
|
||||
{{FILE:sfwl/core/stime.h}}
|
||||
{{FILE:sfwl/core/sfw_time.h}}
|
||||
//--STRIP
|
||||
//#include "core/typedefs.h"
|
||||
//--STRIP
|
||||
|
Loading…
Reference in New Issue
Block a user