Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jakubtomsu/odin-lbp-serialization
Easy-to-use LBP binary serialization utility for Odin.
https://github.com/jakubtomsu/odin-lbp-serialization
Last synced: 18 days ago
JSON representation
Easy-to-use LBP binary serialization utility for Odin.
- Host: GitHub
- URL: https://github.com/jakubtomsu/odin-lbp-serialization
- Owner: jakubtomsu
- License: mit
- Created: 2023-09-14T15:42:30.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-15T10:05:40.000Z (3 months ago)
- Last Synced: 2024-09-15T12:33:07.564Z (3 months ago)
- Language: Odin
- Size: 32.2 KB
- Stars: 28
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-odin - LBP Serialization - to-use LBP binary serialization utility | [MIT](https://github.com/jakubtomsu/odin-lbp-serialization/blob/main/LICENSE) | Gamedev, Serialization, Assets (Libraries / Gamedev)
README
# LBP serialization
This is a small drop-in code sample for binary [LBP](https://handmade.network/p/29/swedish-cubes-for-unity/blog/p/2723-how_media_molecule_does_serialization) serialization.The benefits of this method include:
- You need only one procedure for both seralization and deserialization. This way they can't go out of sync
- Full backwards compatibility with all previous versions
- no need for RTTI> [!NOTE]
> This doesn't serialize data automatically, you need to explicly write the procs. If you want more of a quick-and-dirty serialization I recommend you to check out marshalling in `core:encoding/json` or `core:encoding/cbor`## How to use
The serializer versioning and generic `serialize` procedure depend on other parts of your package, so the indented way of using this is to copy `serializer.odin` into your game package.## Simple example
```odin
Entity :: struct {
pos: [2]f32,
health: f32,
name: string,
foo: i32, // Added in version 'Add_Foo'
}entity_serialize :: proc(s: ^Serializer, entity: ^Entity, loc := #caller_location) -> bool {
// useful for debugging. Set serializer.debug.enable_debug_print to true to enable logging
serializer_debug_scope(s, "entity")
serialize(s, &entity.pos) or_return
serialize(s, &entity.health) or_return
serialize(s, &entity.name) or_return
if s.version >= .Add_Foo do serialize(s, &entity.foo) or_return
return true
}
```## Contributions
All contributions are welcome, I'll try to merge them when I have time!