Coding Style and Conventions¶
haiku is primarly developed in C99 and C++17 (for libraries C++ implementations as in VMA)
Coding style:¶
modules are prefixed by
hkstruct names are prefixed by
hk_modulename_(ex:hk_gfx_)function are prefixed by
hkmodulename_(ex:hkgfx_)struct names and functions are in
snake_case_stylestruct names are suffixed by
_sand typedefs are suffixed by_tenumerations names and typedefs are suffixed by
_eenumerations items are written in
UPPERCASEand prefixed byHK_macros definitions are always written in
UPPERCASE_SCREAMING_STYLEDescription structures used for object creation are suffixed by
_descStructures used as function parameters/arguments are suffixed by
_params
Implementation choices:¶
haiku requires user to provide his own allocations, assertions and logging mechanisms:
hk_user_assert_t: a user-defined assertions (assertand an optional user context)hk_user_logger_t: a user-defined logging (logand an optional user context)hk_user_memory_allocator_t: a user-defined memory allocations (alloc/free/reallocand an optional user context)
haiku C implementation uses:
<string.h>formemset,memcpyandmemmove
haiku/graphics.h vulkan backend uses the following libraries
VulkanMemoryAllocator (as submodule) under MIT License
Vulkan-Headers (as submodule) dual-licensed under MIT or Apache-2.0
volk (as submodule) licensed under MIT
haiku/application.h backend requires one of the following libraries
GLFW under Zlib License
future html/emscripten implementation ?
maybe a future SDL implementation ?
Note
haiku C99 code base does not use <stdio.h> nor <stdlib.h> standard headers.
Useful links and references¶
Modern C for C++ peeps by Andre Weissflog
Automatic Language Bindings by Andre Weissflog
So you want custom allocator support in your C lirabry by Chris Wellons
An Opinionated Post on Modern Rendering Abstraction Layers by Alex Tardif
Resource State Management by Diligent Graphics
HypeHype Mobile Rendering Architecture by Sebastian Aaltonen
Modern Mobile Rendering @ HypeHype by Sebastian Aaltonen