Compare commits

..

No commits in common. "2d35d0ef5302b1f5d827c9e6462e2f0d84f7c83c" and "0a78316bcead4984baa98b6d2bf5fe035ba49d87" have entirely different histories.

10 changed files with 26 additions and 43 deletions

5
.vscode/launch.json vendored
View File

@ -5,7 +5,7 @@
"version": "0.2.0",
"configurations": [
{
"name": "Debug demo - Linux",
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/out/debug/demo",
@ -25,7 +25,7 @@
"preLaunchTask": "Build project",
},
{
"name": "Debug demo - Windows",
"name": "C/C++: cl.exe build and debug active file",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}\\out\\debug\\demo.exe",
@ -34,7 +34,6 @@
"cwd": "${workspaceFolder}\\out\\debug",
"environment": [],
"externalConsole": false,
"preLaunchTask": "Build project",
}
]
}

View File

@ -1,20 +1,21 @@
# Kaliber
A simple, cross-platform 2D game engine with OpenGL and Vulkan renderers.
Supports Linux, Windows and Android platforms.
Supports Linux and Android platforms.
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)
based on this engine. Full game code and assets are included in this repository.
## Pre-requisites:
**GN build system** is required for all platforms except Android:\
https://gn.googlesource.com/gn/
**GN build system** is required for all platforms except Android (support for
APKs, Java code etc. is to be added to the GN configuration). \
Building GN from source:
https://gn.googlesource.com/gn/ \
Pre-built GN binaries:
https://chrome-infra-packages.appspot.com/p/gn/gn/
**Build Tools** is required to build for Windows. if you prefer, you can install
**Visual Studio** which includes the **Build Tools**.
Linux is the supported host platform to build for Android. **Gradle**,
Linux is the supported host platform to build Android. **Gradle**,
**Android SDK** and **NDK** are required. If you prefer, you can install
**Android Studio** which includes all the requirements.
@ -24,7 +25,7 @@ Linux is the supported host platform to build for Android. **Gradle**,
Setup:
```text
gn gen out/release
gn gen --args="is_debug=true" out/debug
gn gen --args='is_debug=true' out/debug
```
Building and running:
```text
@ -32,9 +33,6 @@ ninja -C out/debug
./out/debug/hello_world
./out/debug/demo
```
Building and debugging from VS Code:
* Select "Debug demo - [platform]" from the "Run and Debug" drop down.
* Press F5.
### Android:
```text
cd build/android

View File

@ -203,8 +203,6 @@ config("warnings") {
"/wd4305", # truncation from 'double' to 'float'.
"/wd4365", # conversion, signed/unsigned mismatch.
# "/wd5219", # conversion, possible loss of data. 'int' to 'float'
"/wd4722", # destructor never returns, potential memory leak
"/wd4702", # unreachable code
# Possible compiler bug? Needs investigation.
"/wd4668", # '__STDC_WANT_SECURE_LIB__' is not defined as a preprocessor

View File

@ -134,11 +134,9 @@ add_library(kaliber SHARED
../../../src/third_party/glslang/SPIRV/SPVRemapper.cpp
../../../src/third_party/glslang/SPIRV/SpvTools.cpp
../../../src/third_party/jsoncpp/jsoncpp.cpp
../../../src/third_party/minimp3/minimp3.cc
../../../src/third_party/minizip/ioapi.c
../../../src/third_party/minizip/unzip.c
../../../src/third_party/spirv-reflect/spirv_reflect.c
../../../src/third_party/stb/stb_image.cc
../../../src/third_party/texture_compressor/dxt_encoder_internals.cc
../../../src/third_party/texture_compressor/dxt_encoder.cc
../../../src/third_party/texture_compressor/texture_compressor_etc1.cc

View File

@ -4,11 +4,11 @@
#include <android/log.h>
#elif defined(_WIN32)
#include <windows.h>
#include <format>
#else
#include <cstdio>
#include <iostream>
#endif
#include <cstdlib>
#include <format>
#include <string>
namespace base {
@ -38,17 +38,14 @@ LogMessage::~LogMessage() {
size_t last_slash_pos = filename.find_last_of("\\/");
if (last_slash_pos != std::string::npos)
filename = filename.substr(last_slash_pos + 1);
std::string log_str = std::format("{} [{}:{}] {}", verbosity_level_,
filename.c_str(), line_, message.c_str());
#if defined(__ANDROID__)
__android_log_print(ANDROID_LOG_ERROR, "kaliber", "%d [%s:%d] %s",
verbosity_level_, filename.c_str(), line_,
message.c_str());
__android_log_print(ANDROID_LOG_ERROR, "kaliber", "%s", log_str.c_str());
#elif defined(_WIN32)
OutputDebugStringA(
std::format("{} [{}:{}] {}", verbosity_level_, filename, line_, message)
.c_str());
OutputDebugStringA(log_str.c_str());
#else
printf("%d [%s:%d] %s", verbosity_level_, filename.c_str(), line_,
message.c_str());
std::clog << log_str;
#endif
}

View File

@ -62,7 +62,9 @@ source_set("engine") {
libs = []
if (target_os == "linux" || target_os == "win") {
sources += [ "platform/asset_file_generic.cc" ]
sources += [
"platform/asset_file_generic.cc",
]
}
if (target_os == "linux") {

View File

@ -2,29 +2,21 @@
#define ENGINE_RENDERER_OPENGL_OPENGL_H
#if defined(__ANDROID__)
// Use the modified Khronos header from ndk-helper. This gives access to
// additional functionality the drivers may expose but which the system headers
// do not.
#include "third_party/android/gl3stub.h"
#include <GLES2/gl2ext.h>
#elif defined(__linux__)
#include "third_party/glew/glew.h"
#include "third_party/glew/glxew.h"
#elif defined(_WIN32)
#define GLEW_STATIC
#include "third_party/glew/glew.h"
#include "third_party/glew/wglew.h"
#endif
#if defined(__linux__) || defined(_WIN32)
// Define the missing format for the etc1
#ifndef GL_ETC1_RGB8_OES
#define GL_ETC1_RGB8_OES 0x8D64

View File

@ -1,5 +1,7 @@
executable("hello_world") {
sources = [ "hello_world.cc" ]
sources = [
"hello_world.cc",
]
deps = [
"//src/base",

View File

@ -79,10 +79,7 @@ source_set("third_party") {
"volk/volk.c",
]
defines = [
"VMA_STATIC_VULKAN_FUNCTIONS=1",
"GLEW_STATIC",
]
defines = [ "VMA_STATIC_VULKAN_FUNCTIONS=1", "GLEW_STATIC" ]
if (target_os == "linux" || target_os == "win") {
sources += [