diff --git a/CMakeLists.txt b/CMakeLists.txt index 550c280..c6e9745 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,6 +71,13 @@ SET ( protot_SRCS 3rdparty/glfw/deps/glad.c ) +SET (PROTOT_SOURCE_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +CONFIGURE_FILE ( + "${CMAKE_CURRENT_SOURCE_DIR}/src/protot_config.h.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/src/protot_config.h" + ) + ADD_EXECUTABLE (protot src/main.cc ${protot_SRCS}) file(GLOB glcpp-library_sources diff --git a/src/ModuleManager.cc b/src/ModuleManager.cc index 2e7348c..b39ff61 100644 --- a/src/ModuleManager.cc +++ b/src/ModuleManager.cc @@ -1,11 +1,11 @@ #include "ModuleManager.h" +#include "protot_config.h" + // Runtime Compiled Cpp #include "RuntimeCompiledCpp/RuntimeObjectSystem/IObjectFactorySystem.h" #include "RuntimeCompiledCpp/RuntimeObjectSystem/ObjectInterface.h" -#include "RuntimeCompiledCpp/RuntimeCompiler/AUArray.h" -#include "RuntimeCompiledCpp/RuntimeCompiler/BuildTool.h" #include "RuntimeCompiledCpp/RuntimeCompiler/ICompilerLogger.h" #include "RuntimeCompiledCpp/RuntimeCompiler/FileChangeNotifier.h" #include "RuntimeCompiledCpp/RuntimeObjectSystem/IObjectFactorySystem.h" @@ -21,8 +21,8 @@ #include #include - #include +#include using namespace std; @@ -62,6 +62,15 @@ bool ModuleManager::init() { mRuntimeObjectSystem->GetObjectFactorySystem()->AddListener(this); + // Setup of the compiler settings + mRuntimeObjectSystem->SetAdditionalCompileOptions("--std=c++11"); + + // add include paths + string protot_source_root_path = PROTOT_SOURCE_ROOT_PATH; + mRuntimeObjectSystem->AddIncludeDir ( + string(protot_source_root_path + "/3rdparty/bgfx/include" + ).c_str()); + return true; } @@ -82,24 +91,17 @@ void ModuleManager::OnConstructorsAdded() { } } -void ModuleManager::update() { +void ModuleManager::update(float dt) { if (mRuntimeObjectSystem->GetIsCompiledComplete()) { mRuntimeObjectSystem->LoadCompiledModule(); } if (!mRuntimeObjectSystem->GetIsCompiling()) { - static int num_updates = 0; - num_updates ++; - std::cout << "Main loop. num_updates = " << num_updates << "\n"; - - const float delta_time = 1.0f; - mRuntimeObjectSystem->GetFileChangeNotifier()->Update(delta_time); + mRuntimeObjectSystem->GetFileChangeNotifier()->Update(dt); for (unsigned int i = 0; i < mModules.size(); i++) { - mModules[i]->Update(delta_time); + mModules[i]->Update(dt); } - - usleep(1000 * 100); } } diff --git a/src/ModuleManager.h b/src/ModuleManager.h index d3bd904..8ad86be 100644 --- a/src/ModuleManager.h +++ b/src/ModuleManager.h @@ -17,7 +17,7 @@ struct ModuleManager : IObjectFactoryListener { virtual ~ModuleManager(); bool init(); - void update (); + void update (float dt); void OnConstructorsAdded(); bool RegisterModule(const char* name); diff --git a/src/TestModule.cpp b/src/TestModule.cpp index 448ac0e..c39d709 100644 --- a/src/TestModule.cpp +++ b/src/TestModule.cpp @@ -4,13 +4,24 @@ #include "rcpp/IUpdateable.h" #include "rcpp/InterfaceIds.h" #include +#include + +#include + +#include "Renderer.h" class TestModule : public TInterface { public: virtual void Update( float deltaTime ) { - std::cout << "TestModule: 1 Runtime Object 214 update called!\n"; + std::ostringstream s; + s << "TestModule: 2 Runtime Object 2 " << deltaTime << " update called!"; + + bgfx::dbgTextPrintf(1, 20, 0x6f, s.str().c_str()); + + // wait a little so that we don't hog the CPU. + usleep (1000 * 100); } }; diff --git a/src/main.cc b/src/main.cc index 5ca1168..1060b82 100644 --- a/src/main.cc +++ b/src/main.cc @@ -179,7 +179,7 @@ int main(void) renderer.resize(width, height); } - module_manager.update(); + module_manager.update((float)(frameTime / freq)); renderer.paintGLSimple(); diff --git a/src/protot_config.h.cmake b/src/protot_config.h.cmake new file mode 100644 index 0000000..3f6c41c --- /dev/null +++ b/src/protot_config.h.cmake @@ -0,0 +1,3 @@ +#pragma once + +#cmakedefine PROTOT_SOURCE_ROOT_PATH "@PROTOT_SOURCE_ROOT_PATH@"