diff --git a/src/modules/graphics/opengl/Graphics.cpp b/src/modules/graphics/opengl/Graphics.cpp index 3804c7432..fb6d9fe4a 100644 --- a/src/modules/graphics/opengl/Graphics.cpp +++ b/src/modules/graphics/opengl/Graphics.cpp @@ -231,7 +231,6 @@ void Graphics::reset() void Graphics::clear() { glClear(GL_COLOR_BUFFER_BIT); - glLoadIdentity(); } void Graphics::present() @@ -1318,6 +1317,11 @@ void Graphics::shear(float kx, float ky) glMultMatrixf((const GLfloat *)t.getElements()); } +void Graphics::origin() +{ + glLoadIdentity(); +} + bool Graphics::hasFocus() const { return currentWindow->hasFocus(); diff --git a/src/modules/graphics/opengl/Graphics.h b/src/modules/graphics/opengl/Graphics.h index 7bfc08f77..7fe0805b0 100644 --- a/src/modules/graphics/opengl/Graphics.h +++ b/src/modules/graphics/opengl/Graphics.h @@ -531,6 +531,7 @@ public: void scale(float x, float y = 1.0f); void translate(float x, float y); void shear(float kx, float ky); + void origin(); bool hasFocus() const; private: diff --git a/src/modules/graphics/opengl/wrap_Graphics.cpp b/src/modules/graphics/opengl/wrap_Graphics.cpp index b6eff71d9..1ff55d289 100644 --- a/src/modules/graphics/opengl/wrap_Graphics.cpp +++ b/src/modules/graphics/opengl/wrap_Graphics.cpp @@ -1539,6 +1539,12 @@ int w_shear(lua_State *L) return 0; } +int w_origin(lua_State *L) +{ + instance->origin(); + return 0; +} + int w_hasFocus(lua_State *L) { luax_pushboolean(L, instance->hasFocus()); @@ -1647,6 +1653,7 @@ static const luaL_Reg functions[] = { "scale", w_scale }, { "translate", w_translate }, { "shear", w_shear }, + { "origin", w_origin }, { "hasFocus", w_hasFocus }, diff --git a/src/modules/graphics/opengl/wrap_Graphics.h b/src/modules/graphics/opengl/wrap_Graphics.h index 9be30a723..9a99edda2 100644 --- a/src/modules/graphics/opengl/wrap_Graphics.h +++ b/src/modules/graphics/opengl/wrap_Graphics.h @@ -114,6 +114,7 @@ int w_rotate(lua_State *L); int w_scale(lua_State *L); int w_translate(lua_State *L); int w_shear(lua_State *L); +int w_origin(lua_State *L); int w_hasFocus(lua_State *L); extern "C" LOVE_EXPORT int luaopen_love_graphics(lua_State *L); diff --git a/src/scripts/boot.lua b/src/scripts/boot.lua index 927b6b00e..ee6d3821b 100644 --- a/src/scripts/boot.lua +++ b/src/scripts/boot.lua @@ -396,6 +396,7 @@ function love.init() love.event.pump() love.graphics.setBackgroundColor(89, 157, 220) love.graphics.clear() + love.graphics.origin() love.graphics.print(msg, 70, 70) love.graphics.present() love.graphics.setBackgroundColor(0, 0, 0) @@ -443,6 +444,7 @@ function love.run() if love.update then love.update(dt) end -- will pass 0 if love.timer is disabled if love.graphics then love.graphics.clear() + love.graphics.origin() if love.draw then love.draw() end end @@ -736,6 +738,7 @@ function love.errhand(msg) local trace = debug.traceback() love.graphics.clear() + love.graphics.origin() local err = {} @@ -799,6 +802,7 @@ function love.releaseerrhand(msg) love.graphics.setColor(255, 255, 255, 255) love.graphics.clear() + love.graphics.origin() local err = {} diff --git a/src/scripts/boot.lua.h b/src/scripts/boot.lua.h index 3644af3ee..62dd4be4f 100644 --- a/src/scripts/boot.lua.h +++ b/src/scripts/boot.lua.h @@ -696,6 +696,8 @@ const unsigned char boot_lua[] = 0x09, 0x09, 0x09, 0x09, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x28, 0x29, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, + 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x28, 0x29, 0x0a, + 0x09, 0x09, 0x09, 0x09, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x28, 0x6d, 0x73, 0x67, 0x2c, 0x20, 0x37, 0x30, 0x2c, 0x20, 0x37, 0x30, 0x29, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x70, 0x72, 0x65, 0x73, 0x65, 0x6e, 0x74, 0x28, 0x29, 0x0a, @@ -768,6 +770,8 @@ const unsigned char boot_lua[] = 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x09, 0x09, 0x09, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x28, 0x29, 0x0a, + 0x09, 0x09, 0x09, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x6f, + 0x72, 0x69, 0x67, 0x69, 0x6e, 0x28, 0x29, 0x0a, 0x09, 0x09, 0x09, 0x69, 0x66, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x64, 0x72, 0x61, 0x77, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x64, 0x72, 0x61, 0x77, 0x28, 0x29, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x09, 0x09, 0x65, 0x6e, 0x64, 0x0a, @@ -1767,6 +1771,8 @@ const unsigned char boot_lua[] = 0x75, 0x67, 0x2e, 0x74, 0x72, 0x61, 0x63, 0x65, 0x62, 0x61, 0x63, 0x6b, 0x28, 0x29, 0x0a, 0x09, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x28, 0x29, 0x0a, + 0x09, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x6f, 0x72, 0x69, + 0x67, 0x69, 0x6e, 0x28, 0x29, 0x0a, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x65, 0x72, 0x72, 0x20, 0x3d, 0x20, 0x7b, 0x7d, 0x0a, 0x09, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x2e, 0x69, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x28, 0x65, 0x72, 0x72, 0x2c, 0x20, 0x22, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x5c, 0x6e, 0x22, 0x29, 0x0a, @@ -1857,6 +1863,8 @@ const unsigned char boot_lua[] = 0x35, 0x2c, 0x20, 0x32, 0x35, 0x35, 0x29, 0x0a, 0x09, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x63, 0x6c, 0x65, 0x61, 0x72, 0x28, 0x29, 0x0a, + 0x09, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x6f, 0x72, 0x69, + 0x67, 0x69, 0x6e, 0x28, 0x29, 0x0a, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x65, 0x72, 0x72, 0x20, 0x3d, 0x20, 0x7b, 0x7d, 0x0a, 0x09, 0x70, 0x20, 0x3d, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x28, 0x22, 0x41, 0x6e, 0x20, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x20, 0x68, 0x61, 0x73, 0x20, 0x6f, 0x63, 0x63,