diff --git a/apps/openmw/mwgui/bookpage.hpp b/apps/openmw/mwgui/bookpage.hpp index 4e49b8f67..f9fd93089 100644 --- a/apps/openmw/mwgui/bookpage.hpp +++ b/apps/openmw/mwgui/bookpage.hpp @@ -53,7 +53,7 @@ namespace MWGui { static const int fontHeight = MWBase::Environment::get().getWindowManager()->getFontHeight(); - MyGUI::GlyphInfo* gi = font->getGlyphInfo(ch); + const MyGUI::GlyphInfo* gi = font->getGlyphInfo(ch); if (gi) { const float scale = font->getDefaultHeight() / (float) fontHeight; diff --git a/components/myguiplatform/myguicompat.h b/components/myguiplatform/myguicompat.h new file mode 100644 index 000000000..04ca11a79 --- /dev/null +++ b/components/myguiplatform/myguicompat.h @@ -0,0 +1,12 @@ +#ifndef OPENMW_COMPONENTS_MYGUIPLATFORM_MYGUICOMPAT_H +#define OPENMW_COMPONENTS_MYGUIPLATFORM_MYGUICOMPAT_H + +#include + +#if MYGUI_VERSION > MYGUI_DEFINE_VERSION(3, 4, 0) + #define OPENMW_MYGUI_CONST_GETTER_3_4_1 const +#else + #define OPENMW_MYGUI_CONST_GETTER_3_4_1 +#endif + +#endif // OPENMW_COMPONENTS_MYGUIPLATFORM_MYGUICOMPAT_H diff --git a/components/myguiplatform/myguidatamanager.cpp b/components/myguiplatform/myguidatamanager.cpp index c90e09221..0310e996b 100644 --- a/components/myguiplatform/myguidatamanager.cpp +++ b/components/myguiplatform/myguidatamanager.cpp @@ -15,7 +15,7 @@ void DataManager::setResourcePath(const std::string &path) mResourcePath = path; } -MyGUI::IDataStream *DataManager::getData(const std::string &name) +MyGUI::IDataStream *DataManager::getData(const std::string &name) OPENMW_MYGUI_CONST_GETTER_3_4_1 { std::string fullpath = getDataPath(name); std::unique_ptr stream; @@ -34,13 +34,13 @@ void DataManager::freeData(MyGUI::IDataStream *data) delete data; } -bool DataManager::isDataExist(const std::string &name) +bool DataManager::isDataExist(const std::string &name) OPENMW_MYGUI_CONST_GETTER_3_4_1 { std::string fullpath = mResourcePath + "/" + name; return boost::filesystem::exists(fullpath); } -const MyGUI::VectorString &DataManager::getDataListNames(const std::string &pattern) +const MyGUI::VectorString &DataManager::getDataListNames(const std::string &pattern) OPENMW_MYGUI_CONST_GETTER_3_4_1 { // TODO: pattern matching (unused?) static MyGUI::VectorString strings; @@ -49,7 +49,7 @@ const MyGUI::VectorString &DataManager::getDataListNames(const std::string &patt return strings; } -const std::string &DataManager::getDataPath(const std::string &name) +const std::string &DataManager::getDataPath(const std::string &name) OPENMW_MYGUI_CONST_GETTER_3_4_1 { static std::string result; result.clear(); diff --git a/components/myguiplatform/myguidatamanager.hpp b/components/myguiplatform/myguidatamanager.hpp index a97c6ad2e..ca2f94899 100644 --- a/components/myguiplatform/myguidatamanager.hpp +++ b/components/myguiplatform/myguidatamanager.hpp @@ -3,10 +3,11 @@ #include +#include "myguicompat.h" + namespace osgMyGUI { - class DataManager : public MyGUI::DataManager { public: @@ -18,7 +19,7 @@ public: /** Get data stream from specified resource name. @param _name Resource name (usually file name). */ - MyGUI::IDataStream* getData(const std::string& _name) override; + MyGUI::IDataStream* getData(const std::string& _name) OPENMW_MYGUI_CONST_GETTER_3_4_1 override; /** Free data stream. @param _data Data stream. @@ -28,18 +29,18 @@ public: /** Is data with specified name exist. @param _name Resource name. */ - bool isDataExist(const std::string& _name) override; + bool isDataExist(const std::string& _name) OPENMW_MYGUI_CONST_GETTER_3_4_1 override; /** Get all data names with names that matches pattern. @param _pattern Pattern to match (for example "*.layout"). */ - const MyGUI::VectorString& getDataListNames(const std::string& _pattern) override; + const MyGUI::VectorString& getDataListNames(const std::string& _pattern) OPENMW_MYGUI_CONST_GETTER_3_4_1 override; /** Get full path to data. @param _name Resource name. @return Return full path to specified data. */ - const std::string& getDataPath(const std::string& _name) override; + const std::string& getDataPath(const std::string& _name) OPENMW_MYGUI_CONST_GETTER_3_4_1 override; private: std::string mResourcePath; diff --git a/components/myguiplatform/myguirendermanager.cpp b/components/myguiplatform/myguirendermanager.cpp index dc771f11f..1813c9e01 100644 --- a/components/myguiplatform/myguirendermanager.cpp +++ b/components/myguiplatform/myguirendermanager.cpp @@ -14,6 +14,7 @@ #include +#include "myguicompat.h" #include "myguitexture.hpp" #define MYGUI_PLATFORM_LOG_SECTION "Platform" @@ -263,7 +264,7 @@ public: osg::VertexBufferObject* getVertexBuffer(); void setVertexCount(size_t count) override; - size_t getVertexCount() override; + size_t getVertexCount() OPENMW_MYGUI_CONST_GETTER_3_4_1 override; MyGUI::Vertex *lock() override; void unlock() override; @@ -290,7 +291,7 @@ void OSGVertexBuffer::setVertexCount(size_t count) mNeedVertexCount = count; } -size_t OSGVertexBuffer::getVertexCount() +size_t OSGVertexBuffer::getVertexCount() OPENMW_MYGUI_CONST_GETTER_3_4_1 { return mNeedVertexCount; } @@ -560,4 +561,14 @@ bool RenderManager::checkTexture(MyGUI::ITexture* _texture) return true; } +#if MYGUI_VERSION > MYGUI_DEFINE_VERSION(3, 4, 0) +void RenderManager::registerShader( + const std::string& _shaderName, + const std::string& _vertexProgramFile, + const std::string& _fragmentProgramFile) +{ + MYGUI_PLATFORM_LOG(Warning, "osgMyGUI::RenderManager::registerShader is not implemented"); +} +#endif + } diff --git a/components/myguiplatform/myguirendermanager.hpp b/components/myguiplatform/myguirendermanager.hpp index 72abebd18..3c3fb672d 100644 --- a/components/myguiplatform/myguirendermanager.hpp +++ b/components/myguiplatform/myguirendermanager.hpp @@ -5,6 +5,8 @@ #include +#include "myguicompat.h" + namespace Resource { class ImageManager; @@ -70,7 +72,8 @@ public: const MyGUI::IntSize& getViewSize() const override { return mViewSize; } /** @see RenderManager::getVertexFormat */ - MyGUI::VertexColourType getVertexFormat() override { return mVertexFormat; } + MyGUI::VertexColourType getVertexFormat() OPENMW_MYGUI_CONST_GETTER_3_4_1 override + { return mVertexFormat; } /** @see RenderManager::isFormatSupported */ bool isFormatSupported(MyGUI::PixelFormat format, MyGUI::TextureUsage usage) override; @@ -102,17 +105,22 @@ public: void setInjectState(osg::StateSet* stateSet); /** @see IRenderTarget::getInfo */ - const MyGUI::RenderTargetInfo& getInfo() override { return mInfo; } + const MyGUI::RenderTargetInfo& getInfo() OPENMW_MYGUI_CONST_GETTER_3_4_1 override { return mInfo; } bool checkTexture(MyGUI::ITexture* _texture); // setViewSize() is a part of MyGUI::RenderManager interface since 3.4.0 release -#if MYGUI_VERSION < MYGUI_DEFINE_VERSION(3,4,0) +#if MYGUI_VERSION < MYGUI_DEFINE_VERSION(3, 4, 0) void setViewSize(int width, int height); #else void setViewSize(int width, int height) override; #endif + // registerShader() is a part of MyGUI::RenderManager interface since 3.4.1 release +#if MYGUI_VERSION > MYGUI_DEFINE_VERSION(3, 4, 0) + void registerShader(const std::string& _shaderName, const std::string& _vertexProgramFile, const std::string& _fragmentProgramFile) override; +#endif + /*internal:*/ void collectDrawCalls(); diff --git a/components/myguiplatform/myguitexture.cpp b/components/myguiplatform/myguitexture.cpp index 598f5a14e..ce7332cc7 100644 --- a/components/myguiplatform/myguitexture.cpp +++ b/components/myguiplatform/myguitexture.cpp @@ -115,16 +115,6 @@ namespace osgMyGUI Log(Debug::Warning) << "Would save image to file " << fname; } - int OSGTexture::getWidth() - { - return mWidth; - } - - int OSGTexture::getHeight() - { - return mHeight; - } - void *OSGTexture::lock(MyGUI::TextureUsage /*access*/) { if (!mTexture.valid()) @@ -167,15 +157,14 @@ namespace osgMyGUI mLockedImage = nullptr; } - bool OSGTexture::isLocked() - { - return mLockedImage.valid(); - } - // Render-to-texture not currently implemented. MyGUI::IRenderTarget* OSGTexture::getRenderTarget() { return nullptr; } +#if MYGUI_VERSION > MYGUI_DEFINE_VERSION(3, 4, 0) + void OSGTexture::setShader(const std::string& _shaderName) + { Log(Debug::Warning) << "OSGTexture::setShader is not implemented"; } +#endif } diff --git a/components/myguiplatform/myguitexture.hpp b/components/myguiplatform/myguitexture.hpp index 6baeb7459..a34f1b762 100644 --- a/components/myguiplatform/myguitexture.hpp +++ b/components/myguiplatform/myguitexture.hpp @@ -5,6 +5,12 @@ #include +#if MYGUI_VERSION > MYGUI_DEFINE_VERSION(3, 4, 0) + #define OPENMW_MYGUI_CONST_GETTER_3_4_1 const +#else + #define OPENMW_MYGUI_CONST_GETTER_3_4_1 +#endif + namespace osg { class Image; @@ -47,17 +53,22 @@ namespace osgMyGUI void* lock(MyGUI::TextureUsage access) override; void unlock() override; - bool isLocked() override; + bool isLocked() OPENMW_MYGUI_CONST_GETTER_3_4_1 override { return mLockedImage.valid(); } - int getWidth() override; - int getHeight() override; + int getWidth() OPENMW_MYGUI_CONST_GETTER_3_4_1 override { return mWidth; } + int getHeight() OPENMW_MYGUI_CONST_GETTER_3_4_1 override { return mHeight; } - MyGUI::PixelFormat getFormat() override { return mFormat; } - MyGUI::TextureUsage getUsage() override { return mUsage; } - size_t getNumElemBytes() override { return mNumElemBytes; } + MyGUI::PixelFormat getFormat() OPENMW_MYGUI_CONST_GETTER_3_4_1 override { return mFormat; } + MyGUI::TextureUsage getUsage() OPENMW_MYGUI_CONST_GETTER_3_4_1 override { return mUsage; } + size_t getNumElemBytes() OPENMW_MYGUI_CONST_GETTER_3_4_1 override { return mNumElemBytes; } MyGUI::IRenderTarget *getRenderTarget() override; + // setShader() is a part of MyGUI::RenderManager interface since 3.4.1 release +#if MYGUI_VERSION > MYGUI_DEFINE_VERSION(3, 4, 0) + void setShader(const std::string& _shaderName) override; +#endif + /*internal:*/ osg::Texture2D *getTexture() const { return mTexture.get(); } }; diff --git a/components/myguiplatform/scalinglayer.cpp b/components/myguiplatform/scalinglayer.cpp index 07a5161b2..99ed6d07a 100644 --- a/components/myguiplatform/scalinglayer.cpp +++ b/components/myguiplatform/scalinglayer.cpp @@ -3,6 +3,8 @@ #include #include +#include "myguicompat.h" + namespace osgMyGUI { @@ -37,7 +39,7 @@ namespace osgMyGUI mTarget->doRender(_buffer, _texture, _count); } - const MyGUI::RenderTargetInfo& getInfo() override + const MyGUI::RenderTargetInfo& getInfo() OPENMW_MYGUI_CONST_GETTER_3_4_1 override { mInfo = mTarget->getInfo(); mInfo.hOffset = mHOffset; @@ -51,7 +53,7 @@ namespace osgMyGUI MyGUI::IRenderTarget* mTarget; MyGUI::IntSize mViewSize; float mHOffset, mVOffset; - MyGUI::RenderTargetInfo mInfo; + mutable MyGUI::RenderTargetInfo mInfo; }; MyGUI::ILayerItem *ScalingLayer::getLayerItemByPoint(int _left, int _top) const