OpenGL: fix compatibility with Mac & Mesa

This combines the Mesa fix (16e929e6ff by @brita_) with the Mac fix (89e23c743e by @merwin).

And uses the same fix for another call to glFramebufferTexture introduced in f1fb605ec9.
This commit is contained in:
Mike Erwin 2017-04-18 11:54:13 -04:00
parent b0351bd3bd
commit 45b3555cba
1 changed files with 15 additions and 8 deletions

View File

@ -143,15 +143,13 @@ bool GPU_framebuffer_texture_attach(GPUFrameBuffer *fb, GPUTexture *tex, int slo
else
attachment = GL_COLOR_ATTACHMENT0 + slot;
#if defined(__APPLE__) && defined(WITH_GL_PROFILE_COMPAT)
/* Mac workaround, remove after we switch to core profile */
glFramebufferTextureEXT(GL_FRAMEBUFFER, attachment, GPU_texture_opengl_bindcode(tex), mip);
#elif defined(WITH_GL_PROFILE_COMPAT)
/* Workaround for Mesa compatibility profile, remove after we switch to core profile */
if(!GLEW_VERSION_3_2) /* glFramebufferTexture was introduced in 3.2. It is *not* available in the ARB FBO extension */
glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, GPU_texture_target(tex), GPU_texture_opengl_bindcode(tex), mip);
else
#if defined(WITH_GL_PROFILE_COMPAT)
/* Workaround for Mac & Mesa compatibility profile, remove after we switch to core profile */
/* glFramebufferTexture was introduced in 3.2. It is *not* available in the ARB FBO extension */
if (GLEW_VERSION_3_2)
glFramebufferTexture(GL_FRAMEBUFFER, attachment, GPU_texture_opengl_bindcode(tex), mip); /* normal core call, same as below */
else
glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, GPU_texture_target(tex), GPU_texture_opengl_bindcode(tex), mip);
#else
glFramebufferTexture(GL_FRAMEBUFFER, attachment, GPU_texture_opengl_bindcode(tex), mip);
#endif
@ -194,7 +192,16 @@ void GPU_framebuffer_texture_detach(GPUTexture *tex)
attachment = GL_COLOR_ATTACHMENT0 + fb_attachment;
}
#if defined(WITH_GL_PROFILE_COMPAT)
/* Workaround for Mac & Mesa compatibility profile, remove after we switch to core profile */
/* glFramebufferTexture was introduced in 3.2. It is *not* available in the ARB FBO extension */
if (GLEW_VERSION_3_2)
glFramebufferTexture(GL_FRAMEBUFFER, attachment, 0, 0); /* normal core call, same as below */
else
glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, GPU_texture_target(tex), 0, 0);
#else
glFramebufferTexture(GL_FRAMEBUFFER, attachment, 0, 0);
#endif
GPU_texture_framebuffer_set(tex, NULL, -1);
}