Jump to content

Get RenderTarget / Final Texture from Gui Element


photo

Recommended Posts

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

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

  • Thanks 1
Link to comment

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
  • 4 weeks later...
×
×
  • Create New...