[2.2] How to compile MyGUI for Ogre 2.2
-
- Hobgoblin
- Posts: 583
- Joined: Mon Aug 06, 2007 12:53 pm
- Location: Saarland, Germany
- x 50
[2.2] How to compile MyGUI for Ogre 2.2
I wanted to ask, if someone already ported the MyGUI Engine to Ogre2.2?
I get a lot of erros in Ogre2Platform project, because textures and compositors api has of course changed.
Best Regards
Lax
http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 168
Re: [2.2] How to compile MyGUI for Ogre 2.2
he helped me with that task, and prefer if he shares it.
rujia, maybe you could make a branch/fork on the official myGui repo?
-
- OGRE Expert User
- Posts: 1227
- Joined: Thu Dec 11, 2008 7:56 pm
- Location: Bristol, UK
- x 157
Re: [2.2] How to compile MyGUI for Ogre 2.2
-
- Hobgoblin
- Posts: 583
- Joined: Mon Aug 06, 2007 12:53 pm
- Location: Saarland, Germany
- x 50
Re: [2.2] How to compile MyGUI for Ogre 2.2
that would be great!
Best Regards
Lax
http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62
-
- Goblin
- Posts: 296
- Joined: Mon May 09, 2016 8:21 am
- x 35
Re: [2.2] How to compile MyGUI for Ogre 2.2
haha, I was too lazy and hoped that al2950 would find sometime to publish the changes earlier than I do...
That would be very nice. Even if your changes are not most universal, it must be better than what I originally sent youArggg. I was also helped by rujialiu, but I did say I would create a PR with my changes but have failed to do that. I am not sure my approach to the changes is the most universal, but maybe I should at least make them public. I ve put it off because it requires git, which just irritates me! Ill try and find time this weekend
-
- OGRE Expert User
- Posts: 1227
- Joined: Thu Dec 11, 2008 7:56 pm
- Location: Bristol, UK
- x 157
Re: [2.2] How to compile MyGUI for Ogre 2.2
-
- Hobgoblin
- Posts: 583
- Joined: Mon Aug 06, 2007 12:53 pm
- Location: Saarland, Germany
- x 50
Re: [2.2] How to compile MyGUI for Ogre 2.2
you asked to pestering you
Is there any progress?
Best regards
Lax
http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62
-
- OGRE Expert User
- Posts: 1227
- Joined: Thu Dec 11, 2008 7:56 pm
- Location: Bristol, UK
- x 157
Re: [2.2] How to compile MyGUI for Ogre 2.2
https://github.com/al2950/mygui/tree/Ogre2.2
-
- Hobgoblin
- Posts: 583
- Joined: Mon Aug 06, 2007 12:53 pm
- Location: Saarland, Germany
- x 50
Re: [2.2] How to compile MyGUI for Ogre 2.2
At least it compiled
Best Regards
Lax
http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62
-
- Goblin
- Posts: 296
- Joined: Mon May 09, 2016 8:21 am
- x 35
Re: [2.2] How to compile MyGUI for Ogre 2.2
yeah!!!al2950 wrote: ↑Sun May 26, 2019 11:52 am ok, so it turns out I was even lazier than I thought. I think i took rujialiu changes and made them less sensible! I would really like to sort this properly so there is 1 ogre branch in mygui, with as much shared code as possible. This will obviously take a little while, and might be too messy to actually do. in the meantime I have uploaded what I currently use for 2.2:
https://github.com/al2950/mygui/tree/Ogre2.2
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 168
Re: [2.2] How to compile MyGUI for Ogre 2.2
Now I am porting my engine to Direct3D11 and all the MyGui stuffs don't show on the objects on the scene but it shows on the main render window :S
I am giving the correct texture when I call addWorkspace, and checked that the workspace has indeed the correct texture when update is being called. Also checked on renderdoc that the correct texture is not being filled with the gui image.
anyone else is using MyGui to render in to an Ogre 2.2 texture?
thanks!
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 168
Re: [2.2] How to compile MyGUI for Ogre 2.2
solved this problem thanks to dark_sylinc, by changing MyGUIPass::execute to this:
Code: Select all
void MyGUIPass::execute(const Ogre::Camera *lodCameraconst)
{
profilingBegin();
executeResourceTransitions();
setRenderPassDescToCurrent();
static_cast<MyGUI::Ogre2RenderManager*>(MyGUI::RenderManager::getInstancePtr())->render();
profilingEnd();
}
thanks!
- dark_sylinc
- OGRE Team Member
- Posts: 5299
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1280
- Contact:
Re: [2.2] How to compile MyGUI for Ogre 2.2
setRenderPassDescToCurrent must be called first!
executeResourceTransitions is only relevant for Metal.
-
- Goblin
- Posts: 296
- Joined: Mon May 09, 2016 8:21 am
- x 35
Re: [2.2] How to compile MyGUI for Ogre 2.2
Code: Select all
Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2RTTexture.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2RTTexture.cpp b/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2RTTexture.cpp
index 72a57b5..a32177d 100644
--- a/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2RTTexture.cpp
+++ b/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2RTTexture.cpp
@@ -100,7 +100,7 @@ namespace MyGUI
//mSaveRenderPassDesc = system->getCurrentPassDescriptor();
Ogre::Vector4 viewportSize(0, 0, 1, 1);
Ogre::Vector4 scissors(0, 0, 1, 1);
- system->beginRenderPassDescriptor(mRenderPassDesc, mTexture, 0, viewportSize, scissors, false, false);
+ system->beginRenderPassDescriptor(mRenderPassDesc, mTexture, 0, &viewportSize, &scissors, 1, false, false);
#endif
}
-
- Hobgoblin
- Posts: 583
- Joined: Mon Aug 06, 2007 12:53 pm
- Location: Saarland, Germany
- x 50
Re: [2.2] How to compile MyGUI for Ogre 2.2
was someone able to adapt MyGUI to newest Ogre2.2 version from github?
Now some includes cannot be found anymore:
Code: Select all
#include <OgreTextureManager.h>
#include <OgreTexture.h>
#include <OgrePixelBox.h>
...
Another question, what happened to RenderWindow? It is no more available...
Best Regards
Lax
http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62
- dark_sylinc
- OGRE Team Member
- Posts: 5299
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1280
- Contact:
Re: [2.2] How to compile MyGUI for Ogre 2.2
This was all deadcode, so if the code was fully running on Ogre 2.2 it is very likely that just removing those includes is enough to make things running again.
If for some reason that's not the case, then the header files are still included on the Deprecated folder and add that folder to the list of include_headers so that they can be found by the compiler
-
- Hobgoblin
- Posts: 583
- Joined: Mon Aug 06, 2007 12:53 pm
- Location: Saarland, Germany
- x 50
Re: [2.2] How to compile MyGUI for Ogre 2.2
Unfortunately not.This was all deadcode, so if the code was fully running on Ogre 2.2 it is very likely that just removing those includes is enough to make things running again.
I could replace "OgreTextureManager" with "OgreTextureGpuManager" etc.
Trying to compile MyGUI I found other issues:
- Ogre::TextureUsage is also no more available:
Code: Select all
Ogre::TextureUsage Ogre2Texture::convertUsage(TextureUsage _usage)
{
if (_usage == TextureUsage::Default)
{
return Ogre::TU_STATIC_WRITE_ONLY;
}
else if (_usage == TextureUsage::RenderTarget)
{
return Ogre::TU_RENDERTARGET;
}
else if (_usage.isValue(TextureUsage::Static))
{
if (_usage.isValue(TextureUsage::Write))
{
return Ogre::TU_STATIC_WRITE_ONLY;
}
else
{
return Ogre::TU_STATIC;
}
}
else if (_usage.isValue(TextureUsage::Dynamic))
{
if (_usage.isValue(TextureUsage::Write))
{
return Ogre::TU_DYNAMIC_WRITE_ONLY;
}
else
{
return Ogre::TU_DYNAMIC;
}
}
else if (_usage.isValue(TextureUsage::Stream))
{
if (_usage.isValue(TextureUsage::Write))
{
return Ogre::TU_DYNAMIC_WRITE_ONLY_DISCARDABLE;
}
else
{
return Ogre::TU_DYNAMIC;
}
}
return Ogre::TU_DEFAULT;
}
http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62
-
- Goblin
- Posts: 296
- Joined: Mon May 09, 2016 8:21 am
- x 35
Re: [2.2] How to compile MyGUI for Ogre 2.2
That can be COMPLETELY removed. That function, and the mUsage member variable, because they're not used anyway. Only MyGUI's own usage (_usage) is used. When creating a manual texture, we can directly query _usage instead of mUsage.Lax wrote: ↑Tue Oct 08, 2019 9:20 pm Hi,
Unfortunately not.This was all deadcode, so if the code was fully running on Ogre 2.2 it is very likely that just removing those includes is enough to make things running again.
I could replace "OgreTextureManager" with "OgreTextureGpuManager" etc.
Trying to compile MyGUI I found other issues:
- Ogre::TextureUsage is also no more available:How could that be replaced?Code: Select all
Ogre::TextureUsage Ogre2Texture::convertUsage(TextureUsage _usage) { if (_usage == TextureUsage::Default) { return Ogre::TU_STATIC_WRITE_ONLY; } else if (_usage == TextureUsage::RenderTarget) { return Ogre::TU_RENDERTARGET; } else if (_usage.isValue(TextureUsage::Static)) { if (_usage.isValue(TextureUsage::Write)) { return Ogre::TU_STATIC_WRITE_ONLY; } else { return Ogre::TU_STATIC; } } else if (_usage.isValue(TextureUsage::Dynamic)) { if (_usage.isValue(TextureUsage::Write)) { return Ogre::TU_DYNAMIC_WRITE_ONLY; } else { return Ogre::TU_DYNAMIC; } } else if (_usage.isValue(TextureUsage::Stream)) { if (_usage.isValue(TextureUsage::Write)) { return Ogre::TU_DYNAMIC_WRITE_ONLY_DISCARDABLE; } else { return Ogre::TU_DYNAMIC; } } return Ogre::TU_DEFAULT; }
In case your MyGUI code used it (I'm using my own branch so it's possible that your MyGUI branch is still using it), here is my createManual function:
Code: Select all
void Ogre2Texture::createManual(int _width, int _height, TextureUsage _usage, PixelFormat _format)
{
setFormat(_format);
setUsage(_usage);
uint32 textureFlags = 0; // Ogre::TextureFlags::PrefersLoadingFromFileAsSRGB
if (_usage.isValue(TextureUsage::RenderTarget)) {
textureFlags |= Ogre::TextureFlags::RenderToTexture;
}
// TODO: Ogre::TextureFlags::Manual
Ogre::TextureGpuManager *textureMgr = Ogre::Root::getSingletonPtr()->getRenderSystem()->getTextureGpuManager();
mTexture = textureMgr->createOrRetrieveTexture(
mName,
Ogre::GpuPageOutStrategy::Discard,
textureFlags,
Ogre::TextureTypes::Type2D,
Ogre::ResourceGroupManager::
AUTODETECT_RESOURCE_GROUP_NAME);
if (mTexture) {
mTexture->setResolution(_width, _height);
mTexture->setPixelFormat(mPixelFormat);
}
if (_usage.isValue(TextureUsage::RenderTarget)) {
textureFlags |= Ogre::TextureFlags::RenderToTexture;
if (mTexture->getNextResidencyStatus() != Ogre::GpuResidency::Resident) {
mTexture->_transitionTo(Ogre::GpuResidency::Resident, nullptr);
mTexture->_setNextResidencyStatus(Ogre::GpuResidency::Resident);
}
}
setDataBlockTexture(mTexture);
}
-
- Goblin
- Posts: 296
- Joined: Mon May 09, 2016 8:21 am
- x 35
Re: [2.2] How to compile MyGUI for Ogre 2.2
But... if you already updated to the latest commit or latest this one: https://github.com/OGRECave/ogre-next/c ... f3d539bc48
After your code compiles, it's likely that it'll crash. That's because the with fixing issue 33, RenderQueue::frameEnded() has an assertion inside that expect every render() is followed by renderPassPrepare() AND no VaoManager::_update() is called in-between(). However, that means in MyGUI's Ogre2RenderManager::render(), you have to call renderPassPrepare before calling render(), like this:
Code: Select all
mSceneManager->getRenderQueue()->renderPassPrepare(false, false);
mSceneManager->getRenderQueue()->render(mSceneManager->getDestinationRenderSystem(), RENDER_QUEUE_OVERLAY, RENDER_QUEUE_OVERLAY+1, false, false);
-
- Hobgoblin
- Posts: 583
- Joined: Mon Aug 06, 2007 12:53 pm
- Location: Saarland, Germany
- x 50
Re: [2.2] How to compile MyGUI for Ogre 2.2
thanks, that worked!
Best Regards
Lax
http://www.lukas-kalinowski.com/Homepage/?page_id=1631
Please support Second Earth Technic Base built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd1 ... b97b79be62
- dark_sylinc
- OGRE Team Member
- Posts: 5299
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1280
- Contact:
Re: [2.2] How to compile MyGUI for Ogre 2.2
I took a detailed look: it looks like the assert accidentally caught a bad use. It's not a bug.rujialiu wrote: ↑Wed Oct 09, 2019 2:41 am After your code compiles, it's likely that it'll crash. That's because the with fixing issue 33, RenderQueue::frameEnded() has an assertion inside that expect every render() is followed by renderPassPrepare() AND no VaoManager::_update() is called in-between(). However, that means in MyGUI's Ogre2RenderManager::render(), you have to call renderPassPrepare before calling render(), like this:
That is likely breaking other codes as well. Is it intended, @dark_sylinc?Code: Select all
mSceneManager->getRenderQueue()->renderPassPrepare(false, false); mSceneManager->getRenderQueue()->render(mSceneManager->getDestinationRenderSystem(), RENDER_QUEUE_OVERLAY, RENDER_QUEUE_OVERLAY+1, false, false);
The function RenderQueue::renderPassPrepare must be called if you're calling RenderQueue::render.
In Ogre 2.1 the tasks performed by renderPassPrepare were being done inside RenderQueue::render.
IIRC we had to split them into two functions because of some Metal incompatibility with RenderPassDescriptors. Overlays were being naughty in their _updateRenderQueue calls (a v1 legacy stuff), and were forcing to breakup the close a RenderCommandEncoder too early in order to open a BlitCommandEncoder, so we had to move things around.
And thus we had to move things around. The current order of execution which must be honoured to work correctly in Metal:
- Call RenderSystem::beginRenderPassDescriptor
- Call Overlays' _updateRenderQueue (i.e. in fireRenderQueueStarted). You don't need to if you don't use Overlays. But if you need to copy GPU buffers around, then this still applies.
- Call RenderQueue::renderPassPrepare
- Call executeRenderPassDescriptorDelayedActions (which originally was inside beginRenderPassDescriptor)
- Call RenderQueue::render
Cheers
Update: I've pushed a documentation update to clarify this
-
- Goblin
- Posts: 296
- Joined: Mon May 09, 2016 8:21 am
- x 35
Re: [2.2] How to compile MyGUI for Ogre 2.2
Oh, thanks! So the MyGUI code should also call renderPassPrepare BEFORE you wrote the assertions. I guess everyone here, like me, don't use MyGUI in Metal RSdark_sylinc wrote: ↑Sun Oct 20, 2019 11:50 pm Update: I've pushed a documentation update to clarify this
-
- Greenskin
- Posts: 126
- Joined: Wed Jan 19, 2005 4:48 am
- x 9
Re: [2.2] How to compile MyGUI for Ogre 2.2
I downloaded and attempted to build the 2.2 branch found on al2950's github page: https://github.com/al2950/mygui/tree/Ogre2.2. Then I applied some of the fixes from this thread and now I'm getting an error related to mTmpData which I had commented out since I had commented out the include for include OgrePixelBox.h:
Code: Select all
28%] Building CXX object Platforms/Ogre2/Ogre2Platform/CMakeFiles/MyGUI.Ogre2Platform.dir/src/MyGUI_Ogre2Texture.cpp.o
/home/libolt/builds/mygui-ogre-2.2/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2Texture.cpp: In constructor ‘MyGUI::Ogre2Texture::Ogre2Texture(const string&, const string&)’:
/home/libolt/builds/mygui-ogre-2.2/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2Texture.cpp:35:3: error: ‘mTmpData’ was not declared in this scope
35 | mTmpData.data = nullptr;
| ^~~~~~~~
/home/libolt/builds/mygui-ogre-2.2/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2Texture.cpp: In member function ‘virtual void MyGUI::Ogre2Texture::destroy()’:
/home/libolt/builds/mygui-ogre-2.2/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2Texture.cpp:66:7: error: ‘mTmpData’ was not declared in this scope
66 | if (mTmpData.data != nullptr)
| ^~~~~~~~
/home/libolt/builds/mygui-ogre-2.2/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2Texture.cpp: In member function ‘virtual void* MyGUI::Ogre2Texture::lock(MyGUI::TextureUsage)’:
/home/libolt/builds/mygui-ogre-2.2/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2Texture.cpp:105:4: error: ‘mTmpData’ was not declared in this scope
105 | mTmpData.data = imageData;
| ^~~~~~~~
/home/libolt/builds/mygui-ogre-2.2/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2Texture.cpp: In member function ‘virtual void MyGUI::Ogre2Texture::unlock()’:
/home/libolt/builds/mygui-ogre-2.2/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2Texture.cpp:119:7: error: ‘mTmpData’ was not declared in this scope
119 | if (mTmpData.data != nullptr)
| ^~~~~~~~
/home/libolt/builds/mygui-ogre-2.2/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2Texture.cpp: In member function ‘virtual void MyGUI::Ogre2Texture::loadFromFile(const string&)’:
/home/libolt/builds/mygui-ogre-2.2/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2Texture.cpp:265:9: error: ‘TextureManager’ is not a member of ‘Ogre’; did you mean ‘TextureGpuManager’?
265 | Ogre::TextureManager* manager = Ogre::TextureManager::getSingletonPtr();
| ^~~~~~~~~~~~~~
| TextureGpuManager
/home/libolt/builds/mygui-ogre-2.2/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2Texture.cpp:265:25: error: ‘manager’ was not declared in this scope; did you mean ‘LogManager’?
265 | Ogre::TextureManager* manager = Ogre::TextureManager::getSingletonPtr();
| ^~~~~~~
| LogManager
/home/libolt/builds/mygui-ogre-2.2/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2Texture.cpp:265:41: error: ‘Ogre::TextureManager’ has not been declared
265 | Ogre::TextureManager* manager = Ogre::TextureManager::getSingletonPtr();
| ^~~~~~~~~~~~~~
make[2]: *** [Platforms/Ogre2/Ogre2Platform/CMakeFiles/MyGUI.Ogre2Platform.dir/build.make:135: Platforms/Ogre2/Ogre2Platform/CMakeFiles/MyGUI.Ogre2Platform.dir/src/MyGUI_Ogre2Texture.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:675: Platforms/Ogre2/Ogre2Platform/CMakeFiles/MyGUI.Ogre2Platform.dir/all] Error 2
make: *** [Makefile:150: all] Error 2
-
- Goblin
- Posts: 296
- Joined: Mon May 09, 2016 8:21 am
- x 35
Re: [2.2] How to compile MyGUI for Ogre 2.2
al2950's commit was in May 2019, then there were several other changes to Ogre. The biggest change should be the "deprecated" one (which caused OgrePixelBox.h to be removed in my version, and mTmpData changed to Ogre::uint8*), so it's normal that you can't compile Anyway, I'm attaching my personal changes after May 2019 (actually the first change happened in Sept. 2019). Since the diff is based on my version, not al2950, there maybe it's not 100% applicable to your case, so you need to make some adjustments.libolt wrote: ↑Wed Apr 29, 2020 11:37 pm I downloaded and attempted to build the 2.2 branch found on al2950's github page: https://github.com/al2950/mygui/tree/Ogre2.2. Then I applied some of the fixes from this thread and now I'm getting an error related to mTmpData which I had commented out since I had commented out the include for include OgrePixelBox.h:
Also, the diff looks long because part of my modification is to remove Ogre 2.1 support, but if you look at it carefully it should be easy to understand
Code: Select all
.../Ogre2Platform/include/MyGUI_Ogre2Platform.h | 4 -
.../Ogre2Platform/include/MyGUI_Ogre2RTTexture.h | 10 -
.../include/MyGUI_Ogre2RenderManager.h | 34 ----
.../Ogre2Platform/include/MyGUI_Ogre2Texture.h | 32 +--
.../include/MyGUI_Ogre2VertexBuffer.h | 1 -
.../Ogre2Platform/src/MyGUI_Ogre2RTTexture.cpp | 34 +---
.../Ogre2Platform/src/MyGUI_Ogre2RenderManager.cpp | 44 +----
.../Ogre2/Ogre2Platform/src/MyGUI_Ogre2Texture.cpp | 215 +--------------------
8 files changed, 11 insertions(+), 363 deletions(-)
diff --git a/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2Platform.h b/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2Platform.h
index 88bd536..f176f6b 100644
--- a/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2Platform.h
+++ b/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2Platform.h
@@ -42,11 +42,7 @@ namespace MyGUI
delete mLogManager;
}
-#if OGRE_VERSION_MINOR < 2
- void initialise(Ogre::RenderWindow* _window, Ogre::SceneManager* _scene, const std::string& _group = Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, const std::string& _logName = MYGUI_PLATFORM_LOG_FILENAME)
-#else
void initialise(Ogre::Window* _window, Ogre::SceneManager* _scene, const std::string& _group = Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, const std::string& _logName = MYGUI_PLATFORM_LOG_FILENAME)
-#endif
{
assert(!mIsInitialise);
mIsInitialise = true;
diff --git a/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2RTTexture.h b/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2RTTexture.h
index b592306..ea4f59d 100644
--- a/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2RTTexture.h
+++ b/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2RTTexture.h
@@ -21,11 +21,7 @@ namespace MyGUI
public IRenderTarget
{
public:
-#if OGRE_VERSION_MINOR < 2
- Ogre2RTTexture(Ogre::TexturePtr _texture);
-#else
Ogre2RTTexture(Ogre::TextureGpu* _texture);
-#endif
virtual ~Ogre2RTTexture();
virtual void begin();
@@ -40,15 +36,9 @@ namespace MyGUI
private:
RenderTargetInfo mRenderTargetInfo;
-#if OGRE_VERSION_MINOR < 2
- Ogre::Viewport* mViewport;
- Ogre::Viewport* mSaveViewport;
- Ogre::TexturePtr mTexture;
-#else
Ogre::RenderPassDescriptor* mRenderPassDesc;
Ogre::RenderPassDescriptor* mSaveRenderPassDesc;
Ogre::TextureGpu* mTexture;
-#endif
Ogre::Matrix4 mProjectMatrix;
};
diff --git a/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2RenderManager.h b/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2RenderManager.h
index da00bce..dde2641 100644
--- a/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2RenderManager.h
+++ b/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2RenderManager.h
@@ -41,13 +41,8 @@ namespace MyGUI
class MyGUIPass : public Ogre::CompositorPass
{
public:
-#if OGRE_VERSION_MINOR < 2
- MyGUIPass(const Ogre::CompositorPassDef *definition, const Ogre::CompositorChannel &target,
- Ogre::CompositorNode *parentNode);
-#else
MyGUIPass(const Ogre::CompositorPassDef *definition, const Ogre::RenderTargetViewDef* rtv,
Ogre::CompositorNode *parentNode);
-#endif
virtual void execute(const Ogre::Camera *lodCameraconst);
};
@@ -68,21 +63,12 @@ namespace MyGUI
return OGRE_NEW MyGUI::MyGUIPassDef(parentTargetDef);
}
-#if OGRE_VERSION_MINOR < 2
- Ogre::CompositorPass* addPass(const Ogre::CompositorPassDef *definition, Ogre::Camera *defaultCamera,
- Ogre::CompositorNode *parentNode, const Ogre::CompositorChannel &target,
- Ogre::SceneManager *sceneManager)
- {
- return OGRE_NEW MyGUI::MyGUIPass(definition, target, parentNode);
- }
-#else
Ogre::CompositorPass* addPass(const Ogre::CompositorPassDef *definition, Ogre::Camera *defaultCamera,
Ogre::CompositorNode *parentNode, const Ogre::RenderTargetViewDef* rtv,
Ogre::SceneManager *sceneManager)
{
return OGRE_NEW MyGUI::MyGUIPass(definition, rtv, parentNode);
}
-#endif
static Ogre::IdString mPassId;
};
@@ -100,11 +86,7 @@ namespace MyGUI
// FrameListener
bool frameStarted(const Ogre::FrameEvent &evt);
-#if OGRE_VERSION_MINOR < 2
- void initialise(Ogre::RenderWindow* _window, Ogre::SceneManager* _scene);
-#else
void initialise(Ogre::Window* _window, Ogre::SceneManager* _scene);
-#endif
void shutdown();
static Ogre2RenderManager& getInstance();
@@ -145,21 +127,13 @@ namespace MyGUI
void setRenderSystem(Ogre::RenderSystem* _render);
Ogre::RenderSystem* getRenderSystem();
-#if OGRE_VERSION_MINOR < 2
- void setRenderWindow(Ogre::RenderWindow* _window);
-#else
void setRenderWindow(Ogre::Window* _window);
-#endif
/** Set scene manager where MyGUI will be rendered */
void setSceneManager(Ogre::SceneManager* _scene);
Ogre::SceneManager* getSceneManager();
-#if OGRE_VERSION_MINOR < 2
- Ogre::RenderWindow* getRenderWindow();
-#else
Ogre::Window* getRenderWindow();
-#endif
bool getManualRender();
void setManualRender(bool _value);
@@ -173,11 +147,7 @@ namespace MyGUI
#endif
private:
-#if OGRE_VERSION_MINOR < 2
- virtual void windowResized(Ogre::RenderWindow* _window);
-#else
virtual void windowResized(Ogre::Window* _window);
-#endif
// восстанавливаем буферы
virtual void eventOccurred(const Ogre::String& eventName, const Ogre::NameValuePairList* parameters);
@@ -196,11 +166,7 @@ namespace MyGUI
VertexColourType mVertexFormat;
// окно, на которое мы подписываемся для изменения размеров
-#if OGRE_VERSION_MINOR < 2
- Ogre::RenderWindow* mWindow;
-#else
Ogre::Window* mWindow;
-#endif
Ogre::RenderSystem* mRenderSystem;
diff --git a/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2Texture.h b/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2Texture.h
index cd2eb2c..80b08b6 100644
--- a/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2Texture.h
+++ b/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2Texture.h
@@ -15,8 +15,6 @@
#include <Ogre.h>
#include <OgreResource.h>
-#include <OgreTexture.h>
-#include <OgrePixelBox.h>
#include <OgreSharedPtr.h>
#include <OgreHlms.h>
@@ -25,9 +23,7 @@
#include <OgreHlmsManager.h>
#include <Hlms/Unlit/OgreHlmsUnlitDatablock.h>
-#if OGRE_VERSION_MINOR > 1
#include "OgrePixelFormatGpu.h"
-#endif
#include "MyGUI_LastHeader.h"
@@ -119,27 +115,14 @@ namespace MyGUI
virtual IRenderTarget* getRenderTarget();
- static Ogre::TextureUsage convertUsage(TextureUsage _usage);
-#if OGRE_VERSION_MINOR > 1
static Ogre::PixelFormatGpu convertFormat(PixelFormat _format);
-#else
- static Ogre::PixelFormat convertFormat(PixelFormat _format);
-#endif
/*internal:*/
-#if OGRE_VERSION_MINOR > 1
Ogre::TextureGpu* getOgreTexture()
-#else
- Ogre::TexturePtr getOgreTexture()
-#endif
{
return mTexture;
}
-#if OGRE_VERSION_MINOR > 1
void setOgreTexture(Ogre::TextureGpu* _value)
-#else
- void setOgreTexture(Ogre::TexturePtr _value)
-#endif
{
mTexture = _value;
}
@@ -153,18 +136,10 @@ namespace MyGUI
virtual void loadResource(Ogre::Resource* resource);
-#if OGRE_VERSION_MINOR > 1
void setDataBlockTexture(Ogre::TextureGpu* _value);
-#else
- void setDataBlockTexture(Ogre::TexturePtr _value);
-#endif
private:
-#if OGRE_VERSION_MINOR > 1
Ogre::TextureGpu* mTexture;
-#else
- Ogre::TexturePtr mTexture;
-#endif
std::string mName;
std::string mGroup;
@@ -172,16 +147,11 @@ namespace MyGUI
PixelFormat mOriginalFormat;
size_t mNumElemBytes;
-#if OGRE_VERSION_MINOR > 1
Ogre::PixelFormatGpu mPixelFormat;
-#else
- Ogre::PixelFormat mPixelFormat;
-#endif
- Ogre::TextureUsage mUsage;
ITextureInvalidateListener* mListener;
IRenderTarget* mRenderTarget;
- Ogre::PixelBox mTmpData;
+ Ogre::uint8* mTmpData;
Ogre::HlmsUnlitDatablock* mDataBlock;
diff --git a/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2VertexBuffer.h b/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2VertexBuffer.h
index 912597c..a13fa2c 100644
--- a/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2VertexBuffer.h
+++ b/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2VertexBuffer.h
@@ -15,7 +15,6 @@
#include <OgrePrerequisites.h>
#include <OgreRenderOperation.h>
#include <OgreRenderSystem.h>
-#include <OgreTextureManager.h>
#include <OgreTextureUnitState.h>
#include "MyGUI_LastHeader.h"
diff --git a/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2RTTexture.cpp b/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2RTTexture.cpp
index 72a57b5..bf77ff0 100644
--- a/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2RTTexture.cpp
+++ b/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2RTTexture.cpp
@@ -8,22 +8,14 @@
#include "MyGUI_Ogre2RTTexture.h"
#include "MyGUI_Ogre2RenderManager.h"
-#if OGRE_VERSION_MINOR > 1
#include "OgreTextureGpu.h"
-#endif
namespace MyGUI
{
-#if OGRE_VERSION_MINOR < 2
- Ogre2RTTexture::Ogre2RTTexture(Ogre::TexturePtr _texture) :
- mViewport(nullptr),
- mSaveViewport(nullptr),
-#else
Ogre2RTTexture::Ogre2RTTexture(Ogre::TextureGpu* _texture) :
mRenderPassDesc(nullptr),
mSaveRenderPassDesc(nullptr),
-#endif
mTexture(_texture)
{
mProjectMatrix = Ogre::Matrix4::IDENTITY;
@@ -44,11 +36,7 @@ namespace MyGUI
mRenderTargetInfo.pixScaleY = 1.0f / float(height);
}
-#if OGRE_VERSION_MINOR < 2
- if (mTexture->getBuffer()->getRenderTarget()->requiresTextureFlipping())
-#else
if (mTexture->requiresTextureFlipping())
-#endif
{
mProjectMatrix[1][0] = -mProjectMatrix[1][0];
mProjectMatrix[1][1] = -mProjectMatrix[1][1];
@@ -64,21 +52,6 @@ namespace MyGUI
void Ogre2RTTexture::begin()
{
-#if OGRE_VERSION_MINOR < 2
- Ogre::RenderTexture* rtt = mTexture->getBuffer()->getRenderTarget();
-
- if (mViewport == nullptr)
- {
- mViewport = rtt->addViewport();
- mViewport->setOverlaysEnabled(false);
- }
-
- Ogre::RenderSystem* system = Ogre::Root::getSingleton().getRenderSystem();
- system->_setProjectionMatrix(mProjectMatrix);
- mSaveViewport = system->_getViewport();
- system->_setViewport(mViewport);
- system->clearFrameBuffer(Ogre::FBT_COLOUR, Ogre::ColourValue::ZERO);
-#else
Ogre::RenderSystem* system = Ogre::Root::getSingleton().getRenderSystem();
if (mRenderPassDesc == nullptr)
{
@@ -100,18 +73,13 @@ namespace MyGUI
//mSaveRenderPassDesc = system->getCurrentPassDescriptor();
Ogre::Vector4 viewportSize(0, 0, 1, 1);
Ogre::Vector4 scissors(0, 0, 1, 1);
- system->beginRenderPassDescriptor(mRenderPassDesc, mTexture, 0, viewportSize, scissors, false, false);
-#endif
+ system->beginRenderPassDescriptor(mRenderPassDesc, mTexture, 0, &viewportSize, &scissors, 1, false, false);
}
void Ogre2RTTexture::end()
{
Ogre::RenderSystem* system = Ogre::Root::getSingleton().getRenderSystem();
-#if OGRE_VERSION_MINOR < 2
- system->_setViewport(mSaveViewport);
-#else
// no need to restore RenderPassDesc
-#endif
#if OGRE_VERSION >= MYGUI_DEFINE_VERSION(1, 7, 0) && OGRE_NO_VIEWPORT_ORIENTATIONMODE == 0
Ogre::OrientationMode orient = mSaveViewport->getOrientationMode();
system->_setProjectionMatrix(Ogre::Matrix4::IDENTITY * Ogre::Quaternion(Ogre::Degree(orient * 90.f), Ogre::Vector3::UNIT_Z));
diff --git a/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2RenderManager.cpp b/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2RenderManager.cpp
index f202ef0..8b5c421 100644
--- a/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2RenderManager.cpp
+++ b/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2RenderManager.cpp
@@ -14,31 +14,21 @@
#include <Compositor/OgreCompositorManager2.h>
-#if OGRE_VERSION_MINOR > 1
#include "OgreTextureGpu.h"
#include "OgreTextureGpuManager.h"
#include "OgreWindow.h"
-#endif
namespace MyGUI
{
const Ogre::uint8 Ogre2RenderManager::RENDER_QUEUE_OVERLAY = 254;
Ogre::IdString OgreCompositorPassProvider::mPassId = Ogre::IdString("MYGUI");
-#if OGRE_VERSION_MINOR < 2
- MyGUIPass::MyGUIPass(const Ogre::CompositorPassDef *definition, const Ogre::CompositorChannel &target,
- Ogre::CompositorNode *parentNode)
- : Ogre::CompositorPass(definition, target, parentNode)
- {
- }
-#else
MyGUIPass::MyGUIPass(const Ogre::CompositorPassDef *definition, const Ogre::RenderTargetViewDef* rtv,
Ogre::CompositorNode *parentNode)
: Ogre::CompositorPass(definition, parentNode)
{
this->initialize(rtv);
}
-#endif
void MyGUIPass::execute(const Ogre::Camera *lodCameraconst)
{
@@ -65,11 +55,7 @@ namespace MyGUI
{
}
-#if OGRE_VERSION_MINOR < 2
- void Ogre2RenderManager::initialise(Ogre::RenderWindow* _window, Ogre::SceneManager* _scene)
-#else
void Ogre2RenderManager::initialise(Ogre::Window* _window, Ogre::SceneManager* _scene)
-#endif
{
MYGUI_PLATFORM_ASSERT(!mIsInitialise, getClassTypeName() << " initialised twice");
MYGUI_PLATFORM_LOG(Info, "* Initialise: " << getClassTypeName());
@@ -169,11 +155,7 @@ namespace MyGUI
return mRenderSystem;
}
-#if OGRE_VERSION_MINOR < 2
- void Ogre2RenderManager::setRenderWindow(Ogre::RenderWindow* _window)
-#else
void Ogre2RenderManager::setRenderWindow(Ogre::Window* _window)
-#endif
{
// отписываемся
if (mWindow != nullptr)
@@ -239,6 +221,7 @@ namespace MyGUI
//This will add renderbles to the Ogre render queue
onRenderToTarget(this, mUpdate);
+ mSceneManager->getRenderQueue()->renderPassPrepare(false, false);
mSceneManager->getRenderQueue()->render(mSceneManager->getDestinationRenderSystem(), RENDER_QUEUE_OVERLAY, RENDER_QUEUE_OVERLAY+1, false, false);
// сбрасываем флаг
@@ -268,11 +251,7 @@ namespace MyGUI
}
// для оповещений об изменении окна рендера
-#if OGRE_VERSION_MINOR < 2
- void Ogre2RenderManager::windowResized(Ogre::RenderWindow* _window)
-#else
void Ogre2RenderManager::windowResized(Ogre::Window* _window)
-#endif
{
mViewSize.set(_window->getWidth(), _window->getHeight());
@@ -342,15 +321,6 @@ namespace MyGUI
MapTexture::const_iterator item = mTextures.find(_name);
if (item == mTextures.end())
{
-#if OGRE_VERSION_MINOR < 2
- Ogre::TexturePtr texture = (Ogre::TexturePtr)Ogre::TextureManager::getSingleton().getByName(_name);
- if (!texture.isNull())
- {
- ITexture* result = createTexture(_name);
- static_cast<Ogre2Texture*>(result)->setOgreTexture(texture);
- return result;
- }
-#else
Ogre::TextureGpuManager *textureMgr = Ogre::Root::getSingletonPtr()->getRenderSystem()->getTextureGpuManager();
const Ogre::String* name = textureMgr->findResourceNameStr(_name);
if (name) {
@@ -365,7 +335,6 @@ namespace MyGUI
static_cast<Ogre2Texture*>(result)->setOgreTexture(texture);
return result;
}
-#endif
return nullptr;
}
return item->second;
@@ -373,15 +342,8 @@ namespace MyGUI
bool Ogre2RenderManager::isFormatSupported(PixelFormat _format, TextureUsage _usage)
{
-#if OGRE_VERSION_MINOR == 1
- return Ogre::TextureManager::getSingleton().isFormatSupported(
- Ogre::TEX_TYPE_2D,
- Ogre2Texture::convertFormat(_format),
- Ogre2Texture::convertUsage(_usage));
-#else
if (_format == PixelFormat::L8A8) return false; // 不支持!
return true; // FIXME
-#endif
}
void Ogre2RenderManager::destroyAllResources()
@@ -425,11 +387,7 @@ namespace MyGUI
return mInfo;
}
-#if OGRE_VERSION_MINOR < 2
- Ogre::RenderWindow* Ogre2RenderManager::getRenderWindow()
-#else
Ogre::Window* Ogre2RenderManager::getRenderWindow()
-#endif
{
return mWindow;
}
diff --git a/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2Texture.cpp b/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2Texture.cpp
index 93ae03a..e998133 100644
--- a/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2Texture.cpp
+++ b/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2Texture.cpp
@@ -14,13 +14,11 @@
#include "MyGUI_LastHeader.h"
-#if OGRE_VERSION_MINOR > 1
#include "OgreTextureGpu.h"
#include "OgreTextureGpuManager.h"
#include "OgrePixelFormatGpu.h"
#include "OgrePixelFormatGpuUtils.h"
#include "OgreStagingTexture.h"
-#endif
namespace MyGUI
{
@@ -29,16 +27,11 @@ namespace MyGUI
mName(_name),
mGroup(_group),
mNumElemBytes(0),
-#if OGRE_VERSION_MINOR == 1
- mPixelFormat(Ogre::PF_UNKNOWN),
-#else
mPixelFormat(Ogre::PixelFormatGpu::PFG_UNKNOWN),
-#endif
- mUsage(Ogre::TU_DEFAULT),
mListener(nullptr),
mRenderTarget(nullptr)
{
- mTmpData.data = nullptr;
+ mTmpData = nullptr;
mDataBlock = HLMS_BLOCKS.createUnlitDataBlock(_name);
}
@@ -56,13 +49,6 @@ namespace MyGUI
void Ogre2Texture::saveToFile(const std::string& _filename)
{
Ogre::uchar* readrefdata = static_cast<Ogre::uchar*>(lock(TextureUsage::Read));
-#if OGRE_VERSION_MINOR == 1
- Ogre::Image img;
- img = img.loadDynamicImage(readrefdata, mTexture->getWidth(), mTexture->getHeight(), mTexture->getFormat());
- img.save(_filename);
-#else
-#endif
-
unlock();
}
@@ -73,31 +59,17 @@ namespace MyGUI
void Ogre2Texture::destroy()
{
- if (mTmpData.data != nullptr)
- {
- delete [] (uint8*)mTmpData.data;
- mTmpData.data = nullptr;
- }
-
if (mRenderTarget != nullptr)
{
delete mRenderTarget;
mRenderTarget = nullptr;
}
-#if OGRE_VERSION_MINOR == 1
- if (!mTexture.isNull())
- {
- Ogre::TextureManager::getSingleton().remove(mTexture->getName());
- mTexture.setNull();
- }
-#else
if (mTexture)
{
Ogre::TextureGpuManager *textureMgr = Ogre::Root::getSingletonPtr()->getRenderSystem()->getTextureGpuManager();
textureMgr->destroyTexture(mTexture);
mTexture = nullptr;
}
-#endif
}
int Ogre2Texture::getWidth()
@@ -112,63 +84,29 @@ namespace MyGUI
void* Ogre2Texture::lock(TextureUsage _access)
{
-#if OGRE_VERSION_MINOR == 1
- if (_access == TextureUsage::Write)
- {
- return mTexture->getBuffer()->lock(Ogre::v1::HardwareBuffer::HBL_DISCARD);
- }
-
- // здесь проверить режим создания, и возможно так залочить без пиксель бокса
-
- // для чтения копируем в пиксель бокс
- if (mTmpData.data != nullptr)
- {
- delete [] (uint8*)mTmpData.data;
- mTmpData.data = nullptr;
- }
-
- mTmpData = Ogre::PixelBox(mTexture->getWidth(), mTexture->getHeight(), mTexture->getDepth(), mTexture->getFormat());
- mTmpData.data = new uint8[mTexture->getBuffer()->getSizeInBytes()];
-
- mTexture->getBuffer()->blitToMemory(mTmpData);
-
- return mTmpData.data;
-#else
if (_access == TextureUsage::Write) {
const uint32 rowAlignment = 4u;
const size_t dataSize = Ogre::PixelFormatGpuUtils::getSizeBytes(mTexture->getWidth(), mTexture->getHeight(), 1u, 1u,
mTexture->getPixelFormat(),
rowAlignment);
uint8 *imageData = reinterpret_cast<uint8*>(OGRE_MALLOC_SIMD(dataSize, Ogre::MEMCATEGORY_RESOURCE));
- mTmpData.data = imageData;
- return mTmpData.data;
+ mTmpData = imageData;
+ return mTmpData;
}
else {
// FIXME
return nullptr;
}
-#endif
}
void Ogre2Texture::unlock()
{
-#if OGRE_VERSION_MINOR == 1
- if (mTexture->getBuffer()->isLocked())
- {
- mTexture->getBuffer()->unlock();
- }
- else if (mTmpData.data != nullptr)
- {
- delete [] (uint8*)mTmpData.data;
- mTmpData.data = nullptr;
- }
-#else
Ogre::TextureGpuManager *textureManager = Ogre::Root::getSingletonPtr()->getRenderSystem()->getTextureGpuManager();
- if (mTmpData.data != nullptr)
+ if (mTmpData != nullptr)
{
// write
- uint8 *imageData = reinterpret_cast<uint8*>(mTmpData.data);
+ uint8 *imageData = reinterpret_cast<uint8*>(mTmpData);
const size_t bytesPerRow = mTexture->_getSysRamCopyBytesPerRow(0);
mTexture->_transitionTo(Ogre::GpuResidency::Resident, imageData);
@@ -187,69 +125,17 @@ namespace MyGUI
stagingTexture = 0;
OGRE_FREE_SIMD(imageData, Ogre::MEMCATEGORY_RESOURCE);
- mTmpData.data = nullptr;
+ mTmpData = nullptr;
mTexture->notifyDataIsReady();
}
-#endif
}
bool Ogre2Texture::isLocked()
{
-#if OGRE_VERSION_MINOR == 1
- return mTexture->getBuffer()->isLocked();
-#else
// FIXME
return false;
-#endif
- }
-
- Ogre::TextureUsage Ogre2Texture::convertUsage(TextureUsage _usage)
- {
- if (_usage == TextureUsage::Default)
- {
- return Ogre::TU_STATIC_WRITE_ONLY;
- }
- else if (_usage == TextureUsage::RenderTarget)
- {
- return Ogre::TU_RENDERTARGET;
- }
- else if (_usage.isValue(TextureUsage::Static))
- {
- if (_usage.isValue(TextureUsage::Write))
- {
- return Ogre::TU_STATIC_WRITE_ONLY;
- }
- else
- {
- return Ogre::TU_STATIC;
- }
- }
- else if (_usage.isValue(TextureUsage::Dynamic))
- {
- if (_usage.isValue(TextureUsage::Write))
- {
- return Ogre::TU_DYNAMIC_WRITE_ONLY;
- }
- else
- {
- return Ogre::TU_DYNAMIC;
- }
- }
- else if (_usage.isValue(TextureUsage::Stream))
- {
- if (_usage.isValue(TextureUsage::Write))
- {
- return Ogre::TU_DYNAMIC_WRITE_ONLY_DISCARDABLE;
- }
- else
- {
- return Ogre::TU_DYNAMIC;
- }
- }
- return Ogre::TU_DEFAULT;
}
-#if OGRE_VERSION_MINOR > 1
Ogre::PixelFormatGpu Ogre2Texture::convertFormat(PixelFormat _format)
{
if (_format == PixelFormat::L8) return Ogre::PixelFormatGpu::PFG_R8_UNORM;
@@ -259,17 +145,6 @@ namespace MyGUI
return Ogre::PixelFormatGpu::PFG_UNKNOWN;
}
-#else
- Ogre::PixelFormat Ogre2Texture::convertFormat(PixelFormat _format)
- {
- if (_format == PixelFormat::L8) return Ogre::PF_BYTE_L;
- else if (_format == PixelFormat::L8A8) return Ogre::PF_BYTE_LA;
- else if (_format == PixelFormat::R8G8B8) return Ogre::PF_R8G8B8;
- else if (_format == PixelFormat::R8G8B8A8) return Ogre::PF_A8R8G8B8;
-
- return Ogre::PF_UNKNOWN;
- }
-#endif
void Ogre2Texture::setFormat(PixelFormat _format)
{
@@ -286,28 +161,13 @@ namespace MyGUI
void Ogre2Texture::setUsage(TextureUsage _usage)
{
mOriginalUsage = _usage;
- mUsage = convertUsage(_usage);
+ //mUsage = convertUsage(_usage);
}
void Ogre2Texture::createManual(int _width, int _height, TextureUsage _usage, PixelFormat _format)
{
setFormat(_format);
setUsage(_usage);
-#if OGRE_VERSION_MINOR == 1
- mTexture = Ogre::TextureManager::getSingleton().createManual(
- mName,
- mGroup,
- Ogre::TEX_TYPE_2D,
- _width,
- _height,
- 0,
- mPixelFormat,
- mUsage,
- this,
- true);
-
- mTexture->load();
-#else
uint32 textureFlags = 0; // Ogre::TextureFlags::PrefersLoadingFromFileAsSRGB
if (_usage.isValue(TextureUsage::RenderTarget)) {
textureFlags |= Ogre::TextureFlags::RenderToTexture;
@@ -335,8 +195,6 @@ namespace MyGUI
mTexture->_setNextResidencyStatus(Ogre::GpuResidency::Resident);
}
}
-
-#endif
setDataBlockTexture(mTexture);
}
@@ -344,13 +202,8 @@ namespace MyGUI
{
setUsage(TextureUsage::Default);
- Ogre::TextureManager* manager = Ogre::TextureManager::getSingletonPtr();
-
-#if OGRE_VERSION_MINOR > 1
bool needLoadTexture = false;
-#endif
-
- if ( !manager->resourceExists(_filename) )
+ if ( false )
{
DataManager& resourcer = DataManager::getInstance();
if (!resourcer.isDataExist(_filename))
@@ -359,23 +212,14 @@ namespace MyGUI
}
else
{
-#if OGRE_VERSION_MINOR == 1
- mTexture = manager->load(_filename, mGroup, Ogre::TEX_TYPE_2D, 0, 1.0f, false, Ogre::PF_UNKNOWN, true);
-#else
needLoadTexture = true;
-#endif
}
}
else
{
-#if OGRE_VERSION_MINOR == 1
- mTexture = manager->getByName(_filename);
-#else
needLoadTexture = true;
-#endif
}
-#if OGRE_VERSION_MINOR > 1
if (needLoadTexture) {
Ogre::TextureGpuManager *textureMgr = Ogre::Root::getSingletonPtr()->getRenderSystem()->getTextureGpuManager();
mTexture = textureMgr->createOrRetrieveTexture(
@@ -391,7 +235,6 @@ namespace MyGUI
mTexture->waitForData();
}
}
-#endif
setFormatByOgreTexture();
setDataBlockTexture(mTexture);
@@ -401,40 +244,6 @@ namespace MyGUI
{
mOriginalFormat = PixelFormat::Unknow;
mNumElemBytes = 0;
-#if OGRE_VERSION_MINOR == 1
- mPixelFormat = Ogre::PF_UNKNOWN;
- if (!mTexture.isNull())
- {
- mPixelFormat = mTexture->getFormat();
-
- if (mPixelFormat == Ogre::PF_BYTE_L)
- {
- mOriginalFormat = PixelFormat::L8;
- mNumElemBytes = 1;
- }
- else if (mPixelFormat == Ogre::PF_BYTE_LA)
- {
- mOriginalFormat = PixelFormat::L8A8;
- mNumElemBytes = 2;
- }
- else if (mPixelFormat == Ogre::PF_R8G8B8)
- {
- mOriginalFormat = PixelFormat::R8G8B8;
- mNumElemBytes = 3;
- }
- else if (mPixelFormat == Ogre::PF_A8R8G8B8)
- {
- mOriginalFormat = PixelFormat::R8G8B8A8;
- mNumElemBytes = 4;
- }
- else
- {
- mOriginalFormat = PixelFormat::Unknow;
- mNumElemBytes = Ogre::PixelUtil::getNumElemBytes(mPixelFormat);
- }
-
- }
-#else
mPixelFormat = Ogre::PixelFormatGpu::PFG_UNKNOWN;
if (mTexture)
{
@@ -467,7 +276,6 @@ namespace MyGUI
}
}
-#endif
}
void Ogre2Texture::loadResource(Ogre::Resource* resource)
@@ -484,17 +292,10 @@ namespace MyGUI
return mRenderTarget;
}
-#if OGRE_VERSION_MINOR > 1
void Ogre2Texture::setDataBlockTexture( Ogre::TextureGpu* _value )
{
mDataBlock->setTexture(TEXTURE_UNIT_NUMBER, _value);
}
-#else
- void Ogre2Texture::setDataBlockTexture(Ogre::TexturePtr _value)
- {
- mDataBlock->setTexture(TEXTURE_UNIT_NUMBER, 0, _value);
- }
-#endif
Ogre::HlmsDatablock* Ogre2Texture::getDataBlock()
{
-
- Greenskin
- Posts: 126
- Joined: Wed Jan 19, 2005 4:48 am
- x 9
Re: [2.2] How to compile MyGUI for Ogre 2.2
Thanks I will give this a try later when I have free time. I appreciate the response.rujialiu wrote: ↑Thu Apr 30, 2020 8:52 amal2950's commit was in May 2019, then there were several other changes to Ogre. The biggest change should be the "deprecated" one (which caused OgrePixelBox.h to be removed in my version, and mTmpData changed to Ogre::uint8*), so it's normal that you can't compile Anyway, I'm attaching my personal changes after May 2019 (actually the first change happened in Sept. 2019). Since the diff is based on my version, not al2950, there maybe it's not 100% applicable to your case, so you need to make some adjustments.libolt wrote: ↑Wed Apr 29, 2020 11:37 pm I downloaded and attempted to build the 2.2 branch found on al2950's github page: https://github.com/al2950/mygui/tree/Ogre2.2. Then I applied some of the fixes from this thread and now I'm getting an error related to mTmpData which I had commented out since I had commented out the include for include OgrePixelBox.h:
Also, the diff looks long because part of my modification is to remove Ogre 2.1 support, but if you look at it carefully it should be easy to understand
Code: Select all
.../Ogre2Platform/include/MyGUI_Ogre2Platform.h | 4 - .../Ogre2Platform/include/MyGUI_Ogre2RTTexture.h | 10 - .../include/MyGUI_Ogre2RenderManager.h | 34 ---- .../Ogre2Platform/include/MyGUI_Ogre2Texture.h | 32 +-- .../include/MyGUI_Ogre2VertexBuffer.h | 1 - .../Ogre2Platform/src/MyGUI_Ogre2RTTexture.cpp | 34 +--- .../Ogre2Platform/src/MyGUI_Ogre2RenderManager.cpp | 44 +---- .../Ogre2/Ogre2Platform/src/MyGUI_Ogre2Texture.cpp | 215 +-------------------- 8 files changed, 11 insertions(+), 363 deletions(-) diff --git a/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2Platform.h b/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2Platform.h index 88bd536..f176f6b 100644 --- a/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2Platform.h +++ b/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2Platform.h @@ -42,11 +42,7 @@ namespace MyGUI delete mLogManager; } -#if OGRE_VERSION_MINOR < 2 - void initialise(Ogre::RenderWindow* _window, Ogre::SceneManager* _scene, const std::string& _group = Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, const std::string& _logName = MYGUI_PLATFORM_LOG_FILENAME) -#else void initialise(Ogre::Window* _window, Ogre::SceneManager* _scene, const std::string& _group = Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, const std::string& _logName = MYGUI_PLATFORM_LOG_FILENAME) -#endif { assert(!mIsInitialise); mIsInitialise = true; diff --git a/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2RTTexture.h b/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2RTTexture.h index b592306..ea4f59d 100644 --- a/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2RTTexture.h +++ b/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2RTTexture.h @@ -21,11 +21,7 @@ namespace MyGUI public IRenderTarget { public: -#if OGRE_VERSION_MINOR < 2 - Ogre2RTTexture(Ogre::TexturePtr _texture); -#else Ogre2RTTexture(Ogre::TextureGpu* _texture); -#endif virtual ~Ogre2RTTexture(); virtual void begin(); @@ -40,15 +36,9 @@ namespace MyGUI private: RenderTargetInfo mRenderTargetInfo; -#if OGRE_VERSION_MINOR < 2 - Ogre::Viewport* mViewport; - Ogre::Viewport* mSaveViewport; - Ogre::TexturePtr mTexture; -#else Ogre::RenderPassDescriptor* mRenderPassDesc; Ogre::RenderPassDescriptor* mSaveRenderPassDesc; Ogre::TextureGpu* mTexture; -#endif Ogre::Matrix4 mProjectMatrix; }; diff --git a/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2RenderManager.h b/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2RenderManager.h index da00bce..dde2641 100644 --- a/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2RenderManager.h +++ b/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2RenderManager.h @@ -41,13 +41,8 @@ namespace MyGUI class MyGUIPass : public Ogre::CompositorPass { public: -#if OGRE_VERSION_MINOR < 2 - MyGUIPass(const Ogre::CompositorPassDef *definition, const Ogre::CompositorChannel &target, - Ogre::CompositorNode *parentNode); -#else MyGUIPass(const Ogre::CompositorPassDef *definition, const Ogre::RenderTargetViewDef* rtv, Ogre::CompositorNode *parentNode); -#endif virtual void execute(const Ogre::Camera *lodCameraconst); }; @@ -68,21 +63,12 @@ namespace MyGUI return OGRE_NEW MyGUI::MyGUIPassDef(parentTargetDef); } -#if OGRE_VERSION_MINOR < 2 - Ogre::CompositorPass* addPass(const Ogre::CompositorPassDef *definition, Ogre::Camera *defaultCamera, - Ogre::CompositorNode *parentNode, const Ogre::CompositorChannel &target, - Ogre::SceneManager *sceneManager) - { - return OGRE_NEW MyGUI::MyGUIPass(definition, target, parentNode); - } -#else Ogre::CompositorPass* addPass(const Ogre::CompositorPassDef *definition, Ogre::Camera *defaultCamera, Ogre::CompositorNode *parentNode, const Ogre::RenderTargetViewDef* rtv, Ogre::SceneManager *sceneManager) { return OGRE_NEW MyGUI::MyGUIPass(definition, rtv, parentNode); } -#endif static Ogre::IdString mPassId; }; @@ -100,11 +86,7 @@ namespace MyGUI // FrameListener bool frameStarted(const Ogre::FrameEvent &evt); -#if OGRE_VERSION_MINOR < 2 - void initialise(Ogre::RenderWindow* _window, Ogre::SceneManager* _scene); -#else void initialise(Ogre::Window* _window, Ogre::SceneManager* _scene); -#endif void shutdown(); static Ogre2RenderManager& getInstance(); @@ -145,21 +127,13 @@ namespace MyGUI void setRenderSystem(Ogre::RenderSystem* _render); Ogre::RenderSystem* getRenderSystem(); -#if OGRE_VERSION_MINOR < 2 - void setRenderWindow(Ogre::RenderWindow* _window); -#else void setRenderWindow(Ogre::Window* _window); -#endif /** Set scene manager where MyGUI will be rendered */ void setSceneManager(Ogre::SceneManager* _scene); Ogre::SceneManager* getSceneManager(); -#if OGRE_VERSION_MINOR < 2 - Ogre::RenderWindow* getRenderWindow(); -#else Ogre::Window* getRenderWindow(); -#endif bool getManualRender(); void setManualRender(bool _value); @@ -173,11 +147,7 @@ namespace MyGUI #endif private: -#if OGRE_VERSION_MINOR < 2 - virtual void windowResized(Ogre::RenderWindow* _window); -#else virtual void windowResized(Ogre::Window* _window); -#endif // восстанавливаем буферы virtual void eventOccurred(const Ogre::String& eventName, const Ogre::NameValuePairList* parameters); @@ -196,11 +166,7 @@ namespace MyGUI VertexColourType mVertexFormat; // окно, на которое мы подписываемся для изменения размеров -#if OGRE_VERSION_MINOR < 2 - Ogre::RenderWindow* mWindow; -#else Ogre::Window* mWindow; -#endif Ogre::RenderSystem* mRenderSystem; diff --git a/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2Texture.h b/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2Texture.h index cd2eb2c..80b08b6 100644 --- a/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2Texture.h +++ b/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2Texture.h @@ -15,8 +15,6 @@ #include <Ogre.h> #include <OgreResource.h> -#include <OgreTexture.h> -#include <OgrePixelBox.h> #include <OgreSharedPtr.h> #include <OgreHlms.h> @@ -25,9 +23,7 @@ #include <OgreHlmsManager.h> #include <Hlms/Unlit/OgreHlmsUnlitDatablock.h> -#if OGRE_VERSION_MINOR > 1 #include "OgrePixelFormatGpu.h" -#endif #include "MyGUI_LastHeader.h" @@ -119,27 +115,14 @@ namespace MyGUI virtual IRenderTarget* getRenderTarget(); - static Ogre::TextureUsage convertUsage(TextureUsage _usage); -#if OGRE_VERSION_MINOR > 1 static Ogre::PixelFormatGpu convertFormat(PixelFormat _format); -#else - static Ogre::PixelFormat convertFormat(PixelFormat _format); -#endif /*internal:*/ -#if OGRE_VERSION_MINOR > 1 Ogre::TextureGpu* getOgreTexture() -#else - Ogre::TexturePtr getOgreTexture() -#endif { return mTexture; } -#if OGRE_VERSION_MINOR > 1 void setOgreTexture(Ogre::TextureGpu* _value) -#else - void setOgreTexture(Ogre::TexturePtr _value) -#endif { mTexture = _value; } @@ -153,18 +136,10 @@ namespace MyGUI virtual void loadResource(Ogre::Resource* resource); -#if OGRE_VERSION_MINOR > 1 void setDataBlockTexture(Ogre::TextureGpu* _value); -#else - void setDataBlockTexture(Ogre::TexturePtr _value); -#endif private: -#if OGRE_VERSION_MINOR > 1 Ogre::TextureGpu* mTexture; -#else - Ogre::TexturePtr mTexture; -#endif std::string mName; std::string mGroup; @@ -172,16 +147,11 @@ namespace MyGUI PixelFormat mOriginalFormat; size_t mNumElemBytes; -#if OGRE_VERSION_MINOR > 1 Ogre::PixelFormatGpu mPixelFormat; -#else - Ogre::PixelFormat mPixelFormat; -#endif - Ogre::TextureUsage mUsage; ITextureInvalidateListener* mListener; IRenderTarget* mRenderTarget; - Ogre::PixelBox mTmpData; + Ogre::uint8* mTmpData; Ogre::HlmsUnlitDatablock* mDataBlock; diff --git a/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2VertexBuffer.h b/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2VertexBuffer.h index 912597c..a13fa2c 100644 --- a/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2VertexBuffer.h +++ b/Platforms/Ogre2/Ogre2Platform/include/MyGUI_Ogre2VertexBuffer.h @@ -15,7 +15,6 @@ #include <OgrePrerequisites.h> #include <OgreRenderOperation.h> #include <OgreRenderSystem.h> -#include <OgreTextureManager.h> #include <OgreTextureUnitState.h> #include "MyGUI_LastHeader.h" diff --git a/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2RTTexture.cpp b/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2RTTexture.cpp index 72a57b5..bf77ff0 100644 --- a/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2RTTexture.cpp +++ b/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2RTTexture.cpp @@ -8,22 +8,14 @@ #include "MyGUI_Ogre2RTTexture.h" #include "MyGUI_Ogre2RenderManager.h" -#if OGRE_VERSION_MINOR > 1 #include "OgreTextureGpu.h" -#endif namespace MyGUI { -#if OGRE_VERSION_MINOR < 2 - Ogre2RTTexture::Ogre2RTTexture(Ogre::TexturePtr _texture) : - mViewport(nullptr), - mSaveViewport(nullptr), -#else Ogre2RTTexture::Ogre2RTTexture(Ogre::TextureGpu* _texture) : mRenderPassDesc(nullptr), mSaveRenderPassDesc(nullptr), -#endif mTexture(_texture) { mProjectMatrix = Ogre::Matrix4::IDENTITY; @@ -44,11 +36,7 @@ namespace MyGUI mRenderTargetInfo.pixScaleY = 1.0f / float(height); } -#if OGRE_VERSION_MINOR < 2 - if (mTexture->getBuffer()->getRenderTarget()->requiresTextureFlipping()) -#else if (mTexture->requiresTextureFlipping()) -#endif { mProjectMatrix[1][0] = -mProjectMatrix[1][0]; mProjectMatrix[1][1] = -mProjectMatrix[1][1]; @@ -64,21 +52,6 @@ namespace MyGUI void Ogre2RTTexture::begin() { -#if OGRE_VERSION_MINOR < 2 - Ogre::RenderTexture* rtt = mTexture->getBuffer()->getRenderTarget(); - - if (mViewport == nullptr) - { - mViewport = rtt->addViewport(); - mViewport->setOverlaysEnabled(false); - } - - Ogre::RenderSystem* system = Ogre::Root::getSingleton().getRenderSystem(); - system->_setProjectionMatrix(mProjectMatrix); - mSaveViewport = system->_getViewport(); - system->_setViewport(mViewport); - system->clearFrameBuffer(Ogre::FBT_COLOUR, Ogre::ColourValue::ZERO); -#else Ogre::RenderSystem* system = Ogre::Root::getSingleton().getRenderSystem(); if (mRenderPassDesc == nullptr) { @@ -100,18 +73,13 @@ namespace MyGUI //mSaveRenderPassDesc = system->getCurrentPassDescriptor(); Ogre::Vector4 viewportSize(0, 0, 1, 1); Ogre::Vector4 scissors(0, 0, 1, 1); - system->beginRenderPassDescriptor(mRenderPassDesc, mTexture, 0, viewportSize, scissors, false, false); -#endif + system->beginRenderPassDescriptor(mRenderPassDesc, mTexture, 0, &viewportSize, &scissors, 1, false, false); } void Ogre2RTTexture::end() { Ogre::RenderSystem* system = Ogre::Root::getSingleton().getRenderSystem(); -#if OGRE_VERSION_MINOR < 2 - system->_setViewport(mSaveViewport); -#else // no need to restore RenderPassDesc -#endif #if OGRE_VERSION >= MYGUI_DEFINE_VERSION(1, 7, 0) && OGRE_NO_VIEWPORT_ORIENTATIONMODE == 0 Ogre::OrientationMode orient = mSaveViewport->getOrientationMode(); system->_setProjectionMatrix(Ogre::Matrix4::IDENTITY * Ogre::Quaternion(Ogre::Degree(orient * 90.f), Ogre::Vector3::UNIT_Z)); diff --git a/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2RenderManager.cpp b/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2RenderManager.cpp index f202ef0..8b5c421 100644 --- a/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2RenderManager.cpp +++ b/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2RenderManager.cpp @@ -14,31 +14,21 @@ #include <Compositor/OgreCompositorManager2.h> -#if OGRE_VERSION_MINOR > 1 #include "OgreTextureGpu.h" #include "OgreTextureGpuManager.h" #include "OgreWindow.h" -#endif namespace MyGUI { const Ogre::uint8 Ogre2RenderManager::RENDER_QUEUE_OVERLAY = 254; Ogre::IdString OgreCompositorPassProvider::mPassId = Ogre::IdString("MYGUI"); -#if OGRE_VERSION_MINOR < 2 - MyGUIPass::MyGUIPass(const Ogre::CompositorPassDef *definition, const Ogre::CompositorChannel &target, - Ogre::CompositorNode *parentNode) - : Ogre::CompositorPass(definition, target, parentNode) - { - } -#else MyGUIPass::MyGUIPass(const Ogre::CompositorPassDef *definition, const Ogre::RenderTargetViewDef* rtv, Ogre::CompositorNode *parentNode) : Ogre::CompositorPass(definition, parentNode) { this->initialize(rtv); } -#endif void MyGUIPass::execute(const Ogre::Camera *lodCameraconst) { @@ -65,11 +55,7 @@ namespace MyGUI { } -#if OGRE_VERSION_MINOR < 2 - void Ogre2RenderManager::initialise(Ogre::RenderWindow* _window, Ogre::SceneManager* _scene) -#else void Ogre2RenderManager::initialise(Ogre::Window* _window, Ogre::SceneManager* _scene) -#endif { MYGUI_PLATFORM_ASSERT(!mIsInitialise, getClassTypeName() << " initialised twice"); MYGUI_PLATFORM_LOG(Info, "* Initialise: " << getClassTypeName()); @@ -169,11 +155,7 @@ namespace MyGUI return mRenderSystem; } -#if OGRE_VERSION_MINOR < 2 - void Ogre2RenderManager::setRenderWindow(Ogre::RenderWindow* _window) -#else void Ogre2RenderManager::setRenderWindow(Ogre::Window* _window) -#endif { // отписываемся if (mWindow != nullptr) @@ -239,6 +221,7 @@ namespace MyGUI //This will add renderbles to the Ogre render queue onRenderToTarget(this, mUpdate); + mSceneManager->getRenderQueue()->renderPassPrepare(false, false); mSceneManager->getRenderQueue()->render(mSceneManager->getDestinationRenderSystem(), RENDER_QUEUE_OVERLAY, RENDER_QUEUE_OVERLAY+1, false, false); // сбрасываем флаг @@ -268,11 +251,7 @@ namespace MyGUI } // для оповещений об изменении окна рендера -#if OGRE_VERSION_MINOR < 2 - void Ogre2RenderManager::windowResized(Ogre::RenderWindow* _window) -#else void Ogre2RenderManager::windowResized(Ogre::Window* _window) -#endif { mViewSize.set(_window->getWidth(), _window->getHeight()); @@ -342,15 +321,6 @@ namespace MyGUI MapTexture::const_iterator item = mTextures.find(_name); if (item == mTextures.end()) { -#if OGRE_VERSION_MINOR < 2 - Ogre::TexturePtr texture = (Ogre::TexturePtr)Ogre::TextureManager::getSingleton().getByName(_name); - if (!texture.isNull()) - { - ITexture* result = createTexture(_name); - static_cast<Ogre2Texture*>(result)->setOgreTexture(texture); - return result; - } -#else Ogre::TextureGpuManager *textureMgr = Ogre::Root::getSingletonPtr()->getRenderSystem()->getTextureGpuManager(); const Ogre::String* name = textureMgr->findResourceNameStr(_name); if (name) { @@ -365,7 +335,6 @@ namespace MyGUI static_cast<Ogre2Texture*>(result)->setOgreTexture(texture); return result; } -#endif return nullptr; } return item->second; @@ -373,15 +342,8 @@ namespace MyGUI bool Ogre2RenderManager::isFormatSupported(PixelFormat _format, TextureUsage _usage) { -#if OGRE_VERSION_MINOR == 1 - return Ogre::TextureManager::getSingleton().isFormatSupported( - Ogre::TEX_TYPE_2D, - Ogre2Texture::convertFormat(_format), - Ogre2Texture::convertUsage(_usage)); -#else if (_format == PixelFormat::L8A8) return false; // 不支持! return true; // FIXME -#endif } void Ogre2RenderManager::destroyAllResources() @@ -425,11 +387,7 @@ namespace MyGUI return mInfo; } -#if OGRE_VERSION_MINOR < 2 - Ogre::RenderWindow* Ogre2RenderManager::getRenderWindow() -#else Ogre::Window* Ogre2RenderManager::getRenderWindow() -#endif { return mWindow; } diff --git a/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2Texture.cpp b/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2Texture.cpp index 93ae03a..e998133 100644 --- a/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2Texture.cpp +++ b/Platforms/Ogre2/Ogre2Platform/src/MyGUI_Ogre2Texture.cpp @@ -14,13 +14,11 @@ #include "MyGUI_LastHeader.h" -#if OGRE_VERSION_MINOR > 1 #include "OgreTextureGpu.h" #include "OgreTextureGpuManager.h" #include "OgrePixelFormatGpu.h" #include "OgrePixelFormatGpuUtils.h" #include "OgreStagingTexture.h" -#endif namespace MyGUI { @@ -29,16 +27,11 @@ namespace MyGUI mName(_name), mGroup(_group), mNumElemBytes(0), -#if OGRE_VERSION_MINOR == 1 - mPixelFormat(Ogre::PF_UNKNOWN), -#else mPixelFormat(Ogre::PixelFormatGpu::PFG_UNKNOWN), -#endif - mUsage(Ogre::TU_DEFAULT), mListener(nullptr), mRenderTarget(nullptr) { - mTmpData.data = nullptr; + mTmpData = nullptr; mDataBlock = HLMS_BLOCKS.createUnlitDataBlock(_name); } @@ -56,13 +49,6 @@ namespace MyGUI void Ogre2Texture::saveToFile(const std::string& _filename) { Ogre::uchar* readrefdata = static_cast<Ogre::uchar*>(lock(TextureUsage::Read)); -#if OGRE_VERSION_MINOR == 1 - Ogre::Image img; - img = img.loadDynamicImage(readrefdata, mTexture->getWidth(), mTexture->getHeight(), mTexture->getFormat()); - img.save(_filename); -#else -#endif - unlock(); } @@ -73,31 +59,17 @@ namespace MyGUI void Ogre2Texture::destroy() { - if (mTmpData.data != nullptr) - { - delete [] (uint8*)mTmpData.data; - mTmpData.data = nullptr; - } - if (mRenderTarget != nullptr) { delete mRenderTarget; mRenderTarget = nullptr; } -#if OGRE_VERSION_MINOR == 1 - if (!mTexture.isNull()) - { - Ogre::TextureManager::getSingleton().remove(mTexture->getName()); - mTexture.setNull(); - } -#else if (mTexture) { Ogre::TextureGpuManager *textureMgr = Ogre::Root::getSingletonPtr()->getRenderSystem()->getTextureGpuManager(); textureMgr->destroyTexture(mTexture); mTexture = nullptr; } -#endif } int Ogre2Texture::getWidth() @@ -112,63 +84,29 @@ namespace MyGUI void* Ogre2Texture::lock(TextureUsage _access) { -#if OGRE_VERSION_MINOR == 1 - if (_access == TextureUsage::Write) - { - return mTexture->getBuffer()->lock(Ogre::v1::HardwareBuffer::HBL_DISCARD); - } - - // здесь проверить режим создания, и возможно так залочить без пиксель бокса - - // для чтения копируем в пиксель бокс - if (mTmpData.data != nullptr) - { - delete [] (uint8*)mTmpData.data; - mTmpData.data = nullptr; - } - - mTmpData = Ogre::PixelBox(mTexture->getWidth(), mTexture->getHeight(), mTexture->getDepth(), mTexture->getFormat()); - mTmpData.data = new uint8[mTexture->getBuffer()->getSizeInBytes()]; - - mTexture->getBuffer()->blitToMemory(mTmpData); - - return mTmpData.data; -#else if (_access == TextureUsage::Write) { const uint32 rowAlignment = 4u; const size_t dataSize = Ogre::PixelFormatGpuUtils::getSizeBytes(mTexture->getWidth(), mTexture->getHeight(), 1u, 1u, mTexture->getPixelFormat(), rowAlignment); uint8 *imageData = reinterpret_cast<uint8*>(OGRE_MALLOC_SIMD(dataSize, Ogre::MEMCATEGORY_RESOURCE)); - mTmpData.data = imageData; - return mTmpData.data; + mTmpData = imageData; + return mTmpData; } else { // FIXME return nullptr; } -#endif } void Ogre2Texture::unlock() { -#if OGRE_VERSION_MINOR == 1 - if (mTexture->getBuffer()->isLocked()) - { - mTexture->getBuffer()->unlock(); - } - else if (mTmpData.data != nullptr) - { - delete [] (uint8*)mTmpData.data; - mTmpData.data = nullptr; - } -#else Ogre::TextureGpuManager *textureManager = Ogre::Root::getSingletonPtr()->getRenderSystem()->getTextureGpuManager(); - if (mTmpData.data != nullptr) + if (mTmpData != nullptr) { // write - uint8 *imageData = reinterpret_cast<uint8*>(mTmpData.data); + uint8 *imageData = reinterpret_cast<uint8*>(mTmpData); const size_t bytesPerRow = mTexture->_getSysRamCopyBytesPerRow(0); mTexture->_transitionTo(Ogre::GpuResidency::Resident, imageData); @@ -187,69 +125,17 @@ namespace MyGUI stagingTexture = 0; OGRE_FREE_SIMD(imageData, Ogre::MEMCATEGORY_RESOURCE); - mTmpData.data = nullptr; + mTmpData = nullptr; mTexture->notifyDataIsReady(); } -#endif } bool Ogre2Texture::isLocked() { -#if OGRE_VERSION_MINOR == 1 - return mTexture->getBuffer()->isLocked(); -#else // FIXME return false; -#endif - } - - Ogre::TextureUsage Ogre2Texture::convertUsage(TextureUsage _usage) - { - if (_usage == TextureUsage::Default) - { - return Ogre::TU_STATIC_WRITE_ONLY; - } - else if (_usage == TextureUsage::RenderTarget) - { - return Ogre::TU_RENDERTARGET; - } - else if (_usage.isValue(TextureUsage::Static)) - { - if (_usage.isValue(TextureUsage::Write)) - { - return Ogre::TU_STATIC_WRITE_ONLY; - } - else - { - return Ogre::TU_STATIC; - } - } - else if (_usage.isValue(TextureUsage::Dynamic)) - { - if (_usage.isValue(TextureUsage::Write)) - { - return Ogre::TU_DYNAMIC_WRITE_ONLY; - } - else - { - return Ogre::TU_DYNAMIC; - } - } - else if (_usage.isValue(TextureUsage::Stream)) - { - if (_usage.isValue(TextureUsage::Write)) - { - return Ogre::TU_DYNAMIC_WRITE_ONLY_DISCARDABLE; - } - else - { - return Ogre::TU_DYNAMIC; - } - } - return Ogre::TU_DEFAULT; } -#if OGRE_VERSION_MINOR > 1 Ogre::PixelFormatGpu Ogre2Texture::convertFormat(PixelFormat _format) { if (_format == PixelFormat::L8) return Ogre::PixelFormatGpu::PFG_R8_UNORM; @@ -259,17 +145,6 @@ namespace MyGUI return Ogre::PixelFormatGpu::PFG_UNKNOWN; } -#else - Ogre::PixelFormat Ogre2Texture::convertFormat(PixelFormat _format) - { - if (_format == PixelFormat::L8) return Ogre::PF_BYTE_L; - else if (_format == PixelFormat::L8A8) return Ogre::PF_BYTE_LA; - else if (_format == PixelFormat::R8G8B8) return Ogre::PF_R8G8B8; - else if (_format == PixelFormat::R8G8B8A8) return Ogre::PF_A8R8G8B8; - - return Ogre::PF_UNKNOWN; - } -#endif void Ogre2Texture::setFormat(PixelFormat _format) { @@ -286,28 +161,13 @@ namespace MyGUI void Ogre2Texture::setUsage(TextureUsage _usage) { mOriginalUsage = _usage; - mUsage = convertUsage(_usage); + //mUsage = convertUsage(_usage); } void Ogre2Texture::createManual(int _width, int _height, TextureUsage _usage, PixelFormat _format) { setFormat(_format); setUsage(_usage); -#if OGRE_VERSION_MINOR == 1 - mTexture = Ogre::TextureManager::getSingleton().createManual( - mName, - mGroup, - Ogre::TEX_TYPE_2D, - _width, - _height, - 0, - mPixelFormat, - mUsage, - this, - true); - - mTexture->load(); -#else uint32 textureFlags = 0; // Ogre::TextureFlags::PrefersLoadingFromFileAsSRGB if (_usage.isValue(TextureUsage::RenderTarget)) { textureFlags |= Ogre::TextureFlags::RenderToTexture; @@ -335,8 +195,6 @@ namespace MyGUI mTexture->_setNextResidencyStatus(Ogre::GpuResidency::Resident); } } - -#endif setDataBlockTexture(mTexture); } @@ -344,13 +202,8 @@ namespace MyGUI { setUsage(TextureUsage::Default); - Ogre::TextureManager* manager = Ogre::TextureManager::getSingletonPtr(); - -#if OGRE_VERSION_MINOR > 1 bool needLoadTexture = false; -#endif - - if ( !manager->resourceExists(_filename) ) + if ( false ) { DataManager& resourcer = DataManager::getInstance(); if (!resourcer.isDataExist(_filename)) @@ -359,23 +212,14 @@ namespace MyGUI } else { -#if OGRE_VERSION_MINOR == 1 - mTexture = manager->load(_filename, mGroup, Ogre::TEX_TYPE_2D, 0, 1.0f, false, Ogre::PF_UNKNOWN, true); -#else needLoadTexture = true; -#endif } } else { -#if OGRE_VERSION_MINOR == 1 - mTexture = manager->getByName(_filename); -#else needLoadTexture = true; -#endif } -#if OGRE_VERSION_MINOR > 1 if (needLoadTexture) { Ogre::TextureGpuManager *textureMgr = Ogre::Root::getSingletonPtr()->getRenderSystem()->getTextureGpuManager(); mTexture = textureMgr->createOrRetrieveTexture( @@ -391,7 +235,6 @@ namespace MyGUI mTexture->waitForData(); } } -#endif setFormatByOgreTexture(); setDataBlockTexture(mTexture); @@ -401,40 +244,6 @@ namespace MyGUI { mOriginalFormat = PixelFormat::Unknow; mNumElemBytes = 0; -#if OGRE_VERSION_MINOR == 1 - mPixelFormat = Ogre::PF_UNKNOWN; - if (!mTexture.isNull()) - { - mPixelFormat = mTexture->getFormat(); - - if (mPixelFormat == Ogre::PF_BYTE_L) - { - mOriginalFormat = PixelFormat::L8; - mNumElemBytes = 1; - } - else if (mPixelFormat == Ogre::PF_BYTE_LA) - { - mOriginalFormat = PixelFormat::L8A8; - mNumElemBytes = 2; - } - else if (mPixelFormat == Ogre::PF_R8G8B8) - { - mOriginalFormat = PixelFormat::R8G8B8; - mNumElemBytes = 3; - } - else if (mPixelFormat == Ogre::PF_A8R8G8B8) - { - mOriginalFormat = PixelFormat::R8G8B8A8; - mNumElemBytes = 4; - } - else - { - mOriginalFormat = PixelFormat::Unknow; - mNumElemBytes = Ogre::PixelUtil::getNumElemBytes(mPixelFormat); - } - - } -#else mPixelFormat = Ogre::PixelFormatGpu::PFG_UNKNOWN; if (mTexture) { @@ -467,7 +276,6 @@ namespace MyGUI } } -#endif } void Ogre2Texture::loadResource(Ogre::Resource* resource) @@ -484,17 +292,10 @@ namespace MyGUI return mRenderTarget; } -#if OGRE_VERSION_MINOR > 1 void Ogre2Texture::setDataBlockTexture( Ogre::TextureGpu* _value ) { mDataBlock->setTexture(TEXTURE_UNIT_NUMBER, _value); } -#else - void Ogre2Texture::setDataBlockTexture(Ogre::TexturePtr _value) - { - mDataBlock->setTexture(TEXTURE_UNIT_NUMBER, 0, _value); - } -#endif Ogre::HlmsDatablock* Ogre2Texture::getDataBlock() {