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-05-05 08:40:04 +00:00
|
|
|
Supports Linux 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-04 23:52:07 +00:00
|
|
|
**GN build system** is required for all platforms except Android (support for
|
|
|
|
APKs, Java code etc. is to be added to the GN configuration). \
|
2023-08-03 20:03:44 +00:00
|
|
|
Building GN from source:
|
|
|
|
https://gn.googlesource.com/gn/ \
|
|
|
|
Pre-built GN binaries:
|
|
|
|
https://chrome-infra-packages.appspot.com/p/gn/gn/
|
|
|
|
|
2023-08-04 08:27:13 +00:00
|
|
|
Linux is the supported host platform to build Android. **Gradle**,
|
|
|
|
**Android SDK** and **NDK** are required. If you prefer, you can install
|
2023-08-04 23:52:07 +00:00
|
|
|
**Android Studio** which includes all the requirements.
|
2023-07-29 20:50:29 +00:00
|
|
|
|
|
|
|
## Building from the command-line:
|
|
|
|
|
|
|
|
### All platforms except Android:
|
|
|
|
Setup:
|
2020-06-30 22:23:07 +00:00
|
|
|
```text
|
2023-07-29 20:50:29 +00:00
|
|
|
gn gen out/release
|
|
|
|
gn gen --args='is_debug=true' out/debug
|
2020-06-30 22:23:07 +00:00
|
|
|
```
|
2023-07-29 20:50:29 +00:00
|
|
|
Building and running:
|
|
|
|
```text
|
|
|
|
ninja -C out/debug
|
|
|
|
./out/debug/hello_world
|
|
|
|
./out/debug/demo
|
|
|
|
```
|
|
|
|
### Android:
|
2020-06-30 22:23:07 +00:00
|
|
|
```text
|
|
|
|
cd build/android
|
2023-07-29 20:50:29 +00:00
|
|
|
./gradlew :app:installDebug
|
2020-06-30 22:23:07 +00:00
|
|
|
```
|
2023-07-29 20:50:29 +00:00
|
|
|
|
|
|
|
## Third-party libraries:
|
|
|
|
|
2020-06-30 22:23:07 +00:00
|
|
|
[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),
|
2020-12-24 23:22:41 +00:00
|
|
|
[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),
|
2023-05-19 12:49:33 +00:00
|
|
|
[vulkan-sdk](https://vulkan.lunarg.com),
|
2023-05-12 21:22:18 +00:00
|
|
|
[volk](https://github.com/zeux/volk)
|
2023-07-28 16:25:33 +00:00
|
|
|
|
2023-07-29 20:50:29 +00:00
|
|
|
## Hello World example:
|
2023-07-28 16:25:33 +00:00
|
|
|
|
2023-07-29 20:50:29 +00:00
|
|
|
Shows a smoothly rotating "Hello Wolrd!".
|
|
|
|
```cpp
|
2023-07-28 16:25:33 +00:00
|
|
|
class HelloWorld final : public eng::Game {
|
|
|
|
public:
|
|
|
|
~HelloWorld() final = default;
|
|
|
|
|
|
|
|
bool Initialize() final {
|
|
|
|
eng::Engine::Get().SetImageSource(
|
|
|
|
"hello_world_image",
|
|
|
|
std::bind(&eng::Engine::Print, &eng::Engine::Get(), "Hello World!",
|
|
|
|
base::Vector4f(1, 1, 1, 0)));
|
|
|
|
|
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_);
|
|
|
|
animator_.SetRotation(base::PI2f, 3,
|
|
|
|
std::bind(base::SmootherStep, std::placeholders::_1));
|
|
|
|
animator_.Play(eng::Animator::kRotation, true);
|
|
|
|
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
|
|
|
```
|