diff --git a/src/modules/graphics/Quad.h b/src/modules/graphics/Quad.h index 341bc224d..f5c804961 100644 --- a/src/modules/graphics/Quad.h +++ b/src/modules/graphics/Quad.h @@ -50,11 +50,6 @@ public: virtual void flip(bool x, bool y) = 0; - /** - * Mirror texture coordinates around 0.5 - */ - virtual void mirror(bool x, bool y) = 0; - /** * Gets a pointer to the vertices. **/ diff --git a/src/modules/graphics/opengl/Canvas.cpp b/src/modules/graphics/opengl/Canvas.cpp index 88f50586b..9f6b4b964 100644 --- a/src/modules/graphics/opengl/Canvas.cpp +++ b/src/modules/graphics/opengl/Canvas.cpp @@ -197,13 +197,13 @@ Canvas::Canvas(int width, int height) // world coordinates vertices[0].x = 0; - vertices[0].y = 0; + vertices[0].y = h; vertices[1].x = 0; - vertices[1].y = h; + vertices[1].y = 0; vertices[2].x = w; - vertices[2].y = h; + vertices[2].y = 0; vertices[3].x = w; - vertices[3].y = 0; + vertices[3].y = h; // texture coordinates vertices[0].s = 0; @@ -262,7 +262,7 @@ void Canvas::startGrab() glLoadIdentity(); // Set up orthographic view (no depth) - glOrtho(0.0, width, height, 0.0, -1.0, 1.0); + glOrtho(0.0, width, 0.0, height, -1.0, 1.0); // Switch back to modelview matrix glMatrixMode(GL_MODELVIEW); @@ -312,12 +312,10 @@ void Canvas::draw(float x, float y, float angle, float sx, float sy, float ox, f 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) @@ -325,7 +323,6 @@ love::image::ImageData *Canvas::getImageData(love::image::Image *image) 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); @@ -334,15 +331,8 @@ love::image::ImageData *Canvas::getImageData(love::image::Image *image) else strategy->bindFBO(0); - GLubyte *src = pixels - row; // second line of source image - GLubyte *dst = screenshot + size; // last row of destination image + love::image::ImageData *img = image->newImageData(width, height, (void *)pixels); - 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; diff --git a/src/modules/graphics/opengl/PixelEffect.cpp b/src/modules/graphics/opengl/PixelEffect.cpp index 619fceab8..9679dc5de 100644 --- a/src/modules/graphics/opengl/PixelEffect.cpp +++ b/src/modules/graphics/opengl/PixelEffect.cpp @@ -20,6 +20,7 @@ #include "PixelEffect.h" #include "GLee.h" +#include "Graphics.h" namespace { @@ -134,6 +135,11 @@ bool PixelEffect::loadVolatile() } glDeleteShader(shader); + + Graphics *instance = (Graphics*)Module::getInstance("love.graphics.opengl"); + GLfloat screenSize[2] = {(float)instance->getWidth(), (float)instance->getHeight()}; + sendFloat("love_ScreenSize", 2, screenSize, 1); + return true; } diff --git a/src/modules/graphics/opengl/Quad.cpp b/src/modules/graphics/opengl/Quad.cpp index 242cd2053..842fd64d1 100644 --- a/src/modules/graphics/opengl/Quad.cpp +++ b/src/modules/graphics/opengl/Quad.cpp @@ -113,17 +113,6 @@ void Quad::flip(bool x, bool y) } } -void Quad::mirror(bool x, bool y) -{ - for (size_t i = 0; i < NUM_VERTICES; ++i) - { - if (x) - vertices[i].s = 1.0f - vertices[i].s; - if (y) - vertices[i].t = 1.0f - vertices[i].t; - } -} - const vertex *Quad::getVertices() const { return vertices; diff --git a/src/modules/graphics/opengl/Quad.h b/src/modules/graphics/opengl/Quad.h index fd400005b..699bc08a4 100644 --- a/src/modules/graphics/opengl/Quad.h +++ b/src/modules/graphics/opengl/Quad.h @@ -54,7 +54,6 @@ public: Viewport getViewport() const; void flip(bool x, bool y); - void mirror(bool x, bool y); /** * Gets a pointer to the vertices. diff --git a/src/scripts/graphics.lua b/src/scripts/graphics.lua index 628cb2159..a6b6d0a62 100644 --- a/src/scripts/graphics.lua +++ b/src/scripts/graphics.lua @@ -1290,18 +1290,14 @@ do #define Image sampler2D #define extern uniform #define Texel texture2D - layout(origin_upper_left) in vec4 gl_FragCoord; - uniform sampler2D _tex0_;]] + uniform sampler2D _tex0_; + uniform vec2 love_ScreenSize;]] local footer = [[void main() { // fix weird crashing issue in OSX when _tex0_ is unused within effect() float dummy = texture2D(_tex0_, vec2(.5)).r; - gl_FragColor = effect(gl_Color, _tex0_, gl_TexCoord[0].xy, gl_FragCoord.xy); + gl_FragColor = effect(gl_Color, _tex0_, gl_TexCoord[0].xy, love_ScreenSize - gl_FragCoord.xy); }]] - local function include(quoted_path) return (love.filesystem.read(quoted_path:sub(2,-2))) end - code = code:gsub("#include (%b'')", include) - code = code:gsub('#include (%b"")', include) - return table.concat{header, "\n", code, footer} end @@ -1318,7 +1314,7 @@ do linenumber, what, message = l:match("^%w+: 0:(%d+):%s*(%w+)%([^%)]+%)%s*(.+)$") end if linenumber and what and message then - lines[#lines+1] = ("Line %d: %s: %s"):format(linenumber - 5, what, message) + lines[#lines+1] = ("Line %d: %s: %s"):format(linenumber - 7, what, message) end end -- did not match any known error messages diff --git a/src/scripts/graphics.lua.h b/src/scripts/graphics.lua.h index 83ee2313a..ed7a6250d 100644 --- a/src/scripts/graphics.lua.h +++ b/src/scripts/graphics.lua.h @@ -6273,11 +6273,10 @@ const unsigned char graphics_lua[] = 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x0a, 0x09, 0x09, 0x23, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x20, 0x54, 0x65, 0x78, 0x65, 0x6c, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x32, 0x44, 0x0a, - 0x09, 0x09, 0x6c, 0x61, 0x79, 0x6f, 0x75, 0x74, 0x28, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x5f, 0x75, 0x70, - 0x70, 0x65, 0x72, 0x5f, 0x6c, 0x65, 0x66, 0x74, 0x29, 0x20, 0x69, 0x6e, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, - 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x3b, 0x0a, 0x09, 0x09, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x32, - 0x44, 0x20, 0x5f, 0x74, 0x65, 0x78, 0x30, 0x5f, 0x3b, 0x5d, 0x5d, 0x0a, + 0x44, 0x20, 0x5f, 0x74, 0x65, 0x78, 0x30, 0x5f, 0x3b, 0x0a, + 0x09, 0x09, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x6c, 0x6f, 0x76, + 0x65, 0x5f, 0x53, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x53, 0x69, 0x7a, 0x65, 0x3b, 0x5d, 0x5d, 0x0a, 0x09, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x20, 0x3d, 0x20, 0x5b, 0x5b, 0x76, 0x6f, 0x69, 0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x28, 0x29, 0x20, 0x7b, 0x0a, 0x09, 0x09, 0x09, 0x2f, 0x2f, 0x20, 0x66, 0x69, 0x78, 0x20, 0x77, 0x65, 0x69, 0x72, 0x64, 0x20, 0x63, 0x72, @@ -6291,21 +6290,10 @@ const unsigned char graphics_lua[] = 0x09, 0x09, 0x09, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x65, 0x66, 0x66, 0x65, 0x63, 0x74, 0x28, 0x67, 0x6c, 0x5f, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x2c, 0x20, 0x5f, 0x74, 0x65, 0x78, 0x30, 0x5f, 0x2c, 0x20, 0x67, 0x6c, 0x5f, 0x54, 0x65, 0x78, 0x43, 0x6f, 0x6f, 0x72, 0x64, - 0x5b, 0x30, 0x5d, 0x2e, 0x78, 0x79, 0x2c, 0x20, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6f, + 0x5b, 0x30, 0x5d, 0x2e, 0x78, 0x79, 0x2c, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x5f, 0x53, 0x63, 0x72, 0x65, 0x65, + 0x6e, 0x53, 0x69, 0x7a, 0x65, 0x20, 0x2d, 0x20, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x2e, 0x78, 0x79, 0x29, 0x3b, 0x0a, 0x09, 0x09, 0x7d, 0x5d, 0x5d, 0x0a, - 0x09, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x69, - 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x28, 0x71, 0x75, 0x6f, 0x74, 0x65, 0x64, 0x5f, 0x70, 0x61, 0x74, 0x68, - 0x29, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x28, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x66, 0x69, 0x6c, - 0x65, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x72, 0x65, 0x61, 0x64, 0x28, 0x71, 0x75, 0x6f, 0x74, 0x65, - 0x64, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x3a, 0x73, 0x75, 0x62, 0x28, 0x32, 0x2c, 0x2d, 0x32, 0x29, 0x29, 0x29, - 0x20, 0x65, 0x6e, 0x64, 0x0a, - 0x09, 0x09, 0x63, 0x6f, 0x64, 0x65, 0x20, 0x3d, 0x20, 0x63, 0x6f, 0x64, 0x65, 0x3a, 0x67, 0x73, 0x75, 0x62, - 0x28, 0x22, 0x23, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x20, 0x28, 0x25, 0x62, 0x27, 0x27, 0x29, 0x22, - 0x2c, 0x20, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x29, 0x0a, - 0x09, 0x09, 0x63, 0x6f, 0x64, 0x65, 0x20, 0x3d, 0x20, 0x63, 0x6f, 0x64, 0x65, 0x3a, 0x67, 0x73, 0x75, 0x62, - 0x28, 0x27, 0x23, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x20, 0x28, 0x25, 0x62, 0x22, 0x22, 0x29, 0x27, - 0x2c, 0x20, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x29, 0x0a, 0x09, 0x09, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6e, 0x63, 0x61, 0x74, 0x7b, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2c, 0x20, 0x22, 0x5c, 0x6e, 0x22, 0x2c, 0x20, 0x63, 0x6f, 0x64, 0x65, 0x2c, 0x20, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x7d, 0x0a, @@ -6356,7 +6344,7 @@ const unsigned char graphics_lua[] = 0x09, 0x09, 0x09, 0x09, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x5b, 0x23, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x2b, 0x31, 0x5d, 0x20, 0x3d, 0x20, 0x28, 0x22, 0x4c, 0x69, 0x6e, 0x65, 0x20, 0x25, 0x64, 0x3a, 0x20, 0x25, 0x73, 0x3a, 0x20, 0x25, 0x73, 0x22, 0x29, 0x3a, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x28, 0x6c, 0x69, 0x6e, 0x65, 0x6e, - 0x75, 0x6d, 0x62, 0x65, 0x72, 0x20, 0x2d, 0x20, 0x35, 0x2c, 0x20, 0x77, 0x68, 0x61, 0x74, 0x2c, 0x20, 0x6d, + 0x75, 0x6d, 0x62, 0x65, 0x72, 0x20, 0x2d, 0x20, 0x37, 0x2c, 0x20, 0x77, 0x68, 0x61, 0x74, 0x2c, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x29, 0x0a, 0x09, 0x09, 0x09, 0x65, 0x6e, 0x64, 0x0a, 0x09, 0x09, 0x65, 0x6e, 0x64, 0x0a,