Radium Engine  1.5.20
Loading...
Searching...
No Matches
RadiumEngine.hpp
1#pragma once
2#include <Engine/RaEngine.hpp>
3
4#include <Core/Tasks/TaskQueue.hpp>
5#include <Core/Types.hpp>
6#include <Core/Utils/Singleton.hpp>
7
8#include <glbinding/Version.h>
9#include <globjects/State.h>
10
11#include <map>
12#include <memory>
13#include <stack>
14#include <string>
15#include <vector>
16
17namespace Ra {
18namespace Core {
19
20namespace Asset {
21class FileLoaderInterface;
22class FileData;
23} // namespace Asset
24} // namespace Core
25
27namespace Engine {
28
30namespace Scene {
31class System;
32class Entity;
33class Component;
34class EntityManager;
35class SignalManager;
36} // namespace Scene
37
39namespace Data {
40class ShaderProgramManager;
41class Displayable;
42class TextureManager;
43} // namespace Data
44
46namespace Rendering {
47class RenderObjectManager;
48}
49
54class RA_ENGINE_API RadiumEngine
55{
56 RA_SINGLETON_INTERFACE( RadiumEngine );
57
58 public:
63 void initialize();
64
73 void initializeGL();
74
80 glbinding::Version getOpenGLVersion() const;
81
85 void cleanup();
86
94 void getTasks( Core::TaskQueue* taskQueue, Scalar dt );
95
105 bool registerSystem( const std::string& name, Scene::System* system, int priority = 1 );
106
112 Scene::System* getSystem( const std::string& system ) const;
113
123 Data::Displayable* getMesh( const std::string& entityName,
124 const std::string& componentName,
125 const std::string& roName = std::string() ) const;
126
136 bool loadFile( const std::string& file );
137
145 const Core::Asset::FileData& getFileData() const;
146
153 void releaseFile();
154
157 void endFrameSync();
158
160
165 Rendering::RenderObjectManager* getRenderObjectManager() const;
171 Scene::EntityManager* getEntityManager() const;
172
178 Scene::SignalManager* getSignalManager() const;
179
185 Data::TextureManager* getTextureManager() const;
186
192 Data::ShaderProgramManager* getShaderProgramManager() const;
193
198 void registerFileLoader( std::shared_ptr<Core::Asset::FileLoaderInterface> fileLoader );
199
205
209 Core::Aabb computeSceneAabb() const;
210
215 void pushFboAndViewport();
216
222 void popFboAndViewport();
223
226
234 void setRealTime( bool realTime );
235
240 bool isRealTime() const;
241
246 bool isConstantTime() const;
247
256 bool setConstantTimeStep( Scalar dt, bool forceConstantTime = false );
257
268 void setForwardBackward( bool mode );
269
273 void play( bool isPlaying );
274
278 void step();
279
284 void resetTime();
285
291 void setTime( Scalar t );
292
299 void setStartTime( Scalar t );
300
304 Scalar getStartTime() const;
305
313 void setEndTime( Scalar t );
314
318 Scalar getEndTime() const;
319
323 Scalar getTime() const;
324
328 uint getFrame() const;
330
331 std::string getResourcesDir() { return m_resourcesRootDir; }
332
336 void runGpuTasks();
337
343
347 void removeGpuTask( Core::TaskQueue::TaskId taskId );
348
349 private:
350 RadiumEngine();
352
354 glbinding::Version m_glVersion {};
358 void registerDefaultPrograms();
359
360 using Priority = int;
362 // use transparent functors :
363 // https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-transparent-functors.html
365
366 SystemContainer::const_iterator findSystem( const std::string& name ) const;
367 SystemContainer::iterator findSystem( const std::string& name );
368
373 SystemContainer m_systems;
374
376
381 std::unique_ptr<Data::ShaderProgramManager> m_shaderProgramManager;
383
384 bool m_loadingState { false };
385
387 std::string m_resourcesRootDir;
388
392 class FboAndViewport
393 {
394 public:
395 FboAndViewport( int fbo, std::array<int, 4>&& viewport ) :
396 m_fbo { fbo }, m_viewport { viewport } {}
397 int m_fbo;
398 std::array<int, 4> m_viewport;
399 };
400
402 std::stack<FboAndViewport> m_fboAndViewportStack;
403
404 struct TimeData {
409 void updateTime( Scalar dt );
410
411 Scalar m_dt { 1_ra / 60_ra };
412 Scalar m_startTime { 0_ra };
413 Scalar m_endTime { 1_ra };
414 Scalar m_time { 0_ra };
415 bool m_play { false };
416 bool m_singleStep { true };
417 bool m_realTime { false };
418 bool m_forwardBackward { false };
419 bool m_isBackward { false };
420 };
421
422 TimeData m_timeData;
423
426 std::unique_ptr<globjects::State> m_openglState { nullptr };
427 std::unique_ptr<Core::TaskQueue> m_gpuTaskQueue { new Core::TaskQueue( 0 ) };
428};
429} // namespace Engine
430} // namespace Ra
This class allows tasks to be registered and then executed in parallel on separate threads.
Definition TaskQueue.hpp:48
Utils::Index TaskId
Identifier for a task in the task queue.
Definition TaskQueue.hpp:51
Manage Texture loading and registration.
hepler function to manage enum as underlying types in VariableSet
Definition Cage.cpp:3