55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
# File 'lib/mittsu/renderers/opengl/opengl_state.rb', line 55
def set_blending(blending, blend_equation = nil, blend_src = nil, blend_dst = nil, blend_equation_alpha = nil, blend_src_alpha = nil, blend_dst_alpha = nil)
if blending != @current_blending
case blending
when NoBlending
glDisable(GL_BLEND)
when AdditiveBlending
glEnable(GL_BLEND)
glBlendEquation(GL_FUNC_ADD)
glBlendFunc(GL_SRC_ALPHA, GL_ONE)
when SubtractiveBlending
glEnable(GL_BLEND)
glBlendEquation(GL_FUNC_ADD)
glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR)
when MultiplyBlending
glEnable(GL_BLEND)
glBlendEquation(GL_FUNC_ADD)
glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR)
when CustomBlending
glEnable(GL_BLEND)
else
glEnable(GL_BLEND)
glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD)
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA)
end
@current_blending = blending
end
if blending == CustomBlending
blend_equation_alpha ||= blend_equation
blend_src_alpha ||= blend_src
blend_dst_alpha ||= blend_dst
if blend_equation != @current_blend_equation || blend_equation_alpha != @current_blend_equation_alpha
glBlendEquationSeparate(GL_MITTSU_PARAMS[blend_equation], GL_MITTSU_PARAMS[blend_equation_alpha])
@current_blend_equation = blend_equation
@current_blend_equation_alpha = blend_equation_alpha
end
if blend_src != @current_blend_src || blend_dst != @current_blend_dst || blend_src_alpha != @current_blend_src_alpha || blend_dst_alpha != @current_blend_dst_alpha
glBlendFuncSeparate(GL_MITTSU_PARAMS[blend_src], GL_MITTSU_PARAMS[blend_dst], GL_MITTSU_PARAMS[blend_src_alpha], GL_MITTSU_PARAMS[blend_dst_alpha])
@current_blend_src = nil
@current_blend_dst = nil
@current_blend_src_alpha = nil
@current_blend_dst_alpha = nil
end
else
@current_blend_equation = nil
@current_blend_src = nil
@current_blend_dst = nil
@current_blend_equation_alpha = nil
@current_blend_src_alpha = nil
@current_blend_dst_alpha = nil
end
end
|