|
| 1 | +# Game Window API Reference |
| 2 | + |
| 3 | +This API provides access to the primary game window and allows registration of various input and lifecycle callbacks. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## Core Window Access |
| 8 | + |
| 9 | +| Symbol | Signature | Description | |
| 10 | +|--------|-----------|-------------| |
| 11 | +| `game_window_get_primary_window` | `GameWindowHandle*()` | Returns a pointer to the current primary game window | |
| 12 | + |
| 13 | +| `game_window_is_mouse_locked` | `bool(GameWindowHandle* handle)` | Checks if the mouse is currently locked in the window | |
| 14 | + |
| 15 | +| `game_window_get_input_mode` | `int(GameWindowHandle* handle)` | Retrieves the current input mode from the window callbacks | |
| 16 | + |
| 17 | +--- |
| 18 | + |
| 19 | +## Input Callback Registration |
| 20 | + |
| 21 | +These functions allow you to register input event handlers for keyboard and mouse interactions. |
| 22 | + |
| 23 | +| Symbol | Signature | Description | |
| 24 | +|--------|-----------|-------------| |
| 25 | +| `game_window_add_keyboard_callback` | `void(GameWindowHandle* handle, void* user, bool (*callback)(void* user, int keyCode, int action))` | Registers a keyboard input callback | |
| 26 | +| `game_window_add_mouse_button_callback` | `void(GameWindowHandle* handle, void* user, bool (*callback)(void* user, double x, double y, int button, int action))` | Registers a mouse button input callback | |
| 27 | +| `game_window_add_mouse_position_callback` | `void(GameWindowHandle* handle, void* user, bool (*callback)(void* user, double x, double y, bool relative))` | Registers a mouse movement callback | |
| 28 | +| `game_window_add_mouse_scroll_callback` | `void(GameWindowHandle* handle, void* user, bool (*callback)(void* user, double x, double y, double dx, double dy))` | Registers a mouse scroll callback | |
| 29 | + |
| 30 | +--- |
| 31 | + |
| 32 | +## Lifecycle & Rendering Callbacks |
| 33 | + |
| 34 | +| Symbol | Signature | Description | |
| 35 | +|--------|-----------|-------------| |
| 36 | +| `game_window_add_window_creation_callback` | `void(void* user, void (*onCreated)(void* user))` | Registers a callback to be invoked when the window is created | |
| 37 | +| `game_window_add_swap_buffers_callback` | `void(void* user, void (*callback)(void* user, EGLDisplay display, EGLSurface surface))` | Registers a callback for when buffers are swapped during rendering | |
| 38 | + |
| 39 | +--- |
| 40 | + |
| 41 | +## Library Integration |
| 42 | + |
| 43 | +Use dlopen and dlsym to load the library and access the functions |
| 44 | + |
| 45 | +```cpp |
| 46 | +dlopen("libmcpelauncher_gamewindow.so"); |
| 47 | +``` |
| 48 | +
|
| 49 | +--- |
| 50 | +
|
| 51 | +## Data Types |
| 52 | +
|
| 53 | +### `GameWindowHandle` |
| 54 | +
|
| 55 | +An opaque structure representing the game window. |
0 commit comments