1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2024-12-29 03:19:44 +00:00
OpenMW/components/myguiplatform/myguirendermanager.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

129 lines
3.7 KiB
C++
Raw Normal View History

2015-04-30 23:15:25 +00:00
#ifndef OPENMW_COMPONENTS_MYGUIPLATFORM_MYGUIRENDERMANAGER_H
#define OPENMW_COMPONENTS_MYGUIPLATFORM_MYGUIRENDERMANAGER_H
2015-04-24 19:55:30 +00:00
#include <MyGUI_RenderManager.h>
#include <osg/ref_ptr>
namespace Resource
{
2016-02-05 22:03:53 +00:00
class ImageManager;
2015-04-24 19:55:30 +00:00
}
2021-07-22 22:55:30 +00:00
namespace Shader
{
class ShaderManager;
}
2015-04-24 19:55:30 +00:00
namespace osgViewer
{
class Viewer;
}
namespace osg
{
class Group;
class Camera;
class RenderInfo;
class StateSet;
2015-04-24 19:55:30 +00:00
}
2015-04-30 23:15:25 +00:00
namespace osgMyGUI
2015-04-24 19:55:30 +00:00
{
class Drawable;
2022-07-18 19:14:39 +00:00
class OSGTexture;
2015-04-24 19:55:30 +00:00
class RenderManager : public MyGUI::RenderManager, public MyGUI::IRenderTarget
{
osg::ref_ptr<osgViewer::Viewer> mViewer;
osg::ref_ptr<osg::Group> mSceneRoot;
osg::ref_ptr<Drawable> mDrawable;
Resource::ImageManager* mImageManager;
2015-04-24 19:55:30 +00:00
MyGUI::IntSize mViewSize;
bool mUpdate;
MyGUI::VertexColourType mVertexFormat;
MyGUI::RenderTargetInfo mInfo;
2022-07-18 19:14:39 +00:00
std::map<std::string, OSGTexture> mTextures;
2015-04-24 19:55:30 +00:00
bool mIsInitialise;
osg::ref_ptr<osg::Camera> mGuiRoot;
2015-05-14 22:41:21 +00:00
float mInvScalingFactor;
osg::StateSet* mInjectState;
2015-04-24 19:55:30 +00:00
public:
RenderManager(osgViewer::Viewer* viewer, osg::Group* sceneroot, Resource::ImageManager* imageManager,
float scalingFactor);
2015-04-24 19:55:30 +00:00
virtual ~RenderManager();
void initialise();
2015-04-28 14:02:29 +00:00
void shutdown();
2015-04-24 19:55:30 +00:00
2021-07-22 22:55:30 +00:00
void enableShaders(Shader::ShaderManager& shaderManager);
2015-04-24 19:55:30 +00:00
static RenderManager& getInstance() { return *getInstancePtr(); }
static RenderManager* getInstancePtr()
{
return static_cast<RenderManager*>(MyGUI::RenderManager::getInstancePtr());
}
2023-08-07 11:44:41 +00:00
bool checkTexture(MyGUI::ITexture* _texture) override;
2015-04-24 19:55:30 +00:00
/** @see RenderManager::getViewSize */
2023-08-07 12:09:32 +00:00
const MyGUI::IntSize& getViewSize() const override { return mViewSize; }
2015-04-24 19:55:30 +00:00
/** @see RenderManager::getVertexFormat */
2023-08-07 12:09:32 +00:00
MyGUI::VertexColourType getVertexFormat() const override { return mVertexFormat; }
2015-04-24 19:55:30 +00:00
/** @see RenderManager::isFormatSupported */
bool isFormatSupported(MyGUI::PixelFormat format, MyGUI::TextureUsage usage) override;
2015-04-24 19:55:30 +00:00
/** @see RenderManager::createVertexBuffer */
MyGUI::IVertexBuffer* createVertexBuffer() override;
2015-04-24 19:55:30 +00:00
/** @see RenderManager::destroyVertexBuffer */
void destroyVertexBuffer(MyGUI::IVertexBuffer* buffer) override;
2015-04-24 19:55:30 +00:00
/** @see RenderManager::createTexture */
MyGUI::ITexture* createTexture(const std::string& name) override;
2015-04-24 19:55:30 +00:00
/** @see RenderManager::destroyTexture */
void destroyTexture(MyGUI::ITexture* _texture) override;
2015-04-24 19:55:30 +00:00
/** @see RenderManager::getTexture */
MyGUI::ITexture* getTexture(const std::string& name) override;
2015-04-24 19:55:30 +00:00
// Called by the update traversal
void update();
2015-04-24 19:55:30 +00:00
// Called by the cull traversal
2015-04-24 19:55:30 +00:00
/** @see IRenderTarget::begin */
void begin() override;
2015-04-24 19:55:30 +00:00
/** @see IRenderTarget::end */
void end() override;
2015-04-24 19:55:30 +00:00
/** @see IRenderTarget::doRender */
void doRender(MyGUI::IVertexBuffer* buffer, MyGUI::ITexture* texture, size_t count) override;
2018-10-09 06:21:12 +00:00
/** specify a StateSet to inject for rendering. The StateSet will be used by future doRender calls until you
* reset it to nullptr again. */
void setInjectState(osg::StateSet* stateSet);
2015-04-24 19:55:30 +00:00
/** @see IRenderTarget::getInfo */
2023-08-07 12:09:32 +00:00
const MyGUI::RenderTargetInfo& getInfo() const override { return mInfo; }
2015-04-24 19:55:30 +00:00
2020-10-18 05:55:55 +00:00
void setViewSize(int width, int height) override;
void registerShader(const std::string& _shaderName, const std::string& _vertexProgramFile,
const std::string& _fragmentProgramFile) override;
2015-04-24 19:55:30 +00:00
/*internal:*/
void collectDrawCalls();
2015-04-24 19:55:30 +00:00
};
}
#endif