Banjo API 1.1.0-alpha
Low-level C99 game development API
Loading...
Searching...
No Matches
window.h
Go to the documentation of this file.
1
103
104#ifndef BJ_WINDOW_H
105#define BJ_WINDOW_H
106
107#include <banjo/api.h>
108#include <banjo/error.h>
109#include <banjo/rect.h>
110
112struct bj_window;
113
126struct bj_render_target;
127
144typedef void (*bj_window_draw_fn)(
145 struct bj_window* window,
146 struct bj_render_target* target,
147 const struct bj_rect* dirty,
148 void* user_data
149);
150
177typedef void (*bj_window_resize_fn)(
178 struct bj_window* window,
179 int width,
180 int height,
181 void* user_data
182);
183
200#ifndef BJ_NO_TYPEDEF
202#endif
203
227 const char* title,
228 uint16_t x,
229 uint16_t y,
230 uint16_t width,
231 uint16_t height,
232 uint8_t flags,
233 struct bj_error** error
234);
235
237BANJO_EXPORT struct bj_window* bj_bind_window(const char* title, uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint8_t flags, struct bj_error** error);
238
249 struct bj_window* window
250);
251
254
266 struct bj_window* window
267);
268
278 struct bj_window* window
279);
280
283
293 struct bj_window* window
294);
295
305 struct bj_window* window,
306 uint8_t flag
307);
308
311BANJO_EXPORT uint8_t bj_get_window_flags(struct bj_window* window, uint8_t flags);
312
330 const struct bj_window* window,
331 int key
332);
333
336BANJO_EXPORT int bj_get_key(const struct bj_window* window, int key);
337
348 const struct bj_window* window,
349 int* width,
350 int* height
351);
352
354BANJO_EXPORT int bj_get_window_size(const struct bj_window* window, int* width, int* height);
355
378 struct bj_window* window,
380 void* user_data
381);
382
385
418 struct bj_window* window,
420 void* user_data
421);
422
425
449
461
465
475
478
500 struct bj_window* window,
501 const struct bj_rect* rect
502);
503
513static inline void bj_invalidate_window(struct bj_window* window) {
515}
516
539 struct bj_render_target* target
540);
541
542
543#endif
General-purpose definitions for Banjo API.
bj_window * window
Definition bitmap_blit.c:24
Recoverable error handling.
struct bj_render_target bj_render_target
Definition api.h:369
struct bj_error bj_error
Definition api.h:348
#define BANJO_EXPORT
Definition api.h:179
uint32_t bj_bool
Boolean type used throughout the Banjo API.
Definition api.h:264
struct bj_bitmap bj_bitmap
Definition api.h:340
struct bj_window bj_window
Definition api.h:384
Axis-aligned rectangle: a top-left corner plus a width and height.
Definition rect.h:33
uint8_t bj_get_window_flags(struct bj_window *window, uint8_t flags)
void(* bj_window_draw_fn)(struct bj_window *window, struct bj_render_target *target, const struct bj_rect *dirty, void *user_data)
Redraw callback signature.
Definition window.h:144
void bj_set_window_fullscreen(struct bj_window *window, bj_bool enable)
bj_bool bj_window_has_flag(struct bj_window *window, uint8_t flag)
Report whether a window has a given flag set.
void bj_set_draw_callback(struct bj_window *window, bj_window_draw_fn fn, void *user_data)
static void bj_invalidate_window(struct bj_window *window)
Mark the whole window as needing a repaint.
Definition window.h:513
bj_bool bj_window_should_close(struct bj_window *window)
Report whether a window's close flag is set.
struct bj_window * bj_create_window(const char *title, uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint8_t flags, struct bj_error **error)
Create a window with the given attributes.
void bj_set_window_draw_callback(struct bj_window *window, bj_window_draw_fn fn, void *user_data)
Register the redraw callback for window.
void bj_set_window_should_close(struct bj_window *window)
Flag a window to be closed.
bj_bool bj_is_window_fullscreen(struct bj_window *window)
struct bj_window * bj_bind_window(const char *title, uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint8_t flags, struct bj_error **error)
void bj_window_leave_fullscreen(struct bj_window *window)
Return window from fullscreen to a normal window.
int bj_get_key(const struct bj_window *window, int key)
bj_window_flag
A set of flags describing some properties of a bj_window.
Definition window.h:192
void bj_window_enter_fullscreen(struct bj_window *window)
Put window into fullscreen.
bj_bool bj_window_is_key_pressed(const struct bj_window *window, int key)
Report whether a key is currently held down on a window.
void bj_set_resize_callback(struct bj_window *window, bj_window_resize_fn fn, void *user_data)
struct bj_bitmap * bj_render_target_bitmap(struct bj_render_target *target)
Reach the software framebuffer behind a render target.
void(* bj_window_resize_fn)(struct bj_window *window, int width, int height, void *user_data)
Window-resize callback signature.
Definition window.h:177
bj_bool bj_window_is_fullscreen(struct bj_window *window)
Report whether window is currently fullscreen.
void bj_set_window_resize_callback(struct bj_window *window, bj_window_resize_fn fn, void *user_data)
Register the resize callback for window.
uint8_t bj_window_flags(struct bj_window *window)
Return all of a window's flags.
int bj_window_size(const struct bj_window *window, int *width, int *height)
Retrieve a window's drawable size, in pixels.
bj_bool bj_should_close_window(struct bj_window *window)
void bj_unbind_window(struct bj_window *window)
void bj_destroy_window(struct bj_window *window)
Destroy a window and release its resources.
int bj_get_window_size(const struct bj_window *window, int *width, int *height)
void bj_invalidate_rect(struct bj_window *window, const struct bj_rect *rect)
Mark a region of window as needing a repaint.
@ BJ_WINDOW_FLAG_NONE
No Flag.
Definition window.h:193
@ BJ_WINDOW_FLAG_FULLSCREEN
Start the window fullscreen (see bj_window_enter_fullscreen).
Definition window.h:197
@ BJ_WINDOW_FLAG_KEY_REPEAT
Key repeat event is enabled (see bj_set_key_callback).
Definition window.h:195
@ BJ_WINDOW_FLAG_RESIZABLE
User may resize the window.
Definition window.h:196
@ BJ_WINDOW_FLAG_ALL
All flags set.
Definition window.h:198
@ BJ_WINDOW_FLAG_CLOSE
Window should be closed by the application.
Definition window.h:194
Axis-aligned rectangle in pixel coordinates.