Merge pull request #460 from DrChat/color_copy_fix

Color Copy Fix
This commit is contained in:
Ben Vanik 2015-11-16 18:25:22 -08:00
commit c08b2b48e9
1 changed files with 11 additions and 0 deletions

View File

@ -268,6 +268,15 @@ void Blitter::CopyColorTexture2D(GLuint src_texture, Rect2D src_rect,
glDepthMask(GL_FALSE);
glBindProgramPipeline(color_pipeline_);
// Make sure the texture swizzles match before performing a copy
// TODO: Is this a good place for this?
GLint swizzle_map[2][4] = {{0, 0, 0, 0}, {0, 0, 0, 0}};
glGetTextureParameteriv(src_texture, GL_TEXTURE_SWIZZLE_RGBA, swizzle_map[0]);
glGetTextureParameteriv(dest_texture, GL_TEXTURE_SWIZZLE_RGBA,
swizzle_map[1]);
glTextureParameteriv(src_texture, GL_TEXTURE_SWIZZLE_RGBA, swizzle_map[1]);
glNamedFramebufferTexture(scratch_framebuffer_, GL_COLOR_ATTACHMENT0,
dest_texture, 0);
glNamedFramebufferDrawBuffer(scratch_framebuffer_, GL_COLOR_ATTACHMENT0);
@ -277,6 +286,8 @@ void Blitter::CopyColorTexture2D(GLuint src_texture, Rect2D src_rect,
glNamedFramebufferTexture(scratch_framebuffer_, GL_COLOR_ATTACHMENT0, GL_NONE,
0);
glTextureParameteriv(src_texture, GL_TEXTURE_SWIZZLE_RGBA, swizzle_map[0]);
state.Restore();
}