Fixed alpha-blended drawables getting incorrect alpha values when rendered through a RenderImage
Replaced internal calls to glewIsSupported with the corresponding constants (faster checks) git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1264 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
5d778b2bc4
commit
f593ea29e7
@ -90,14 +90,28 @@ void Batch::Render(GeometryRenderer& renderer) const
|
|||||||
{
|
{
|
||||||
GLCheck(glEnable(GL_BLEND));
|
GLCheck(glEnable(GL_BLEND));
|
||||||
|
|
||||||
// @todo the resulting alpha may not be correct, which matters when target is a RenderImage.
|
|
||||||
// find a fix for this (glBlendFuncSeparate -- but not supported by every graphics card)
|
|
||||||
switch (myBlendMode)
|
switch (myBlendMode)
|
||||||
{
|
{
|
||||||
|
// Alpha blending
|
||||||
|
// glBlendFuncSeparateEXT is used when available to avoid an incorrect alpha value when the target
|
||||||
|
// is a RenderImage -- in this case the alpha value must be written directly to the target buffer
|
||||||
default :
|
default :
|
||||||
case Blend::Alpha : GLCheck(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)); break;
|
case Blend::Alpha :
|
||||||
case Blend::Add : GLCheck(glBlendFunc(GL_SRC_ALPHA, GL_ONE)); break;
|
if (GLEW_EXT_blend_func_separate)
|
||||||
case Blend::Multiply : GLCheck(glBlendFunc(GL_DST_COLOR, GL_ZERO)); break;
|
GLCheck(glBlendFuncSeparateEXT(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO));
|
||||||
|
else
|
||||||
|
GLCheck(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Additive blending
|
||||||
|
case Blend::Add :
|
||||||
|
GLCheck(glBlendFunc(GL_SRC_ALPHA, GL_ONE));
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Multiplicative blending
|
||||||
|
case Blend::Multiply :
|
||||||
|
GLCheck(glBlendFunc(GL_DST_COLOR, GL_ZERO));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ bool GeometryRendererVA::IsSupported()
|
|||||||
{
|
{
|
||||||
priv::EnsureGlewInit();
|
priv::EnsureGlewInit();
|
||||||
|
|
||||||
return glewIsSupported("GL_EXT_vertex_array") != 0;
|
return GLEW_EXT_vertex_array != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -47,8 +47,6 @@ GeometryRendererVA::GeometryRendererVA() :
|
|||||||
myIndices(NULL)
|
myIndices(NULL)
|
||||||
{
|
{
|
||||||
priv::EnsureGlewInit();
|
priv::EnsureGlewInit();
|
||||||
|
|
||||||
myCanLock = glewIsSupported("GL_EXT_compiled_vertex_array") != 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -71,7 +69,7 @@ void GeometryRendererVA::Begin(const float* vertices, std::size_t verticesCount,
|
|||||||
GLCheck(glTexCoordPointer(2, GL_FLOAT, stride, vertices + 6));
|
GLCheck(glTexCoordPointer(2, GL_FLOAT, stride, vertices + 6));
|
||||||
|
|
||||||
// Lock (compile) the vertex array if supported
|
// Lock (compile) the vertex array if supported
|
||||||
if (myCanLock)
|
if (GLEW_EXT_compiled_vertex_array)
|
||||||
GLCheck(glLockArraysEXT(0, verticesCount / 8));
|
GLCheck(glLockArraysEXT(0, verticesCount / 8));
|
||||||
|
|
||||||
// Store indices for later use
|
// Store indices for later use
|
||||||
@ -83,7 +81,7 @@ void GeometryRendererVA::Begin(const float* vertices, std::size_t verticesCount,
|
|||||||
void GeometryRendererVA::End()
|
void GeometryRendererVA::End()
|
||||||
{
|
{
|
||||||
// Unlock the vertex array if it was locked
|
// Unlock the vertex array if it was locked
|
||||||
if (myCanLock)
|
if (GLEW_EXT_compiled_vertex_array)
|
||||||
GLCheck(glUnlockArraysEXT());
|
GLCheck(glUnlockArraysEXT());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +96,6 @@ public :
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool myCanLock; ///< Is geometry locking supported?
|
|
||||||
const unsigned int* myIndices; ///< Pointer to the indices to render
|
const unsigned int* myIndices; ///< Pointer to the indices to render
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ bool GeometryRendererVBO::IsSupported()
|
|||||||
{
|
{
|
||||||
priv::EnsureGlewInit();
|
priv::EnsureGlewInit();
|
||||||
|
|
||||||
return glewIsSupported("GL_ARB_vertex_buffer_object") != 0;
|
return GLEW_ARB_vertex_buffer_object != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -584,7 +584,7 @@ unsigned int Image::GetValidTextureSize(unsigned int size)
|
|||||||
// Make sure that GLEW is initialized
|
// Make sure that GLEW is initialized
|
||||||
priv::EnsureGlewInit();
|
priv::EnsureGlewInit();
|
||||||
|
|
||||||
if (glewIsSupported("GL_ARB_texture_non_power_of_two") != 0)
|
if (GLEW_ARB_texture_non_power_of_two)
|
||||||
{
|
{
|
||||||
// If hardware supports NPOT textures, then just return the unmodified size
|
// If hardware supports NPOT textures, then just return the unmodified size
|
||||||
return size;
|
return size;
|
||||||
|
@ -75,7 +75,7 @@ bool RenderImageImplFBO::IsSupported()
|
|||||||
// Make sure that GLEW is initialized
|
// Make sure that GLEW is initialized
|
||||||
priv::EnsureGlewInit();
|
priv::EnsureGlewInit();
|
||||||
|
|
||||||
return glewIsSupported("GL_EXT_framebuffer_object") != 0;
|
return GLEW_EXT_framebuffer_object != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -309,10 +309,10 @@ bool Shader::IsAvailable()
|
|||||||
// Make sure that GLEW is initialized
|
// Make sure that GLEW is initialized
|
||||||
priv::EnsureGlewInit();
|
priv::EnsureGlewInit();
|
||||||
|
|
||||||
return glewIsSupported("GL_ARB_shading_language_100") != 0 &&
|
return GLEW_ARB_shading_language_100 &&
|
||||||
glewIsSupported("GL_ARB_shader_objects") != 0 &&
|
GLEW_ARB_shader_objects &&
|
||||||
glewIsSupported("GL_ARB_vertex_shader") != 0 &&
|
GLEW_ARB_vertex_shader &&
|
||||||
glewIsSupported("GL_ARB_fragment_shader") != 0;
|
GLEW_ARB_fragment_shader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -79,8 +79,7 @@ bool RenderImageImplPBuffer::IsSupported()
|
|||||||
// Make sure that GLEW is initialized
|
// Make sure that GLEW is initialized
|
||||||
priv::EnsureGlewInit();
|
priv::EnsureGlewInit();
|
||||||
|
|
||||||
return wglewIsSupported("WGL_ARB_pbuffer") &&
|
return WGLEW_ARB_pbuffer && WGLEW_ARB_pixel_format;
|
||||||
wglewIsSupported("WGL_ARB_pixel_format");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user