Module csfml_system

Types

Time = object 
  microseconds*: int64
Represents a time value
Clock = ptr object 
Mutex = ptr object 
Thread = ptr object 
InputStreamReadFunc = proc (data: pointer; size: int64; userData: pointer): int64 {.
    cdecl.}
InputStreamSeekFunc = proc (position: int64; userData: pointer): int64 {.cdecl.}
InputStreamTellFunc = proc (userData: pointer): int64 {.cdecl.}
InputStreamGetSizeFunc = proc (userData: pointer): int64 {.cdecl.}
InputStream = object 
  read*: InputStreamReadFunc
  seek*: InputStreamSeekFunc
  tell*: InputStreamTellFunc
  getSize*: InputStreamGetSizeFunc
  userData*: pointer
Set of callbacks that allow users to define custom file streams
Vector2i = object 
  x*: cint
  y*: cint
2-component vector of integers
Vector2f = object 
  x*: cfloat
  y*: cfloat
2-component vector of floats
Vector3f = object 
  x*: cfloat
  y*: cfloat
  z*: cfloat
3-component vector of floats

Procs

proc asSeconds(time: Time): cfloat {.cdecl, importc: "sfTime_asSeconds".}

Return a time value as a number of seconds

Arguments:

  • time: Time value

Returns: Time in seconds

proc asMilliseconds(time: Time): int32 {.cdecl, importc: "sfTime_asMilliseconds".}

Return a time value as a number of milliseconds

Arguments:

  • time: Time value

Returns: Time in milliseconds

proc asMicroseconds(time: Time): int64 {.cdecl, importc: "sfTime_asMicroseconds".}

Return a time value as a number of microseconds

Arguments:

  • time: Time value

Returns: Time in microseconds

proc seconds(amount: cfloat): Time {.cdecl, importc: "sfSeconds".}

Construct a time value from a number of seconds

Arguments:

  • amount: Number of seconds

Returns: Time value constructed from the amount of seconds

proc milliseconds(amount: int32): Time {.cdecl, importc: "sfMilliseconds".}

Construct a time value from a number of milliseconds

Arguments:

  • amount: Number of milliseconds

Returns: Time value constructed from the amount of milliseconds

proc microseconds(amount: int64): Time {.cdecl, importc: "sfMicroseconds".}

Construct a time value from a number of microseconds

Arguments:

  • amount: Number of microseconds

Returns: Time value constructed from the amount of microseconds

proc newClock(): Clock {.cdecl, importc: "sfClock_create".}

Create a new clock and start it

Returns: A new Clock object

proc copy(clock: Clock): Clock {.cdecl, importc: "sfClock_copy".}

Create a new clock by copying an existing one

Arguments:

  • clock: Clock to copy

Returns: A new Clock object which is a copy of clock

proc destroy(clock: Clock) {.override, cdecl, importc: "sfClock_destroy".}

Destroy a clock

Arguments:

  • clock: Clock to destroy
proc elapsedTime(clock: Clock): Time {.cdecl, importc: "sfClock_getElapsedTime".}

Get the time elapsed in a clock

This function returns the time elapsed since the last call to Clock_restart (or the construction of the object if Clock_restart has not been called).

Arguments:

  • clock: Clock object

Returns: Time elapsed

proc restart(clock: Clock): Time {.cdecl, importc: "sfClock_restart".}

Restart a clock

This function puts the time counter back to zero. It also returns the time elapsed since the clock was started.

Arguments:

  • clock: Clock object

Returns: Time elapsed

proc sleep(duration: Time) {.cdecl, importc: "sfSleep".}

Make the current thread sleep for a given duration

Sleep is the best way to block a program or one of its threads, as it doesn't consume any CPU power.

Arguments:

  • duration: Time to sleep
proc vec2(x, y: cint): Vector2i 
Returns: Vector2i with these coordinates
proc vec2(x, y: int): Vector2i 
Returns: Vector2i with these coordinates
proc vec2(x, y: cfloat): Vector2f 
Returns: Vector2f with these coordinates
proc vec2(x, y: float): Vector2f 
Returns: Vector2f with these coordinates
proc vec3(x, y, z: cfloat): Vector3f 
Returns: Vector3f with these coordinates
proc vec3(x, y, z: float): Vector3f 
Returns: Vector3f with these coordinates
proc `+`(a, b: Vector2f): Vector2f 
Returns: memberwise addition
proc `-`(a, b: Vector2f): Vector2f 
Returns: memberwise subtraction
proc `*`(a: Vector2f; b: cfloat): Vector2f 
Returns: memberwise multiplication by b
proc `/`(a: Vector2f; b: cfloat): Vector2f 
Returns: memberwise division by b
proc `-`(a: Vector2f): Vector2f 
Returns: memberwise opposite
proc `==`(a, b: Vector2f): bool 
Returns: whether corresponding members of two Vector2fs are equal
proc `+`(a, b: Vector2i): Vector2i 
Returns: memberwise addition
proc `-`(a, b: Vector2i): Vector2i 
Returns: memberwise subtraction
proc `*`(a: Vector2i; b: cint): Vector2i 
Returns: memberwise multiplication by b
proc `div`(a: Vector2i; b: cint): Vector2i 
Returns: memberwise integer division by b
proc `-`(a: Vector2i): Vector2i 
Returns: memberwise opposite
proc `==`(a, b: Vector2i): bool 
Returns: whether corresponding members of two Vector2is are equal
proc `+`(a, b: Vector3f): Vector3f 
Returns: memberwise addition
proc `-`(a, b: Vector3f): Vector3f 
Returns: memberwise subtraction
proc `*`(a: Vector3f; b: cfloat): Vector3f 
Returns: memberwise multiplication by b
proc `/`(a: Vector3f; b: cfloat): Vector3f 
Returns: memberwise division by b
proc `-`(a: Vector3f): Vector3f 
Returns: memberwise opposite
proc `==`(a, b: Vector3f): bool 
Returns: whether corresponding members of two Vector3fs are equal
proc `==`(a, b: Time): bool 
Returns: whether two time values are equal
proc `<=`(a, b: Time): bool 
Returns: whether a is not later than b
proc `<`(a, b: Time): bool 
Returns: whether a is earlier than b
proc `-`(a: Time): Time 
Returns: negated Time value
proc `+`(a, b: Time): Time 
Returns: sum of the two Time values
proc `-`(a, b: Time): Time 
Returns: difference of the two Time values

Converters

converter vec2(a: Vector2i): Vector2f 
Conversion from Vector2i to Vector2f