Getting started¶
Graphics module initialization¶
Instead of calling the function haiku_module_create
, the user must call the function hkgfx_module_create
(and equivalent destroy function) to properly setup and cleanup the graphic backend implementation.
hkgfx_module_create( &(hk_module_desc) {
.allocator = {
.context = NULL,
.realloc_fn = my_sample_realloc,
.alloc_fn = my_sample_alloc,
.free_fn = my_sample_free,
},
.assertion = {
.context = NULL,
.assert_fn = my_sample_assert
},
.logger = {
.context = NULL,
.log_fn = my_sample_logger
}
});
/* [...] */
hkgfx_module_destroy();
-
void hkgfx_module_create(const hk_module_desc *desc)¶
Initialize Haiku Graphics module. This call is mandatory at the beginning of the program.
The user:
must provide its own memory allocator.
required
must provide its own logger function.
required
can provide its own assertion function.
optional
Assertions are muted in release using the usual NDEBUG mechanism.
Required user-defined allocator with the following fields:
A pointer to an user-defined context data structure
void* context;
A pointer to an allocation function
void* (*alloc_fn)(size_t bytesize, void* context);
A pointer to a deallocation function
void (*free_fn)(void* pointer, size_t bytesize, void* context);
A pointer to a reallocation function
void* (*realloc_fn)(size_t newsize, void* old_pointer, size_t oldsize, void* context);
Required user-defined logger with the following fields:
A pointer to an user-defined context data structure
void* context;
A pointer to a log function
void (*log_fn)(const char* message, void* context);
Optional user-defined assertion with the following fields:
A pointer to an user-defined context data structure
void* context;
A pointer to an assertion function
void (*assert_fn)(bool invariant, const char* message, void* context);
-
void hkgfx_module_destroy(void)¶
Deinitialize the haiku graphics module. This call is mandatory at the end of the program.
Graphics Definitions¶
haiku provides definitions to help user checking the compiled backend:
Variable
HAIKU_GFX_API_NAME
(ex: “Vulkan”)Variable
HAIKU_GFX_API_VERSION_MAJOR
(ex: 1)Variable
HAIKU_GFX_API_VERSION_MINOR
(ex: 3)Variable
HAIKU_GFX_API_SURFACE_NAME
(ex: “VK_KHR_win32_surface”)Definition
HAIKU_GFX_<BACKEND>
(ex:HAIKU_GFX_VULKAN
)