sdl-gpu icon indicating copy to clipboard operation
sdl-gpu copied to clipboard

AddDepthBuffer Breaks iOS

Open DiegoAce opened this issue 6 years ago • 2 comments

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, &param);

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);

DiegoAce avatar Mar 16 '18 15:03 DiegoAce

That's weird. I'm fine merging that in, though I'm not certain what the consequences of this behavior are generally.

grimfang4 avatar Mar 18 '18 23:03 grimfang4

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

dhiahassen avatar Mar 21 '18 08:03 dhiahassen