Kore 3
Loading...
Searching...
No Matches
system.h File Reference

Provides basic system and application-management functionality which doesn't fit anywhere else. More...

#include <kore3/global.h>
#include <kore3/log.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Typedefs

typedef uint64_t kore_ticks

Functions

KORE_FUNC int kore_init (const char *name, int width, int height, struct kore_window_parameters *win, struct kore_framebuffer_parameters *frame)
 Initializes a Kore application and creates an initial window for systems which support windows (systems which do not support windows are treated as if the would provide a single window which cannot change). This has to be called before any other Kore-function with the exception of the Display-API which can optionally be initialized beforehand using kore_display_init.
KORE_FUNC const char * kore_application_name (void)
 Returns the current application name as set by kore_init or kore_set_application_name.
KORE_FUNC void kore_set_application_name (const char *name)
 Changes the application-name that was initially set by kore_init.
KORE_FUNC int kore_width (void)
 Returns the current width of the initial application-window which is equivalent to calling kore_window_width(0).
KORE_FUNC int kore_height (void)
 Returns the current height of the initial application-window which is equivalent to calling kore_window_height(0).
KORE_FUNC void kore_load_url (const char *url)
 Instruct the system to load up the provided URL which will usually open it in the system's default browser.
KORE_FUNC const char * kore_system_id (void)
 Returns an ID representing the current type of target-system.
KORE_FUNC const char * kore_language (void)
 Returns the current system-language.
KORE_FUNC void kore_vibrate (int milliseconds)
 Vibrates the whole system if supported. This is primarily supported on mobile phones but don't blame us if your computer falls over.
KORE_FUNC float kore_safe_zone (void)
 Returns the portion of the screen which can be safely used for important content. This is mostly relevant for TVs which often scale the image by default and thefore cut off some of the content.
KORE_FUNC bool kore_automatic_safe_zone (void)
 Returns whether the system itself handles configuration of the safe-zone.
KORE_FUNC void kore_set_safe_zone (float value)
 Sets the safe-zone for systems which return false for kore_automatic_safe_zone.
KORE_FUNC double kore_frequency (void)
 Returns the frequency of system-timestamps.
KORE_FUNC kore_ticks kore_timestamp (void)
 Returns a timestamp for right now in a system-specific unit.
KORE_FUNC int kore_cpu_cores (void)
 Returns the number of proper CPU-cores (not the number of hardware-threads).
KORE_FUNC int kore_hardware_threads (void)
 Returns the number of hardware-threads.
KORE_FUNC double kore_time (void)
 Returns the current time. This can also be calculated ala kore_timestamp() / kore_frequency() but kore_time is a little more precise on some systems.
KORE_FUNC void kore_start (void)
 Starts Kore's main-loop. kore_set_update_callback should be called before kore_start so the main-loop actually has something to do.
KORE_FUNC void kore_stop (void)
 Stops Kore's main loop and thereby returns to the function which called kore_start.
KORE_FUNC void kore_login (void)
 Instructs the system to login a user if that is supported.
KORE_FUNC bool kore_waiting_for_login (void)
 Returns true if kore_login was called and the login-process is still ongoing.
KORE_FUNC void kore_unlock_achievement (int id)
 Unlocks an achievement or trophy or however you prefer to call it.
KORE_FUNC void kore_disallow_user_change (void)
 Disallows the system to logout the current user.
KORE_FUNC void kore_allow_user_change (void)
 Allows the system to logout the current user.
KORE_FUNC void kore_set_keep_screen_on (bool on)
 Instructs the system whether it is allowed to turn off the screen while the application is running.
KORE_INLINE void kore_debug_break (void)
 Tries to halt program-execution in an attached debugger when compiled in debug-mode (aka when NDEBUG is not defined).
KORE_FUNC bool kore_debugger_attached (void)
 Returns whether a debugger is currently attached to the running program. This is not yet working though.
KORE_FUNC void kore_copy_to_clipboard (const char *text)
 Copies the provided string to the system's clipboard.
KORE_FUNC void kore_set_update_callback (void(*callback)(void *), void *data)
 Sets the update-callback which drives the application and is called for every frame.
KORE_FUNC void kore_set_foreground_callback (void(*callback)(void *), void *data)
 Sets a callback which is called whenever the application is brought to the foreground.
KORE_FUNC void kore_set_resume_callback (void(*callback)(void *), void *data)
 Sets a callback which is called whenever the application was paused and is being resumed.
KORE_FUNC void kore_set_pause_callback (void(*callback)(void *), void *data)
 Sets a callback which is called whenever the application is paused.
KORE_FUNC void kore_set_background_callback (void(*callback)(void *), void *data)
 Sets a callback which is called whenever the application is brought to the background.
KORE_FUNC void kore_set_shutdown_callback (void(*callback)(void *), void *data)
 Sets a callback which is called whenever the application is about to shut down.
KORE_FUNC void kore_set_drop_files_callback (void(*callback)(wchar_t *, void *), void *data)
 Sets a callback which is called when files are dropped on the application-window.
KORE_FUNC void kore_set_cut_callback (char *(*callback)(void *), void *data)
 Sets a callback which is called when the application is instructed to cut, typically via ctrl+x or cmd+x. Kore does not take ownership of the provided string.
KORE_FUNC void kore_set_copy_callback (char *(*callback)(void *), void *data)
 Sets a callback which is called when the application is instructed to copy, typically via ctrl+c or cmd+c. Kore does not take ownership of the provided string.
KORE_FUNC void kore_set_paste_callback (void(*callback)(char *, void *), void *data)
 Sets a callback which is called when the application is instructed to paste, typically via ctrl+v or cmd+v. The provided string is only valid during the callback-call - copy it if you want to keep it.
KORE_FUNC void kore_set_login_callback (void(*callback)(void *), void *data)
 Sets a callback which is called when a user logs in.
KORE_FUNC void kore_set_logout_callback (void(*callback)(void *), void *data)
 Sets a callback which is called when a user logs out.
static void kore_marker_start (const char *name, uint32_t color)
 Starts a marker for profiling. Please match it with a marker_end-call in the same function.
static void kore_marker_end (const char *name)
 Ends the previously started marker of the same function.
KORE_FUNC void kore_LivePP_start (void)
 Currently only supported on Windows. Starts up Live++ (see https://liveplusplus.tech), typically called right before kore_start(). After calling this you can hit Ctrl+Alt+F11 to hot-reload. Call Project.addLivePP(path) in your kfile to make this do something. The path-parameter for addLivePP is the path to the unpacked Live++-archive that has to contain a LivePP-subdirectory. This will set the appropricate compiler- and linker-options and set the KORE_LIVEPP-define for the Debug- and Develop-configs (it does not touch the Release-config).
KORE_FUNC void kore_LivePP_stop (void)
 Stops Live++, typically called right after kore_start().

Detailed Description

Provides basic system and application-management functionality which doesn't fit anywhere else.

Function Documentation

◆ kore_application_name()

KORE_FUNC const char * kore_application_name ( void )

Returns the current application name as set by kore_init or kore_set_application_name.

Returns
The current name of the application

◆ kore_automatic_safe_zone()

KORE_FUNC bool kore_automatic_safe_zone ( void )

Returns whether the system itself handles configuration of the safe-zone.

Returns
Whether the safe-zone is handlet by the syste

◆ kore_copy_to_clipboard()

KORE_FUNC void kore_copy_to_clipboard ( const char * text)

Copies the provided string to the system's clipboard.

Parameters
textThe text to be copied into the clipboard

◆ kore_cpu_cores()

KORE_FUNC int kore_cpu_cores ( void )

Returns the number of proper CPU-cores (not the number of hardware-threads).

Returns
Number of cores

◆ kore_debugger_attached()

KORE_FUNC bool kore_debugger_attached ( void )

Returns whether a debugger is currently attached to the running program. This is not yet working though.

Returns
Whether a debugger is currently attached

◆ kore_frequency()

KORE_FUNC double kore_frequency ( void )

Returns the frequency of system-timestamps.

Returns
The frequency of the system's timestamps in 1 / second

◆ kore_hardware_threads()

KORE_FUNC int kore_hardware_threads ( void )

Returns the number of hardware-threads.

Returns
Number of hardware-threads

◆ kore_height()

KORE_FUNC int kore_height ( void )

Returns the current height of the initial application-window which is equivalent to calling kore_window_height(0).

Returns
The height of the initial window

◆ kore_init()

KORE_FUNC int kore_init ( const char * name,
int width,
int height,
struct kore_window_parameters * win,
struct kore_framebuffer_parameters * frame )

Initializes a Kore application and creates an initial window for systems which support windows (systems which do not support windows are treated as if the would provide a single window which cannot change). This has to be called before any other Kore-function with the exception of the Display-API which can optionally be initialized beforehand using kore_display_init.

Returns
The id of the initial window

◆ kore_language()

KORE_FUNC const char * kore_language ( void )

Returns the current system-language.

Returns
The current system-language as a two-letter language code

◆ kore_LivePP_start()

KORE_FUNC void kore_LivePP_start ( void )

Currently only supported on Windows. Starts up Live++ (see https://liveplusplus.tech), typically called right before kore_start(). After calling this you can hit Ctrl+Alt+F11 to hot-reload. Call Project.addLivePP(path) in your kfile to make this do something. The path-parameter for addLivePP is the path to the unpacked Live++-archive that has to contain a LivePP-subdirectory. This will set the appropricate compiler- and linker-options and set the KORE_LIVEPP-define for the Debug- and Develop-configs (it does not touch the Release-config).

Returns

◆ kore_LivePP_stop()

KORE_FUNC void kore_LivePP_stop ( void )

Stops Live++, typically called right after kore_start().

Returns

◆ kore_load_url()

KORE_FUNC void kore_load_url ( const char * url)

Instruct the system to load up the provided URL which will usually open it in the system's default browser.

Parameters
urlThe URL to open

◆ kore_marker_start()

void kore_marker_start ( const char * name,
uint32_t color )
inlinestatic

Starts a marker for profiling. Please match it with a marker_end-call in the same function.

Parameters
nameA unique name that will be shown in the profiler
colorA nice color in RGBX that will show up in the profiler

◆ kore_safe_zone()

KORE_FUNC float kore_safe_zone ( void )

Returns the portion of the screen which can be safely used for important content. This is mostly relevant for TVs which often scale the image by default and thefore cut off some of the content.

Returns
The safe-zone which can be multiplied with the width or height of the display to convert it to pixels

◆ kore_set_application_name()

KORE_FUNC void kore_set_application_name ( const char * name)

Changes the application-name that was initially set by kore_init.

Parameters
nameThe new application-name

◆ kore_set_background_callback()

KORE_FUNC void kore_set_background_callback ( void(* callback )(void *),
void * data )

Sets a callback which is called whenever the application is brought to the background.

Parameters
callbackThe background-callback
dataArbitrary data-pointer that's passed to the callback

◆ kore_set_copy_callback()

KORE_FUNC void kore_set_copy_callback ( char *(* callback )(void *),
void * data )

Sets a callback which is called when the application is instructed to copy, typically via ctrl+c or cmd+c. Kore does not take ownership of the provided string.

Parameters
callbackThe copy-callback
dataArbitrary data-pointer that's passed to the callback

◆ kore_set_cut_callback()

KORE_FUNC void kore_set_cut_callback ( char *(* callback )(void *),
void * data )

Sets a callback which is called when the application is instructed to cut, typically via ctrl+x or cmd+x. Kore does not take ownership of the provided string.

Parameters
callbackThe cut-callback
dataArbitrary data-pointer that's passed to the callback

◆ kore_set_drop_files_callback()

KORE_FUNC void kore_set_drop_files_callback ( void(* callback )(wchar_t *, void *),
void * data )

Sets a callback which is called when files are dropped on the application-window.

Parameters
callbackThe drop-files-callback
dataArbitrary data-pointer that's passed to the callback

◆ kore_set_foreground_callback()

KORE_FUNC void kore_set_foreground_callback ( void(* callback )(void *),
void * data )

Sets a callback which is called whenever the application is brought to the foreground.

Parameters
callbackThe foreground-callback
dataArbitrary data-pointer that's passed to the callback

◆ kore_set_keep_screen_on()

KORE_FUNC void kore_set_keep_screen_on ( bool on)

Instructs the system whether it is allowed to turn off the screen while the application is running.

Parameters
onWhether turning off the screen is allowed

◆ kore_set_login_callback()

KORE_FUNC void kore_set_login_callback ( void(* callback )(void *),
void * data )

Sets a callback which is called when a user logs in.

Parameters
callbackThe login-callback
dataArbitrary data-pointer that's passed to the callback

◆ kore_set_logout_callback()

KORE_FUNC void kore_set_logout_callback ( void(* callback )(void *),
void * data )

Sets a callback which is called when a user logs out.

Parameters
callbackThe logout-callback
dataArbitrary data-pointer that's passed to the callback

◆ kore_set_paste_callback()

KORE_FUNC void kore_set_paste_callback ( void(* callback )(char *, void *),
void * data )

Sets a callback which is called when the application is instructed to paste, typically via ctrl+v or cmd+v. The provided string is only valid during the callback-call - copy it if you want to keep it.

Parameters
callbackThe paste-callback
dataArbitrary data-pointer that's passed to the callback

◆ kore_set_pause_callback()

KORE_FUNC void kore_set_pause_callback ( void(* callback )(void *),
void * data )

Sets a callback which is called whenever the application is paused.

Parameters
callbackThe pause-callback
dataArbitrary data-pointer that's passed to the callback

◆ kore_set_resume_callback()

KORE_FUNC void kore_set_resume_callback ( void(* callback )(void *),
void * data )

Sets a callback which is called whenever the application was paused and is being resumed.

Parameters
callbackThe resume-callback
dataArbitrary data-pointer that's passed to the callback

◆ kore_set_safe_zone()

KORE_FUNC void kore_set_safe_zone ( float value)

Sets the safe-zone for systems which return false for kore_automatic_safe_zone.

Parameters
valueThe safe-zone for width and height as a ratio of the full display-resolution.

◆ kore_set_shutdown_callback()

KORE_FUNC void kore_set_shutdown_callback ( void(* callback )(void *),
void * data )

Sets a callback which is called whenever the application is about to shut down.

Parameters
callbackThe shutdown-callback
dataArbitrary data-pointer that's passed to the callback

◆ kore_set_update_callback()

KORE_FUNC void kore_set_update_callback ( void(* callback )(void *),
void * data )

Sets the update-callback which drives the application and is called for every frame.

Parameters
callbackThe callback
dataArbitrary data-pointer that's passed to the callback

◆ kore_system_id()

KORE_FUNC const char * kore_system_id ( void )

Returns an ID representing the current type of target-system.

Returns
The ID representing the target system

◆ kore_time()

KORE_FUNC double kore_time ( void )

Returns the current time. This can also be calculated ala kore_timestamp() / kore_frequency() but kore_time is a little more precise on some systems.

Returns
The current time in seconds

◆ kore_timestamp()

KORE_FUNC kore_ticks kore_timestamp ( void )

Returns a timestamp for right now in a system-specific unit.

Returns
The current timestamp

◆ kore_unlock_achievement()

KORE_FUNC void kore_unlock_achievement ( int id)

Unlocks an achievement or trophy or however you prefer to call it.

Parameters
idThe id of the achievement/tropy

◆ kore_waiting_for_login()

KORE_FUNC bool kore_waiting_for_login ( void )

Returns true if kore_login was called and the login-process is still ongoing.

Returns
Whether a login-process is still in progress

◆ kore_width()

KORE_FUNC int kore_width ( void )

Returns the current width of the initial application-window which is equivalent to calling kore_window_width(0).

Returns
The width of the initial window