feheim Posted January 12, 2021 Share Posted January 12, 2021 Hi, is there a possibility to get the RenderTarget (or Final Color Texture) used by Unigine::Gui? Our Setup is a follows: We use Unigine inside a Qt Application and use a Gui with WidgetSprites. The WidgetSprites themselves contain Overlays (Images) or Viewports. The Gui then generates the final image from all its children. The rendering happens through the use of the PlatformRender like in the ViewportQt Sample: platform_render->create(); platform_render->begin(); /* Render Viewports */ gui->enable(/* */); // Gui RenderTarget is bound --> clear it Unigine::RenderState::clearBuffer(Unigine::RenderState::BUFFER_COLOR, /* color vec*/); gui->render(/* */); gui->disable(); platform_render->end(); We found out how to clear the Color Texture through Unigine::RenderState::clearBuffer but now way to get TexturePtr or similar. The goal is to write the Buffer Date to an Image in order to write it to the disk. Thank you for any help! Link to comment
rohit.gonsalves Posted January 12, 2021 Share Posted January 12, 2021 Dear @feheim, You can create your own texture and render the gui on it. Then you may use that texture for any other reason you want. The following thing works for me. RenderState::saveState(); RenderState::clearStates(); RenderState::flushStates(); m_objTextureRender->enable(); m_objTextureRender->bindColorTexture(0, objTextureGUI); m_pObjWidgetCanvas->setPolygonColor(ID_GuiPoygon[iIndex], lerp( vec4(0.6f, 0.0f, 0.0f, 1.0f), vec4(0.0f, 0.4f, 0.0f, 1.0f), m_rAmount)); m_pObjWidgetCanvas->setTextText(ID_GuiText[iIndex], NAME_PIN_ChannelName[iIndex].c_str()); m_pObjWidgetCanvas->setTextPosition(ID_GuiText[iIndex], vec2(rStartPosX, rStartPosY)); ////Canvas Printing with additional Information m_pObjGui->update(Game::getIFps()); m_pObjGui->enable(m_vec2RenderSize.getValue().x, m_vec2RenderSize.getValue().y); m_pObjGui->render(App::getMouseX(), App::getMouseY(), App::getMouseButton(), 0); m_pObjGui->disable(); m_objTextureRender->flush(); m_objTextureRender->disable(); m_objTextureRender->unbindColorTexture(0); RenderState::restoreState(); RenderState::flushStates(); Now use objTextureGUI to save or draw. Hope this helps. Rohit 1 Link to comment
feheim Posted January 18, 2021 Author Share Posted January 18, 2021 Hi @rohit.gonsalves, thanks for you quick answer. Unfortunately I'm currently working on other stuff, but I will try your idea hopefully this week. Do you, by chance, also know if it's possible to use GUI and WidgetSprite alignments for Offscreen Rendering? (Thus without displaying it on screen) Thank you! Link to comment
feheim Posted February 15, 2021 Author Share Posted February 15, 2021 Hi @rohit.gonsalves, just wanted to catch up, it worked. Thank you again! However the gui unfortunately seems to be tied to a PlatformRenderer and won't render the right dimensions into the Render Target when using it offscreen. 1 Link to comment
rohit.gonsalves Posted February 16, 2021 Share Posted February 16, 2021 @feheim, It is little harder to understand the problem without some screens and images. May you post some? Rohit Link to comment
Recommended Posts