Fixing #935: Secure function against random data return.

This commit is contained in:
Ferdinand Thiessen 2015-08-14 00:10:46 +02:00 committed by Lukas Dürrenberger
parent 506ec95fde
commit 0f1dc5a754

View File

@ -32,9 +32,9 @@
#include <SFML/Graphics/VertexArray.hpp> #include <SFML/Graphics/VertexArray.hpp>
#include <SFML/Graphics/GLCheck.hpp> #include <SFML/Graphics/GLCheck.hpp>
#include <SFML/System/Err.hpp> #include <SFML/System/Err.hpp>
#include <cassert>
#include <iostream> #include <iostream>
namespace namespace
{ {
// Convert an sf::BlendMode::Factor constant to the corresponding OpenGL constant. // Convert an sf::BlendMode::Factor constant to the corresponding OpenGL constant.
@ -53,6 +53,10 @@ namespace
case sf::BlendMode::DstAlpha: return GL_DST_ALPHA; case sf::BlendMode::DstAlpha: return GL_DST_ALPHA;
case sf::BlendMode::OneMinusDstAlpha: return GL_ONE_MINUS_DST_ALPHA; case sf::BlendMode::OneMinusDstAlpha: return GL_ONE_MINUS_DST_ALPHA;
} }
sf::err() << "Invalid value for sf::BlendMode::Factor! Fallback to sf::BlendMode::Zero." << std::endl;
assert(false);
return GL_ZERO;
} }
@ -64,6 +68,10 @@ namespace
case sf::BlendMode::Add: return GLEXT_GL_FUNC_ADD; case sf::BlendMode::Add: return GLEXT_GL_FUNC_ADD;
case sf::BlendMode::Subtract: return GLEXT_GL_FUNC_SUBTRACT; case sf::BlendMode::Subtract: return GLEXT_GL_FUNC_SUBTRACT;
} }
sf::err() << "Invalid value for sf::BlendMode::Equation! Fallback to sf::BlendMode::Add." << std::endl;
assert(false);
return GLEXT_GL_FUNC_ADD;
} }
} }