From 6a76e082e48be5b8053a5a2d06c4bc579de4a52e Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Tue, 28 May 2013 20:23:31 -0300 Subject: [PATCH] Re-added love.graphics.getWidth/getHeight --- changes.txt | 2 +- src/modules/graphics/opengl/wrap_Graphics.cpp | 22 +++++++++++++++++++ src/modules/graphics/opengl/wrap_Graphics.h | 3 +++ src/scripts/boot.lua | 4 ++-- src/scripts/boot.lua.h | 8 +++---- 5 files changed, 32 insertions(+), 7 deletions(-) diff --git a/changes.txt b/changes.txt index 453faf5f4..800e9cbdc 100644 --- a/changes.txt +++ b/changes.txt @@ -28,7 +28,7 @@ LOVE 0.9.0 [Baby Inspector] * Added SpriteBatch:getCount and SpriteBatch:getBufferSize. * Added ParticleSystem:emit. * Added many ParticleSystem getter methods. - * Added DXT-compressed texture support via love.image.newCompressedData. + * Added DXT compressed texture support via love.image.newCompressedData. * Added love.image.isCompressed and Image:isCompressed. * Added Image/Canvas/ImageData:getDimensions. * Added anisotropic filtering support for Images, Canvases, and Fonts. diff --git a/src/modules/graphics/opengl/wrap_Graphics.cpp b/src/modules/graphics/opengl/wrap_Graphics.cpp index a2f091fbf..b9453c08b 100644 --- a/src/modules/graphics/opengl/wrap_Graphics.cpp +++ b/src/modules/graphics/opengl/wrap_Graphics.cpp @@ -62,6 +62,25 @@ int w_isCreated(lua_State *L) return 1; } +int w_getWidth(lua_State *L) +{ + lua_pushinteger(L, instance->getWidth()); + return 1; +} + +int w_getHeight(lua_State *L) +{ + lua_pushinteger(L, instance->getHeight()); + return 1; +} + +int w_getDimensions(lua_State *L) +{ + lua_pushinteger(L, instance->getWidth()); + lua_pushinteger(L, instance->getHeight()); + return 2; +} + int w_setScissor(lua_State *L) { if (lua_gettop(L) == 0) @@ -1514,6 +1533,9 @@ static const luaL_Reg functions[] = { "printf", w_printf }, { "isCreated", w_isCreated }, + { "getWidth", w_getWidth }, + { "getHeight", w_getHeight }, + { "getDimensions", w_getDimensions }, { "setScissor", w_setScissor }, { "getScissor", w_getScissor }, diff --git a/src/modules/graphics/opengl/wrap_Graphics.h b/src/modules/graphics/opengl/wrap_Graphics.h index dac6c03d3..2a79be54d 100644 --- a/src/modules/graphics/opengl/wrap_Graphics.h +++ b/src/modules/graphics/opengl/wrap_Graphics.h @@ -42,6 +42,9 @@ int w_reset(lua_State *L); int w_clear(lua_State *L); int w_present(lua_State *L); int w_isCreated(lua_State *L); +int w_getWidth(lua_State *L); +int w_getHeight(lua_State *L); +int w_getDimensions(lua_State *L); int w_setScissor(lua_State *L); int w_getScissor(lua_State *L); int w_setStencil(lua_State *L); diff --git a/src/scripts/boot.lua b/src/scripts/boot.lua index 2f113e718..50fd781a0 100644 --- a/src/scripts/boot.lua +++ b/src/scripts/boot.lua @@ -775,7 +775,7 @@ function love.errhand(msg) local function draw() love.graphics.clear() - love.graphics.printf(p, 70, 70, love.window.getWidth() - 70) + love.graphics.printf(p, 70, 70, love.graphics.getWidth() - 70) love.graphics.present() end @@ -826,7 +826,7 @@ function love.releaseerrhand(msg) local function draw() love.graphics.clear() - love.graphics.printf(p, 70, 70, love.window.getWidth() - 70) + love.graphics.printf(p, 70, 70, love.graphics.getWidth() - 70) love.graphics.present() end diff --git a/src/scripts/boot.lua.h b/src/scripts/boot.lua.h index fd1356506..0089f0b9a 100644 --- a/src/scripts/boot.lua.h +++ b/src/scripts/boot.lua.h @@ -1834,8 +1834,8 @@ const unsigned char boot_lua[] = 0x65, 0x61, 0x72, 0x28, 0x29, 0x0a, 0x09, 0x09, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x66, 0x28, 0x70, 0x2c, 0x20, 0x37, 0x30, 0x2c, 0x20, 0x37, 0x30, 0x2c, 0x20, 0x6c, 0x6f, - 0x76, 0x65, 0x2e, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x2e, 0x67, 0x65, 0x74, 0x57, 0x69, 0x64, 0x74, 0x68, - 0x28, 0x29, 0x20, 0x2d, 0x20, 0x37, 0x30, 0x29, 0x0a, + 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x67, 0x65, 0x74, 0x57, 0x69, 0x64, + 0x74, 0x68, 0x28, 0x29, 0x20, 0x2d, 0x20, 0x37, 0x30, 0x29, 0x0a, 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, 0x09, 0x65, 0x6e, 0x64, 0x0a, @@ -1915,8 +1915,8 @@ const unsigned char boot_lua[] = 0x65, 0x61, 0x72, 0x28, 0x29, 0x0a, 0x09, 0x09, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x66, 0x28, 0x70, 0x2c, 0x20, 0x37, 0x30, 0x2c, 0x20, 0x37, 0x30, 0x2c, 0x20, 0x6c, 0x6f, - 0x76, 0x65, 0x2e, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x2e, 0x67, 0x65, 0x74, 0x57, 0x69, 0x64, 0x74, 0x68, - 0x28, 0x29, 0x20, 0x2d, 0x20, 0x37, 0x30, 0x29, 0x0a, + 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x67, 0x65, 0x74, 0x57, 0x69, 0x64, + 0x74, 0x68, 0x28, 0x29, 0x20, 0x2d, 0x20, 0x37, 0x30, 0x29, 0x0a, 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, 0x09, 0x65, 0x6e, 0x64, 0x0a,