GLState: Remove 'BlendNone' mode in favor of disabling blending alltogether
This commit is contained in:
parent
7ce747d34d
commit
27b7815f52
|
@ -166,9 +166,9 @@ struct BitmapPrivate
|
|||
|
||||
void blitQuad(Quad &quad)
|
||||
{
|
||||
glState.blendMode.pushSet(BlendNone);
|
||||
glState.blend.pushSet(false);
|
||||
quad.draw();
|
||||
glState.blendMode.pop();
|
||||
glState.blend.pop();
|
||||
}
|
||||
|
||||
void fillRect(const IntRect &rect,
|
||||
|
@ -540,7 +540,7 @@ void Bitmap::blur()
|
|||
BlurShader::HPass &pass1 = shader.pass1;
|
||||
BlurShader::VPass &pass2 = shader.pass2;
|
||||
|
||||
glState.blendMode.pushSet(BlendNone);
|
||||
glState.blend.pushSet(false);
|
||||
glState.viewport.pushSet(IntRect(0, 0, width(), height()));
|
||||
|
||||
TEX::bind(p->gl.tex);
|
||||
|
@ -562,7 +562,7 @@ void Bitmap::blur()
|
|||
quad.draw();
|
||||
|
||||
glState.viewport.pop();
|
||||
glState.blendMode.pop();
|
||||
glState.blend.pop();
|
||||
|
||||
shState->texPool().release(auxTex);
|
||||
|
||||
|
@ -959,11 +959,8 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align)
|
|||
p->bindFBO();
|
||||
p->pushSetViewport(shader);
|
||||
|
||||
glState.blendMode.pushSet(BlendNone);
|
||||
p->blitQuad(quad);
|
||||
|
||||
quad.draw();
|
||||
|
||||
glState.blendMode.pop();
|
||||
p->popViewport();
|
||||
}
|
||||
|
||||
|
|
|
@ -31,8 +31,6 @@ struct SDL_Color;
|
|||
|
||||
enum BlendType
|
||||
{
|
||||
BlendNone = -1, /* Only internal use */
|
||||
|
||||
BlendNormal = 0,
|
||||
BlendAddition = 1,
|
||||
BlendSubstraction = 2
|
||||
|
|
|
@ -26,6 +26,11 @@
|
|||
|
||||
#include <SDL_rect.h>
|
||||
|
||||
static void applyBool(GLenum state, bool mode)
|
||||
{
|
||||
mode ? gl.Enable(state) : gl.Disable(state);
|
||||
}
|
||||
|
||||
void GLClearColor::apply(const Vec4 &value)
|
||||
{
|
||||
gl.ClearColor(value.x, value.y, value.z, value.w);
|
||||
|
@ -52,18 +57,13 @@ void GLScissorBox::setIntersect(const IntRect &value)
|
|||
|
||||
void GLScissorTest::apply(const bool &value)
|
||||
{
|
||||
value ? gl.Enable(GL_SCISSOR_TEST) : gl.Disable(GL_SCISSOR_TEST);
|
||||
applyBool(GL_SCISSOR_TEST, value);
|
||||
}
|
||||
|
||||
void GLBlendMode::apply(const BlendType &value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case BlendNone :
|
||||
gl.BlendEquation(GL_FUNC_ADD);
|
||||
gl.BlendFunc(GL_ONE, GL_ZERO);
|
||||
break;
|
||||
|
||||
case BlendNormal :
|
||||
gl.BlendEquation(GL_FUNC_ADD);
|
||||
gl.BlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA,
|
||||
|
@ -85,6 +85,11 @@ void GLBlendMode::apply(const BlendType &value)
|
|||
}
|
||||
}
|
||||
|
||||
void GLBlend::apply(const bool &value)
|
||||
{
|
||||
applyBool(GL_BLEND, value);
|
||||
}
|
||||
|
||||
void GLViewport::apply(const IntRect &value)
|
||||
{
|
||||
gl.Viewport(value.x, value.y, value.w, value.h);
|
||||
|
@ -102,11 +107,11 @@ GLState::Caps::Caps()
|
|||
|
||||
GLState::GLState()
|
||||
{
|
||||
gl.Enable(GL_BLEND);
|
||||
gl.Disable(GL_DEPTH_TEST);
|
||||
|
||||
clearColor.init(Vec4(0, 0, 0, 1));
|
||||
blendMode.init(BlendNormal);
|
||||
blend.init(true);
|
||||
scissorTest.init(false);
|
||||
scissorBox.init(IntRect(0, 0, 640, 480));
|
||||
program.init(0);
|
||||
|
|
|
@ -95,6 +95,11 @@ class GLBlendMode : public GLProperty<BlendType>
|
|||
void apply(const BlendType &value);
|
||||
};
|
||||
|
||||
class GLBlend : public GLProperty<bool>
|
||||
{
|
||||
void apply(const bool &value);
|
||||
};
|
||||
|
||||
class GLViewport : public GLProperty<IntRect>
|
||||
{
|
||||
void apply(const IntRect &value);
|
||||
|
@ -113,6 +118,7 @@ public:
|
|||
GLScissorBox scissorBox;
|
||||
GLScissorTest scissorTest;
|
||||
GLBlendMode blendMode;
|
||||
GLBlend blend;
|
||||
GLViewport viewport;
|
||||
GLProgram program;
|
||||
|
||||
|
|
|
@ -180,11 +180,11 @@ public:
|
|||
|
||||
TEX::bind(pp.backBuffer().tex);
|
||||
|
||||
glState.blendMode.pushSet(BlendNone);
|
||||
glState.blend.pushSet(false);
|
||||
|
||||
screenQuad.draw();
|
||||
|
||||
glState.blendMode.pop();
|
||||
glState.blend.pop();
|
||||
}
|
||||
|
||||
#ifdef RGSS2
|
||||
|
@ -627,7 +627,7 @@ void Graphics::transition(int duration,
|
|||
shader.setTexSize(p->scRes);
|
||||
}
|
||||
|
||||
glState.blendMode.pushSet(BlendNone);
|
||||
glState.blend.pushSet(false);
|
||||
|
||||
for (int i = 0; i < duration; ++i)
|
||||
{
|
||||
|
@ -670,7 +670,7 @@ void Graphics::transition(int duration,
|
|||
p->swapGLBuffer();
|
||||
}
|
||||
|
||||
glState.blendMode.pop();
|
||||
glState.blend.pop();
|
||||
|
||||
delete transMap;
|
||||
|
||||
|
|
|
@ -435,12 +435,13 @@ struct WindowPrivate
|
|||
/* We need to blit the background without blending,
|
||||
* because we want to retain its correct alpha value.
|
||||
* Otherwise it would be mutliplied by the backgrounds 0 alpha */
|
||||
glState.blendMode.pushSet(BlendNone);
|
||||
glState.blend.pushSet(false);
|
||||
|
||||
baseQuadArray.draw(0, backgroundVert.count);
|
||||
|
||||
/* Now draw the rest (ie. the frame) with blending */
|
||||
glState.blendMode.set(BlendNormal);
|
||||
glState.blend.pop();
|
||||
glState.blendMode.pushSet(BlendNormal);
|
||||
|
||||
baseQuadArray.draw(backgroundVert.count, baseQuadArray.count()-backgroundVert.count);
|
||||
|
||||
|
|
Loading…
Reference in New Issue