2
\$\begingroup\$

I'm using Ogre 1.10.12 (openglES2 as render system) to create a manual texture like this:

    rtt_texture = Ogre::TextureManager::getSingleton().createManual("RttTex",
                                                                Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
                                                                Ogre::TEX_TYPE_2D,
                                                                m_size.width(),
                                                                m_size.height(),
                                                                0,
                                                                Ogre::PF_A1R5G5B5,
                                                                Ogre::TU_RENDERTARGET);

m_renderTexture = static_cast<Ogre::GLES2FBORenderTexture *>(rtt_texture->getBuffer()->getRenderTarget());

m_renderTexture->addViewport(m_camera);
m_renderTexture->getViewport(0)->setClearEveryFrame(true);
m_renderTexture->getViewport(0)->setBackgroundColour(Ogre::ColourValue::Red);
m_renderTexture->getViewport(0)->setOverlaysEnabled(false);

then, I bind the texture to the FBO and retrieve the FBO's ID like:

Ogre::GLES2FrameBufferObject *ogreFbo = 0;
m_renderTexture->getCustomAttribute("FBO", &ogreFbo);
Ogre::GLES2FBOManager *manager = ogreFbo->getManager();
manager->bind(m_renderTexture);

GLint id;
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &id);

My concern is that id is 0 so I cannot render this texture outside my display, it's getting visible which I don't want it to be.

Shouldn't be ogre creating an unused frame buffer object when creating a manual texture with the TU_RENDERTARGET parameter?

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

Finally got the answer to my question: Creating a texture with parameter TU_RENDERTARGET, Ogre will always attempt to create a new frame buffer object (fbo) and then bind it, i.e, Ogre will call glGenFramebuffers followed by glBindFramebuffer. But this can fail if for example you are playing with opengl contexts (sharing, switching between them), this was the cause of my problem since I was sharing Ogre's context with other opengl app, and the visual effect was that everything was being rendered to the main framebuffer (id 0) making all contexts visible all time, mixing them up. So if you encounter with this kind of problems, always check that Ogre's context is well defined, debugging the state of member mContext of class OgreRenderSystem helps a lot.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .