Hello, I use cocos2d-x 2.1.5
I noticed that, in the RenderTextureTest, 4th test “Testing depthStencil attachment” doesn’t work with Asus TF300 (Tegra 3 chipset)
Seems the problem is in glRenderbufferStorage when using GL_DEPTH24_STENCIL8 as second parameter. With this parameter (0x88F0), glGetError return 0x500 (INVALID_ENUM)
Someone have solved this problem?
Thanks
Don
1 Like
That appears to be a bug with the TF300 hardware, similar issues with Unity.
Thanks for reply.
If you know, I would you like to ask a little information.
Do you know how to identify if you are on a tegra 3?
This problem also happens with Tegra 2 and Tegra 4 or later?
Thanks
Don
I solved using this method:
https://github.com/blackberry/GamePlay/commit/a8656a693d4efade367f1f13076144638e18d2df
use GL_DEPTH_COMPONENT16 + GL_STENCIL_INDEX8 separately, in the init() of the CCRenderTexture (Cocos2d-x 2.1.5)
1 Like
I have some problem as like it. How solved it? I use cocos2dx 3.6.
Obg1
January 22, 2016, 1:57pm
#7
Based on @Donmizzi suggestion I’ve made the following fix to RenderTexture:
// generate FBO
glGenFramebuffers(1, &_FBO);
glBindFramebuffer(GL_FRAMEBUFFER, _FBO);
// associate texture with FBO
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _texture->getName(), 0);
if (depthStencilFormat != 0)
{
//create and attach depth buffer
glGenRenderbuffers(1, &_depthRenderBufffer);
glBindRenderbuffer(GL_RENDERBUFFER, _depthRenderBufffer);
glRenderbufferStorage(GL_RENDERBUFFER, depthStencilFormat, (GLsizei)powW, (GLsizei)powH);
// Hack
{
cocos2d::log("Hack - Depth 16 stencil 8");
// Fall back to less common GLES2 extension combination for separate depth24 + stencil8 or depth16 + stencil8
auto __gl_error_code = glGetError();
if (__gl_error_code != GL_NO_ERROR)
{
cocos2d::log("Hack - Error - so check and apply hack Depth 16 stencil 8");
const char* extString = (const char*)glGetString(GL_EXTENSIONS);
if (strstr(extString, "GL_OES_packed_depth_stencil") != 0)
{
cocos2d::log("Hack - GL_OES_packed_depth_stencil");
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, (GLsizei)powW, (GLsizei)powH);
}
else
{
cocos2d::log("Hack - Not Packed");
if (strstr(extString, "GL_OES_depth24") != 0)
{
cocos2d::log("Hack - GL_OES_depth24");
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, (GLsizei)powW, (GLsizei)powH);
}
else
{
cocos2d::log("Hack - GL_OES_depth16");
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, (GLsizei)powW, (GLsizei)powH);
}
if (depthStencilFormat == GL_DEPTH24_STENCIL8)
{
cocos2d::log("Hack - depthStencilFormat == GL_DEPTH24_STENCIL8");
glGenRenderbuffers(1, &_stencilRenderBufffer);
glBindRenderbuffer(GL_RENDERBUFFER, _stencilRenderBufffer);
glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, (GLsizei)powW, (GLsizei)powH);
}
}
}
}
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, _depthRenderBufffer);
// if depth format is the one with stencil part, bind same render buffer as stencil attachment
if (depthStencilFormat == GL_DEPTH24_STENCIL8)
{
if (_stencilRenderBufffer)
{
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, _stencilRenderBufffer);
}
else
{
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, _depthRenderBufffer);
}
}
}
// check if it worked (probably worth doing :) )
CCASSERT(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE, "Could not attach texture to framebuffer");
Obg1
January 24, 2016, 3:34pm
#8