Browse Source

Re-added love.graphics.getWidth/getHeight

Alex Szpakowski 12 years ago
parent
commit
6a76e082e4

+ 1 - 1
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.

+ 22 - 0
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 },

+ 3 - 0
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);

+ 2 - 2
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
 

+ 4 - 4
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,