mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 12:51:05 +08:00
Fixed Texture::LoadFromXxx functions not working when loading a sub-rectangle of the image
This commit is contained in:
parent
541509d2a7
commit
9cda5d0474
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user