How to load and display a bitmap in a window.
#define BJ_AUTOMAIN_CALLBACKS
#include <banjo/event.h>
#include <banjo/main.h>
int bj_app_begin(void** user_data, int argc, char* argv[]) {
(void)user_data; (void)argc; (void)argv;
return bj_callback_exit_error;
}
bj_bitmap_width(bmp_sprite_sheet) * 10,
bj_bitmap_height(bmp_sprite_sheet) * 10,
0
);
bj_bitmap_blit_stretched(bmp_sprite_sheet, 0, p_window_framebuffer, 0,
BJ_BLIT_OP_COPY);
return bj_callback_continue;
}
int bj_app_iterate(void* user_data) {
(void)user_data;
? bj_callback_exit_success
: bj_callback_continue;
}
int bj_app_end(void* user_data, int status) {
(void)user_data;
return status;
}
Header file for Bitmap type.
void bj_bitmap_del(bj_bitmap *p_bitmap)
Deletes a bj_bitmap object and releases associated memory.
struct bj_bitmap_t bj_bitmap
Typedef for the bj_bitmap struct.
Definition bitmap.h:40
bj_bitmap * bj_bitmap_new_from_file(const char *p_path, bj_error **p_error)
Creates a new bitmap by loading from a file.
@ BJ_BLIT_OP_COPY
Copy source to destination (fast path when formats match)
Definition bitmap.h:29
uint32_t code
Error code.
Definition error.h:132
char message[BJ_ERROR_MESSAGE_MAX_LEN+1]
Optional error description.
Definition error.h:133
Error structure.
Definition error.h:131
bj_key_callback_fn_t bj_set_key_callback(bj_key_callback_fn_t p_callback, void *p_user_data)
Set the global callback for keyboard key events.
void bj_dispatch_events(void)
Poll and dispatch all pending events.
void bj_close_on_escape(bj_window *, const bj_key_event *, void *p_user_data)
Handle the ESC key to close a window.
#define bj_err(...)
Log a message using the BJ_LOG_ERROR level.
Definition log.h:131
void bj_end(bj_error **p_error)
De-initializes the system.
bj_bool bj_begin(bj_error **p_error)
Initializes the system.
bj_window * bj_window_new(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.
bj_bool bj_window_should_close(bj_window *p_window)
Get the close flag state of a window.
struct bj_window_t bj_window
Opaque typedef for the window type.
Definition window.h:17
bj_bitmap * bj_window_get_framebuffer(bj_window *p_window, bj_error **p_error)
Return the framebuffer attached to the window.
void bj_window_del(bj_window *p_window)
Deletes a bj_window object and releases associated memory.
void bj_window_update_framebuffer(bj_window *p_window)
Copy window's framebuffer onto screen.
Logging utility functions.
All memory-related functions, including custom allocators.
Header file for system interactions.
Header file for time manipulation utilities.
Header file for bj_window type.