OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
myguirendermanager.hpp
Go to the documentation of this file.
1 #ifndef OPENMW_COMPONENTS_MYGUIPLATFORM_MYGUIRENDERMANAGER_H
2 #define OPENMW_COMPONENTS_MYGUIPLATFORM_MYGUIRENDERMANAGER_H
3 
4 #include <MyGUI_RenderManager.h>
5 
6 #include <osg/ref_ptr>
7 
8 namespace Resource
9 {
10  class ImageManager;
11 }
12 
13 namespace osgViewer
14 {
15  class Viewer;
16 }
17 
18 namespace osg
19 {
20  class Group;
21  class Camera;
22  class RenderInfo;
23  class StateSet;
24 }
25 
26 namespace osgMyGUI
27 {
28 
29 class Drawable;
30 
31 class RenderManager : public MyGUI::RenderManager, public MyGUI::IRenderTarget
32 {
33  osg::ref_ptr<osgViewer::Viewer> mViewer;
34  osg::ref_ptr<osg::Group> mSceneRoot;
35  osg::ref_ptr<Drawable> mDrawable;
37 
38  MyGUI::IntSize mViewSize;
39  bool mUpdate;
40  MyGUI::VertexColourType mVertexFormat;
41  MyGUI::RenderTargetInfo mInfo;
42 
43  typedef std::map<std::string, MyGUI::ITexture*> MapTexture;
45 
47 
48  osg::ref_ptr<osg::Camera> mGuiRoot;
49 
51 
52  osg::StateSet* mInjectState;
53 
54  void destroyAllResources();
55 
56 public:
57  RenderManager(osgViewer::Viewer *viewer, osg::Group *sceneroot, Resource::ImageManager* imageManager, float scalingFactor);
58  virtual ~RenderManager();
59 
60  void initialise();
61  void shutdown();
62 
63  void setScalingFactor(float factor);
64 
65  static RenderManager& getInstance() { return *getInstancePtr(); }
67  { return static_cast<RenderManager*>(MyGUI::RenderManager::getInstancePtr()); }
68 
70  virtual const MyGUI::IntSize& getViewSize() const { return mViewSize; }
71 
73  virtual MyGUI::VertexColourType getVertexFormat() { return mVertexFormat; }
74 
76  virtual bool isFormatSupported(MyGUI::PixelFormat format, MyGUI::TextureUsage usage);
77 
79  virtual MyGUI::IVertexBuffer* createVertexBuffer();
81  virtual void destroyVertexBuffer(MyGUI::IVertexBuffer *buffer);
82 
84  virtual MyGUI::ITexture* createTexture(const std::string &name);
86  virtual void destroyTexture(MyGUI::ITexture* _texture);
88  virtual MyGUI::ITexture* getTexture(const std::string &name);
89 
90  // Called by the update traversal
91  void update();
92 
93  // Called by the cull traversal
95  virtual void begin();
97  virtual void end();
99  virtual void doRender(MyGUI::IVertexBuffer *buffer, MyGUI::ITexture *texture, size_t count);
100 
102  void setInjectState(osg::StateSet* stateSet);
103 
105  virtual const MyGUI::RenderTargetInfo& getInfo() { return mInfo; }
106 
107  bool checkTexture(MyGUI::ITexture* _texture);
108 
109 /*internal:*/
110 
111  void collectDrawCalls();
112  void setViewSize(int width, int height);
113 };
114 
115 }
116 
117 #endif
Resource::ImageManager * mImageManager
Definition: myguirendermanager.hpp:36
virtual const MyGUI::RenderTargetInfo & getInfo()
Definition: myguirendermanager.hpp:105
bool checkTexture(MyGUI::ITexture *_texture)
Definition: myguirendermanager.cpp:559
virtual void destroyTexture(MyGUI::ITexture *_texture)
Definition: myguirendermanager.cpp:525
virtual void end()
Definition: myguirendermanager.cpp:460
static RenderManager * getInstancePtr()
Definition: myguirendermanager.hpp:66
osg::ref_ptr< osg::Camera > mGuiRoot
Definition: myguirendermanager.hpp:48
virtual bool isFormatSupported(MyGUI::PixelFormat format, MyGUI::TextureUsage usage)
Definition: myguirendermanager.cpp:506
osg::StateSet * mInjectState
Definition: myguirendermanager.hpp:52
void setInjectState(osg::StateSet *stateSet)
Definition: myguirendermanager.cpp:455
bool mUpdate
Definition: myguirendermanager.hpp:39
virtual void doRender(MyGUI::IVertexBuffer *buffer, MyGUI::ITexture *texture, size_t count)
Definition: myguirendermanager.cpp:436
void destroyAllResources()
Definition: myguirendermanager.cpp:552
void update()
Definition: myguirendermanager.cpp:464
MyGUI::IntSize mViewSize
Definition: myguirendermanager.hpp:38
osg::ref_ptr< osg::Group > mSceneRoot
Definition: myguirendermanager.hpp:34
Handles loading/caching of Images.
Definition: imagemanager.hpp:23
virtual MyGUI::VertexColourType getVertexFormat()
Definition: myguirendermanager.hpp:73
static RenderManager & getInstance()
Definition: myguirendermanager.hpp:65
std::map< std::string, MyGUI::ITexture * > MapTexture
Definition: myguirendermanager.hpp:43
MyGUI::VertexColourType mVertexFormat
Definition: myguirendermanager.hpp:40
virtual const MyGUI::IntSize & getViewSize() const
Definition: myguirendermanager.hpp:70
void setViewSize(int width, int height)
Definition: myguirendermanager.cpp:485
virtual void destroyVertexBuffer(MyGUI::IVertexBuffer *buffer)
Definition: myguirendermanager.cpp:423
virtual MyGUI::IVertexBuffer * createVertexBuffer()
Definition: myguirendermanager.cpp:418
virtual MyGUI::ITexture * createTexture(const std::string &name)
Definition: myguirendermanager.cpp:511
float mInvScalingFactor
Definition: myguirendermanager.hpp:50
void initialise()
Definition: myguirendermanager.cpp:381
void shutdown()
Definition: myguirendermanager.cpp:412
MapTexture mTextures
Definition: myguirendermanager.hpp:44
osg::ref_ptr< Drawable > mDrawable
Definition: myguirendermanager.hpp:35
MyGUI::RenderTargetInfo mInfo
Definition: myguirendermanager.hpp:41
Definition: myguirendermanager.hpp:31
virtual ~RenderManager()
Definition: myguirendermanager.cpp:364
RenderManager(osgViewer::Viewer *viewer, osg::Group *sceneroot, Resource::ImageManager *imageManager, float scalingFactor)
Definition: myguirendermanager.cpp:351
void collectDrawCalls()
Definition: myguirendermanager.cpp:476
bool mIsInitialise
Definition: myguirendermanager.hpp:46
virtual void begin()
Definition: myguirendermanager.cpp:429
osg::ref_ptr< osgViewer::Viewer > mViewer
Definition: myguirendermanager.hpp:33
virtual MyGUI::ITexture * getTexture(const std::string &name)
Definition: myguirendermanager.cpp:537
void setScalingFactor(float factor)
const char * name
Definition: crashcatcher.cpp:59