Compare commits

..

5 Commits

Author SHA1 Message Date
Attila Uygun 2d35d0ef53 fix 2023-08-13 00:00:09 +02:00
Attila Uygun b06092ef8d more warnings 2023-08-12 22:56:01 +02:00
Attila Uygun 66990f26ba readme 2023-08-12 23:39:57 +02:00
Attila Uygun 7c148d7555 format 2023-08-12 23:08:04 +02:00
Attila Uygun 1b6352b775 fix 2023-08-12 22:57:54 +02:00
10 changed files with 43 additions and 26 deletions

5
.vscode/launch.json vendored
View File

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

View File

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

View File

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

View File

@ -134,9 +134,11 @@ add_library(kaliber SHARED
../../../src/third_party/glslang/SPIRV/SPVRemapper.cpp ../../../src/third_party/glslang/SPIRV/SPVRemapper.cpp
../../../src/third_party/glslang/SPIRV/SpvTools.cpp ../../../src/third_party/glslang/SPIRV/SpvTools.cpp
../../../src/third_party/jsoncpp/jsoncpp.cpp ../../../src/third_party/jsoncpp/jsoncpp.cpp
../../../src/third_party/minimp3/minimp3.cc
../../../src/third_party/minizip/ioapi.c ../../../src/third_party/minizip/ioapi.c
../../../src/third_party/minizip/unzip.c ../../../src/third_party/minizip/unzip.c
../../../src/third_party/spirv-reflect/spirv_reflect.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_internals.cc
../../../src/third_party/texture_compressor/dxt_encoder.cc ../../../src/third_party/texture_compressor/dxt_encoder.cc
../../../src/third_party/texture_compressor/texture_compressor_etc1.cc ../../../src/third_party/texture_compressor/texture_compressor_etc1.cc

View File

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

View File

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

View File

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

View File

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

View File

@ -79,7 +79,10 @@ source_set("third_party") {
"volk/volk.c", "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") { if (target_os == "linux" || target_os == "win") {
sources += [ sources += [