From 9cda5d04744e5a6412f9b779b334f0a9ad6c56c1 Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Tue, 16 Aug 2011 08:11:36 +0200 Subject: [PATCH] Fixed Texture::LoadFromXxx functions not working when loading a sub-rectangle of the image --- src/SFML/Graphics/Texture.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SFML/Graphics/Texture.cpp b/src/SFML/Graphics/Texture.cpp index e623e325..9e4cdbca 100644 --- a/src/SFML/Graphics/Texture.cpp +++ b/src/SFML/Graphics/Texture.cpp @@ -194,12 +194,12 @@ bool Texture::LoadFromImage(const Image& image, const IntRect& area) if (Create(rectangle.Width, rectangle.Height)) { // Copy the pixels to the texture, row by row - const Uint8* pixels = image.GetPixelsPtr() + rectangle.Left + (width * rectangle.Top); + const Uint8* pixels = image.GetPixelsPtr() + 4 * (rectangle.Left + (width * rectangle.Top)); GLCheck(glBindTexture(GL_TEXTURE_2D, myTexture)); for (int i = 0; i < rectangle.Height; ++i) { GLCheck(glTexSubImage2D(GL_TEXTURE_2D, 0, 0, i, myWidth, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels)); - pixels += width; + pixels += 4 * width; } return true;