Something went wrong. Try again.
This is my attempt at a basic rendering engine in C
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140#pragma once
#ifndef PTSD_TIME_HEADER#define PTSD_TIME_HEADER#ifndef PTSD_TIME_STANDALONE#include "general.h"#else#error not implemented yet#endif
#if defined(__cplusplus)extern "C" {#endif
typedef s64 ptimepoint_t;
enum pclocktype_t { PTSD_STEADY_CLOCK, PTSD_HIGH_RESOLUTION_CLOCK, PTSD_SYSTEM_CLOCK};
ptimepoint_t pget_tick(enum pclocktype_t);ptimepoint_t psystem_time(void); // same as pget_tick with PTSD_SYSTEM_CLOCK
#define pget_time_nano_seconds(rettype, timepoint) \ (rettype)_Generic((rettype)0, \ f64: pget_time_nano_d, \ f32: pget_time_nano_f,\ s8: pget_time_nano_lls,\ s16: pget_time_nano_lls,\ s32: pget_time_nano_lls, \ s64: pget_time_nano_lls,\ u8: pget_time_nano_llu, \ u16: pget_time_nano_llu, \ u32: pget_time_nano_llu, \ u64: pget_time_nano_llu\ )(_Generic(timepoint, ptimepoint_t: pget_timepoint_from_timepoint)(timepoint))
#define pget_time_mili_seconds(rettype, timepoint) \ (rettype)_Generic((rettype)0, \ f64: pget_time_mili_d, \ f32: pget_time_mili_f,\ s8: pget_time_mili_lls, \ s16: pget_time_mili_lls, \ s32: pget_time_mili_lls, \ s64: pget_time_mili_lls,\ u8: pget_time_mili_llu, \ u16: pget_time_mili_llu, \ u32: pget_time_mili_llu, \ u64: pget_time_mili_llu\ )(_Generic(timepoint, ptimepoint_t: pget_timepoint_from_timepoint)(timepoint))
#define pget_time_seconds(rettype, timepoint) \ (rettype)_Generic((rettype)0, \ f64: pget_time_seconds_d, \ f32: pget_time_seconds_f,\ s8: pget_time_seconds_lls,\ s16: pget_time_seconds_lls,\ s32: pget_time_seconds_lls, \ s64: pget_time_seconds_lls,\ u8: pget_time_seconds_llu, \ u16: pget_time_seconds_llu, \ u32: pget_time_seconds_llu, \ u64: pget_time_seconds_llu\ )(_Generic(timepoint, ptimepoint_t: pget_timepoint_from_timepoint)(timepoint))
#define PTSD_TIME_MILI 1000000#define PTSD_TIME_SECONDS 1000000000
PTSD_UNUSEDstatic inline ptimepoint_t pget_timepoint_from_timepoint(ptimepoint_t point) { return point;}
PTSD_UNUSEDstatic inline f64 pget_time_nano_d(ptimepoint_t timepoint) { return (f64) timepoint; }
PTSD_UNUSEDstatic inline f32 pget_time_nano_f(ptimepoint_t timepoint) { return (f32) timepoint; }
PTSD_UNUSEDstatic inline s64 pget_time_nano_lls(ptimepoint_t timepoint) { return (s64) timepoint; }
PTSD_UNUSEDstatic inline u64 pget_time_nano_llu(ptimepoint_t timepoint) { return (u64) timepoint; }
PTSD_UNUSEDstatic inline f64 pget_time_mili_d(ptimepoint_t timepoint) { return (f64)timepoint / (f64) PTSD_TIME_MILI; }
PTSD_UNUSEDstatic inline f32 pget_time_mili_f(ptimepoint_t timepoint) { return (f32)timepoint / (f32) PTSD_TIME_MILI; }
PTSD_UNUSEDstatic inline s64 pget_time_mili_lls(ptimepoint_t timepoint) { return (s64)timepoint / (s64) PTSD_TIME_MILI; }
PTSD_UNUSEDstatic inline u64 pget_time_mili_llu(ptimepoint_t timepoint) { return (u64)timepoint / (u64) PTSD_TIME_MILI; }
PTSD_UNUSEDstatic inline f64 pget_time_seconds_d(ptimepoint_t timepoint) { return (f64)timepoint / (f64) PTSD_TIME_SECONDS; }
PTSD_UNUSEDstatic inline f32 pget_time_seconds_f(ptimepoint_t timepoint) { return (f32)timepoint / (f32) PTSD_TIME_SECONDS; }
PTSD_UNUSEDstatic inline s64 pget_time_seconds_lls(ptimepoint_t timepoint) { return (s64)timepoint / (s64) PTSD_TIME_SECONDS; }
PTSD_UNUSEDstatic inline u64 pget_time_seconds_llu(ptimepoint_t timepoint) { return (u64)timepoint / (u64) PTSD_TIME_SECONDS; }
#if defined(__cplusplus)}#endif#endif // PTSD_TIME_HEADER