Render Texture with a depth attachment in iOS

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
ajmalk
Posts: 2
Joined: Tue Jan 31, 2017 8:20 pm

Render Texture with a depth attachment in iOS

Post by ajmalk »

I didn't get any replies in Beginner so reposting here.

I'm having trouble with rendering to an offscreen texture on opengles. I want to draw objects into a render texture and then draw using the render texture onto the screen. I'm using the ogl-es branch on iOS 10 and trying to render into a custom view in our cocoa app.

This is all I'm doing to instantiate the render target.
renderTargetTex = driver->addRenderTargetTexture(core::dimension2d<u32>(256, 256), "RTT1", video::ECF_A8R8G8B8);
video::ITexture* renderTargetDepth = driver->addRenderTargetTexture(core::dimension2d<u32>(256, 256), "DepthStencil", video::ECF_D16);

renderTarget = driver->addRenderTarget();
renderTarget->setTexture(renderTargetTex, renderTargetDepth);
When I run glCheckFramebufferStatus on the resulting frame buffer, I'm getting a GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT status. In all my research that status means one of the either the color texture or the depth texture are the wrong format or initialized improperly. What am I doing wrong here?

After some more research I figured out a few things.

1) The frame buffer works as a render texture if I instantiate it without a depth texture attachment like this: renderTarget->setTexture(renderTargetTex, NULL) .
2) It doesn't work with only a depth attachment either. It works with only a color attachment.
3) I tried many different combinations of flags for the internalformat parameter when creating a texture including the OES variants and it didn't seam to help. I think this is where the problem is.
4) I tried the flags suggested in OpenGL ES 2 Programming Guide and this link from Apple https://developer.apple.com/library/con ... texts.html.
5) There doesn't seem to be a way to attach a render buffer instead of a render texture as a depth attachment in irrlicht. All the examples I've seen in iOS attaches a render buffer as a depth attachment instead of a texture. Is this a limitation in IOS. The book says I am allowed to use a texture as a depth attachment as long as it has the right type.
6) The way I'm testing these flags is by editing the opengles 2 driver file in irrlicht. Is irrlicht doing something before or after that may screw with this in any way? I've pretty much stepped through every line at this point but I thought I would ask.

Any help would be much appreciated! I set up a repository with some test code here: https://github.com/meograph/irrlicht-ex ... S/main.cpp.

Just run the HelloWorld_iOS target in BuildAllExamples.workspace. I've already linked the relevant code.
Post Reply