Skip to content

Instantly share code, notes, and snippets.

@xophiix
Last active August 29, 2015 14:19
Show Gist options
  • Save xophiix/9f102de46f3d5ed3875d to your computer and use it in GitHub Desktop.
Save xophiix/9f102de46f3d5ed3875d to your computer and use it in GitHub Desktop.
my own android gles bug fix and tricks
// MIUI3 not support GL_OES_packed_depth_stencil workaround
glGenRenderbuffers(1, &m_pDepthStencil);
glBindRenderbuffer(GL_RENDERBUFFER, m_pDepthStencil);
static bool supportedPackedDepthStencil = strstr((const char*)glGetString(GL_EXTENSIONS), "GL_OES_packed_depth_stencil") != NULL;
GLenum internalFormat = supportedPackedDepthStencil ? GL_DEPTH24_STENCIL8 : GL_DEPTH_COMPONENT16;
glRenderbufferStorage(GL_RENDERBUFFER, internalFormat, nWidth, nHeight);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_pDepthStencil);
if (supportedPackedDepthStencil) {
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_pDepthStencil);
checkGLError("create render target");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment