bf_gpu: Add GPU_state module.

This has wrappers for the most common gl* functions in the codebase, and is in preparation for D3502

Reviewers: brecht, fclem

Differential Revision: https://developer.blender.org/D3501
This commit is contained in:
2018-06-26 15:17:31 -06:00
parent a61480c271
commit 6f2c9ea3e1
7 changed files with 228 additions and 57 deletions

View File

@@ -1260,43 +1260,3 @@ int GPU_texture_detach_framebuffer(GPUTexture *tex, GPUFrameBuffer *fb)
BLI_assert(!"Error: Texture: Framebuffer is not attached");
return 0;
}
void GPU_blend(bool enable)
{
if (enable) {
glEnable(GL_BLEND);
}
else {
glDisable(GL_BLEND);
}
}
static GLenum gpu_get_gl_blendfunction(GPUBlendFunction blend)
{
switch (blend) {
case GPU_ONE:
return GL_ONE;
case GPU_SRC_ALPHA:
return GL_SRC_ALPHA;
case GPU_ONE_MINUS_SRC_ALPHA:
return GL_ONE_MINUS_SRC_ALPHA;
default:
BLI_assert(!"Unhandled blend mode");
return GL_ZERO;
}
}
void GPU_blend_set_func_separate(
GPUBlendFunction src_rgb, GPUBlendFunction dst_rgb,
GPUBlendFunction src_alpha, GPUBlendFunction dst_alpha)
{
glBlendFuncSeparate(gpu_get_gl_blendfunction(src_rgb),
gpu_get_gl_blendfunction(dst_rgb),
gpu_get_gl_blendfunction(src_alpha),
gpu_get_gl_blendfunction(dst_alpha));
}
void GPU_blend_set_func(GPUBlendFunction sfactor, GPUBlendFunction dfactor)
{
glBlendFunc(gpu_get_gl_blendfunction(sfactor), gpu_get_gl_blendfunction(dfactor));
}