Added compiler settings to ModuleManager (include paths, C++11), added some test bgfx calls to the test module.

master
Martin Felis 2016-09-03 19:48:24 +02:00
parent 523c9996a8
commit d862f0b659
6 changed files with 39 additions and 16 deletions

View File

@ -71,6 +71,13 @@ SET ( protot_SRCS
3rdparty/glfw/deps/glad.c 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}) ADD_EXECUTABLE (protot src/main.cc ${protot_SRCS})
file(GLOB glcpp-library_sources file(GLOB glcpp-library_sources

View File

@ -1,11 +1,11 @@
#include "ModuleManager.h" #include "ModuleManager.h"
#include "protot_config.h"
// Runtime Compiled Cpp // Runtime Compiled Cpp
#include "RuntimeCompiledCpp/RuntimeObjectSystem/IObjectFactorySystem.h" #include "RuntimeCompiledCpp/RuntimeObjectSystem/IObjectFactorySystem.h"
#include "RuntimeCompiledCpp/RuntimeObjectSystem/ObjectInterface.h" #include "RuntimeCompiledCpp/RuntimeObjectSystem/ObjectInterface.h"
#include "RuntimeCompiledCpp/RuntimeCompiler/AUArray.h"
#include "RuntimeCompiledCpp/RuntimeCompiler/BuildTool.h"
#include "RuntimeCompiledCpp/RuntimeCompiler/ICompilerLogger.h" #include "RuntimeCompiledCpp/RuntimeCompiler/ICompilerLogger.h"
#include "RuntimeCompiledCpp/RuntimeCompiler/FileChangeNotifier.h" #include "RuntimeCompiledCpp/RuntimeCompiler/FileChangeNotifier.h"
#include "RuntimeCompiledCpp/RuntimeObjectSystem/IObjectFactorySystem.h" #include "RuntimeCompiledCpp/RuntimeObjectSystem/IObjectFactorySystem.h"
@ -21,8 +21,8 @@
#include <iostream> #include <iostream>
#include <unistd.h> #include <unistd.h>
#include <iostream> #include <iostream>
#include <string>
using namespace std; using namespace std;
@ -62,6 +62,15 @@ bool ModuleManager::init() {
mRuntimeObjectSystem->GetObjectFactorySystem()->AddListener(this); 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; return true;
} }
@ -82,24 +91,17 @@ void ModuleManager::OnConstructorsAdded() {
} }
} }
void ModuleManager::update() { void ModuleManager::update(float dt) {
if (mRuntimeObjectSystem->GetIsCompiledComplete()) { if (mRuntimeObjectSystem->GetIsCompiledComplete()) {
mRuntimeObjectSystem->LoadCompiledModule(); mRuntimeObjectSystem->LoadCompiledModule();
} }
if (!mRuntimeObjectSystem->GetIsCompiling()) { if (!mRuntimeObjectSystem->GetIsCompiling()) {
static int num_updates = 0; mRuntimeObjectSystem->GetFileChangeNotifier()->Update(dt);
num_updates ++;
std::cout << "Main loop. num_updates = " << num_updates << "\n";
const float delta_time = 1.0f;
mRuntimeObjectSystem->GetFileChangeNotifier()->Update(delta_time);
for (unsigned int i = 0; i < mModules.size(); i++) { for (unsigned int i = 0; i < mModules.size(); i++) {
mModules[i]->Update(delta_time); mModules[i]->Update(dt);
} }
usleep(1000 * 100);
} }
} }

View File

@ -17,7 +17,7 @@ struct ModuleManager : IObjectFactoryListener {
virtual ~ModuleManager(); virtual ~ModuleManager();
bool init(); bool init();
void update (); void update (float dt);
void OnConstructorsAdded(); void OnConstructorsAdded();
bool RegisterModule(const char* name); bool RegisterModule(const char* name);

View File

@ -4,13 +4,24 @@
#include "rcpp/IUpdateable.h" #include "rcpp/IUpdateable.h"
#include "rcpp/InterfaceIds.h" #include "rcpp/InterfaceIds.h"
#include <iostream> #include <iostream>
#include <sstream>
#include <unistd.h>
#include "Renderer.h"
class TestModule : public TInterface<IID_IUPDATEABLE,IUpdateable> class TestModule : public TInterface<IID_IUPDATEABLE,IUpdateable>
{ {
public: public:
virtual void Update( float deltaTime ) 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);
} }
}; };

View File

@ -179,7 +179,7 @@ int main(void)
renderer.resize(width, height); renderer.resize(width, height);
} }
module_manager.update(); module_manager.update((float)(frameTime / freq));
renderer.paintGLSimple(); renderer.paintGLSimple();

View File

@ -0,0 +1,3 @@
#pragma once
#cmakedefine PROTOT_SOURCE_ROOT_PATH "@PROTOT_SOURCE_ROOT_PATH@"