Banjo API 0.0.1
C99 game development API
|
Typedefs | |
typedef struct bj_window_t | bj_window |
typedef enum bj_window_flag_t | bj_window_flag |
Enumerations | |
enum | bj_window_flag_t { BJ_WINDOW_FLAG_NONE = 0x00 , BJ_WINDOW_FLAG_CLOSE = 0x01 , BJ_WINDOW_FLAG_KEY_REPEAT = 0x02 , BJ_WINDOW_FLAG_ALL = 0xFF } |
Functions | |
bj_window * | bj_bind_window (const char *p_title, uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint8_t flags) |
void | bj_unbind_window (bj_window *p_window) |
void | bj_set_window_should_close (bj_window *p_window) |
bj_bool | bj_should_close_window (bj_window *p_window) |
uint8_t | bj_get_window_flags (bj_window *p_window, uint8_t flags) |
int | bj_get_key (const bj_window *p_window, int key) |
bj_bitmap * | bj_get_window_framebuffer (bj_window *p_window, bj_error **p_error) |
int | bj_get_window_size (const bj_window *p_window, int *width, int *height) |
void | bj_update_window_framebuffer (bj_window *p_window) |
Window creation and management API.
This module provides functions to create, destroy, and control application windows. It handles window properties such as position, size, flags, and attached framebuffers. It also provides input queries such as key state inspection.
Typical usage:
Banjo supports windows manipulation for Windows, GNU/Linux and WebAssembly.
Add support for windows on macOS
Add support for windows on Wayland
typedef struct bj_window_t bj_window |
Opaque typedef for the window type.
typedef enum bj_window_flag_t bj_window_flag |
A set of flags describing some properties of a bj_window.
These flags can be provided at window creation with bj_bind_window. The may also change during the window lifetime. You can use bj_get_window_flags to query the status of any flag on an active window instance.
enum bj_window_flag_t |
A set of flags describing some properties of a bj_window.
These flags can be provided at window creation with bj_bind_window. The may also change during the window lifetime. You can use bj_get_window_flags to query the status of any flag on an active window instance.
Enumerator | |
---|---|
BJ_WINDOW_FLAG_NONE | No Flag. |
BJ_WINDOW_FLAG_CLOSE | Window should be closed by the application. |
BJ_WINDOW_FLAG_KEY_REPEAT | Key repeat event is enabled (see bj_set_key_callback). |
BJ_WINDOW_FLAG_ALL | All flags set. |
bj_window * bj_bind_window | ( | const char * | p_title, |
uint16_t | x, | ||
uint16_t | y, | ||
uint16_t | width, | ||
uint16_t | height, | ||
uint8_t | flags ) |
Create a new bj_window with the specified attributes.
p_title | Title of the window |
x | Horizontal position of the window on-screen, expressed in pixels |
y | Vertical position of the window on-screen, expressed in pixels |
width | Width of the window. |
height | Height of the window. |
flags | A set of options flags. |
The caller is responsible for releasing the returned bj_window object with bj_unbind_window.
int bj_get_key | ( | const bj_window * | p_window, |
int | key ) |
Query the current state of a key for a given window.
Returns the state of the specified key as either BJ_RELEASE or BJ_PRESS. If p_window
is NULL or if key
is outside the valid range [0, 0xFE], the function returns BJ_RELEASE.
p_window | Pointer to the target window, or NULL |
key | Key code in [0, 0xFE] |
uint8_t bj_get_window_flags | ( | bj_window * | p_window, |
uint8_t | flags ) |
Get window flags.
This function returns all the flag sets for p_window. flags is a filter to only get the flag you are interested into. It can be a single flag, an OR'd combination of multiple flags or even BJ_WINDOW_FLAG_ALL if you want to retrieve them all.
p_window | The window handler. |
flags | Filter flag set. |
Return the framebuffer attached to the window.
The framebuffer is an instance of bj_bitmap attached (and owned) by the window. If necessary, bj_get_window_flags will create (or recreate) the framebuffer object upon calling this function. This can happen when the window is resize, minimized or any even that invalidate the window drawing area.
TODO: The instance should stay the same and the framebuffer only change internally.
p_window | The window handler |
p_error | Optional error location |
The function performs nothing if p_window is 0.
The library is responsible for the return bj_bitmap object.
int bj_get_window_size | ( | const bj_window * | p_window, |
int * | width, | ||
int * | height ) |
Retrieve the size of the window.
p_window | The window handler |
width | A location to the destination width |
height | A location to the destination height |
The function performs nothing if p_window is 0.
width and height can be 0 if you are only interested in retrieving one of the values.
You are responsible for the memory of width and height.
void bj_set_window_should_close | ( | bj_window * | p_window | ) |
Flag a given window to be closed.
Once, flagged, the window is not automatically closed. Instead, call bj_unbind_window.
Note that it is not possible to remove a closed flag once set.
p_window | Pointer to the window object to flag. |
This function effectively returns bj_get_window_flags(p_window, BJ_WINDOW_FLAG_CLOSE) > 0.
Get the close flag state of a window.
p_window | Pointer to the window object to flag. |
If p_window is 0, the function returns BJ_TRUE.
void bj_unbind_window | ( | bj_window * | p_window | ) |
Deletes a bj_window object and releases associated memory.
p_window | Pointer to the window object to delete. |
void bj_update_window_framebuffer | ( | bj_window * | p_window | ) |
Copy window's framebuffer onto screen.
p_window | The window handler |
Use this function to apply any change made to the framebuffer on the window.
The function performs nothing if p_window is 0 or does not contain any framebuffer.