Olex
Topic Author
Posts: 2
Joined: 01 Sep 2015, 00:18

[New User] Ogre3D + NoesisGUI => Render to Texture

01 Sep 2015, 23:47

Hi, folks!

I am just starting out with NoesisGUI. So far it is looking slick!
I got Ogre3D binding sample to work from https://github.com/Noesis/OgreBindings
I had 2D UI sample UI running in my own project, which is really awesome.

The next step for me is render to texture in Ogre3D.
I see that it lists the following limitation on its readme.
Known problems:
Render to texture not working yet. The API of the Ogre bindings need to be expanded for this.

So now I am curious:
1. How much work is it to expand Ogre bindings for that?
2. Which NoesisGUI API need to be expanded there?
3. Is there isn't much work, perhaps I can hack something up myself?


Currently, I have cairographics.org vector graphics library drawing to a texture buffer and updating that into an Ogre3D texture in my project. So I believe I should be half way there to use NoesisGUI instead?


/Olex

P.S. I have done some forum searching. I see some examples on how to do that with Unity but not with straight up OpenGL/Ogre3D.
 
paultech
Posts: 1
Joined: 22 Aug 2015, 19:09

Re: [New User] Ogre3D + NoesisGUI => Render to Texture

02 Sep 2015, 19:14

You would need to add some structure to the API that holds a reference to a texture (or framebuffer etc) then bind to that before call on uiRenderer->Render().

This is mentioned into the Core Bind Tutorial: http://www.noesisengine.com/docs/Gui.Core.SDKGuide.html:

// Start frame
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Render HUD
xamlRenderer->Render(commands.commands.GetPtr());

Just bind to the framebuffer that has the texture bound prior to Noesis_GPURender and you should get your desired output!
 
User avatar
sfernandez
Site Admin
Posts: 1912
Joined: 22 Dec 2011, 19:20

Re: [New User] Ogre3D + NoesisGUI => Render to Texture

03 Sep 2015, 16:39

Hi,

Thanks @paultech for your help here, you are right.

Our integration API is very simple, and only requires that the correct framebuffer/render target is active before calling Noesis_GPURender().

If you want to render to to a texture, you just need to call glBindFrameBuffer()/SetRenderTarget() providing the texture id/ptr that corresponds to the texture. In OpenGL will be something like this:
// Render offscreen
Noesis_GPURenderOffscreen(renderer);

// Activate texture
glBindFramebuffer(GL_FRAMEBUFFER, texId);
glViewport(0, 0, width, height);

// Render UI
Noesis_GPURender(renderer);
Anyway, if you need to modify anything from the OgreBindings to make this work correctly, please feel free to do it and send as a pull request. We will check the changes and upload them for everyone.

Who is online

Users browsing this forum: No registered users and 2 guests