mirror of
https://github.com/love2d/love.git
synced 2026-08-15 15:51:12 +02:00
Revert Canvas flipping (commits 9cb824e2fa84, e0234edd0026) in order to fix issue #324.
This commit is contained in:
@@ -195,10 +195,10 @@ namespace opengl
|
||||
vertices[3].x = w; vertices[3].y = 0;
|
||||
|
||||
// texture coordinates
|
||||
vertices[0].s = 0; vertices[0].t = 0;
|
||||
vertices[1].s = 0; vertices[1].t = 1;
|
||||
vertices[2].s = 1; vertices[2].t = 1;
|
||||
vertices[3].s = 1; vertices[3].t = 0;
|
||||
vertices[0].s = 0; vertices[0].t = 1;
|
||||
vertices[1].s = 0; vertices[1].t = 0;
|
||||
vertices[2].s = 1; vertices[2].t = 0;
|
||||
vertices[3].s = 1; vertices[3].t = 1;
|
||||
|
||||
loadStrategy();
|
||||
|
||||
@@ -246,8 +246,8 @@ namespace opengl
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
|
||||
// Set up upside-down orthographic view (no depth)
|
||||
glOrtho(0.0, width, 0.0, height, -1.0, 1.0);
|
||||
// Set up orthographic view (no depth)
|
||||
glOrtho(0.0, width, height, 0.0, -1.0, 1.0);
|
||||
|
||||
// Switch back to modelview matrix
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
@@ -297,15 +297,20 @@ namespace opengl
|
||||
void Canvas::drawq(love::graphics::Quad * quad, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const
|
||||
{
|
||||
static Matrix t;
|
||||
quad->mirror(false, true);
|
||||
const vertex * v = quad->getVertices();
|
||||
|
||||
t.setTransformation(x, y, angle, sx, sy, ox, oy, kx, ky);
|
||||
drawv(t, v);
|
||||
quad->mirror(false, true);
|
||||
}
|
||||
|
||||
love::image::ImageData * Canvas::getImageData(love::image::Image * image)
|
||||
{
|
||||
GLubyte * pixels = new GLubyte[4*width*height];
|
||||
int row = 4 * width;
|
||||
int size = row * height;
|
||||
GLubyte* pixels = new GLubyte[size];
|
||||
GLubyte* screenshot = new GLubyte[size];
|
||||
|
||||
strategy->bindFBO( fbo );
|
||||
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
|
||||
@@ -314,8 +319,15 @@ namespace opengl
|
||||
else
|
||||
strategy->bindFBO( 0 );
|
||||
|
||||
love::image::ImageData * img = image->newImageData(width, height, (void*)pixels);
|
||||
GLubyte * src = pixels - row; // second line of source image
|
||||
GLubyte * dst = screenshot + size; // last row of destination image
|
||||
|
||||
for (int i = 0; i < height; ++i)
|
||||
memcpy(dst -= row, src += row, row);
|
||||
|
||||
love::image::ImageData* img = image->newImageData(width, height, (void*)screenshot);
|
||||
|
||||
delete[] screenshot;
|
||||
delete[] pixels;
|
||||
|
||||
return img;
|
||||
|
||||
Reference in New Issue
Block a user