New try for pixel-perfect rendering -- waiting for feedbacks

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1390 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
LaurentGom 2010-02-03 14:07:19 +00:00
parent 9fe66bdc5e
commit e2b5268504
3 changed files with 18 additions and 40 deletions

View File

@ -372,7 +372,6 @@ private :
bool myShaderIsValid; ///< Is the cached shader valid? (if not, the cached value is ignored)
bool myBlendModeIsValid; ///< Is the cached blend mode valid? (if not, the cached value is ignored)
bool myViewportIsValid; ///< Is the cached viewport valid? (if not, the cached value is ignored)
Vector2f myViewportSize; ///< Half-size of the current viewport, stored for optimiation purpose
};
} // namespace sf
@ -384,4 +383,19 @@ private :
////////////////////////////////////////////////////////////
/// \class sf::Renderer
///
/// sf::Renderer is the abstraction layer between SFML code
/// and the low-level drawing API (OpenGL). It manages
/// render states efficiently, and provides a lightweight
/// abstraction for rendering geometry.
///
/// The purpose of this class is to provide a single abstract
/// entry point for everything related to low-level rendering.
/// Hiding everything behind sf::Renderer makes optimizing
/// easy, as well as porting to other technologies in the future
/// (like OpenGL ES or OpenGL 3.x).
///
/// This class is mainly meant for internal usage, you should
/// never care about it unless you write your own sf::Drawable
/// class that uses raw geometry in its Render function.
///
////////////////////////////////////////////////////////////

View File

@ -31,34 +31,6 @@
#include <SFML/Graphics/GLCheck.hpp>
////////////////////////////////////////////////////////////
// Private data
////////////////////////////////////////////////////////////
namespace
{
// Fast float to int conversion
inline sf::Int32 Round(double value)
{
// Use a union rather than reinterpret_cast, because it doesn't break strict-aliasing
// rules and results in a correct behaviour when compiling in optimized mode
union DoubleToInt
{
double d;
sf::Int32 i[2];
};
DoubleToInt u;
u.d = value + 6755399441055744.0;
#if defined(SFML_ENDIAN_LITTLE)
return u.i[0];
#else
return u.i[1];
#endif
}
}
namespace sf
{
////////////////////////////////////////////////////////////
@ -215,10 +187,6 @@ void Renderer::SetViewport(const IntRect& viewport)
// Store it
myViewport = viewport;
myViewportIsValid = true;
// Store the half-size of the viewport for later computations
myViewportSize.x = myViewport.GetSize().x / 2.f;
myViewportSize.y = myViewport.GetSize().y / 2.f;
}
}
@ -365,12 +333,6 @@ void Renderer::ProcessVertex(float x, float y, float u, float v, float r, float
// Transform the vertex position by the current model-view-projection matrix
Vector2f position = myTransform.Transform(Vector2f(x, y));
// Round the vertex position so that it matches the
// viewport's pixels, and thus avoid rendering artifacts
// @todo remove and find a better solution :)
position.x = Round((position.x + 1.f) * myViewportSize.x) / myViewportSize.x - 1.f;
position.y = Round((position.y + 1.f) * myViewportSize.y) / myViewportSize.y - 1.f;
// Modulate the vertex color with the current global color
r *= myStates->r;
g *= myStates->g;

View File

@ -45,7 +45,9 @@ myDeviceContext(NULL),
myContext (NULL),
myOwnsWindow (true)
{
// TODO : try to create a bitmap in memory instead of a dummy window
// Creating a dummy window is mandatory: we could create a memory DC but then
// its pixel format wouldn't match the regular contexts' format, and thus
// wglShareLists would always fail. Too bad...
// Create a dummy window (disabled and hidden)
myWindow = CreateWindowA("STATIC", "", WS_POPUP | WS_DISABLED, 0, 0, 1, 1, NULL, NULL, GetModuleHandle(NULL), NULL);