From 8b50dd499b3657bb6faa411b6f48e362948dfd53 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Sun, 28 Apr 2013 18:15:03 -0700 Subject: [PATCH] Removed now-unnecessary optional filter parameters from love.graphics.newImageFont --- src/modules/graphics/opengl/Font.cpp | 2 + src/modules/graphics/opengl/Graphics.cpp | 6 +-- src/modules/graphics/opengl/Graphics.h | 11 ++---- src/modules/graphics/opengl/wrap_Graphics.cpp | 39 ++++--------------- src/modules/graphics/opengl/wrap_Shader.cpp | 4 +- 5 files changed, 18 insertions(+), 44 deletions(-) diff --git a/src/modules/graphics/opengl/Font.cpp b/src/modules/graphics/opengl/Font.cpp index 9301ad5b9..a76c15270 100644 --- a/src/modules/graphics/opengl/Font.cpp +++ b/src/modules/graphics/opengl/Font.cpp @@ -49,6 +49,8 @@ Font::Font(love::font::Rasterizer *r, const Image::Filter &filter) , mSpacing(1) , filter(filter) { + this->filter.mipmap = Image::FILTER_NONE; + // Try to find the best texture size match for the font size. default to the // largest texture size if no rough match is found. textureSizeIndex = NUM_TEXTURE_SIZES - 1; diff --git a/src/modules/graphics/opengl/Graphics.cpp b/src/modules/graphics/opengl/Graphics.cpp index 2571c6f6c..9ffc9cab8 100644 --- a/src/modules/graphics/opengl/Graphics.cpp +++ b/src/modules/graphics/opengl/Graphics.cpp @@ -268,11 +268,9 @@ void Graphics::setCaption(const char *caption) currentWindow->setWindowTitle(title); } -int Graphics::getCaption(lua_State *L) const +std::string Graphics::getCaption() const { - std::string title = currentWindow->getWindowTitle(); - lua_pushstring(L, title.c_str()); - return 1; + return currentWindow->getWindowTitle(); } int Graphics::getWidth() const diff --git a/src/modules/graphics/opengl/Graphics.h b/src/modules/graphics/opengl/Graphics.h index 1459a7ac5..a6d3dafb8 100644 --- a/src/modules/graphics/opengl/Graphics.h +++ b/src/modules/graphics/opengl/Graphics.h @@ -84,10 +84,6 @@ struct DisplayState // Color mask. bool colorMask[4]; - // Window info. - std::string caption; - bool mouseVisible; - // Default values. DisplayState() { @@ -103,8 +99,6 @@ struct DisplayState alphaTest = false; scissor = false; colorMask[0] = colorMask[1] = colorMask[2] = colorMask[3] = true; - caption = ""; - mouseVisible = true; } }; @@ -182,7 +176,10 @@ public: **/ void setCaption(const char *caption); - int getCaption(lua_State *L) const; + /** + * Gets the window's caption. + **/ + std::string getCaption() const; /** * Gets the width of the current display mode. diff --git a/src/modules/graphics/opengl/wrap_Graphics.cpp b/src/modules/graphics/opengl/wrap_Graphics.cpp index 48d52ed92..a12ebacb6 100644 --- a/src/modules/graphics/opengl/wrap_Graphics.cpp +++ b/src/modules/graphics/opengl/wrap_Graphics.cpp @@ -178,7 +178,9 @@ int w_setCaption(lua_State *L) int w_getCaption(lua_State *L) { - return instance->getCaption(L); + std::string caption = instance->getCaption(); + lua_pushstring(L, caption.c_str()); + return 1; } int w_getWidth(lua_State *L) @@ -511,12 +513,8 @@ int w_newFont(lua_State *L) int w_newImageFont(lua_State *L) { - // filter for glyphs, defaults to linear/linear - Image::Filter img_filter; - bool setFilter = false; - - // For the filter modes.. - int startIndex = 2; + // filter for glyphs + Image::Filter filter = instance->getDefaultFilter(); // Convert to ImageData if necessary. if (lua_isstring(L, 1) || luax_istype(L, 1, FILESYSTEM_FILE_T) || luax_istype(L, 1, FILESYSTEM_FILE_DATA_T)) @@ -524,11 +522,10 @@ int w_newImageFont(lua_State *L) else if (luax_istype(L, 1, GRAPHICS_IMAGE_T)) { Image *i = luax_checktype(L, 1, "Image", GRAPHICS_IMAGE_T); - img_filter = i->getFilter(); - setFilter = true; + filter = i->getFilter(); love::image::ImageData *id = i->getData(); if (!id) - return luaL_argerror(L, 1, "image cannot be compressed"); + return luaL_argerror(L, 1, "Image cannot be compressed."); luax_newtype(L, "ImageData", IMAGE_IMAGE_DATA_T, (void *)id, false); lua_replace(L, 1); } @@ -538,32 +535,12 @@ int w_newImageFont(lua_State *L) { int idxs[] = {1, 2}; luax_convobj(L, idxs, 2, "font", "newRasterizer"); - startIndex = 3; // There's a glyphs args in there, move up } love::font::Rasterizer *rasterizer = luax_checktype(L, 1, "Rasterizer", FONT_RASTERIZER_T); - if (lua_isstring(L, startIndex) && lua_isstring(L, startIndex+1)) - { - Image::FilterMode min; - Image::FilterMode mag; - const char *minstr = luaL_checkstring(L, startIndex); - const char *magstr = luaL_checkstring(L, startIndex+1); - if (!Image::getConstant(minstr, min)) - return luaL_error(L, "Invalid filter mode: %s", minstr); - if (!Image::getConstant(magstr, mag)) - return luaL_error(L, "Invalid filter mode: %s", magstr); - - img_filter.min = min; - img_filter.mag = mag; - setFilter = true; - } - - if (!setFilter) - img_filter = instance->getDefaultFilter(); - // Create the font. - Font *font = instance->newFont(rasterizer, img_filter); + Font *font = instance->newFont(rasterizer, filter); if (font == 0) return luaL_error(L, "Could not load font."); diff --git a/src/modules/graphics/opengl/wrap_Shader.cpp b/src/modules/graphics/opengl/wrap_Shader.cpp index a9f0331f0..3d77f90e9 100644 --- a/src/modules/graphics/opengl/wrap_Shader.cpp +++ b/src/modules/graphics/opengl/wrap_Shader.cpp @@ -139,9 +139,9 @@ int w_Shader_sendInt(lua_State *L) delete[] values; return luaL_error(L, "%s", e.what()); } - + delete[] values; - + return 0; }