sdl-gpu
sdl-gpu copied to clipboard
AddDepthBuffer Breaks iOS
When AddDepthBuffer is used on iOS only a black screen is rendered thereafter. Apparently, the colorbuffer needs to be rebound after the depth_buffer calls.
I used this question to find the solution: https://stackoverflow.com/questions/9909473/opengl-es-2-0-buffer-setup
I rebound the color buffer afterwards and everything worked as expected. I tested this on iOS using OpenGLES 2.0 and 3.0 and OpenGL 3 on my Mac. Below are the changes I made to AddDepthBuffer of renderer_GL_common.inl. I wasn't sure what the colorbuffer id was so I used glGetIntegerv. It was 1. Maybe it's always 1.
GLint param;
glGetIntegerv(GL_RENDERBUFFER_BINDING, ¶m);
glGenRenderbuffers(1, &depth_buffer);
glBindRenderbuffer(GL_RENDERBUFFER, depth_buffer);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, target->base_w, target->base_h);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth_buffer);
glBindRenderbuffer(GL_RENDERBUFFER, param);
That's weird. I'm fine merging that in, though I'm not certain what the consequences of this behavior are generally.
please set an IOS check macro arround the new code , we don't want weird behaviours to appear in other platforms , i mean if the code is restrickted to IOS