cbuild 2.3.5

This commit is contained in:
2026-06-07 17:07:18 +05:00
parent ec781256cc
commit abb8d97a15
13 changed files with 106 additions and 102 deletions

View File

@@ -4,15 +4,16 @@
"name": "all", "name": "all",
"defines": [ "defines": [
"SDL_DISABLE_ANALYZE_MACROS", "SDL_DISABLE_ANALYZE_MACROS",
"DEBUG=1" "DEBUG=1",
], ],
"includePath": [ "includePath": [
"dependencies/include", "dependencies/include",
"dependencies/include/SDL2", "dependencies/include/SDL2",
"dependencies/cimgui/imgui", "dependencies/cimgui/imgui",
"${default}" "${default}",
], ],
"cppStandard": "c++20" "cppStandard": "c++20",
"cStandard": "c11",
} }
], ],
"version": 4 "version": 4

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
CBUILD_VERSION=2.2.1 CBUILD_VERSION=2.3.5
CONFIG_VERSION=1 CONFIG_VERSION=1
PROJECT="cimgui" PROJECT="cimgui"
@@ -7,8 +7,8 @@ CMP_C="gcc"
CMP_CPP="g++" CMP_CPP="g++"
STD_C="c11" STD_C="c11"
STD_CPP="c++11" STD_CPP="c++11"
WARN_C="-Wall -Wno-discarded-qualifiers -Wno-unused-parameter" WARN_C=""
WARN_CPP="-Wall -Wno-unused-parameter" WARN_CPP=""
SRC_C="" SRC_C=""
SRC_CPP="imgui/imgui.cpp SRC_CPP="imgui/imgui.cpp
imgui/imgui_demo.cpp imgui/imgui_demo.cpp
@@ -42,12 +42,12 @@ case "$OS" in
WINDOWS) WINDOWS)
SHARED_LIB_FILE="$PROJECT.dll" SHARED_LIB_FILE="$PROJECT.dll"
LINKER_LIBS="-L../precompiled/$OS-$ARCH -l:SDL2.dll" LINKER_LIBS="-L../precompiled/$OS-$ARCH -l:SDL2.dll"
DEFINE="-DIMGUI_API=__declspec(dllexport)" DEFINES="-DIMGUI_API=__declspec(dllexport)"
;; ;;
LINUX) LINUX)
SHARED_LIB_FILE="$PROJECT.so" SHARED_LIB_FILE="$PROJECT.so"
LINKER_LIBS="-lSDL2" LINKER_LIBS="-lSDL2"
DEFINE="-DIMGUI_API=__attribute__((__visibility__(\"default\")))" DEFINES="-DIMGUI_API=__attribute__((__visibility__(\"default\")))"
;; ;;
*) *)
error "operating system $OS has no configuration variants" error "operating system $OS has no configuration variants"
@@ -58,41 +58,33 @@ esac
case "$TASK" in case "$TASK" in
# creates shared library # creates shared library
build_shared_lib) build_shared_lib)
C_ARGS="-O2 -fpic -shared $DEFINE" C_ARGS="-O2 -fpic -shared $DEFINES"
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS -Wl,-soname,$SHARED_LIB_FILE" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS -Wl,-soname,$SHARED_LIB_FILE"
PRE_TASK_SCRIPT= TASK_SCRIPT="@cbuild/default_tasks/build_shared_lib.sh"
TASK_SCRIPT=cbuild/default_tasks/build_shared_lib.sh
POST_TASK_SCRIPT=
;; ;;
# creates shared library with debug symbols and no optimizations # creates shared library with debug symbols and no optimizations
build_shared_lib_dbg) build_shared_lib_dbg)
C_ARGS="-O0 -g3 -fpic -shared $DEFINE" C_ARGS="-O0 -g3 -fpic -shared $DEFINES"
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS -Wl,-soname,$SHARED_LIB_FILE" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS -Wl,-soname,$SHARED_LIB_FILE"
PRE_TASK_SCRIPT= TASK_SCRIPT="@cbuild/default_tasks/build_shared_lib.sh"
TASK_SCRIPT=cbuild/default_tasks/build_shared_lib.sh
POST_TASK_SCRIPT=
;; ;;
# creates static library # creates static library
build_static_lib) build_static_lib)
C_ARGS="-O2 $DEFINE" C_ARGS="-O2 $DEFINES"
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
PRE_TASK_SCRIPT= TASK_SCRIPT="@cbuild/default_tasks/build_static_lib.sh"
TASK_SCRIPT=cbuild/default_tasks/build_static_lib.sh
POST_TASK_SCRIPT=
;; ;;
# creates static library with debug symbols and no optimizations # creates static library with debug symbols and no optimizations
build_static_lib_dbg) build_static_lib_dbg)
C_ARGS="-O0 -g3 $DEFINE" C_ARGS="-O0 -g3 $DEFINES"
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
PRE_TASK_SCRIPT= TASK_SCRIPT="@cbuild/default_tasks/build_static_lib.sh"
TASK_SCRIPT=cbuild/default_tasks/build_static_lib.sh
POST_TASK_SCRIPT=
;; ;;
# deletes generated files # deletes generated files
clean) clean)
TASK_SCRIPT=cbuild/default_tasks/clean.sh TASK_SCRIPT="@cbuild/default_tasks/clean.sh"
;; ;;
# nothing to do # nothing to do
"" | no_task) "" | no_task)

View File

@@ -1,13 +1,24 @@
#!/usr/bin/env bash #!/usr/bin/env bash
CBUILD_VERSION=2.2.1 CBUILD_VERSION=2.3.5
PROJECT="ougge" PROJECT="ougge"
CMP_C="gcc" CMP_C="gcc"
CMP_CPP="g++" CMP_CPP="g++"
STD_C="c11" STD_C="c11"
STD_CPP="c++20" STD_CPP="c++20"
WARN_C="-Wall -Wno-discarded-qualifiers -Wextra -Wno-unused-parameter" WARN_COMMON="-Wall -Wextra
WARN_CPP="-Wall -Wextra -Wno-unused-parameter" -Wduplicated-branches
-Wduplicated-cond
-Wformat=2
-Wmissing-include-dirs
-Wshadow
-Werror=return-type
-Werror=pointer-arith
-Werror=init-self
-Wno-unused-parameter"
WARN_C="$WARN_COMMON
-Werror=incompatible-pointer-types"
WARN_CPP="$WARN_COMMON"
SRC_C="$(find src -name '*.c')" SRC_C="$(find src -name '*.c')"
SRC_CPP="$(find src -name '*.cpp')" SRC_CPP="$(find src -name '*.cpp')"
@@ -24,10 +35,11 @@ ENABLED_DEPENDENCIES='precompiled resources cimgui src-csharp'
# └── profile/ - gcc *.gcda profiling info files # └── profile/ - gcc *.gcda profiling info files
OBJDIR="obj" OBJDIR="obj"
OUTDIR="bin" OUTDIR="bin"
STATIC_LIB_FILE="lib$PROJECT.a" STATIC_LIB_FILE="$PROJECT.a"
# header include directories # header include directories
INCLUDE="-I./dependencies/cimgui/imgui -I./dependencies/include -I./dependencies/include/SDL2" INCLUDE="-I./dependencies/cimgui/imgui -I./dependencies/include -I./dependencies/include/SDL2"
DEFINES=""
# OS-specific options # OS-specific options
case "$OS" in case "$OS" in
@@ -35,18 +47,21 @@ case "$OS" in
EXEC_FILE="$PROJECT.exe" EXEC_FILE="$PROJECT.exe"
SHARED_LIB_FILE="$PROJECT.dll" SHARED_LIB_FILE="$PROJECT.dll"
LINKER_LIBS="-static -lstdc++ -lpthread" LINKER_LIBS="-static -lstdc++ -lpthread"
INCLUDE="$INCLUDE "
DEFINES="$DEFINES "
;; ;;
LINUX) LINUX)
EXEC_FILE="$PROJECT" EXEC_FILE="$PROJECT"
SHARED_LIB_FILE="$PROJECT.so" SHARED_LIB_FILE="$PROJECT.so"
LINKER_LIBS="-lSDL2 -lSDL2_image" LINKER_LIBS="-lSDL2 -lSDL2_image"
INCLUDE="$INCLUDE "
DEFINES="$DEFINES "
;; ;;
*) *)
error "operating system $OS has no configuration variants" error "operating system $OS has no configuration variants"
;; ;;
esac esac
# TASKS # TASKS
case "$TASK" in case "$TASK" in
# creates executable using profiling info if it exists # creates executable using profiling info if it exists
@@ -57,64 +72,56 @@ case "$TASK" in
# -fprofile-use enables compiler to use profiling info files to optimize executable # -fprofile-use enables compiler to use profiling info files to optimize executable
# -fprofile-prefix-path sets path where profiling info about objects are be saved # -fprofile-prefix-path sets path where profiling info about objects are be saved
# -fdata-sections -ffunction-sections -Wl,--gc-sections removes unused code # -fdata-sections -ffunction-sections -Wl,--gc-sections removes unused code
C_ARGS="-O2 -flto=auto -fuse-linker-plugin -fprofile-use -fprofile-prefix-path=$(realpath $OBJDIR)/objects -fdata-sections -ffunction-sections -Wl,--gc-sections" C_ARGS="-O2 -flto=auto -fuse-linker-plugin -fprofile-use -fprofile-prefix-path=$(realpath $OBJDIR)/objects -fdata-sections -ffunction-sections -Wl,--gc-sections $DEFINES"
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
PRE_TASK_SCRIPT= PRE_TASK_SCRIPT=""
TASK_SCRIPT=cbuild/default_tasks/build_exec.sh TASK_SCRIPT="@cbuild/default_tasks/build_exec.sh"
POST_TASK_SCRIPT= POST_TASK_SCRIPT="@cbuild/default_tasks/strip_exec.sh"
;; ;;
# creates executable with debug info and no optimizations # creates executable with debug info and no optimizations
build_exec_dbg) build_exec_dbg)
C_ARGS="-O0 -g3" C_ARGS="-O0 -g3 $DEFINES"
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
PRE_TASK_SCRIPT= PRE_TASK_SCRIPT=""
TASK_SCRIPT=cbuild/default_tasks/build_exec.sh TASK_SCRIPT="@cbuild/default_tasks/build_exec.sh"
POST_TASK_SCRIPT= POST_TASK_SCRIPT=""
;; ;;
# creates shared library # creates shared library
build_shared_lib) build_shared_lib)
C_ARGS="-O2 -fpic -flto -shared" C_ARGS="-O2 -fpic -flto -shared $DEFINES"
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS -Wl,-soname,$SHARED_LIB_FILE" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS -Wl,-soname,$SHARED_LIB_FILE"
PRE_TASK_SCRIPT= TASK_SCRIPT="@cbuild/default_tasks/build_shared_lib.sh"
TASK_SCRIPT=cbuild/default_tasks/build_shared_lib.sh
POST_TASK_SCRIPT=
;; ;;
# creates shared library with debug symbols and no optimizations # creates shared library with debug symbols and no optimizations
build_shared_lib_dbg) build_shared_lib_dbg)
C_ARGS="-O0 -g3 -fpic -shared" C_ARGS="-O0 -g3 -fpic -shared $DEFINES"
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS -Wl,-soname,$SHARED_LIB_FILE" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS -Wl,-soname,$SHARED_LIB_FILE"
PRE_TASK_SCRIPT= TASK_SCRIPT="@cbuild/default_tasks/build_shared_lib.sh"
TASK_SCRIPT=cbuild/default_tasks/build_shared_lib.sh
POST_TASK_SCRIPT=
;; ;;
# creates static library # creates static library
build_static_lib) build_static_lib)
C_ARGS="-O2 -fpic -fdata-sections -ffunction-sections" C_ARGS="-O2 -fpic -fdata-sections -ffunction-sections $DEFINES"
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
PRE_TASK_SCRIPT= TASK_SCRIPT="@cbuild/default_tasks/build_static_lib.sh"
TASK_SCRIPT=cbuild/default_tasks/build_static_lib.sh
POST_TASK_SCRIPT=
;; ;;
# creates static library with debug symbols and no optimizations # creates static library with debug symbols and no optimizations
build_static_lib_dbg) build_static_lib_dbg)
C_ARGS="-O0 -g3" C_ARGS="-O0 -g3 $DEFINES"
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
PRE_TASK_SCRIPT= TASK_SCRIPT="@cbuild/default_tasks/build_static_lib.sh"
TASK_SCRIPT=cbuild/default_tasks/build_static_lib.sh
POST_TASK_SCRIPT=
;; ;;
# executes $EXEC_FILE # executes $EXEC_FILE
exec) exec)
TASK_SCRIPT=cbuild/default_tasks/exec.sh TASK_SCRIPT="@cbuild/default_tasks/exec.sh"
;; ;;
# executes $EXEC_FILE with valgrind memory checker # executes $EXEC_FILE with valgrind memory checker
valgrind) valgrind)
VALGRIND_ARGS="-s --read-var-info=yes --track-origins=yes --fullpath-after=$(pwd)/ --leak-check=full --show-leak-kinds=all" VALGRIND_ARGS="-s --read-var-info=yes --track-origins=yes --fullpath-after=$(pwd)/ --leak-check=full --show-leak-kinds=all"
TASK_SCRIPT=cbuild/default_tasks/valgrind.sh TASK_SCRIPT="@cbuild/default_tasks/valgrind.sh"
;; ;;
# generates profiling info # generates profiling info
profile) profile)
@@ -125,25 +132,27 @@ case "$TASK" in
# -pg adds code to executable, that generates file containing function call info (gmon.out) # -pg adds code to executable, that generates file containing function call info (gmon.out)
# -fprofile-generate generates executable with profiling code # -fprofile-generate generates executable with profiling code
# -fprofile-prefix-path sets path where profiling info about objects will be saved # -fprofile-prefix-path sets path where profiling info about objects will be saved
C_ARGS="-O2 -flto=auto -fuse-linker-plugin -fprofile-generate -fprofile-prefix-path=$(realpath $OBJDIR)/objects" C_ARGS="-O2 -flto=auto -fuse-linker-plugin -fprofile-generate
-fprofile-prefix-path=$(realpath $OBJDIR)/objects $DEFINES"
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh PRE_TASK_SCRIPT="@cbuild/default_tasks/build_exec.sh"
TASK_SCRIPT=cbuild/default_tasks/profile.sh TASK_SCRIPT="@cbuild/default_tasks/profile.sh"
POST_TASK_SCRIPT=
;; ;;
# compiles program with -pg and runs it with gprof # compiles program with -pg and runs it with gprof
# uses gprof2dot python script to generate function call tree (pip install gprof2dot) # uses gprof2dot python script to generate function call tree (pip install gprof2dot)
# requires graphviz (https://www.graphviz.org/download/source/) # requires graphviz (https://www.graphviz.org/download/source/)
gprof) gprof)
OUTDIR="$OUTDIR/gprof" OUTDIR="$OUTDIR/gprof"
# -pg adds code to executable, that generates file containing function call info (gmon.out) # arguments that emit some call counter code and disable optimizations to see function names
C_ARGS="-O2 -flto=auto -fuse-linker-plugin -pg" # https://github.com/msys2/MINGW-packages/issues/8503#issuecomment-1365475205
C_ARGS="-O0 -g -pg -no-pie -fno-omit-frame-pointer
-fno-inline-functions -fno-inline-functions-called-once
-fno-optimize-sibling-calls -fopenmp $DEFINES"
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh PRE_TASK_SCRIPT="@cbuild/default_tasks/build_exec.sh"
TASK_SCRIPT=cbuild/default_tasks/gprof.sh TASK_SCRIPT="@cbuild/default_tasks/gprof.sh"
POST_TASK_SCRIPT=
;; ;;
# compiles program and runs it with callgrind (part of valgrind) # compiles program and runs it with callgrind (part of valgrind)
# uses gprof2dot python script to generate function call tree (pip install gprof2dot) # uses gprof2dot python script to generate function call tree (pip install gprof2dot)
@@ -152,35 +161,37 @@ case "$TASK" in
callgrind) callgrind)
OUTDIR="$OUTDIR/callgrind" OUTDIR="$OUTDIR/callgrind"
# -pg adds code to executable, that generates file containing function call info (gmon.out) # -pg adds code to executable, that generates file containing function call info (gmon.out)
C_ARGS="-O2 -flto=auto -fuse-linker-plugin" C_ARGS="-O2 -flto=auto -fuse-linker-plugin $DEFINES"
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh PRE_TASK_SCRIPT="@cbuild/default_tasks/build_exec.sh"
TASK_SCRIPT=cbuild/default_tasks/callgrind.sh TASK_SCRIPT="@cbuild/default_tasks/callgrind.sh"
POST_TASK_SCRIPT=
;; ;;
# compiles executable with sanitizers and executes it to find errors and warnings # compiles executable with sanitizers and executes it to find errors and warnings
sanitize) sanitize)
OUTDIR="$OUTDIR/sanitize" OUTDIR="$OUTDIR/sanitize"
C_ARGS="-O0 -g3 -fsanitize=undefined,address" C_ARGS="-O0 -g3 -fsanitize=undefined,address $DEFINES"
CPP_ARGS="$C_ARGS" CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS" LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh PRE_TASK_SCRIPT="@cbuild/default_tasks/build_exec.sh"
TASK_SCRIPT=cbuild/default_tasks/exec.sh TASK_SCRIPT="@cbuild/default_tasks/exec.sh"
POST_TASK_SCRIPT=
;; ;;
# rebuilds specified dependencies # rebuilds specified dependencies
# EXAMPLE: `cbuild rebuild_dependencies=libexample1,fonts` # EXAMPLE: `cbuild rebuild_dependencies=libexample1,fonts`
# 'all' can be specified to rebuild all dependencies # 'all' can be specified to rebuild all dependencies
rebuild_dependencies) rebuild_dependencies)
TASK_SCRIPT=cbuild/default_tasks/rebuild_dependencies.sh TASK_SCRIPT="@cbuild/default_tasks/rebuild_dependencies.sh"
;; ;;
# Downloads mono runtime package from nuget.
# Extracts libs to dependencies/precompiled/$OS-$ARCH
# Extracts headers to dependencies/include/mono
# download_mono_from_nuget=VERSION
download_mono_from_nuget) download_mono_from_nuget)
TASK_SCRIPT=tasks/download_mono_from_nuget.sh TASK_SCRIPT=tasks/download_mono_from_nuget.sh
;; ;;
# deletes generated files # deletes generated files
clean) clean)
TASK_SCRIPT=cbuild/default_tasks/clean.sh TASK_SCRIPT="@cbuild/default_tasks/clean.sh"
;; ;;
# nothing to do # nothing to do
"" | no_task) "" | no_task)

View File

@@ -7,8 +7,8 @@
namespace ougge { namespace ougge {
IEngineModule::IEngineModule(Engine& engine) IEngineModule::IEngineModule(Engine& _engine)
: engine(engine) : engine(_engine)
{} {}
void IEngineModule::beginFrame() {} void IEngineModule::beginFrame() {}

View File

@@ -4,15 +4,15 @@
namespace ougge::game { namespace ougge::game {
GameObjectPool::GameObjectPool(u32 size) GameObjectPool::GameObjectPool(u32 _size)
: size(_size)
{ {
useful_assert(size % 64 == 0, "size of GameObjectPool must be a multiple of 64"); useful_assert(_size % 64 == 0, "size of GameObjectPool must be a multiple of 64");
this->size = size;
first_unused_index = 0; first_unused_index = 0;
buffer = new GameObject[size]; buffer = new GameObject[_size];
used_indices = new u64[size/64]; used_indices = new u64[_size/64];
// std::memset(buffer, 0, size*sizeof(GameObject)); // std::memset(buffer, 0, size*sizeof(GameObject));
std::memset(used_indices, 0, size/8); std::memset(used_indices, 0, _size/8);
} }
GameObjectPool::~GameObjectPool() GameObjectPool::~GameObjectPool()
@@ -110,8 +110,8 @@ bool GameObjectPool::erase(u32 index)
return true; return true;
} }
GameObjectPool::iterator::iterator(GameObjectPool* pool, u32 index) GameObjectPool::iterator::iterator(GameObjectPool* _pool, u32 _index)
: pool(pool), index(index) : pool(_pool), index(_index)
{ {
} }

View File

@@ -11,8 +11,8 @@ using namespace ougge;
class TutelModule : public IEngineModule { class TutelModule : public IEngineModule {
resources::CacheStorage<resources::Texture> textures; resources::CacheStorage<resources::Texture> textures;
public: public:
TutelModule(Engine& engine, resources::ResourceManager& resourceManager) : TutelModule(Engine& _engine, resources::ResourceManager& resourceManager) :
IEngineModule(engine), IEngineModule(_engine),
textures(&resourceManager) textures(&resourceManager)
{ {
//TODO: add something like `assert(requireModule(MainWindow))` //TODO: add something like `assert(requireModule(MainWindow))`

View File

@@ -25,10 +25,10 @@ f32 MainWindowSDL2::getDPI(){
return dpi; return dpi;
} }
MainWindowSDL2::MainWindowSDL2(Engine& engine, MainWindowSDL2::MainWindowSDL2(Engine& _engine,
const std::string& window_title, const std::string& window_title,
resources::ResourceManager& resourceManager) resources::ResourceManager& resourceManager)
: IEngineModule(engine) : IEngineModule(_engine)
{ {
SDL_TRY(SDL_Init(SDL_INIT_EVERYTHING)); SDL_TRY(SDL_Init(SDL_INIT_EVERYTHING));
SDL_version v; SDL_version v;

View File

@@ -6,8 +6,8 @@ const std::string& MonoGameObjectSystem::getName() {
return ougge_type_name<MonoGameObjectSystem>(); return ougge_type_name<MonoGameObjectSystem>();
} }
MonoGameObjectSystem::MonoGameObjectSystem(Engine& engine, u32 max_game_objects) : MonoGameObjectSystem::MonoGameObjectSystem(Engine& _engine, u32 max_game_objects) :
IEngineModule(engine), IEngineModule(_engine),
gameObjectPool(max_game_objects) gameObjectPool(max_game_objects)
{ {
engineManagedAssembly = mono.loadAssembly("Ougge.dll"); engineManagedAssembly = mono.loadAssembly("Ougge.dll");
@@ -53,7 +53,7 @@ void MonoGameObjectSystem::beginFrame(){
// is used in NativeFunctions.cs // is used in NativeFunctions.cs
game::GameObject& MonoGameObjectSystem::createGameObjectInPool(u64* id_out, u32* index_out){ game::GameObject& MonoGameObjectSystem::createGameObjectInPool(u64* id_out, u32* index_out){
auto pair = gameObjectPool.emplace(game::GameObject(mono.createObject(gameObjectClass))); auto pair = gameObjectPool.emplace(game::GameObject(mono.createObject(gameObjectClass)));
*id_out = ++obj_id; *id_out = ++last_obj_id;
*index_out = pair.first; *index_out = pair.first;
game::GameObject& obj = pair.second; game::GameObject& obj = pair.second;
return obj; return obj;

View File

@@ -10,7 +10,7 @@ namespace ougge::modules {
class MonoGameObjectSystem : public IEngineModule { class MonoGameObjectSystem : public IEngineModule {
Mono::RuntimeJIT mono; Mono::RuntimeJIT mono;
game::GameObjectPool gameObjectPool; game::GameObjectPool gameObjectPool;
u64 obj_id = 0; u64 last_obj_id = 0;
MonoClass* gameObjectClass; MonoClass* gameObjectClass;
Mono::Method<void(u64, u32)> gameObjectCtor; Mono::Method<void(u64, u32)> gameObjectCtor;
Mono::Method<void(f64)> gameObjectInvokeUpdate; Mono::Method<void(f64)> gameObjectInvokeUpdate;

View File

@@ -2,8 +2,8 @@
namespace Mono { namespace Mono {
Assembly::Assembly(MonoAssembly *ptr) Assembly::Assembly(MonoAssembly *_ptr)
: ptr(ptr), image(mono_assembly_get_image(ptr)) : ptr(_ptr), image(mono_assembly_get_image(_ptr))
{ {
} }

View File

@@ -8,8 +8,8 @@
namespace ougge::resources { namespace ougge::resources {
ResourceFactory::ResourceFactory(const std::string& path, const std::size_t size, StreamFactoryMethod open_read_steam_func) ResourceFactory::ResourceFactory(const std::string& _path, const std::size_t _size, StreamFactoryMethod _open_read_steam_func)
: path(path), size(size), openStream(open_read_steam_func) : path(_path), size(_size), openStream(_open_read_steam_func)
{} {}

View File

@@ -4,12 +4,12 @@
namespace ougge::resources { namespace ougge::resources {
Texture::Texture(ResourceFactory* r, SDL_Renderer* renderer) Texture::Texture(ResourceFactory* r, SDL_Renderer* _renderer)
: Texture(*r->openStream(), r->size, renderer) : Texture(*r->openStream(), r->size, _renderer)
{} {}
Texture::Texture(std::istream& s, size_t size, SDL_Renderer* renderer) Texture::Texture(std::istream& s, size_t size, SDL_Renderer* _renderer)
: renderer(renderer), texture(nullptr), w(0), h(0) : renderer(_renderer), texture(nullptr), w(0), h(0)
{ {
SDL_RWops* sdl_stream = SDL_RWFromIStream(s, size); SDL_RWops* sdl_stream = SDL_RWFromIStream(s, size);
if(!sdl_stream) if(!sdl_stream)

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
package_version="$TASK_ARGS" package_version="$TASK_ARGS"
if [ -z "$package_version" ]; then if [ -z "$package_version" ]; then
package_version="8.0.15" package_version="8.0.27"
myprint "${YELLOW}You can choose package version manually: cbuild get_mono_files_from=x.y.z" myprint "${YELLOW}You can choose package version manually: cbuild get_mono_files_from=x.y.z"
fi fi
myprint "${BLUE}package_version: ${CYAN}$package_version" myprint "${BLUE}package_version: ${CYAN}$package_version"