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;
|
2015-11-07 16:21:03 +00:00
|
|
|
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
|
|
|
{
|
|
|
|
|
2015-05-04 20:17:28 +00:00
|
|
|
class Drawable;
|
2022-07-18 19:14:39 +00:00
|
|
|
class OSGTexture;
|
2015-05-04 20:17:28 +00:00
|
|
|
|
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;
|
2015-05-04 20:17:28 +00:00
|
|
|
osg::ref_ptr<Drawable> mDrawable;
|
2016-02-05 22:10:27 +00:00
|
|
|
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;
|
|
|
|
|
2015-11-07 16:21:03 +00:00
|
|
|
osg::StateSet* mInjectState;
|
|
|
|
|
2015-04-24 19:55:30 +00:00
|
|
|
public:
|
2016-02-05 22:10:27 +00:00
|
|
|
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;
|
2023-08-06 16:05:59 +00:00
|
|
|
|
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 */
|
2020-10-16 18:18:54 +00:00
|
|
|
bool isFormatSupported(MyGUI::PixelFormat format, MyGUI::TextureUsage usage) override;
|
2015-04-24 19:55:30 +00:00
|
|
|
|
|
|
|
/** @see RenderManager::createVertexBuffer */
|
2020-10-16 18:18:54 +00:00
|
|
|
MyGUI::IVertexBuffer* createVertexBuffer() override;
|
2015-04-24 19:55:30 +00:00
|
|
|
/** @see RenderManager::destroyVertexBuffer */
|
2020-10-16 18:18:54 +00:00
|
|
|
void destroyVertexBuffer(MyGUI::IVertexBuffer* buffer) override;
|
2015-04-24 19:55:30 +00:00
|
|
|
|
|
|
|
/** @see RenderManager::createTexture */
|
2020-10-16 18:18:54 +00:00
|
|
|
MyGUI::ITexture* createTexture(const std::string& name) override;
|
2015-04-24 19:55:30 +00:00
|
|
|
/** @see RenderManager::destroyTexture */
|
2020-10-16 18:18:54 +00:00
|
|
|
void destroyTexture(MyGUI::ITexture* _texture) override;
|
2015-04-24 19:55:30 +00:00
|
|
|
/** @see RenderManager::getTexture */
|
2020-10-16 18:18:54 +00:00
|
|
|
MyGUI::ITexture* getTexture(const std::string& name) override;
|
2015-04-24 19:55:30 +00:00
|
|
|
|
2015-05-04 20:17:28 +00:00
|
|
|
// Called by the update traversal
|
|
|
|
void update();
|
2015-04-24 19:55:30 +00:00
|
|
|
|
2015-05-04 20:17:28 +00:00
|
|
|
// Called by the cull traversal
|
2015-04-24 19:55:30 +00:00
|
|
|
/** @see IRenderTarget::begin */
|
2020-10-16 18:18:54 +00:00
|
|
|
void begin() override;
|
2015-04-24 19:55:30 +00:00
|
|
|
/** @see IRenderTarget::end */
|
2020-10-16 18:18:54 +00:00
|
|
|
void end() override;
|
2015-04-24 19:55:30 +00:00
|
|
|
/** @see IRenderTarget::doRender */
|
2020-10-16 18:18:54 +00:00
|
|
|
void doRender(MyGUI::IVertexBuffer* buffer, MyGUI::ITexture* texture, size_t count) override;
|
2015-05-04 20:17:28 +00:00
|
|
|
|
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. */
|
2015-11-07 16:21:03 +00:00
|
|
|
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;
|
|
|
|
|
2021-01-23 13:49:16 +00:00
|
|
|
void registerShader(const std::string& _shaderName, const std::string& _vertexProgramFile,
|
|
|
|
const std::string& _fragmentProgramFile) override;
|
|
|
|
|
2015-04-24 19:55:30 +00:00
|
|
|
/*internal:*/
|
2015-05-04 20:17:28 +00:00
|
|
|
|
|
|
|
void collectDrawCalls();
|
2015-04-24 19:55:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|