Ogre Version: 2.3
Operating System: Windows 11
Render System: Vulkan
Hello, I'm at the start of creating a simple GUI system, my 1st goal is to load an image on the screen.
I tried doing that with Rectangle2D but the image did not appear on screen, everything else is rendering normally though.
Here's the code:
Code: Select all
Ogre::HlmsManager* hlmsManager = mRoot->getHlmsManager();
Ogre::HlmsUnlitDatablock* datablock = 0;
Ogre::HlmsSamplerblock samplerBlock;
samplerBlock.setAddressingMode(Ogre::TAM_WRAP);
Ogre::HlmsBlendblock blendBlock;
blendBlock.setBlendType(Ogre::SBT_TRANSPARENT_ALPHA);
Ogre::HlmsMacroblock macroBlock;
macroBlock.mDepthCheck = false;
macroBlock.mDepthWrite = false;
const Ogre::String datablockName = "RectDatablock";
OGRE_ASSERT(dynamic_cast<Ogre::HlmsUnlit*>(hlmsManager->getHlms(Ogre::HLMS_UNLIT)));
Ogre::HlmsUnlit* hlmsUnlit =
static_cast<Ogre::HlmsUnlit*>(hlmsManager->getHlms(Ogre::HLMS_UNLIT));
datablock = static_cast<Ogre::HlmsUnlitDatablock*>(
hlmsUnlit->createDatablock(Ogre::IdString(datablockName), datablockName, macroBlock,
blendBlock, Ogre::HlmsParamVec()));
datablock->setTexture(0u, "leaf.png");
datablock->setSamplerblock(0, samplerBlock);
Ogre::Rectangle2D* Rect = mSceneMgr->createRectangle2D(Ogre::SCENE_DYNAMIC);
Rect->initialize(Ogre::BT_DEFAULT, Ogre::Rectangle2D::GeometryFlagQuad);
Rect->setGeometry(Ogre::Vector2(0.0f, 0.0f), Ogre::Vector2(2.0f, 2.0f));
Rect->setRenderQueueGroup(10u); // Render after most stuff
Rect->setDatablock(datablock);
Ogre::SceneNode* rectNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
rectNode->attachObject(Rect);
rectNode->setPosition(0, 0, 0);
It worked when I did the same thing for Billboard and a planemesh, but Rectangle2D didn't appear for some reason.
I chose Rectangle2D for my GUI implementation since there seems to be a way to position it through screen coords, but since it's not visible I can't even test to see if that's possible