GLPS Documentation
Version 1.0
Complete API reference and developer guides
API Reference
glps_audio_stream.h
Functions
glps_audio_stream_destroy
functionDestroys audio manager and releases all resources
void glps_audio_stream_destroy(glps_audio_stream * am);
Parameters
| Type | Name | Description |
|---|---|---|
glps_audio_stream * | am | Audio manager instance |
Return Value
void
glps_audio_stream_pause
functionPauses current playback
void glps_audio_stream_pause(glps_audio_stream * am);
Parameters
| Type | Name | Description |
|---|---|---|
glps_audio_stream * | am | Audio manager instance |
Return Value
void
glps_audio_stream_resume
functionResumes paused playback
void glps_audio_stream_resume(glps_audio_stream * am);
Parameters
| Type | Name | Description |
|---|---|---|
glps_audio_stream * | am | Audio manager instance |
Return Value
void
glps_audio_stream_set_position
functionSets playback position
void glps_audio_stream_set_position(glps_audio_stream * am, unsigned int position);
Parameters
| Type | Name | Description |
|---|---|---|
glps_audio_stream * | am | Audio manager instance |
unsigned int | position | Position in samples |
Return Value
void
glps_audio_stream_set_volume
functionSets playback volume
void glps_audio_stream_set_volume(glps_audio_stream * am, float volume);
Parameters
| Type | Name | Description |
|---|---|---|
glps_audio_stream * | am | Audio manager instance |
float | volume | Volume level (0.0 to 1.0) |
Return Value
void
glps_audio_stream_stop
functionInitializes a new audio manager instance
void glps_audio_stream_stop(glps_audio_stream * am);
Parameters
| Type | Name | Description |
|---|---|---|
glps_audio_stream * | am |
Return Value
void
glps_thread.h
Data Types
typedef gthread_attr_t
typedeftypedef HANDLE gthread_t; /**< Thread handle type for Windows
typedef DWORD gthread_attr_t; /**< Thread attribute type for Windows */
typedef gthread_attr_t
typedeftypedef pthread_t gthread_t; /**< Thread handle type for POSIX
typedef pthread_attr_t gthread_attr_t; /**< Thread attribute type for POSIX */
typedef gthread_cond_t
typedeftypedef int gthread_mutexattr_t; /**< Mutex attribute type (unused)
typedef CONDITION_VARIABLE gthread_cond_t; /**< Condition variable type for Windows */
typedef gthread_cond_t
typedeftypedef pthread_mutexattr_t gthread_mutexattr_t; /**< Mutex attribute type for POSIX
typedef pthread_cond_t gthread_cond_t; /**< Condition variable type for POSIX */
typedef gthread_condattr_t
typedeftypedef CONDITION_VARIABLE gthread_cond_t; /**< Condition variable type for Windows
typedef int gthread_condattr_t; /**< Condition variable attribute type (unused) */
typedef gthread_condattr_t
typedeftypedef pthread_cond_t gthread_cond_t; /**< Condition variable type for POSIX
typedef pthread_condattr_t gthread_condattr_t; /**< Condition variable attribute type for POSIX */
typedef gthread_mutex_t
typedeftypedef DWORD gthread_attr_t; /**< Thread attribute type for Windows
typedef CRITICAL_SECTION gthread_mutex_t; /**< Mutex type for Windows */
typedef gthread_mutex_t
typedeftypedef pthread_attr_t gthread_attr_t; /**< Thread attribute type for POSIX
typedef pthread_mutex_t gthread_mutex_t; /**< Mutex type for POSIX */
typedef gthread_mutexattr_t
typedeftypedef CRITICAL_SECTION gthread_mutex_t; /**< Mutex type for Windows
typedef int gthread_mutexattr_t; /**< Mutex attribute type (unused) */
typedef gthread_mutexattr_t
typedeftypedef pthread_mutex_t gthread_mutex_t; /**< Mutex type for POSIX
typedef pthread_mutexattr_t gthread_mutexattr_t; /**< Mutex attribute type for POSIX */
typedef gthread_t
typedefCross-platform thread, mutex, and condition variable abstractions for GLPS. Provides a unified interface for threads, mutexes, and condition variables on Windows and POSIX platforms.
typedef HANDLE gthread_t; /**< Thread handle type for Windows */
typedef gthread_t
typedeftypedef int gthread_condattr_t; /**< Condition variable attribute type (unused)
typedef pthread_t gthread_t; /**< Thread handle type for POSIX */
Functions
glps_thread_attr_destroy
functionDestroys a thread attribute object.
int glps_thread_attr_destroy(gthread_attr_t * attr);
Parameters
| Type | Name | Description |
|---|---|---|
gthread_attr_t * | attr | Pointer to the attribute object. |
Return Value
int
glps_thread_attr_getdetachstate
functionGets the detach state of a thread attribute.
int glps_thread_attr_getdetachstate(const gthread_attr_t * attr, int * detachstate);
Parameters
| Type | Name | Description |
|---|---|---|
const gthread_attr_t * | attr | Pointer to the attribute object. |
int * | detachstate | Pointer to store the detach state. |
Return Value
int
glps_thread_attr_init
function@}
int glps_thread_attr_init(gthread_attr_t * attr);
Parameters
| Type | Name | Description |
|---|---|---|
gthread_attr_t * | attr |
Return Value
int
glps_thread_attr_setdetachstate
functionSets the detach state of a thread attribute.
int glps_thread_attr_setdetachstate(gthread_attr_t * attr, int detachstate);
Parameters
| Type | Name | Description |
|---|---|---|
gthread_attr_t * | attr | Pointer to the attribute object. |
int | detachstate | Detach state (0 = joinable, 1 = detached). |
Return Value
int
glps_thread_cond_broadcast
functionBroadcasts a condition variable. Wakes up all threads waiting on the condition variable.
int glps_thread_cond_broadcast(gthread_cond_t * cond);
Parameters
| Type | Name | Description |
|---|---|---|
gthread_cond_t * | cond | Pointer to the condition variable. |
Return Value
int
glps_thread_cond_destroy
functionDestroys a condition variable.
int glps_thread_cond_destroy(gthread_cond_t * cond);
Parameters
| Type | Name | Description |
|---|---|---|
gthread_cond_t * | cond | Pointer to the condition variable to destroy. |
Return Value
int
glps_thread_cond_init
function@}
int glps_thread_cond_init(gthread_cond_t * cond, const gthread_condattr_t * attr);
Parameters
| Type | Name | Description |
|---|---|---|
gthread_cond_t * | cond | |
const gthread_condattr_t * | attr |
Return Value
int
glps_thread_cond_signal
functionSignals a condition variable. Wakes up one thread waiting on the condition variable.
int glps_thread_cond_signal(gthread_cond_t * cond);
Parameters
| Type | Name | Description |
|---|---|---|
gthread_cond_t * | cond | Pointer to the condition variable. |
Return Value
int
glps_thread_cond_wait
functionWaits on a condition variable. Unlocks the given mutex and blocks until the condition variable is signaled. The mutex is automatically re-acquired before returning.
int glps_thread_cond_wait(gthread_cond_t * cond, gthread_mutex_t * mutex);
Parameters
| Type | Name | Description |
|---|---|---|
gthread_cond_t * | cond | Pointer to the condition variable. |
gthread_mutex_t * | mutex | Pointer to the associated mutex. |
Return Value
int
glps_thread_detach
functionDetaches a thread. Marks the thread as detached so its resources are automatically released upon termination.
int glps_thread_detach(gthread_t thread);
Parameters
| Type | Name | Description |
|---|---|---|
gthread_t | thread | Thread handle to detach. |
Return Value
int
glps_thread_equal
functionCompares two threads for equality.
int glps_thread_equal(gthread_t t1, gthread_t t2);
Parameters
| Type | Name | Description |
|---|---|---|
gthread_t | t1 | First thread handle. |
gthread_t | t2 | Second thread handle. |
Return Value
int
glps_thread_exit
functionExits the calling thread. Terminates the current thread and optionally provides a return value.
void glps_thread_exit(void * retval);
Parameters
| Type | Name | Description |
|---|---|---|
void * | retval | Pointer to the return value of the thread. |
Return Value
void
glps_thread_join
functionWaits for a thread to terminate. Blocks the calling thread until the specified thread finishes execution.
int glps_thread_join(gthread_t thread, void ** retval);
Parameters
| Type | Name | Description |
|---|---|---|
gthread_t | thread | Thread handle to wait for. |
void ** | retval | Optional pointer to store the thread's return value (can be NULL). |
Return Value
int
glps_thread_mutex_destroy
functionDestroys a mutex.
int glps_thread_mutex_destroy(gthread_mutex_t * mutex);
Parameters
| Type | Name | Description |
|---|---|---|
gthread_mutex_t * | mutex | Pointer to the mutex to destroy. |
Return Value
int
glps_thread_mutex_init
function@}
int glps_thread_mutex_init(gthread_mutex_t * mutex, const gthread_mutexattr_t * attr);
Parameters
| Type | Name | Description |
|---|---|---|
gthread_mutex_t * | mutex | |
const gthread_mutexattr_t * | attr |
Return Value
int
glps_thread_mutex_lock
functionLocks a mutex. Blocks the calling thread until the mutex is acquired.
int glps_thread_mutex_lock(gthread_mutex_t * mutex);
Parameters
| Type | Name | Description |
|---|---|---|
gthread_mutex_t * | mutex | Pointer to the mutex to lock. |
Return Value
int
glps_thread_mutex_trylock
functionAttempts to lock a mutex without blocking.
int glps_thread_mutex_trylock(gthread_mutex_t * mutex);
Parameters
| Type | Name | Description |
|---|---|---|
gthread_mutex_t * | mutex | Pointer to the mutex. |
Return Value
int
glps_thread_mutex_unlock
functionUnlocks a mutex. Releases a previously acquired mutex.
int glps_thread_mutex_unlock(gthread_mutex_t * mutex);
Parameters
| Type | Name | Description |
|---|---|---|
gthread_mutex_t * | mutex | Pointer to the mutex to unlock. |
Return Value
int
glps_thread_self
functionReturns the calling thread's handle.
gthread_t glps_thread_self();
Return Value
gthread_t
glps_timer.h
Data Types
struct glps_timer
structRepresents a high-resolution timer in GLPS.
Members
| Type | Name | Description |
|---|---|---|
uint64_t | start_time_ms | |
uint64_t | end_time_ms | |
uint64_t | duration_ms | |
timer_callback | callback | |
void | *callback_arg | |
bool | is_valid |
typedef struct glps_timer {
uint64_t start_time_ms; /**< Start time of the timer in milliseconds. */
uint64_t end_time_ms; /**< End time of the timer in milliseconds. */
uint64_t duration_ms; /**< Duration of the timer in milliseconds. */
timer_callback callback; /**< Function to call when the timer expires. */
void *callback_arg; /**< Argument to pass to the callback function. */
bool is_valid; /**< Indicates if the timer is currently valid/active. */
} glps_timer;
Functions
*glps_timer_init
functionRepresents a high-resolution timer in GLPS.
glps_timer *glps_timer_init();
Return Value
glps_timer
glps_timer_check_and_call
functionChecks if the timer has expired and calls the callback if it has.
void glps_timer_check_and_call(glps_timer * timer);
Parameters
| Type | Name | Description |
|---|---|---|
glps_timer * | timer | Pointer to the glps_timer instance. |
Return Value
void
glps_timer_destroy
functionDestroys a timer and frees associated resources.
void glps_timer_destroy(glps_timer * timer);
Parameters
| Type | Name | Description |
|---|---|---|
glps_timer * | timer | Pointer to the glps_timer instance. |
Return Value
void
glps_timer_elapsed_ms
functionReturns the elapsed time since the timer was started in milliseconds.
double glps_timer_elapsed_ms(glps_timer * timer);
Parameters
| Type | Name | Description |
|---|---|---|
glps_timer * | timer | Pointer to the glps_timer instance. |
Return Value
double
glps_timer_elapsed_us
functionReturns the elapsed time since the timer was started in microseconds.
double glps_timer_elapsed_us(glps_timer * timer);
Parameters
| Type | Name | Description |
|---|---|---|
glps_timer * | timer | Pointer to the glps_timer instance. |
Return Value
double
glps_timer_start
functionStarts a timer with a specified duration and callback.
void glps_timer_start(glps_timer * timer, uint64_t duration_ms, timer_callback callback, void * arg);
Parameters
| Type | Name | Description |
|---|---|---|
glps_timer * | timer | Pointer to the glps_timer instance. |
uint64_t | duration_ms | Duration of the timer in milliseconds. |
timer_callback | callback | Function to call when the timer expires. |
void * | arg | Argument to pass to the callback function. |
Return Value
void
glps_timer_stop
functionStops a running timer.
void glps_timer_stop(glps_timer * timer);
Parameters
| Type | Name | Description |
|---|---|---|
glps_timer * | timer | Pointer to the glps_timer instance. |
Return Value
void
glps_window_manager.h
Functions
*glps_get_proc_addr
functionReturns the address of an OpenGL/Vulkan procedure.
void *glps_get_proc_addr(const char * name);
Parameters
| Type | Name | Description |
|---|---|---|
const char * | name |
Return Value
void
*glps_wm_get_display
functionReturns the X11 Display pointer.
void *glps_wm_get_display(glps_WindowManager * wm);
Parameters
| Type | Name | Description |
|---|---|---|
glps_WindowManager * | wm |
Return Value
void
*glps_wm_init
functionHeader file for the GLPS Window Manager. This module provides an abstraction for creating and managing windows, handling rendering contexts, input events, clipboard, drag & drop, and platform-specific operations for OpenGL and Vulkan.
glps_WindowManager *glps_wm_init();
Return Value
glps_WindowManager
*glps_wm_window_get_native_ptr
functionGets the native window pointer for a given window.
void *glps_wm_window_get_native_ptr(glps_WindowManager * wm, size_t window_id);
Parameters
| Type | Name | Description |
|---|---|---|
glps_WindowManager * | wm | Pointer to the GLPS Window Manager. |
size_t | window_id | ID of the window. |
Return Value
void
glps_wm_cursor_change
functionSets the callback for mouse movement events.
void glps_wm_cursor_change(glps_WindowManager * wm, GLPS_CURSOR_TYPE cursor_type);
Parameters
| Type | Name | Description |
|---|---|---|
glps_WindowManager * | wm | |
GLPS_CURSOR_TYPE | cursor_type |
Return Value
void
glps_wm_destroy
functionCleans up and destroys the GLPS Window Manager.
void glps_wm_destroy(glps_WindowManager * wm);
Parameters
| Type | Name | Description |
|---|---|---|
glps_WindowManager * | wm | Pointer to the GLPS Window Manager. |
Return Value
void
glps_wm_get_fps
functionStarts a drag & drop operation.
double glps_wm_get_fps(glps_WindowManager * wm, size_t window_id);
Parameters
| Type | Name | Description |
|---|---|---|
glps_WindowManager * | wm | |
size_t | window_id |
Return Value
double
glps_wm_get_platform
functionRetrieves the platform identifier used by GLPS.
uint8_t glps_wm_get_platform();
Return Value
uint8_t
glps_wm_get_window_count
functionReturns the total number of windows.
size_t glps_wm_get_window_count(glps_WindowManager * wm);
Parameters
| Type | Name | Description |
|---|---|---|
glps_WindowManager * | wm | Pointer to the GLPS Window Manager. |
Return Value
size_t
glps_wm_set_window_background_transparent
functionMakes the window background transparent.
void glps_wm_set_window_background_transparent(glps_WindowManager * wm, size_t window_id);
Parameters
| Type | Name | Description |
|---|---|---|
glps_WindowManager * | wm | Pointer to the GLPS Window Manager. |
size_t | window_id | ID of the window. |
Return Value
void
glps_wm_set_window_blur
functionRetrieves the dimensions of a window.
void glps_wm_set_window_blur(glps_WindowManager * wm, size_t window_id, bool enable, int blur_radius);
Parameters
| Type | Name | Description |
|---|---|---|
glps_WindowManager * | wm | Pointer to the GLPS Window Manager. |
size_t | window_id | ID of the window. |
bool | enable | |
int | blur_radius |
Return Value
void
glps_wm_set_window_ctx_curr
functionSets the OpenGL context of a window as the current context.
void glps_wm_set_window_ctx_curr(glps_WindowManager * wm, size_t window_id);
Parameters
| Type | Name | Description |
|---|---|---|
glps_WindowManager * | wm | Pointer to the GLPS Window Manager. |
size_t | window_id | ID of the window. |
Return Value
void
glps_wm_set_window_opacity
functionSets window opacity.
void glps_wm_set_window_opacity(glps_WindowManager * wm, size_t window_id, float opacity);
Parameters
| Type | Name | Description |
|---|---|---|
glps_WindowManager * | wm | Pointer to the GLPS Window Manager. |
size_t | window_id | ID of the window. |
float | opacity | Opacity value (0.0 to 1.0). |
Return Value
void
glps_wm_should_close
functionChecks if any window should close.
bool glps_wm_should_close(glps_WindowManager * wm);
Parameters
| Type | Name | Description |
|---|---|---|
glps_WindowManager * | wm | Pointer to the GLPS Window Manager. |
Return Value
bool
glps_wm_swap_buffers
functionSwaps the front and back buffers for a window.
void glps_wm_swap_buffers(glps_WindowManager * wm, size_t window_id);
Parameters
| Type | Name | Description |
|---|---|---|
glps_WindowManager * | wm | Pointer to the GLPS Window Manager. |
size_t | window_id | ID of the window. |
Return Value
void
glps_wm_swap_interval
functionSets the swap interval for buffer swaps.
void glps_wm_swap_interval(glps_WindowManager * wm, unsigned int swap_interval);
Parameters
| Type | Name | Description |
|---|---|---|
glps_WindowManager * | wm | Pointer to the GLPS Window Manager. |
unsigned int | swap_interval | Number of vertical refreshes between swaps. |
Return Value
void
glps_wm_toggle_window_decorations
functionChecks if required extensions are available
void glps_wm_toggle_window_decorations(glps_WindowManager * wm, bool state, size_t window_id);
Parameters
| Type | Name | Description |
|---|---|---|
glps_WindowManager * | wm | |
bool | state | |
size_t | window_id |
Return Value
void
glps_wm_vk_create_surface
functionCreates a Vulkan surface for a window.
void glps_wm_vk_create_surface(glps_WindowManager * wm, size_t window_id, VkInstance * instance, VkSurfaceKHR * surface);
Parameters
| Type | Name | Description |
|---|---|---|
glps_WindowManager * | wm | |
size_t | window_id | |
VkInstance * | instance | |
VkSurfaceKHR * | surface |
Return Value
void
glps_wm_vk_free_extensions_arr
functionFrees memory allocated by glps_wm_vk_get_extensions_arr()
void glps_wm_vk_free_extensions_arr(glps_VulkanExtensionArray * extensions);
Parameters
| Type | Name | Description |
|---|---|---|
glps_VulkanExtensionArray * | extensions | Pointer to extensions array to free |
Return Value
void
glps_wm_vk_get_extensions_arr
functionRetrieves available Vulkan instance extensions with proper memory management
glps_VulkanExtensionArray glps_wm_vk_get_extensions_arr();
Return Value
glps_VulkanExtensionArray
glps_wm_window_destroy
functionDestroys a window.
void glps_wm_window_destroy(glps_WindowManager * wm, size_t window_id);
Parameters
| Type | Name | Description |
|---|---|---|
glps_WindowManager * | wm | Pointer to the GLPS Window Manager. |
size_t | window_id | ID of the window. |
Return Value
void
glps_wm_window_is_resizable
functionCreates a new window.
void glps_wm_window_is_resizable(glps_WindowManager * wm, bool state, size_t window_id);
Parameters
| Type | Name | Description |
|---|---|---|
glps_WindowManager * | wm | Pointer to the GLPS Window Manager. |
bool | state | |
size_t | window_id |
Return Value
void
glps_wm_window_update
functionUpdates a window (polls events, refreshes).
void glps_wm_window_update(glps_WindowManager * wm, size_t window_id);
Parameters
| Type | Name | Description |
|---|---|---|
glps_WindowManager * | wm | Pointer to the GLPS Window Manager. |
size_t | window_id | ID of the window. |
Return Value
void