Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2020-08-16 15:47:13 +0300
committerClément Foucault <foucault.clem@gmail.com>2020-08-18 22:30:10 +0300
commita1459b2f7a53fc9e7a52260e975c47c48c6c383d (patch)
tree2a6c612d8efd0fa3240a7618b66490b8be1b8bbd /source/blender/gpu/intern
parent2ae1c895a2f7590d0783a27176085da45ef12bc5 (diff)
Cleanup: GPU: Move towards an explicit Blend state
This make use of the GLStateStack functions for: - `GPU_blend()` - `GPU_blend_set_func()` - `GPU_blend_set_func_separate()` The goal is to unify them using an explicit state setting. This will remove the need to use obscure blend functions
Diffstat (limited to 'source/blender/gpu/intern')
-rw-r--r--source/blender/gpu/intern/gpu_state.cc29
1 files changed, 26 insertions, 3 deletions
diff --git a/source/blender/gpu/intern/gpu_state.cc b/source/blender/gpu/intern/gpu_state.cc
index 485aa3b852e..d2aa0816a3f 100644
--- a/source/blender/gpu/intern/gpu_state.cc
+++ b/source/blender/gpu/intern/gpu_state.cc
@@ -35,8 +35,17 @@
#include "gpu_state_private.hh"
+/* TODO remove */
+#include "gl_state.hh"
+
using namespace blender::gpu;
+// /* This should replace GPU_blend, GPU_blend_set_func and GPU_blend_set_func_separate. */
+// void GPU_blend_set(eGPUBlend blend)
+// {
+// GLStateStack::set_blend(blend);
+// }
+
static GLenum gpu_get_gl_blendfunction(eGPUBlendFunction blend)
{
switch (blend) {
@@ -59,16 +68,30 @@ static GLenum gpu_get_gl_blendfunction(eGPUBlendFunction blend)
void GPU_blend(bool enable)
{
if (enable) {
- glEnable(GL_BLEND);
+ GLStateStack::set_blend(GPU_BLEND_ALPHA);
}
else {
- glDisable(GL_BLEND);
+ GLStateStack::set_blend(GPU_BLEND_NONE);
}
}
void GPU_blend_set_func(eGPUBlendFunction sfactor, eGPUBlendFunction dfactor)
{
- glBlendFunc(gpu_get_gl_blendfunction(sfactor), gpu_get_gl_blendfunction(dfactor));
+ if (sfactor == GPU_ONE && dfactor == GPU_ONE) {
+ GLStateStack::set_blend(GPU_BLEND_ADDITIVE);
+ }
+ else if (sfactor == GPU_ONE && dfactor == GPU_ONE_MINUS_SRC_ALPHA) {
+ GLStateStack::set_blend(GPU_BLEND_ALPHA_PREMULT);
+ }
+ else if (sfactor == GPU_SRC_ALPHA && dfactor == GPU_ONE_MINUS_SRC_ALPHA) {
+ GLStateStack::set_blend(GPU_BLEND_ALPHA);
+ }
+ else if (sfactor == GPU_DST_COLOR && dfactor == GPU_ZERO) {
+ GLStateStack::set_blend(GPU_BLEND_MULTIPLY);
+ }
+ else {
+ BLI_assert(0);
+ }
}
void GPU_blend_set_func_separate(eGPUBlendFunction src_rgb,