mirror of
https://github.com/odin-lang/Odin.git
synced 2026-02-15 23:54:07 +00:00
Add sdl3 time/timer
This commit is contained in:
2
vendor/sdl3/sdl3_filesystem.odin
vendored
2
vendor/sdl3/sdl3_filesystem.odin
vendored
@@ -49,10 +49,8 @@ EnumerationResult :: enum c.int {
|
||||
EnumerateDirectoryCallback :: #type proc "c" (userdata: rawptr, dirname, fname: cstring) -> EnumerationResult
|
||||
|
||||
|
||||
|
||||
@(default_calling_convention="c", link_prefix="SDL_")
|
||||
foreign lib {
|
||||
|
||||
GetBasePath :: proc() -> cstring ---
|
||||
GetPrefPath :: proc(org, app: cstring) -> [^]c.char ---
|
||||
GetUserFolder :: proc(folder: Folder) -> cstring ---
|
||||
|
||||
40
vendor/sdl3/sdl3_time.odin
vendored
Normal file
40
vendor/sdl3/sdl3_time.odin
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
package sdl3
|
||||
|
||||
import "core:c"
|
||||
|
||||
DateTime :: struct {
|
||||
year: c.int, /**< Year */
|
||||
month: c.int, /**< Month [01-12] */
|
||||
day: c.int, /**< Day of the month [01-31] */
|
||||
hour: c.int, /**< Hour [0-23] */
|
||||
minute: c.int, /**< Minute [0-59] */
|
||||
second: c.int, /**< Seconds [0-60] */
|
||||
nanosecond: c.int, /**< Nanoseconds [0-999999999] */
|
||||
day_of_week: c.int, /**< Day of the week [0-6] (0 being Sunday) */
|
||||
utc_offset: c.int, /**< Seconds east of UTC */
|
||||
}
|
||||
|
||||
DateFormat :: enum c.int {
|
||||
YYYYMMDD = 0, /**< Year/Month/Day */
|
||||
DDMMYYYY = 1, /**< Day/Month/Year */
|
||||
MMDDYYYY = 2, /**< Month/Day/Year */
|
||||
}
|
||||
|
||||
TimeFormat :: enum c.int {
|
||||
HR24 = 0, /**< 24 hour time */
|
||||
HR12 = 1, /**< 12 hour time */
|
||||
}
|
||||
|
||||
|
||||
@(default_calling_convention="c", link_prefix="SDL_", require_results)
|
||||
foreign lib {
|
||||
GetDateTimeLocalePreferences :: proc(dateFormat: ^DateFormat, timeFormat: ^TimeFormat) -> bool ---
|
||||
GetCurrentTime :: proc(ticks: ^Time) -> bool ---
|
||||
TimeToDateTime :: proc(ticks: Time, dt: ^DateTime, localTime: bool) -> bool ---
|
||||
DateTimeToTime :: proc(#by_ptr dt: DateTime, ticks: ^Time) -> bool ---
|
||||
TimeToWindows :: proc(ticks: Time, dwLowDateTime, dwHighDateTime: ^Uint32) ---
|
||||
TimeFromWindows :: proc(dwLowDateTime, dwHighDateTime: Uint32) -> Time ---
|
||||
GetDaysInMonth :: proc(year, month: c.int) -> c.int ---
|
||||
GetDayOfYear :: proc(year, month, day: c.int) -> c.int ---
|
||||
GetDayOfWeek :: proc(year, month, day: c.int) -> c.int ---
|
||||
}
|
||||
33
vendor/sdl3/sdl3_timer.odin
vendored
Normal file
33
vendor/sdl3/sdl3_timer.odin
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
package sdl3
|
||||
|
||||
MS_PER_SECOND :: 1000
|
||||
US_PER_SECOND :: 1000000
|
||||
NS_PER_SECOND :: 1000000000
|
||||
NS_PER_MS :: 1000000
|
||||
NS_PER_US :: 1000
|
||||
|
||||
@(require_results) SECONDS_TO_NS :: #force_inline proc "c" (S: Uint64) -> Uint64 { return S * NS_PER_SECOND }
|
||||
@(require_results) NS_TO_SECONDS :: #force_inline proc "c" (NS: Uint64) -> Uint64 { return NS / NS_PER_SECOND }
|
||||
@(require_results) MS_TO_NS :: #force_inline proc "c" (MS: Uint64) -> Uint64 { return MS * NS_PER_MS }
|
||||
@(require_results) NS_TO_MS :: #force_inline proc "c" (NS: Uint64) -> Uint64 { return NS / NS_PER_MS }
|
||||
@(require_results) US_TO_NS :: #force_inline proc "c" (US: Uint64) -> Uint64 { return US * NS_PER_US }
|
||||
@(require_results) NS_TO_US :: #force_inline proc "c" (NS: Uint64) -> Uint64 { return NS / NS_PER_US }
|
||||
|
||||
TimerID :: distinct Uint32
|
||||
|
||||
TimerCallback :: #type proc "c" (userdata: rawptr, timerID: TimerID, interval: Uint32) -> Uint32
|
||||
NSTimerCallback :: #type proc "c" (userdata: rawptr, timerID: TimerID, interval: Uint64) -> Uint64
|
||||
|
||||
@(default_calling_convention="c", link_prefix="SDL_", require_results)
|
||||
foreign lib {
|
||||
GetTicks :: proc() -> Uint64 ---
|
||||
GetTicksNS :: proc() -> Uint64 ---
|
||||
GetPerformanceCounter :: proc() -> Uint64 ---
|
||||
GetPerformanceFrequency :: proc() -> Uint64 ---
|
||||
Delay :: proc(ms: Uint32) ---
|
||||
DelayNS :: proc(ns: Uint64) ---
|
||||
DelayPrecise :: proc(ns: Uint64) ---
|
||||
AddTimer :: proc(interval: Uint32, callback: TimerCallback, userdata: rawptr) -> TimerID ---
|
||||
AddTimerNS :: proc(interval: Uint64, callback: NSTimerCallback, userdata: rawptr) -> TimerID ---
|
||||
RemoveTimer :: proc(id: TimerID) -> bool ---
|
||||
}
|
||||
Reference in New Issue
Block a user