Elaztek Developer Hub
Blamite Game Engine - blam!  00423.10.27.24.0533.blamite
The core library for the Blamite Game Engine.
GraphicsSystem.h
Go to the documentation of this file.
1 
2 #ifndef _Demo_GraphicsSystem_H_
3 #define _Demo_GraphicsSystem_H_
4 
5 #include "BaseSystem.h"
6 #include "GameEntityManager.h"
8 #include "OGRE/OgrePrerequisites.h"
9 #include "OGRE/OgreColourValue.h"
10 #include "OGRE/Overlay/OgreOverlayPrerequisites.h"
11 #include "OGRE/OgreLog.h"
12 
13 #include "OGRE/Threading/OgreUniformScalableTask.h"
14 #include "SdlEmulationLayer.h"
15 #include "OGRE/Overlay/OgreOverlaySystem.h"
16 
18 
19 #if OGRE_USE_SDL2
20  #include <SDL2/SDL.h>
21 #endif
22 
23 namespace Demo
24 {
25  class SdlInputHandler;
26 
27  class GraphicsSystem : public BaseSystem, public Ogre::UniformScalableTask, public Ogre::LogListener
28  {
29  private:
31 
32  protected:
34 
35  #if OGRE_USE_SDL2
36  SDL_Window *mSdlWindow;
37  #endif
38 
39  Ogre::Root *mRoot;
40  Ogre::Window *mRenderWindow;
41  Ogre::SceneManager *mSceneManager;
42  Ogre::Camera *mCamera;
43  Ogre::CompositorWorkspace *mWorkspace;
44  Ogre::String mPluginsFolder;
45  Ogre::String mWriteAccessFolder;
46  Ogre::String mResourcePath;
47 
48  Ogre::v1::OverlaySystem *mOverlaySystem;
49 
51 
55  Ogre::uint32 mCurrentTransformIdx;
56  GameEntityVec mGameEntities[Ogre::NUM_SCENE_MEMORY_MANAGER_TYPES];
59 
60  bool mQuit;
64 
65  Ogre::ColourValue mBackgroundColour;
66 
67  bool isWriteAccessFolder( const Ogre::String &folderPath, const Ogre::String &fileToSave );
68 
70  virtual void processIncomingMessage( Mq::MessageId messageId, const void *data );
71 
72  static void addResourceLocation( const Ogre::String &archName, const Ogre::String &typeName,
73  const Ogre::String &secName );
74  void loadTextureCache(void);
75  void saveTextureCache(void);
76  void loadHlmsDiskCache(void);
77  void saveHlmsDiskCache(void);
78  virtual void setupResources(void);
79  virtual void registerHlms(void);
82  virtual void loadResources(void);
83  virtual void chooseSceneManager(void);
84  virtual void createCamera(void);
88  virtual Ogre::CompositorWorkspace* setupCompositor(void);
89 
91  virtual void initMiscParamsListener( Ogre::NameValuePairList &params );
92 
94  virtual void createResourceListener(void) {}
95 
96  void gameEntityAdded( const GameEntityManager::CreatedGameEntity *createdGameEntity );
97  void gameEntityRemoved( GameEntity *toRemove );
98  public:
100 
102 
103  GraphicsSystem( GameState *gameState = nullptr, Ogre::String resourcePath = Ogre::String(""), Ogre::ColourValue backgroundColour = Ogre::ColourValue( 0.2f, 0.4f, 0.6f ) );
104  virtual ~GraphicsSystem();
105 
106  void _notifyLogicSystem( BaseSystem *logicSystem ) { mLogicSystem = logicSystem; }
107 
108  void initialize( const Ogre::String &windowTitle );
109  void deinitialize(void);
110 
111 #if OGRE_USE_SDL2
112  void handleWindowEvent(const SDL_Event& evt);
113  SdlInputHandler* mInputHandler;
114 #endif
115 
116  void update( float timeSinceLast );
117 
126  void updateGameEntities( const GameEntityVec &gameEntities, float weight );
127 
129  virtual void execute( size_t threadId, size_t numThreads );
130 
133  const GameEntityVec& getGameEntities( Ogre::SceneMemoryMgrTypes type ) const
134  { return mGameEntities[type]; }
135 
136  #if OGRE_USE_SDL2
137  SdlInputHandler* getInputHandler(void) { return mInputHandler; }
138  #endif
139 
140  void setQuit(void) { mQuit = true; }
141  bool getQuit(void) const { return mQuit; }
142 
144 
145  Ogre::Root* getRoot(void) const { return mRoot; }
146  Ogre::Window* getRenderWindow(void) const { return mRenderWindow; }
147  Ogre::SceneManager* getSceneManager(void) const { return mSceneManager; }
148  Ogre::Camera* getCamera(void) const { return mCamera; }
149  Ogre::CompositorWorkspace* getCompositorWorkspace(void) const { return mWorkspace; }
150  Ogre::v1::OverlaySystem* getOverlaySystem(void) const { return mOverlaySystem; }
151 
152  void setAlwaysAskForConfig( bool alwaysAskForConfig );
153  bool getAlwaysAskForConfig( void ) const { return mAlwaysAskForConfig; }
154 
155  const Ogre::String& getPluginsFolder(void) const { return mPluginsFolder; }
156  const Ogre::String& getWriteAccessFolder(void) const { return mWriteAccessFolder; }
157  const Ogre::String& getResourcePath(void) const { return mResourcePath; }
158  const char *getMediaReadArchiveType( void ) const;
159 
160  virtual void stopCompositor(void);
161  virtual void restartCompositor(void);
162 
163  void messageLogged(const Ogre::String& message, Ogre::LogMessageLevel lml, bool maskDebug,
164  const Ogre::String& logName, bool& skipThisMessage) override;
165  };
166 }
167 
168 #endif
Demo::GraphicsSystem::mGameEntities
GameEntityVec mGameEntities[Ogre::NUM_SCENE_MEMORY_MANAGER_TYPES]
Definition: GraphicsSystem.h:56
Demo::MoTypeItem
@ MoTypeItem
Definition: GameEntity.h:15
Blam::Settings::Config::GetEngineConfiguration
BLAM BlamConfigurationFile * GetEngineConfiguration()
Retrieves the main engine configuration file.
Definition: config.cpp:60
Demo::GraphicsSystem::mUseMicrocodeCache
bool mUseMicrocodeCache
Definition: GraphicsSystem.h:63
Demo::GraphicsSystem::getRenderWindow
Ogre::Window * getRenderWindow(void) const
Definition: GraphicsSystem.h:146
Demo::GraphicsSystem::mPluginsFolder
Ogre::String mPluginsFolder
Definition: GraphicsSystem.h:44
if
if(WIN32) set(OGRE_MEDIA_PATH "Media") elseif(APPLE) set(OGRE_MEDIA_PATH "Media") elseif(UNIX) set(OGRE_MEDIA_PATH "share/$
Definition: CMakeLists.txt:15
Blam::Logger::LogEvent
BLAM void LogEvent(std::string message)
Logs a message to the log and/or console.
Definition: aliases.cpp:130
Demo::Mq::MessageQueueSystem::queueSendMessage
void queueSendMessage(MessageQueueSystem *dstSystem, Mq::MessageId messageId, const T &msg)
Queues message 'msg' to be sent to a destination MessageQueueSystem.
Definition: MessageQueueSystem.h:66
Demo::GraphicsSystem::loadResources
virtual void loadResources(void)
Optional override method where you can perform resource group loading Must at least do ResourceGroupM...
Definition: GraphicsSystem.cpp:988
Demo::GraphicsSystem::addResourceLocation
static void addResourceLocation(const Ogre::String &archName, const Ogre::String &typeName, const Ogre::String &secName)
Definition: GraphicsSystem.cpp:670
logger.h
Demo::GraphicsSystem::ogre_pass_registry
BlamCompositorPassRegistry * ogre_pass_registry
Definition: GraphicsSystem.h:101
Demo::GraphicsSystem::getResourcePath
const Ogre::String & getResourcePath(void) const
Definition: GraphicsSystem.h:157
Demo::GameEntity::mTransform
GameEntityTransform * mTransform[NUM_GAME_ENTITY_BUFFERS]
Definition: GameEntity.h:53
Demo::GraphicsSystem::mThreadWeight
float mThreadWeight
Definition: GraphicsSystem.h:58
Demo::GraphicsSystem::getGameEntities
const GameEntityVec & getGameEntities(Ogre::SceneMemoryMgrTypes type) const
Returns the GameEntities that are ready to be rendered.
Definition: GraphicsSystem.h:133
Demo::GraphicsSystem::mCamera
Ogre::Camera * mCamera
Definition: GraphicsSystem.h:42
Demo::GameEntityTransform::qRot
Ogre::Quaternion qRot
Definition: GameEntity.h:31
Demo::GraphicsSystem::gameEntityRemoved
void gameEntityRemoved(GameEntity *toRemove)
Definition: GraphicsSystem.cpp:1190
Demo::GameEntity::mMovableObject
Ogre::MovableObject * mMovableObject
Definition: GameEntity.h:45
Demo::Mq::GAME_ENTITY_REMOVED
@ GAME_ENTITY_REMOVED
Definition: MqMessages.h:17
Demo::GraphicsSystem::getWriteAccessFolder
const Ogre::String & getWriteAccessFolder(void) const
Definition: GraphicsSystem.h:156
Demo::GameEntityTransform::vPos
Ogre::Vector3 vPos
Definition: GameEntity.h:30
Demo::GraphicsSystem::mCurrentTransformIdx
Ogre::uint32 mCurrentTransformIdx
Definition: GraphicsSystem.h:55
Demo::GraphicsSystem::mWriteAccessFolder
Ogre::String mWriteAccessFolder
Definition: GraphicsSystem.h:45
Demo::GraphicsSystem::mOverlaySystem
Ogre::v1::OverlaySystem * mOverlaySystem
Definition: GraphicsSystem.h:48
Demo::GraphicsSystem::initMiscParamsListener
virtual void initMiscParamsListener(Ogre::NameValuePairList &params)
Called right before initializing Ogre's first window, so the params can be customized.
Definition: GraphicsSystem.cpp:1068
Demo::GraphicsSystem::getCompositorWorkspace
Ogre::CompositorWorkspace * getCompositorWorkspace(void) const
Definition: GraphicsSystem.h:149
Demo::GraphicsSystem::messageLogged
void messageLogged(const Ogre::String &message, Ogre::LogMessageLevel lml, bool maskDebug, const Ogre::String &logName, bool &skipThisMessage) override
Definition: GraphicsSystem.cpp:1102
Demo::GraphicsSystem::getAccumTimeSinceLastLogicFrame
float getAccumTimeSinceLastLogicFrame(void) const
Definition: GraphicsSystem.h:143
GameEntity.h
Demo::BaseSystem::update
void update(float timeSinceLast)
Definition: BaseSystem.cpp:64
USER_DATA_PATH
#define USER_DATA_PATH(path)
Macro to quickly access a user data folder.
Definition: config.h:41
Demo::GameEntity::mSceneNode
Ogre::SceneNode * mSceneNode
Definition: GameEntity.h:44
Demo
Definition: BaseSystem.cpp:5
Demo::GraphicsSystem::loadTextureCache
void loadTextureCache(void)
Definition: GraphicsSystem.cpp:687
config
ImFontConfig config
Definition: README.txt:49
Demo::GraphicsSystem::getAlwaysAskForConfig
bool getAlwaysAskForConfig(void) const
Definition: GraphicsSystem.h:153
Demo::GraphicsSystem::isWriteAccessFolder
bool isWriteAccessFolder(const Ogre::String &folderPath, const Ogre::String &fileToSave)
Definition: GraphicsSystem.cpp:103
SdlEmulationLayer.h
Demo::GraphicsSystem::execute
virtual void execute(size_t threadId, size_t numThreads)
Overload Ogre::UniformScalableTask.
Definition: GraphicsSystem.cpp:1222
Demo::GameEntityTransform::vScale
Ogre::Vector3 vScale
Definition: GameEntity.h:32
Demo::GraphicsSystem::getSceneManager
Ogre::SceneManager * getSceneManager(void) const
Definition: GraphicsSystem.h:147
GameEntityManager.h
Demo::GraphicsSystem::mRenderWindow
Ogre::Window * mRenderWindow
Definition: GraphicsSystem.h:40
Demo::GameEntity::mType
Ogre::SceneMemoryMgrTypes mType
Definition: GameEntity.h:54
Demo::GraphicsSystem::stopCompositor
virtual void stopCompositor(void)
Definition: GraphicsSystem.cpp:1086
uint64_t
unsigned long long uint64_t
Definition: stdint.h:18
Demo::GraphicsSystem::mStaticPluginLoader
StaticPluginLoader mStaticPluginLoader
Definition: GraphicsSystem.h:50
Demo::GameState
Definition: GameState.h:9
Demo::GraphicsSystem::debug_mode_thread_count
size_t debug_mode_thread_count
Definition: GraphicsSystem.h:99
Demo::GraphicsSystem::saveHlmsDiskCache
void saveHlmsDiskCache(void)
Definition: GraphicsSystem.cpp:803
Demo::GraphicsSystem::setupResources
virtual void setupResources(void)
Definition: GraphicsSystem.cpp:845
Demo::GraphicsSystem::getMediaReadArchiveType
const char * getMediaReadArchiveType(void) const
Definition: GraphicsSystem.cpp:1077
GameState.h
ENGINE_DATA_PATH
#define ENGINE_DATA_PATH(path)
Macro to quickly access a game engine data folder.
Definition: config.h:34
Demo::BaseSystem
Definition: BaseSystem.h:11
Demo::GameEntity::mMoDefinition
const MovableObjectDefinition * mMoDefinition
Definition: GameEntity.h:59
Demo::GraphicsSystem::setupCompositor
virtual Ogre::CompositorWorkspace * setupCompositor(void)
Virtual so that advanced samples such as Sample_Compositor can override this method to change the def...
Definition: GraphicsSystem.cpp:1053
OGRE_USE_SDL2
#define OGRE_USE_SDL2
Definition: SdlEmulationLayer.h:8
Demo::GraphicsSystem::mSceneManager
Ogre::SceneManager * mSceneManager
Definition: GraphicsSystem.h:41
Demo::GraphicsSystem::~GraphicsSystem
virtual ~GraphicsSystem()
Definition: GraphicsSystem.cpp:94
Demo::GraphicsSystem::getCamera
Ogre::Camera * getCamera(void) const
Definition: GraphicsSystem.h:148
Demo::MovableObjectDefinition::moType
MovableObjectType moType
Definition: GameEntity.h:25
Demo::GraphicsSystem::registerHlms
virtual void registerHlms(void)
Definition: GraphicsSystem.cpp:888
BlamEngineDataFolder::Resources
@ Resources
Directory containing other resources and data, usually string tables and globals. Defaults to ....
Demo::GraphicsSystem::getOverlaySystem
Ogre::v1::OverlaySystem * getOverlaySystem(void) const
Definition: GraphicsSystem.h:150
Demo::GraphicsSystem::GraphicsSystem
GraphicsSystem(GameState *gameState=nullptr, Ogre::String resourcePath=Ogre::String(""), Ogre::ColourValue backgroundColour=Ogre::ColourValue(0.2f, 0.4f, 0.6f))
Definition: GraphicsSystem.cpp:53
Demo::GraphicsSystem::saveTextureCache
void saveTextureCache(void)
Definition: GraphicsSystem.cpp:727
Demo::GraphicsSystem::getPluginsFolder
const Ogre::String & getPluginsFolder(void) const
Definition: GraphicsSystem.h:155
Demo::GameEntityManager::CreatedGameEntity::gameEntity
GameEntity * gameEntity
Definition: GameEntityManager.h:18
Demo::GraphicsSystem::_notifyLogicSystem
void _notifyLogicSystem(BaseSystem *logicSystem)
Definition: GraphicsSystem.h:106
endif
Media endif() install(DIRECTORY $
Definition: CMakeLists.txt:21
Demo::BaseSystem::deinitialize
virtual void deinitialize(void)
Definition: BaseSystem.cpp:24
Demo::GraphicsSystem::deinitialize
void deinitialize(void)
Definition: GraphicsSystem.cpp:535
Demo::GraphicsSystem::mResourcePath
Ogre::String mResourcePath
Definition: GraphicsSystem.h:46
Demo::GraphicsSystem::mAlwaysAskForConfig
bool mAlwaysAskForConfig
Definition: GraphicsSystem.h:61
Demo::GraphicsSystem::gameEntityAdded
void gameEntityAdded(const GameEntityManager::CreatedGameEntity *createdGameEntity)
Definition: GraphicsSystem.cpp:1147
Demo::MovableObjectDefinition::resourceGroup
Ogre::String resourceGroup
Definition: GameEntity.h:23
Demo::GraphicsSystem::mQuit
bool mQuit
Definition: GraphicsSystem.h:60
file
sock planetquake com All rights reserved Quake III Arena is a registered trademark of id Inc This level may be electronically distributed only at NO CHARGE to the recipient in its current MUST include this txt file
Definition: chiropteraDM.txt:95
Demo::Mq::GAME_ENTITY_SCHEDULED_FOR_REMOVAL_SLOT
@ GAME_ENTITY_SCHEDULED_FOR_REMOVAL_SLOT
Definition: MqMessages.h:19
Demo::GraphicsSystem::setQuit
void setQuit(void)
Definition: GraphicsSystem.h:140
Demo::Mq::MessageId
MessageId
Definition: MqMessages.h:12
Demo::GraphicsSystem::updateGameEntities
void updateGameEntities(const GameEntityVec &gameEntities, float weight)
Updates the SceneNodes of all the game entities in the container, interpolating them according to wei...
Definition: GraphicsSystem.cpp:1211
StaticPluginLoader.h
Demo::GameEntity
Definition: GameEntity.h:35
Demo::GraphicsSystem::loadHlmsDiskCache
void loadHlmsDiskCache(void)
Definition: GraphicsSystem.cpp:745
Demo::GraphicsSystem::setAlwaysAskForConfig
void setAlwaysAskForConfig(bool alwaysAskForConfig)
Definition: GraphicsSystem.cpp:1072
timeSinceLast
double timeSinceLast
Definition: ogre.cpp:56
Demo::StaticPluginLoader::install
void install(Ogre::Root *root)
Definition: StaticPluginLoader.cpp:104
GraphicsSystem.h
BaseSystem.h
Demo::GraphicsSystem
Definition: GraphicsSystem.h:27
Demo::GraphicsSystem::processIncomingMessage
virtual void processIncomingMessage(Mq::MessageId messageId, const void *data)
Definition: GraphicsSystem.cpp:630
NUM_GAME_ENTITY_BUFFERS
#define NUM_GAME_ENTITY_BUFFERS
Definition: GameEntity.h:11
Demo::GraphicsSystem::mBackgroundColour
Ogre::ColourValue mBackgroundColour
Definition: GraphicsSystem.h:65
SdlInputHandler.h
Demo::GraphicsSystem::mThreadGameEntityToUpdate
const GameEntityVec * mThreadGameEntityToUpdate
Definition: GraphicsSystem.h:57
Demo::GraphicsSystem::createResourceListener
virtual void createResourceListener(void)
Optional override method where you can create resource listeners (e.g. for loading screens)
Definition: GraphicsSystem.h:94
Demo::GameEntityCmp::operator()
bool operator()(const GameEntity *_l, const Ogre::Matrix4 *RESTRICT_ALIAS _r) const
Definition: GraphicsSystem.cpp:1127
BlamCompositorPassRegistry
Class used to make custom compositor passes available to OGRE.
Definition: compositor.h:52
Demo::GraphicsSystem::update
void update(float timeSinceLast)
Definition: GraphicsSystem.cpp:569
uintptr_t
_W64 unsigned int uintptr_t
Definition: stdint.h:52
Demo::GraphicsSystem::getQuit
bool getQuit(void) const
Definition: GraphicsSystem.h:141
Demo::GameEntityManager::CreatedGameEntity
Definition: GameEntityManager.h:16
Demo::MovableObjectDefinition::submeshMaterials
Ogre::StringVector submeshMaterials
Definition: GameEntity.h:24
Demo::GraphicsSystem::chooseSceneManager
virtual void chooseSceneManager(void)
Definition: GraphicsSystem.cpp:1016
Demo::GameEntityVec
std::vector< GameEntity * > GameEntityVec
Definition: GameEntity.h:88
config.h
Demo::GraphicsSystem::restartCompositor
virtual void restartCompositor(void)
Definition: GraphicsSystem.cpp:1096
Demo::StaticPluginLoader
Utility class to load plugins statically.
Definition: StaticPluginLoader.h:59
Demo::GraphicsSystem::mAccumTimeSinceLastLogicFrame
float mAccumTimeSinceLastLogicFrame
Tracks the amount of elapsed time since we last heard from the LogicSystem finishing a frame.
Definition: GraphicsSystem.h:54
BlamUserDataFolder::DataRoot
@ DataRoot
The root of all user data. Defaults to BlamStrings::Utils::IO::GetEngineDataRoot().
Demo::BaseSystem::initialize
virtual void initialize(void)
Definition: BaseSystem.cpp:16
compositor.h
SDL_Event
Definition: SdlEmulationLayer.h:735
Demo::GameEntityCmp
Definition: GraphicsSystem.cpp:1125
Demo::GraphicsSystem::mWorkspace
Ogre::CompositorWorkspace * mWorkspace
Definition: GraphicsSystem.h:43
Demo::BaseSystem::mCurrentGameState
GameState * mCurrentGameState
Definition: BaseSystem.h:14
Demo::GameEntityManager::CreatedGameEntity::initialTransform
GameEntityTransform initialTransform
Definition: GameEntityManager.h:19
Demo::GraphicsSystem::getRoot
Ogre::Root * getRoot(void) const
Definition: GraphicsSystem.h:145
Demo::GraphicsSystem::mRoot
Ogre::Root * mRoot
Definition: GraphicsSystem.h:39
Demo::GraphicsSystem::mUseHlmsDiskCache
bool mUseHlmsDiskCache
Definition: GraphicsSystem.h:62
Demo::GraphicsSystem::createCamera
virtual void createCamera(void)
Definition: GraphicsSystem.cpp:1040
Demo::MovableObjectDefinition::meshName
Ogre::String meshName
Definition: GameEntity.h:22
Demo::Mq::GAME_ENTITY_ADDED
@ GAME_ENTITY_ADDED
Definition: MqMessages.h:16
Blam::GetMainWindowHandle
BLAM SDL_Window * GetMainWindowHandle()
Retrieves the main window handle of the application, when using SDL.
Definition: main.cpp:550
Demo::GraphicsSystem::mLogicSystem
BaseSystem * mLogicSystem
Definition: GraphicsSystem.h:33
Demo::Mq::LOGICFRAME_FINISHED
@ LOGICFRAME_FINISHED
Definition: MqMessages.h:15