Elaztek Developer Hub
Blamite Game Engine - blam!  00398.09.22.23.2015.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 
12 #include "OGRE/Threading/OgreUniformScalableTask.h"
13 #include "SdlEmulationLayer.h"
14 #include "OGRE/Overlay/OgreOverlaySystem.h"
15 
17 
18 #if OGRE_USE_SDL2
19  #include <SDL2/SDL.h>
20 #endif
21 
22 namespace Demo
23 {
24  class SdlInputHandler;
25 
26  class GraphicsSystem : public BaseSystem, public Ogre::UniformScalableTask
27  {
28  private:
30 
31  protected:
33 
34  #if OGRE_USE_SDL2
35  SDL_Window *mSdlWindow;
36  #endif
37 
38  Ogre::Root *mRoot;
39  Ogre::Window *mRenderWindow;
40  Ogre::SceneManager *mSceneManager;
41  Ogre::Camera *mCamera;
42  Ogre::CompositorWorkspace *mWorkspace;
46 
47  Ogre::v1::OverlaySystem *mOverlaySystem;
48 
50 
54  Ogre::uint32 mCurrentTransformIdx;
55  GameEntityVec mGameEntities[Ogre::NUM_SCENE_MEMORY_MANAGER_TYPES];
58 
59  bool mQuit;
63 
64  Ogre::ColourValue mBackgroundColour;
65 
66  bool isWriteAccessFolder( const Ogre::String &folderPath, const Ogre::String &fileToSave );
67 
69  virtual void processIncomingMessage( Mq::MessageId messageId, const void *data );
70 
71  static void addResourceLocation( const Ogre::String &archName, const Ogre::String &typeName,
72  const Ogre::String &secName );
73  void loadTextureCache(void);
74  void saveTextureCache(void);
75  void loadHlmsDiskCache(void);
76  void saveHlmsDiskCache(void);
77  virtual void setupResources(void);
78  virtual void registerHlms(void);
81  virtual void loadResources(void);
82  virtual void chooseSceneManager(void);
83  virtual void createCamera(void);
87  virtual Ogre::CompositorWorkspace* setupCompositor(void);
88 
90  virtual void initMiscParamsListener( Ogre::NameValuePairList &params );
91 
93  virtual void createResourceListener(void) {}
94 
95  void gameEntityAdded( const GameEntityManager::CreatedGameEntity *createdGameEntity );
96  void gameEntityRemoved( GameEntity *toRemove );
97  public:
99 
101 
102  GraphicsSystem( GameState *gameState = nullptr, Ogre::String resourcePath = Ogre::String(""), Ogre::ColourValue backgroundColour = Ogre::ColourValue( 0.2f, 0.4f, 0.6f ) );
103  virtual ~GraphicsSystem();
104 
105  void _notifyLogicSystem( BaseSystem *logicSystem ) { mLogicSystem = logicSystem; }
106 
107  void initialize( const Ogre::String &windowTitle );
108  void deinitialize(void);
109 
110 #if OGRE_USE_SDL2
111  void handleWindowEvent(const SDL_Event& evt);
112  SdlInputHandler* mInputHandler;
113 #endif
114 
115  void update( float timeSinceLast );
116 
125  void updateGameEntities( const GameEntityVec &gameEntities, float weight );
126 
128  virtual void execute( size_t threadId, size_t numThreads );
129 
132  const GameEntityVec& getGameEntities( Ogre::SceneMemoryMgrTypes type ) const
133  { return mGameEntities[type]; }
134 
135  #if OGRE_USE_SDL2
136  SdlInputHandler* getInputHandler(void) { return mInputHandler; }
137  #endif
138 
139  void setQuit(void) { mQuit = true; }
140  bool getQuit(void) const { return mQuit; }
141 
143 
144  Ogre::Root* getRoot(void) const { return mRoot; }
145  Ogre::Window* getRenderWindow(void) const { return mRenderWindow; }
146  Ogre::SceneManager* getSceneManager(void) const { return mSceneManager; }
147  Ogre::Camera* getCamera(void) const { return mCamera; }
148  Ogre::CompositorWorkspace* getCompositorWorkspace(void) const { return mWorkspace; }
149  Ogre::v1::OverlaySystem* getOverlaySystem(void) const { return mOverlaySystem; }
150 
151  void setAlwaysAskForConfig( bool alwaysAskForConfig );
152  bool getAlwaysAskForConfig( void ) const { return mAlwaysAskForConfig; }
153 
154  const Ogre::String& getPluginsFolder(void) const { return mPluginsFolder; }
155  const Ogre::String& getWriteAccessFolder(void) const { return mWriteAccessFolder; }
156  const Ogre::String& getResourcePath(void) const { return mResourcePath; }
157  const char *getMediaReadArchiveType( void ) const;
158 
159  virtual void stopCompositor(void);
160  virtual void restartCompositor(void);
161  };
162 }
163 
164 #endif
Demo::GraphicsSystem::mGameEntities
GameEntityVec mGameEntities[Ogre::NUM_SCENE_MEMORY_MANAGER_TYPES]
Definition: GraphicsSystem.h:55
Demo::MoTypeItem
@ MoTypeItem
Definition: GameEntity.h:15
Blam::Settings::Config::GetEngineConfiguration
BLAM BlamConfigurationFile * GetEngineConfiguration()
Definition: config.cpp:58
Demo::GraphicsSystem::mUseMicrocodeCache
bool mUseMicrocodeCache
Definition: GraphicsSystem.h:62
Demo::GraphicsSystem::getRenderWindow
Ogre::Window * getRenderWindow(void) const
Definition: GraphicsSystem.h:145
Demo::GraphicsSystem::mPluginsFolder
Ogre::String mPluginsFolder
Definition: GraphicsSystem.h:43
Blam::Logger::LogEvent
BLAM void LogEvent(std::string message)
Logs a message to the log and/or console.
Definition: aliases.cpp:142
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:947
width
int width
Definition: bgfx.cpp:19
Demo::GraphicsSystem::addResourceLocation
static void addResourceLocation(const Ogre::String &archName, const Ogre::String &typeName, const Ogre::String &secName)
Definition: GraphicsSystem.cpp:629
logger.h
Demo::GraphicsSystem::ogre_pass_registry
BlamCompositorPassRegistry * ogre_pass_registry
Definition: GraphicsSystem.h:100
Demo::GraphicsSystem::getResourcePath
const Ogre::String & getResourcePath(void) const
Definition: GraphicsSystem.h:156
Demo::GameEntity::mTransform
GameEntityTransform * mTransform[NUM_GAME_ENTITY_BUFFERS]
Definition: GameEntity.h:53
Demo::GraphicsSystem::mThreadWeight
float mThreadWeight
Definition: GraphicsSystem.h:57
Demo::GraphicsSystem::getGameEntities
const GameEntityVec & getGameEntities(Ogre::SceneMemoryMgrTypes type) const
Returns the GameEntities that are ready to be rendered.
Definition: GraphicsSystem.h:132
Demo::GraphicsSystem::mCamera
Ogre::Camera * mCamera
Definition: GraphicsSystem.h:41
Demo::GameEntityTransform::qRot
Ogre::Quaternion qRot
Definition: GameEntity.h:31
Demo::GraphicsSystem::gameEntityRemoved
void gameEntityRemoved(GameEntity *toRemove)
Definition: GraphicsSystem.cpp:1127
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:155
Demo::GameEntityTransform::vPos
Ogre::Vector3 vPos
Definition: GameEntity.h:30
Demo::GraphicsSystem::mCurrentTransformIdx
Ogre::uint32 mCurrentTransformIdx
Definition: GraphicsSystem.h:54
Demo::GraphicsSystem::mWriteAccessFolder
Ogre::String mWriteAccessFolder
Definition: GraphicsSystem.h:44
Demo::GraphicsSystem::mOverlaySystem
Ogre::v1::OverlaySystem * mOverlaySystem
Definition: GraphicsSystem.h:47
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:1027
Demo::GraphicsSystem::getCompositorWorkspace
Ogre::CompositorWorkspace * getCompositorWorkspace(void) const
Definition: GraphicsSystem.h:148
Demo::GraphicsSystem::getAccumTimeSinceLastLogicFrame
float getAccumTimeSinceLastLogicFrame(void) const
Definition: GraphicsSystem.h:142
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:43
Demo::GameEntity::mSceneNode
Ogre::SceneNode * mSceneNode
Definition: GameEntity.h:44
Demo
Definition: BaseSystem.cpp:5
Demo::GraphicsSystem::loadTextureCache
void loadTextureCache(void)
Definition: GraphicsSystem.cpp:646
Demo::GraphicsSystem::getAlwaysAskForConfig
bool getAlwaysAskForConfig(void) const
Definition: GraphicsSystem.h:152
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:1159
config
ImFontConfig config
Definition: README.txt:49
Demo::GameEntityTransform::vScale
Ogre::Vector3 vScale
Definition: GameEntity.h:32
Demo::GraphicsSystem::getSceneManager
Ogre::SceneManager * getSceneManager(void) const
Definition: GraphicsSystem.h:146
GameEntityManager.h
Demo::GraphicsSystem::mRenderWindow
Ogre::Window * mRenderWindow
Definition: GraphicsSystem.h:39
Demo::GameEntity::mType
Ogre::SceneMemoryMgrTypes mType
Definition: GameEntity.h:54
Demo::GraphicsSystem::stopCompositor
virtual void stopCompositor(void)
Definition: GraphicsSystem.cpp:1045
Blam::Globals::String
@ String
Represents a std::string.
Definition: globals.h:48
Demo::GraphicsSystem::mStaticPluginLoader
StaticPluginLoader mStaticPluginLoader
Definition: GraphicsSystem.h:49
Demo::GameState
Definition: GameState.h:9
Demo::GraphicsSystem::debug_mode_thread_count
size_t debug_mode_thread_count
Definition: GraphicsSystem.h:98
Demo::GraphicsSystem::saveHlmsDiskCache
void saveHlmsDiskCache(void)
Definition: GraphicsSystem.cpp:762
Demo::GraphicsSystem::setupResources
virtual void setupResources(void)
Definition: GraphicsSystem.cpp:804
Demo::GraphicsSystem::getMediaReadArchiveType
const char * getMediaReadArchiveType(void) const
Definition: GraphicsSystem.cpp:1036
GameState.h
ENGINE_DATA_PATH
#define ENGINE_DATA_PATH(path)
Macro to quickly access a game engine data folder.
Definition: config.h:36
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:1012
OGRE_USE_SDL2
#define OGRE_USE_SDL2
Definition: SdlEmulationLayer.h:8
Demo::GraphicsSystem::mSceneManager
Ogre::SceneManager * mSceneManager
Definition: GraphicsSystem.h:40
Demo::GraphicsSystem::~GraphicsSystem
virtual ~GraphicsSystem()
Definition: GraphicsSystem.cpp:94
Demo::GraphicsSystem::getCamera
Ogre::Camera * getCamera(void) const
Definition: GraphicsSystem.h:147
Demo::MovableObjectDefinition::moType
MovableObjectType moType
Definition: GameEntity.h:25
Demo::GraphicsSystem::registerHlms
virtual void registerHlms(void)
Definition: GraphicsSystem.cpp:847
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:149
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:686
Demo::GraphicsSystem::getPluginsFolder
const Ogre::String & getPluginsFolder(void) const
Definition: GraphicsSystem.h:154
Demo::GameEntityManager::CreatedGameEntity::gameEntity
GameEntity * gameEntity
Definition: GameEntityManager.h:18
Demo::GraphicsSystem::_notifyLogicSystem
void _notifyLogicSystem(BaseSystem *logicSystem)
Definition: GraphicsSystem.h:105
Demo::BaseSystem::deinitialize
virtual void deinitialize(void)
Definition: BaseSystem.cpp:24
Demo::GraphicsSystem::deinitialize
void deinitialize(void)
Definition: GraphicsSystem.cpp:494
Demo::GraphicsSystem::mResourcePath
Ogre::String mResourcePath
Definition: GraphicsSystem.h:45
Demo::GraphicsSystem::mAlwaysAskForConfig
bool mAlwaysAskForConfig
Definition: GraphicsSystem.h:60
Demo::GraphicsSystem::gameEntityAdded
void gameEntityAdded(const GameEntityManager::CreatedGameEntity *createdGameEntity)
Definition: GraphicsSystem.cpp:1084
Demo::MovableObjectDefinition::resourceGroup
Ogre::String resourceGroup
Definition: GameEntity.h:23
Demo::GraphicsSystem::mQuit
bool mQuit
Definition: GraphicsSystem.h:59
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:139
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:1148
StaticPluginLoader.h
Demo::GameEntity
Definition: GameEntity.h:35
Demo::GraphicsSystem::loadHlmsDiskCache
void loadHlmsDiskCache(void)
Definition: GraphicsSystem.cpp:704
Demo::GraphicsSystem::setAlwaysAskForConfig
void setAlwaysAskForConfig(bool alwaysAskForConfig)
Definition: GraphicsSystem.cpp:1031
timeSinceLast
double timeSinceLast
Definition: ogre.cpp:57
Demo::StaticPluginLoader::install
void install(Ogre::Root *root)
Definition: StaticPluginLoader.cpp:104
height
int height
Definition: bgfx.cpp:20
GraphicsSystem.h
BaseSystem.h
Demo::GraphicsSystem
Definition: GraphicsSystem.h:26
Demo::GraphicsSystem::processIncomingMessage
virtual void processIncomingMessage(Mq::MessageId messageId, const void *data)
Definition: GraphicsSystem.cpp:589
NUM_GAME_ENTITY_BUFFERS
#define NUM_GAME_ENTITY_BUFFERS
Definition: GameEntity.h:11
Demo::GraphicsSystem::mBackgroundColour
Ogre::ColourValue mBackgroundColour
Definition: GraphicsSystem.h:64
SdlInputHandler.h
Demo::GraphicsSystem::mThreadGameEntityToUpdate
const GameEntityVec * mThreadGameEntityToUpdate
Definition: GraphicsSystem.h:56
Demo::GraphicsSystem::createResourceListener
virtual void createResourceListener(void)
Optional override method where you can create resource listeners (e.g. for loading screens)
Definition: GraphicsSystem.h:93
Demo::GameEntityCmp::operator()
bool operator()(const GameEntity *_l, const Ogre::Matrix4 *RESTRICT_ALIAS _r) const
Definition: GraphicsSystem.cpp:1064
BlamCompositorPassRegistry
Definition: compositor.h:29
Demo::GraphicsSystem::update
void update(float timeSinceLast)
Definition: GraphicsSystem.cpp:528
uintptr_t
_W64 unsigned int uintptr_t
Definition: stdint.h:52
Demo::GraphicsSystem::getQuit
bool getQuit(void) const
Definition: GraphicsSystem.h:140
Demo::GameEntityManager::CreatedGameEntity
Definition: GameEntityManager.h:16
core.h
Demo::MovableObjectDefinition::submeshMaterials
Ogre::StringVector submeshMaterials
Definition: GameEntity.h:24
Demo::GraphicsSystem::chooseSceneManager
virtual void chooseSceneManager(void)
Definition: GraphicsSystem.cpp:975
Demo::GameEntityVec
std::vector< GameEntity * > GameEntityVec
Definition: GameEntity.h:88
config.h
Demo::GraphicsSystem::restartCompositor
virtual void restartCompositor(void)
Definition: GraphicsSystem.cpp:1055
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:53
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:1062
Demo::GraphicsSystem::mWorkspace
Ogre::CompositorWorkspace * mWorkspace
Definition: GraphicsSystem.h:42
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:144
Demo::GraphicsSystem::mRoot
Ogre::Root * mRoot
Definition: GraphicsSystem.h:38
Demo::GraphicsSystem::mUseHlmsDiskCache
bool mUseHlmsDiskCache
Definition: GraphicsSystem.h:61
Demo::GraphicsSystem::createCamera
virtual void createCamera(void)
Definition: GraphicsSystem.cpp:999
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:729
Demo::GraphicsSystem::mLogicSystem
BaseSystem * mLogicSystem
Definition: GraphicsSystem.h:32
Demo::Mq::LOGICFRAME_FINISHED
@ LOGICFRAME_FINISHED
Definition: MqMessages.h:15