GLPS Documentation

Version 1.0

Complete API reference and developer guides

4
Header Files
55
Functions
13
Data Types
0
Guides

API Reference

glps_audio_stream.h

Functions

glps_audio_stream_destroy

function

Destroys audio manager and releases all resources

Signature
void glps_audio_stream_destroy(glps_audio_stream * am);

Parameters

TypeNameDescription
glps_audio_stream *amAudio manager instance

Return Value

void

glps_audio_stream_pause

function

Pauses current playback

Signature
void glps_audio_stream_pause(glps_audio_stream * am);

Parameters

TypeNameDescription
glps_audio_stream *amAudio manager instance

Return Value

void

glps_audio_stream_resume

function

Resumes paused playback

Signature
void glps_audio_stream_resume(glps_audio_stream * am);

Parameters

TypeNameDescription
glps_audio_stream *amAudio manager instance

Return Value

void

glps_audio_stream_set_position

function

Sets playback position

Signature
void glps_audio_stream_set_position(glps_audio_stream * am, unsigned int position);

Parameters

TypeNameDescription
glps_audio_stream *amAudio manager instance
unsigned intpositionPosition in samples

Return Value

void

glps_audio_stream_set_volume

function

Sets playback volume

Signature
void glps_audio_stream_set_volume(glps_audio_stream * am, float volume);

Parameters

TypeNameDescription
glps_audio_stream *amAudio manager instance
floatvolumeVolume level (0.0 to 1.0)

Return Value

void

glps_audio_stream_stop

function

Initializes a new audio manager instance

Signature
void glps_audio_stream_stop(glps_audio_stream * am);

Parameters

TypeNameDescription
glps_audio_stream *am

Return Value

void

glps_thread.h

Data Types

typedef gthread_attr_t

typedef

typedef HANDLE gthread_t; /**< Thread handle type for Windows

Definition
typedef DWORD gthread_attr_t;          /**< Thread attribute type for Windows */

typedef gthread_attr_t

typedef

typedef pthread_t gthread_t; /**< Thread handle type for POSIX

Definition
typedef pthread_attr_t gthread_attr_t;    /**< Thread attribute type for POSIX */

typedef gthread_cond_t

typedef

typedef int gthread_mutexattr_t; /**< Mutex attribute type (unused)

Definition
typedef CONDITION_VARIABLE gthread_cond_t; /**< Condition variable type for Windows */

typedef gthread_cond_t

typedef

typedef pthread_mutexattr_t gthread_mutexattr_t; /**< Mutex attribute type for POSIX

Definition
typedef pthread_cond_t gthread_cond_t;       /**< Condition variable type for POSIX */

typedef gthread_condattr_t

typedef

typedef CONDITION_VARIABLE gthread_cond_t; /**< Condition variable type for Windows

Definition
typedef int gthread_condattr_t;            /**< Condition variable attribute type (unused) */

typedef gthread_condattr_t

typedef

typedef pthread_cond_t gthread_cond_t; /**< Condition variable type for POSIX

Definition
typedef pthread_condattr_t gthread_condattr_t; /**< Condition variable attribute type for POSIX */

typedef gthread_mutex_t

typedef

typedef DWORD gthread_attr_t; /**< Thread attribute type for Windows

Definition
typedef CRITICAL_SECTION gthread_mutex_t; /**< Mutex type for Windows */

typedef gthread_mutex_t

typedef

typedef pthread_attr_t gthread_attr_t; /**< Thread attribute type for POSIX

Definition
typedef pthread_mutex_t gthread_mutex_t;       /**< Mutex type for POSIX */

typedef gthread_mutexattr_t

typedef

typedef CRITICAL_SECTION gthread_mutex_t; /**< Mutex type for Windows

Definition
typedef int gthread_mutexattr_t;           /**< Mutex attribute type (unused) */

typedef gthread_mutexattr_t

typedef

typedef pthread_mutex_t gthread_mutex_t; /**< Mutex type for POSIX

Definition
typedef pthread_mutexattr_t gthread_mutexattr_t; /**< Mutex attribute type for POSIX */

typedef gthread_t

typedef

Cross-platform thread, mutex, and condition variable abstractions for GLPS. Provides a unified interface for threads, mutexes, and condition variables on Windows and POSIX platforms.

Definition
typedef HANDLE gthread_t;              /**< Thread handle type for Windows */

typedef gthread_t

typedef

typedef int gthread_condattr_t; /**< Condition variable attribute type (unused)

Definition
typedef pthread_t gthread_t;              /**< Thread handle type for POSIX */

Functions

glps_thread_attr_destroy

function

Destroys a thread attribute object.

Signature
int glps_thread_attr_destroy(gthread_attr_t * attr);

Parameters

TypeNameDescription
gthread_attr_t *attrPointer to the attribute object.

Return Value

int

glps_thread_attr_getdetachstate

function

Gets the detach state of a thread attribute.

Signature
int glps_thread_attr_getdetachstate(const gthread_attr_t * attr, int * detachstate);

Parameters

TypeNameDescription
const gthread_attr_t *attrPointer to the attribute object.
int *detachstatePointer to store the detach state.

Return Value

int

glps_thread_attr_init

function

@}

Signature
int glps_thread_attr_init(gthread_attr_t * attr);

Parameters

TypeNameDescription
gthread_attr_t *attr

Return Value

int

glps_thread_attr_setdetachstate

function

Sets the detach state of a thread attribute.

Signature
int glps_thread_attr_setdetachstate(gthread_attr_t * attr, int detachstate);

Parameters

TypeNameDescription
gthread_attr_t *attrPointer to the attribute object.
intdetachstateDetach state (0 = joinable, 1 = detached).

Return Value

int

glps_thread_cond_broadcast

function

Broadcasts a condition variable. Wakes up all threads waiting on the condition variable.

Signature
int glps_thread_cond_broadcast(gthread_cond_t * cond);

Parameters

TypeNameDescription
gthread_cond_t *condPointer to the condition variable.

Return Value

int

glps_thread_cond_destroy

function

Destroys a condition variable.

Signature
int glps_thread_cond_destroy(gthread_cond_t * cond);

Parameters

TypeNameDescription
gthread_cond_t *condPointer to the condition variable to destroy.

Return Value

int

glps_thread_cond_init

function

@}

Signature
int glps_thread_cond_init(gthread_cond_t * cond, const gthread_condattr_t * attr);

Parameters

TypeNameDescription
gthread_cond_t *cond
const gthread_condattr_t *attr

Return Value

int

glps_thread_cond_signal

function

Signals a condition variable. Wakes up one thread waiting on the condition variable.

Signature
int glps_thread_cond_signal(gthread_cond_t * cond);

Parameters

TypeNameDescription
gthread_cond_t *condPointer to the condition variable.

Return Value

int

glps_thread_cond_wait

function

Waits on a condition variable. Unlocks the given mutex and blocks until the condition variable is signaled. The mutex is automatically re-acquired before returning.

Signature
int glps_thread_cond_wait(gthread_cond_t * cond, gthread_mutex_t * mutex);

Parameters

TypeNameDescription
gthread_cond_t *condPointer to the condition variable.
gthread_mutex_t *mutexPointer to the associated mutex.

Return Value

int

glps_thread_detach

function

Detaches a thread. Marks the thread as detached so its resources are automatically released upon termination.

Signature
int glps_thread_detach(gthread_t thread);

Parameters

TypeNameDescription
gthread_tthreadThread handle to detach.

Return Value

int

glps_thread_equal

function

Compares two threads for equality.

Signature
int glps_thread_equal(gthread_t t1, gthread_t t2);

Parameters

TypeNameDescription
gthread_tt1First thread handle.
gthread_tt2Second thread handle.

Return Value

int

glps_thread_exit

function

Exits the calling thread. Terminates the current thread and optionally provides a return value.

Signature
void glps_thread_exit(void * retval);

Parameters

TypeNameDescription
void *retvalPointer to the return value of the thread.

Return Value

void

glps_thread_join

function

Waits for a thread to terminate. Blocks the calling thread until the specified thread finishes execution.

Signature
int glps_thread_join(gthread_t thread, void ** retval);

Parameters

TypeNameDescription
gthread_tthreadThread handle to wait for.
void **retvalOptional pointer to store the thread's return value (can be NULL).

Return Value

int

glps_thread_mutex_destroy

function

Destroys a mutex.

Signature
int glps_thread_mutex_destroy(gthread_mutex_t * mutex);

Parameters

TypeNameDescription
gthread_mutex_t *mutexPointer to the mutex to destroy.

Return Value

int

glps_thread_mutex_init

function

@}

Signature
int glps_thread_mutex_init(gthread_mutex_t * mutex, const gthread_mutexattr_t * attr);

Parameters

TypeNameDescription
gthread_mutex_t *mutex
const gthread_mutexattr_t *attr

Return Value

int

glps_thread_mutex_lock

function

Locks a mutex. Blocks the calling thread until the mutex is acquired.

Signature
int glps_thread_mutex_lock(gthread_mutex_t * mutex);

Parameters

TypeNameDescription
gthread_mutex_t *mutexPointer to the mutex to lock.

Return Value

int

glps_thread_mutex_trylock

function

Attempts to lock a mutex without blocking.

Signature
int glps_thread_mutex_trylock(gthread_mutex_t * mutex);

Parameters

TypeNameDescription
gthread_mutex_t *mutexPointer to the mutex.

Return Value

int

glps_thread_mutex_unlock

function

Unlocks a mutex. Releases a previously acquired mutex.

Signature
int glps_thread_mutex_unlock(gthread_mutex_t * mutex);

Parameters

TypeNameDescription
gthread_mutex_t *mutexPointer to the mutex to unlock.

Return Value

int

glps_thread_self

function

Returns the calling thread's handle.

Signature
gthread_t glps_thread_self();

Return Value

gthread_t

glps_timer.h

Data Types

struct glps_timer

struct

Represents a high-resolution timer in GLPS.

Members

TypeNameDescription
uint64_tstart_time_ms
uint64_tend_time_ms
uint64_tduration_ms
timer_callbackcallback
void*callback_arg
boolis_valid
Definition
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

function

Represents a high-resolution timer in GLPS.

Signature
glps_timer *glps_timer_init();

Return Value

glps_timer

glps_timer_check_and_call

function

Checks if the timer has expired and calls the callback if it has.

Signature
void glps_timer_check_and_call(glps_timer * timer);

Parameters

TypeNameDescription
glps_timer *timerPointer to the glps_timer instance.

Return Value

void

glps_timer_destroy

function

Destroys a timer and frees associated resources.

Signature
void glps_timer_destroy(glps_timer * timer);

Parameters

TypeNameDescription
glps_timer *timerPointer to the glps_timer instance.

Return Value

void

glps_timer_elapsed_ms

function

Returns the elapsed time since the timer was started in milliseconds.

Signature
double glps_timer_elapsed_ms(glps_timer * timer);

Parameters

TypeNameDescription
glps_timer *timerPointer to the glps_timer instance.

Return Value

double

glps_timer_elapsed_us

function

Returns the elapsed time since the timer was started in microseconds.

Signature
double glps_timer_elapsed_us(glps_timer * timer);

Parameters

TypeNameDescription
glps_timer *timerPointer to the glps_timer instance.

Return Value

double

glps_timer_start

function

Starts a timer with a specified duration and callback.

Signature
void glps_timer_start(glps_timer * timer, uint64_t duration_ms, timer_callback callback, void * arg);

Parameters

TypeNameDescription
glps_timer *timerPointer to the glps_timer instance.
uint64_tduration_msDuration of the timer in milliseconds.
timer_callbackcallbackFunction to call when the timer expires.
void *argArgument to pass to the callback function.

Return Value

void

glps_timer_stop

function

Stops a running timer.

Signature
void glps_timer_stop(glps_timer * timer);

Parameters

TypeNameDescription
glps_timer *timerPointer to the glps_timer instance.

Return Value

void

glps_window_manager.h

Functions

*glps_get_proc_addr

function

Returns the address of an OpenGL/Vulkan procedure.

Signature
void *glps_get_proc_addr(const char * name);

Parameters

TypeNameDescription
const char *name

Return Value

void

*glps_wm_get_display

function

Returns the X11 Display pointer.

Signature
void *glps_wm_get_display(glps_WindowManager * wm);

Parameters

TypeNameDescription
glps_WindowManager *wm

Return Value

void

*glps_wm_init

function

Header 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.

Signature
glps_WindowManager *glps_wm_init();

Return Value

glps_WindowManager

*glps_wm_window_get_native_ptr

function

Gets the native window pointer for a given window.

Signature
void *glps_wm_window_get_native_ptr(glps_WindowManager * wm, size_t window_id);

Parameters

TypeNameDescription
glps_WindowManager *wmPointer to the GLPS Window Manager.
size_twindow_idID of the window.

Return Value

void

glps_wm_cursor_change

function

Sets the callback for mouse movement events.

Signature
void glps_wm_cursor_change(glps_WindowManager * wm, GLPS_CURSOR_TYPE cursor_type);

Parameters

TypeNameDescription
glps_WindowManager *wm
GLPS_CURSOR_TYPEcursor_type

Return Value

void

glps_wm_destroy

function

Cleans up and destroys the GLPS Window Manager.

Signature
void glps_wm_destroy(glps_WindowManager * wm);

Parameters

TypeNameDescription
glps_WindowManager *wmPointer to the GLPS Window Manager.

Return Value

void

glps_wm_get_fps

function

Starts a drag & drop operation.

Signature
double glps_wm_get_fps(glps_WindowManager * wm, size_t window_id);

Parameters

TypeNameDescription
glps_WindowManager *wm
size_twindow_id

Return Value

double

glps_wm_get_platform

function

Retrieves the platform identifier used by GLPS.

Signature
uint8_t glps_wm_get_platform();

Return Value

uint8_t

glps_wm_get_window_count

function

Returns the total number of windows.

Signature
size_t glps_wm_get_window_count(glps_WindowManager * wm);

Parameters

TypeNameDescription
glps_WindowManager *wmPointer to the GLPS Window Manager.

Return Value

size_t

glps_wm_set_window_background_transparent

function

Makes the window background transparent.

Signature
void glps_wm_set_window_background_transparent(glps_WindowManager * wm, size_t window_id);

Parameters

TypeNameDescription
glps_WindowManager *wmPointer to the GLPS Window Manager.
size_twindow_idID of the window.

Return Value

void

glps_wm_set_window_blur

function

Retrieves the dimensions of a window.

Signature
void glps_wm_set_window_blur(glps_WindowManager * wm, size_t window_id, bool enable, int blur_radius);

Parameters

TypeNameDescription
glps_WindowManager *wmPointer to the GLPS Window Manager.
size_twindow_idID of the window.
boolenable
intblur_radius

Return Value

void

glps_wm_set_window_ctx_curr

function

Sets the OpenGL context of a window as the current context.

Signature
void glps_wm_set_window_ctx_curr(glps_WindowManager * wm, size_t window_id);

Parameters

TypeNameDescription
glps_WindowManager *wmPointer to the GLPS Window Manager.
size_twindow_idID of the window.

Return Value

void

glps_wm_set_window_opacity

function

Sets window opacity.

Signature
void glps_wm_set_window_opacity(glps_WindowManager * wm, size_t window_id, float opacity);

Parameters

TypeNameDescription
glps_WindowManager *wmPointer to the GLPS Window Manager.
size_twindow_idID of the window.
floatopacityOpacity value (0.0 to 1.0).

Return Value

void

glps_wm_should_close

function

Checks if any window should close.

Signature
bool glps_wm_should_close(glps_WindowManager * wm);

Parameters

TypeNameDescription
glps_WindowManager *wmPointer to the GLPS Window Manager.

Return Value

bool

glps_wm_swap_buffers

function

Swaps the front and back buffers for a window.

Signature
void glps_wm_swap_buffers(glps_WindowManager * wm, size_t window_id);

Parameters

TypeNameDescription
glps_WindowManager *wmPointer to the GLPS Window Manager.
size_twindow_idID of the window.

Return Value

void

glps_wm_swap_interval

function

Sets the swap interval for buffer swaps.

Signature
void glps_wm_swap_interval(glps_WindowManager * wm, unsigned int swap_interval);

Parameters

TypeNameDescription
glps_WindowManager *wmPointer to the GLPS Window Manager.
unsigned intswap_intervalNumber of vertical refreshes between swaps.

Return Value

void

glps_wm_toggle_window_decorations

function

Checks if required extensions are available

Signature
void glps_wm_toggle_window_decorations(glps_WindowManager * wm, bool state, size_t window_id);

Parameters

TypeNameDescription
glps_WindowManager *wm
boolstate
size_twindow_id

Return Value

void

glps_wm_vk_create_surface

function

Creates a Vulkan surface for a window.

Signature
void glps_wm_vk_create_surface(glps_WindowManager * wm, size_t window_id, VkInstance * instance, VkSurfaceKHR * surface);

Parameters

TypeNameDescription
glps_WindowManager *wm
size_twindow_id
VkInstance *instance
VkSurfaceKHR *surface

Return Value

void

glps_wm_vk_free_extensions_arr

function

Frees memory allocated by glps_wm_vk_get_extensions_arr()

Signature
void glps_wm_vk_free_extensions_arr(glps_VulkanExtensionArray * extensions);

Parameters

TypeNameDescription
glps_VulkanExtensionArray *extensionsPointer to extensions array to free

Return Value

void

glps_wm_vk_get_extensions_arr

function

Retrieves available Vulkan instance extensions with proper memory management

Signature
glps_VulkanExtensionArray glps_wm_vk_get_extensions_arr();

Return Value

glps_VulkanExtensionArray

glps_wm_window_destroy

function

Destroys a window.

Signature
void glps_wm_window_destroy(glps_WindowManager * wm, size_t window_id);

Parameters

TypeNameDescription
glps_WindowManager *wmPointer to the GLPS Window Manager.
size_twindow_idID of the window.

Return Value

void

glps_wm_window_is_resizable

function

Creates a new window.

Signature
void glps_wm_window_is_resizable(glps_WindowManager * wm, bool state, size_t window_id);

Parameters

TypeNameDescription
glps_WindowManager *wmPointer to the GLPS Window Manager.
boolstate
size_twindow_id

Return Value

void

glps_wm_window_update

function

Updates a window (polls events, refreshes).

Signature
void glps_wm_window_update(glps_WindowManager * wm, size_t window_id);

Parameters

TypeNameDescription
glps_WindowManager *wmPointer to the GLPS Window Manager.
size_twindow_idID of the window.

Return Value

void