mirror of
https://github.com/love2d/love.git
synced 2026-08-18 11:44:15 +02:00
Added love.graphics.origin(): resets the coordinate system (replaces the current transformation matrix with the identity)
--HG-- branch : love.graphics.origin
This commit is contained in:
@@ -207,7 +207,6 @@ void Graphics::reset()
|
||||
void Graphics::clear()
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glLoadIdentity();
|
||||
}
|
||||
|
||||
void Graphics::present()
|
||||
@@ -1117,6 +1116,11 @@ void Graphics::shear(float kx, float ky)
|
||||
glMultMatrixf((const GLfloat *)t.getElements());
|
||||
}
|
||||
|
||||
void Graphics::origin()
|
||||
{
|
||||
glLoadIdentity();
|
||||
}
|
||||
|
||||
bool Graphics::hasFocus() const
|
||||
{
|
||||
return currentWindow->hasFocus();
|
||||
|
||||
@@ -510,6 +510,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:
|
||||
|
||||
@@ -1250,6 +1250,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());
|
||||
@@ -1352,6 +1358,7 @@ static const luaL_Reg functions[] =
|
||||
{ "scale", w_scale },
|
||||
{ "translate", w_translate },
|
||||
{ "shear", w_shear },
|
||||
{ "origin", w_origin },
|
||||
|
||||
{ "hasFocus", w_hasFocus },
|
||||
|
||||
|
||||
@@ -110,6 +110,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);
|
||||
|
||||
|
||||
@@ -369,6 +369,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)
|
||||
@@ -416,6 +417,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
|
||||
|
||||
@@ -709,6 +711,7 @@ function love.errhand(msg)
|
||||
local trace = debug.traceback()
|
||||
|
||||
love.graphics.clear()
|
||||
love.graphics.origin()
|
||||
|
||||
local err = {}
|
||||
|
||||
@@ -772,6 +775,7 @@ function love.releaseerrhand(msg)
|
||||
love.graphics.setColor(255, 255, 255, 255)
|
||||
|
||||
love.graphics.clear()
|
||||
love.graphics.origin()
|
||||
|
||||
local err = {}
|
||||
|
||||
|
||||
@@ -642,6 +642,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,
|
||||
@@ -714,6 +716,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,
|
||||
@@ -1713,6 +1717,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,
|
||||
@@ -1803,6 +1809,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,
|
||||
|
||||
Reference in New Issue
Block a user