2023-08-04 23:52:07 +00:00
|
|
|
# Kaliber
|
2023-07-29 20:50:29 +00:00
|
|
|
|
2020-12-24 23:22:41 +00:00
|
|
|
A simple, cross-platform 2D game engine with OpenGL and Vulkan renderers.
|
2023-08-08 21:26:31 +00:00
|
|
|
Supports Linux, Windows and Android platforms.
|
2020-12-24 23:22:41 +00:00
|
|
|
This is a personal hobby project. I've published a little game on
|
|
|
|
[Google Play](https://play.google.com/store/apps/details?id=com.woom.game)
|
2021-08-31 21:21:29 +00:00
|
|
|
based on this engine. Full game code and assets are included in this repository.
|
2023-07-29 20:50:29 +00:00
|
|
|
|
2023-08-04 08:27:13 +00:00
|
|
|
## Pre-requisites:
|
2023-07-29 20:50:29 +00:00
|
|
|
|
2023-08-29 10:54:06 +00:00
|
|
|
GN build system is required for all platforms:\
|
2023-08-08 21:26:31 +00:00
|
|
|
https://gn.googlesource.com/gn/
|
2023-08-03 20:03:44 +00:00
|
|
|
|
2023-07-29 20:50:29 +00:00
|
|
|
## Building from the command-line:
|
|
|
|
|
|
|
|
### All platforms except Android:
|
2023-08-29 10:54:06 +00:00
|
|
|
#### Setup:
|
|
|
|
Generate build files for Ninja in release and debug modes.
|
2020-06-30 22:23:07 +00:00
|
|
|
```text
|
2023-07-29 20:50:29 +00:00
|
|
|
gn gen out/release
|
2023-08-29 10:54:06 +00:00
|
|
|
gn gen --args='is_debug=true' out/debug
|
2020-06-30 22:23:07 +00:00
|
|
|
```
|
2023-08-29 10:54:06 +00:00
|
|
|
#### Building and running:
|
|
|
|
Build all games in release mode and run "hello_world".
|
2023-07-29 20:50:29 +00:00
|
|
|
```text
|
2023-08-29 10:54:06 +00:00
|
|
|
ninja -C out/release
|
|
|
|
./out/release/hello_world
|
|
|
|
```
|
2023-09-03 19:33:10 +00:00
|
|
|
Build "demo" in debug mode and run.
|
2023-08-29 10:54:06 +00:00
|
|
|
```text
|
|
|
|
ninja -C out/debug demo
|
2023-07-29 20:50:29 +00:00
|
|
|
./out/debug/demo
|
|
|
|
```
|
2023-09-02 15:08:19 +00:00
|
|
|
|
2023-07-29 20:50:29 +00:00
|
|
|
### Android:
|
2023-09-03 19:33:10 +00:00
|
|
|
Build "hello_world" in debug mode for all ABIs and install. GN will be run by
|
2023-09-05 17:06:53 +00:00
|
|
|
Gradle so no setup is required. Location of gn and ninja executables can be
|
|
|
|
specified via "gn" and "ninja" properties (-Pgn="path/gn").
|
2020-06-30 22:23:07 +00:00
|
|
|
```text
|
|
|
|
cd build/android
|
2023-09-05 17:06:53 +00:00
|
|
|
./gradlew :app:installHelloWorldAllArchsDebug
|
2020-06-30 22:23:07 +00:00
|
|
|
```
|
2023-09-05 17:06:53 +00:00
|
|
|
Build "demo" in debug mode for x86_64 ABI and install. Valid ABI targets are
|
2023-09-05 16:04:47 +00:00
|
|
|
Arm7, Arm8, X86, X86_64, AllArchs, ArmOnly, X86Only.
|
2023-08-29 10:54:06 +00:00
|
|
|
```text
|
2023-09-05 16:04:47 +00:00
|
|
|
./gradlew :app:installDemoX86_64Debug
|
2023-08-29 10:54:06 +00:00
|
|
|
```
|
2023-09-02 15:08:19 +00:00
|
|
|
|
2023-08-13 22:14:34 +00:00
|
|
|
### Generate Visual Studio solution:
|
|
|
|
```text
|
|
|
|
gn.exe gen --args="is_debug=true" --ide=vs2022 out\vs
|
|
|
|
devenv out\vs\all.sln
|
|
|
|
```
|
2023-07-29 20:50:29 +00:00
|
|
|
|
|
|
|
## Hello World example:
|
2023-07-28 16:25:33 +00:00
|
|
|
|
2023-09-05 20:09:47 +00:00
|
|
|
Shows a smoothly rotating "Hello World".
|
2023-07-29 20:50:29 +00:00
|
|
|
```cpp
|
2023-07-28 16:25:33 +00:00
|
|
|
class HelloWorld final : public eng::Game {
|
|
|
|
public:
|
|
|
|
bool Initialize() final {
|
|
|
|
eng::Engine::Get().SetImageSource(
|
|
|
|
"hello_world_image",
|
2023-09-05 20:09:47 +00:00
|
|
|
std::bind(&eng::Engine::Print, &eng::Engine::Get(), "Hello World",
|
|
|
|
/*bg_color*/ base::Vector4f(1, 1, 1, 0)));
|
2023-07-28 16:25:33 +00:00
|
|
|
|
2023-08-04 23:52:07 +00:00
|
|
|
hello_world_.Create("hello_world_image").SetVisible(true);
|
2023-07-28 16:25:33 +00:00
|
|
|
animator_.Attach(&hello_world_);
|
2023-09-05 20:09:47 +00:00
|
|
|
animator_.SetRotation(base::PI2f, /*duration*/ 3,
|
2023-07-28 16:25:33 +00:00
|
|
|
std::bind(base::SmootherStep, std::placeholders::_1));
|
2023-09-05 20:09:47 +00:00
|
|
|
animator_.Play(eng::Animator::kRotation, /*loop*/ true);
|
2023-07-28 16:25:33 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
eng::ImageQuad hello_world_;
|
|
|
|
eng::Animator animator_;
|
|
|
|
};
|
|
|
|
|
2023-08-04 23:52:07 +00:00
|
|
|
GAME_FACTORIES{GAME_CLASS(HelloWorld)};
|
2023-07-28 16:25:33 +00:00
|
|
|
```
|
2023-09-02 15:08:19 +00:00
|
|
|
|
|
|
|
## Third-party libraries:
|
|
|
|
|
|
|
|
[glew](https://github.com/nigels-com/glew),
|
|
|
|
[jsoncpp](https://github.com/open-source-parsers/jsoncpp),
|
|
|
|
[minimp3](https://github.com/lieff/minimp3),
|
|
|
|
[oboe](https://github.com/google/oboe),
|
|
|
|
[stb](https://github.com/nothings/stb),
|
|
|
|
[texture-compressor](https://github.com/auygun/kaliber/tree/master/src/third_party/texture_compressor),
|
|
|
|
[minizip](https://github.com/madler/zlib/tree/master/contrib/minizip),
|
|
|
|
[glslang](https://github.com/KhronosGroup/glslang),
|
|
|
|
[spirv-reflect](https://github.com/KhronosGroup/SPIRV-Reflect),
|
|
|
|
[vma](https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator),
|
|
|
|
[vulkan-sdk](https://vulkan.lunarg.com),
|
2023-10-14 19:07:05 +00:00
|
|
|
[volk](https://github.com/zeux/volk),
|
|
|
|
[imgui](https://github.com/ocornut/imgui)
|