gsdx-ogl: create a new function to set the blending state

This commit is contained in:
Gregory Hainaut 2015-07-31 19:42:01 +02:00
parent 1da611fb75
commit 59cdf77784
2 changed files with 43 additions and 0 deletions

View File

@ -1353,6 +1353,48 @@ void GSDeviceOGL::OMSetColorMaskState(OMColorMaskSelector sel)
}
}
void GSDeviceOGL::OMSetBlendState(int blend_index, float blend_factor, bool is_blend_constant)
{
if (blend_index) {
if (!GLState::blend) {
GLState::blend = true;
glEnable(GL_BLEND);
}
if (is_blend_constant && GLState::bf != blend_factor) {
GLState::bf = blend_factor;
gl_BlendColor(blend_factor, blend_factor, blend_factor, 0);
}
// FIXME test to use uint16 (cache friendly)
const GLenum& op = m_blendMapD3D9[blend_index].op;
if (GLState::eq_RGB != op) {
GLState::eq_RGB = op;
if (gl_BlendEquationSeparateiARB)
gl_BlendEquationSeparateiARB(0, op, GL_FUNC_ADD);
else
gl_BlendEquationSeparate(op, GL_FUNC_ADD);
}
const GLenum& src = m_blendMapD3D9[blend_index].src;
const GLenum& dst = m_blendMapD3D9[blend_index].dst;
if (GLState::f_sRGB != src || GLState::f_dRGB != dst) {
GLState::f_sRGB = src;
GLState::f_dRGB = dst;
if (gl_BlendFuncSeparateiARB)
gl_BlendFuncSeparateiARB(0, src, dst, GL_ONE, GL_ZERO);
else
gl_BlendFuncSeparate(src, dst, GL_ONE, GL_ZERO);
}
} else {
if (GLState::blend) {
GLState::blend = false;
glDisable(GL_BLEND);
}
}
}
void GSDeviceOGL::OMSetBlendState(GSBlendStateOGL* bs, float bf)
{
// SW date might change the enable state without updating the object

View File

@ -638,6 +638,7 @@ class GSDeviceOGL : public GSDevice
void OMSetDepthStencilState(GSDepthStencilOGL* dss, uint8 sref);
void OMSetBlendState(GSBlendStateOGL* bs, float bf);
void OMSetBlendState(int blend_index = 0, float blend_factor = 0.0f, bool is_blend_constant = false);
void OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector4i* scissor = NULL);
void OMSetWriteBuffer(GLenum buffer = GL_COLOR_ATTACHMENT0);
void OMSetColorMaskState(OMColorMaskSelector sel = OMColorMaskSelector());