diff --git a/src/modules/graphics/opengl/Font.cpp b/src/modules/graphics/opengl/Font.cpp index 291bc61be..94e8896e9 100644 --- a/src/modules/graphics/opengl/Font.cpp +++ b/src/modules/graphics/opengl/Font.cpp @@ -48,7 +48,6 @@ Font::Font(love::font::Rasterizer *r, const Image::Filter &filter) , lineHeight(1) , mSpacing(1) , filter(filter) - , mipmapsharpness(0.0f) { // try to find the best texture size match for the font size // default to the largest texture size if no rough match is found @@ -125,8 +124,8 @@ void Font::createTexture() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); GLint format = (type == FONT_TRUETYPE ? GL_LUMINANCE_ALPHA : GL_RGBA); @@ -167,7 +166,6 @@ void Font::createTexture() &emptyData[0]); setFilter(filter); - setMipmapSharpness(mipmapsharpness); } Font::Glyph *Font::addGlyph(unsigned int glyph) @@ -498,39 +496,6 @@ float Font::getSpacing() const return mSpacing; } -void Font::checkMipmapsCreated() const -{ - if (filter.mipmap != Image::FILTER_NEAREST && filter.mipmap != Image::FILTER_LINEAR) - return; - - if (!Image::hasMipmapSupport()) - throw love::Exception("Mipmap filtering is not supported on this system!"); - - GLint mipmapscreated; - glGetTexParameteriv(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, &mipmapscreated); - - // generate mipmaps for this image if we haven't already - if (!mipmapscreated) - { - glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); - - if (GLEE_VERSION_3_0 || GLEE_ARB_framebuffer_object) - glGenerateMipmap(GL_TEXTURE_2D); - else - { - // modify single texel to trigger mipmap chain generation - std::vector emptydata(type == FONT_TRUETYPE ? 2 : 4); - glTexSubImage2D(GL_TEXTURE_2D, - 0, - 0, 0, - 1, 1, - type == FONT_TRUETYPE ? GL_LUMINANCE_ALPHA : GL_RGBA, - GL_UNSIGNED_BYTE, - &emptydata[0]); - } - } -} - void Font::setFilter(const Image::Filter &f) { filter = f; @@ -539,7 +504,6 @@ void Font::setFilter(const Image::Filter &f) for (it = textures.begin(); it != textures.end(); ++it) { bindTexture(*it); - checkMipmapsCreated(); setTextureFilter(f); } } @@ -549,32 +513,8 @@ const Image::Filter &Font::getFilter() return filter; } -void Font::setMipmapSharpness(float sharpness) -{ - if (!Image::hasMipmapSharpnessSupport()) - return; - - // LOD bias has the range (-maxbias, maxbias) - mipmapsharpness = std::min(std::max(sharpness, -maxmipmapsharpness + 0.01f), maxmipmapsharpness - 0.01f); - - std::vector::const_iterator it; - for (it = textures.begin(); it != textures.end(); ++it) - { - bindTexture(*it); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_LOD_BIAS, -mipmapsharpness); // negative bias is sharper - } -} - -float Font::getMipmapSharpness() const -{ - return mipmapsharpness; -} - bool Font::loadVolatile() { - if (Image::hasMipmapSharpnessSupport()) - glGetFloatv(GL_MAX_TEXTURE_LOD_BIAS, &maxmipmapsharpness); - createTexture(); return true; } diff --git a/src/modules/graphics/opengl/Font.h b/src/modules/graphics/opengl/Font.h index d8f671b69..9a157e551 100644 --- a/src/modules/graphics/opengl/Font.h +++ b/src/modules/graphics/opengl/Font.h @@ -129,9 +129,6 @@ public: void setFilter(const Image::Filter &f); const Image::Filter &getFilter(); - void setMipmapSharpness(float sharpness); - float getMipmapSharpness() const; - // Implements Volatile. bool loadVolatile(); void unloadVolatile(); @@ -204,14 +201,6 @@ private: int texture_x, texture_y; int rowHeight; - // Mipmap texture LOD bias value - float mipmapsharpness; - - // Implementation-dependent maximum/minimum mipmap sharpness values - float maxmipmapsharpness; - - void checkMipmapsCreated() const; - bool initializeTexture(GLint format); void createTexture(); Glyph *addGlyph(unsigned int glyph); diff --git a/src/modules/graphics/opengl/wrap_Font.cpp b/src/modules/graphics/opengl/wrap_Font.cpp index ff5ee70aa..fda13c776 100644 --- a/src/modules/graphics/opengl/wrap_Font.cpp +++ b/src/modules/graphics/opengl/wrap_Font.cpp @@ -128,63 +128,6 @@ int w_Font_getFilter(lua_State *L) return 2; } -int w_Font_setMipmapFilter(lua_State *L) -{ - Font *t = luax_checkfont(L, 1); - Image::Filter f = t->getFilter(); - - if (lua_isnoneornil(L, 2)) - f.mipmap = Image::FILTER_NONE; // mipmapping is disabled if no argument is given - else - { - const char *mipmapstr = luaL_checkstring(L, 2); - if (!Image::getConstant(mipmapstr, f.mipmap)) - return luaL_error(L, "Invalid filter mode: %s", mipmapstr); - } - - try - { - t->setFilter(f); - } - catch(love::Exception &e) - { - return luaL_error(L, "%s", e.what()); - } - - return 0; -} - -int w_Font_getMipmapFilter(lua_State *L) -{ - Font *t = luax_checkfont(L, 1); - const Image::Filter f = t->getFilter(); - - const char *mipmapstr; - if (!Image::getConstant(f.mipmap, mipmapstr)) - return 0; // only return a mipmap filter if mipmapping is enabled - - lua_pushstring(L, mipmapstr); - - return 1; -} - -int w_Font_setMipmapSharpness(lua_State *L) -{ - Font *t = luax_checkfont(L, 1); - - float sharpness = (float) luaL_checknumber(L, 2); - t->setMipmapSharpness(sharpness); - - return 0; -} - -int w_Font_getMipmapSharpness(lua_State *L) -{ - Font *t = luax_checkfont(L, 1); - lua_pushnumber(L, t->getMipmapSharpness()); - return 1; -} - int w_Font_getAscent(lua_State *L) { Font *t = luax_checkfont(L, 1); @@ -215,10 +158,6 @@ static const luaL_Reg functions[] = { "getLineHeight", w_Font_getLineHeight }, { "setFilter", w_Font_setFilter }, { "getFilter", w_Font_getFilter }, - { "setMipmapFilter", w_Font_setMipmapFilter }, - { "getMipmapFilter", w_Font_getMipmapFilter }, - { "setMipmapSharpness", w_Font_setMipmapSharpness }, - { "getMipmapSharpness", w_Font_getMipmapSharpness }, { "getAscent", w_Font_getAscent }, { "getDescent", w_Font_getDescent }, { "getBaseline", w_Font_getBaseline }, diff --git a/src/modules/graphics/opengl/wrap_Font.h b/src/modules/graphics/opengl/wrap_Font.h index 68cd5a857..3482baf7f 100644 --- a/src/modules/graphics/opengl/wrap_Font.h +++ b/src/modules/graphics/opengl/wrap_Font.h @@ -40,10 +40,6 @@ int w_Font_setLineHeight(lua_State *L); int w_Font_getLineHeight(lua_State *L); int w_Font_setFilter(lua_State *L); int w_Font_getFilter(lua_State *L); -int w_Font_setMipmapFilter(lua_State *L); -int w_Font_getMipmapFilter(lua_State *L); -int w_Font_setMipmapSharpness(lua_State *L); -int w_Font_getMipmapSharpness(lua_State *L); int w_Font_getAscent(lua_State *L); int w_Font_getDescent(lua_State *L); int w_Font_getBaseline(lua_State *L);