From 57aa63284185ae93294385050286b221b347bad7 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Wed, 17 Jul 2013 00:35:25 -0300 Subject: [PATCH] Added love.graphics.getMaxImageSize --- src/modules/graphics/opengl/Graphics.cpp | 5 +++++ src/modules/graphics/opengl/Graphics.h | 6 ++++++ src/modules/graphics/opengl/wrap_Graphics.cpp | 7 +++++++ src/modules/graphics/opengl/wrap_Graphics.h | 1 + 4 files changed, 19 insertions(+) diff --git a/src/modules/graphics/opengl/Graphics.cpp b/src/modules/graphics/opengl/Graphics.cpp index a08921eba..54ee6df31 100644 --- a/src/modules/graphics/opengl/Graphics.cpp +++ b/src/modules/graphics/opengl/Graphics.cpp @@ -394,6 +394,11 @@ unsigned char Graphics::getAlphaTestRef() return ref * 255; } +int Graphics::getMaxImageSize() const +{ + return gl.getMaxTextureSize(); +} + Image *Graphics::newImage(love::image::ImageData *data) { // Create the image. diff --git a/src/modules/graphics/opengl/Graphics.h b/src/modules/graphics/opengl/Graphics.h index d5eb4fa72..b945d990d 100644 --- a/src/modules/graphics/opengl/Graphics.h +++ b/src/modules/graphics/opengl/Graphics.h @@ -216,6 +216,12 @@ public: */ unsigned char getAlphaTestRef(); + /** + * Gets the maximum supported width or height of Images and Canvases on this + * system. + **/ + int getMaxImageSize() const; + /** * Creates an Image object with padding and/or optimization. **/ diff --git a/src/modules/graphics/opengl/wrap_Graphics.cpp b/src/modules/graphics/opengl/wrap_Graphics.cpp index d66988fe7..71d579754 100644 --- a/src/modules/graphics/opengl/wrap_Graphics.cpp +++ b/src/modules/graphics/opengl/wrap_Graphics.cpp @@ -175,6 +175,12 @@ int w_getAlphaTest(lua_State *L) return 2; } +int w_getMaxImageSize(lua_State *L) +{ + lua_pushinteger(L, instance->getMaxImageSize()); + return 1; +} + int w_newImage(lua_State *L) { love::image::ImageData *data = 0; @@ -1544,6 +1550,7 @@ static const luaL_Reg functions[] = { "getPointSize", w_getPointSize }, { "getPointStyle", w_getPointStyle }, { "getMaxPointSize", w_getMaxPointSize }, + { "getMaxImageSize", w_getMaxImageSize }, { "newScreenshot", w_newScreenshot }, { "setCanvas", w_setCanvas }, { "setCanvases", w_setCanvases }, diff --git a/src/modules/graphics/opengl/wrap_Graphics.h b/src/modules/graphics/opengl/wrap_Graphics.h index b012fd3a7..a521b7f9f 100644 --- a/src/modules/graphics/opengl/wrap_Graphics.h +++ b/src/modules/graphics/opengl/wrap_Graphics.h @@ -50,6 +50,7 @@ int w_getScissor(lua_State *L); int w_setStencil(lua_State *L); int w_setAlphaTest(lua_State *L); int w_getAlphaTest(lua_State *L); +int w_getMaxImageSize(lua_State *L); int w_newImage(lua_State *L); int w_newGeometry(lua_State *L); int w_newQuad(lua_State *L);