GPUTexture: Add support for depth_stencil textures.

This commit is contained in:
2017-03-18 01:26:08 +01:00
parent b7355425cd
commit c4644b484d
4 changed files with 56 additions and 28 deletions

View File

@@ -133,14 +133,16 @@ bool GPU_framebuffer_texture_attach(GPUFrameBuffer *fb, GPUTexture *tex, int slo
}
}
if (GPU_texture_depth(tex))
glBindFramebuffer(GL_FRAMEBUFFER, fb->object);
GG.currentfb = fb->object;
if (GPU_texture_stencil(tex) && GPU_texture_depth(tex))
attachment = GL_DEPTH_STENCIL_ATTACHMENT;
else if (GPU_texture_depth(tex))
attachment = GL_DEPTH_ATTACHMENT;
else
attachment = GL_COLOR_ATTACHMENT0 + slot;
glBindFramebuffer(GL_FRAMEBUFFER, fb->object);
GG.currentfb = fb->object;
glFramebufferTexture2D(GL_FRAMEBUFFER, attachment,
GPU_texture_target(tex), GPU_texture_opengl_bindcode(tex), 0);
@@ -168,7 +170,11 @@ void GPU_framebuffer_texture_detach(GPUTexture *tex)
GG.currentfb = fb->object;
}
if (GPU_texture_depth(tex)) {
if (GPU_texture_stencil(tex) && GPU_texture_depth(tex)) {
fb->depthtex = NULL;
attachment = GL_DEPTH_STENCIL_ATTACHMENT;
}
else if (GPU_texture_depth(tex)) {
fb->depthtex = NULL;
attachment = GL_DEPTH_ATTACHMENT;
}