diff --git a/platform/macosx/love.xcodeproj/project.pbxproj b/platform/macosx/love.xcodeproj/project.pbxproj index 51a5b44ad..acc0a3e42 100644 --- a/platform/macosx/love.xcodeproj/project.pbxproj +++ b/platform/macosx/love.xcodeproj/project.pbxproj @@ -26,8 +26,6 @@ A93E6E5510420B57007D418B /* Lua.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A93E6E5310420B57007D418B /* Lua.framework */; }; A93E6EED10420BA8007D418B /* love.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A93E6A3410420AC0007D418B /* love.cpp */; }; A946CE821172BCD7005E1462 /* wrap_EncodedImageData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A946CE811172BCD7005E1462 /* wrap_EncodedImageData.cpp */; }; - A946D3BB117681BD005E1462 /* FontData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A946D3BA117681BC005E1462 /* FontData.cpp */; }; - A946D3C611768D69005E1462 /* wrap_FontData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A946D3C511768D69005E1462 /* wrap_FontData.cpp */; }; A946D67F104248DA002BF36C /* Reference.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A93E69EA10420ABF007D418B /* Reference.cpp */; }; A946D680104248DA002BF36C /* Matrix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A93E69E310420ABF007D418B /* Matrix.cpp */; }; A946D681104248DA002BF36C /* Object.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A93E69E810420ABF007D418B /* Object.cpp */; }; @@ -84,8 +82,6 @@ A946D702104249A4002BF36C /* Graphics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A93E6A8D10420AC2007D418B /* Graphics.cpp */; }; A946D703104249A4002BF36C /* Font.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A93E6A8710420AC2007D418B /* Font.cpp */; }; A946D704104249A4002BF36C /* SpriteBatch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A93E6A9510420AC2007D418B /* SpriteBatch.cpp */; }; - A946D705104249A4002BF36C /* wrap_Glyph.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A93E6A9B10420AC2007D418B /* wrap_Glyph.cpp */; }; - A946D706104249A4002BF36C /* Glyph.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A93E6A8B10420AC2007D418B /* Glyph.cpp */; }; A946D708104249A4002BF36C /* Drawable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A93E6A8210420AC2007D418B /* Drawable.cpp */; }; A946D709104249A4002BF36C /* wrap_Graphics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A93E6A9D10420AC3007D418B /* wrap_Graphics.cpp */; }; A946D70A104249A4002BF36C /* Image.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A93E6A8F10420AC2007D418B /* Image.cpp */; }; @@ -362,8 +358,6 @@ A93E6A8810420AC2007D418B /* Font.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Font.h; sourceTree = ""; }; A93E6A8910420AC2007D418B /* GLee.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = GLee.c; sourceTree = ""; }; A93E6A8A10420AC2007D418B /* GLee.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GLee.h; sourceTree = ""; }; - A93E6A8B10420AC2007D418B /* Glyph.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Glyph.cpp; sourceTree = ""; }; - A93E6A8C10420AC2007D418B /* Glyph.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Glyph.h; sourceTree = ""; }; A93E6A8D10420AC2007D418B /* Graphics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Graphics.cpp; sourceTree = ""; }; A93E6A8E10420AC2007D418B /* Graphics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Graphics.h; sourceTree = ""; }; A93E6A8F10420AC2007D418B /* Image.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Image.cpp; sourceTree = ""; }; @@ -374,8 +368,6 @@ A93E6A9610420AC2007D418B /* SpriteBatch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpriteBatch.h; sourceTree = ""; }; A93E6A9910420AC2007D418B /* wrap_Font.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_Font.cpp; sourceTree = ""; }; A93E6A9A10420AC2007D418B /* wrap_Font.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_Font.h; sourceTree = ""; }; - A93E6A9B10420AC2007D418B /* wrap_Glyph.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_Glyph.cpp; sourceTree = ""; }; - A93E6A9C10420AC2007D418B /* wrap_Glyph.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_Glyph.h; sourceTree = ""; }; A93E6A9D10420AC3007D418B /* wrap_Graphics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_Graphics.cpp; sourceTree = ""; }; A93E6A9E10420AC3007D418B /* wrap_Graphics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_Graphics.h; sourceTree = ""; }; A93E6A9F10420AC3007D418B /* wrap_Image.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_Image.cpp; sourceTree = ""; }; @@ -572,10 +564,6 @@ A93E6E5310420B57007D418B /* Lua.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Lua.framework; path = /Library/Frameworks/Lua.framework; sourceTree = ""; }; A946CE801172BCD6005E1462 /* wrap_EncodedImageData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_EncodedImageData.h; sourceTree = ""; }; A946CE811172BCD7005E1462 /* wrap_EncodedImageData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_EncodedImageData.cpp; sourceTree = ""; }; - A946D3B9117681BC005E1462 /* FontData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontData.h; sourceTree = ""; }; - A946D3BA117681BC005E1462 /* FontData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontData.cpp; sourceTree = ""; }; - A946D3C411768D69005E1462 /* wrap_FontData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_FontData.h; sourceTree = ""; }; - A946D3C511768D69005E1462 /* wrap_FontData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_FontData.cpp; sourceTree = ""; }; A946D4421176AC42005E1462 /* Font.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Font.h; sourceTree = ""; }; A95684F5125D3555001B276B /* b64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = b64.cpp; sourceTree = ""; }; A95684F6125D3555001B276B /* b64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = b64.h; sourceTree = ""; }; @@ -939,8 +927,6 @@ isa = PBXGroup; children = ( A946D4421176AC42005E1462 /* Font.h */, - A946D3BA117681BC005E1462 /* FontData.cpp */, - A946D3B9117681BC005E1462 /* FontData.h */, A93E6A7010420AC1007D418B /* freetype */, A93E6A7710420AC2007D418B /* GlyphData.cpp */, A93E6A7810420AC2007D418B /* GlyphData.h */, @@ -948,8 +934,6 @@ A93E6A7A10420AC2007D418B /* ImageRasterizer.h */, A93E6A7B10420AC2007D418B /* Rasterizer.cpp */, A93E6A7C10420AC2007D418B /* Rasterizer.h */, - A946D3C511768D69005E1462 /* wrap_FontData.cpp */, - A946D3C411768D69005E1462 /* wrap_FontData.h */, A93E6A7D10420AC2007D418B /* wrap_GlyphData.cpp */, A93E6A7E10420AC2007D418B /* wrap_GlyphData.h */, A93E6A7F10420AC2007D418B /* wrap_Rasterizer.cpp */, @@ -996,8 +980,6 @@ A9BD60711226C988007DEC63 /* Framebuffer.h */, A93E6A8910420AC2007D418B /* GLee.c */, A93E6A8A10420AC2007D418B /* GLee.h */, - A93E6A8B10420AC2007D418B /* Glyph.cpp */, - A93E6A8C10420AC2007D418B /* Glyph.h */, A93E6A8D10420AC2007D418B /* Graphics.cpp */, A93E6A8E10420AC2007D418B /* Graphics.h */, A93E6A8F10420AC2007D418B /* Image.cpp */, @@ -1012,8 +994,6 @@ A93E6A9A10420AC2007D418B /* wrap_Font.h */, A9BD60721226C988007DEC63 /* wrap_Framebuffer.cpp */, A9BD60731226C988007DEC63 /* wrap_Framebuffer.h */, - A93E6A9B10420AC2007D418B /* wrap_Glyph.cpp */, - A93E6A9C10420AC2007D418B /* wrap_Glyph.h */, A93E6A9D10420AC3007D418B /* wrap_Graphics.cpp */, A93E6A9E10420AC3007D418B /* wrap_Graphics.h */, A93E6A9F10420AC3007D418B /* wrap_Image.cpp */, @@ -1542,8 +1522,6 @@ A946D702104249A4002BF36C /* Graphics.cpp in Sources */, A946D703104249A4002BF36C /* Font.cpp in Sources */, A946D704104249A4002BF36C /* SpriteBatch.cpp in Sources */, - A946D705104249A4002BF36C /* wrap_Glyph.cpp in Sources */, - A946D706104249A4002BF36C /* Glyph.cpp in Sources */, A946D708104249A4002BF36C /* Drawable.cpp in Sources */, A946D709104249A4002BF36C /* wrap_Graphics.cpp in Sources */, A946D70A104249A4002BF36C /* Image.cpp in Sources */, @@ -1648,8 +1626,6 @@ A986DEB5113249A800810279 /* Thread.cpp in Sources */, A986DEB6113249A800810279 /* wrap_Thread.cpp in Sources */, A946CE821172BCD7005E1462 /* wrap_EncodedImageData.cpp in Sources */, - A946D3BB117681BD005E1462 /* FontData.cpp in Sources */, - A946D3C611768D69005E1462 /* wrap_FontData.cpp in Sources */, A9BD60741226C988007DEC63 /* Framebuffer.cpp in Sources */, A9BD60751226C988007DEC63 /* wrap_Framebuffer.cpp in Sources */, A95684F7125D3555001B276B /* b64.cpp in Sources */, diff --git a/src/modules/font/Font.h b/src/modules/font/Font.h index 788796ec9..c2790e251 100644 --- a/src/modules/font/Font.h +++ b/src/modules/font/Font.h @@ -22,7 +22,6 @@ #define LOVE_FONT_FONT_H // LOVE -#include "FontData.h" #include "Rasterizer.h" #include #include @@ -44,7 +43,6 @@ namespace font virtual Rasterizer * newRasterizer(love::image::ImageData * data, std::string glyphs) = 0; virtual Rasterizer * newRasterizer(love::image::ImageData * data, unsigned short * glyphs, int length) = 0; virtual GlyphData * newGlyphData(Rasterizer * r, unsigned short glyph) = 0; - virtual FontData * newFontData(Rasterizer * r) = 0; // Implement Module virtual const char * getName() const = 0; diff --git a/src/modules/font/FontData.cpp b/src/modules/font/FontData.cpp deleted file mode 100644 index 726d6c18b..000000000 --- a/src/modules/font/FontData.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/** -* Copyright (c) 2006-2011 LOVE Development Team -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -**/ - - -#include "FontData.h" - -namespace love -{ -namespace font -{ - - FontData::FontData(Rasterizer * raster) - : raster(raster) - { - data = new GlyphData *[MAX_CHARS]; - for (unsigned int i = 0; i < MAX_CHARS; i++) { - data[i] = raster->getGlyphData(i); - } - } - - FontData::~FontData() - { - for (unsigned int i = 0; i < MAX_CHARS; i++) { - data[i]->release(); - } - delete[] data; - } - - void * FontData::getData() const - { - return (void *)data; - } - - int FontData::getSize() const - { - return MAX_CHARS; - } - - GlyphData * FontData::getGlyphData(unsigned short glyph) const - { - return data[glyph]; - } - - int FontData::getHeight() const - { - return raster->getHeight(); - } - -} // font -} // love diff --git a/src/modules/font/FontData.h b/src/modules/font/FontData.h deleted file mode 100644 index 18be20a90..000000000 --- a/src/modules/font/FontData.h +++ /dev/null @@ -1,56 +0,0 @@ -/** -* Copyright (c) 2006-2011 LOVE Development Team -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -**/ - -#ifndef LOVE_FONT_FONT_DATA_H -#define LOVE_FONT_FONT_DATA_H - -// LOVE -#include - -#include "GlyphData.h" -#include "Rasterizer.h" - -namespace love -{ -namespace font -{ - class FontData : public Data - { - public: - FontData(Rasterizer * raster); - virtual ~FontData(); - - // Implements Data. - void * getData() const; - int getSize() const; - - GlyphData * getGlyphData(unsigned short glyph) const; - int getHeight() const; - - static const unsigned int MAX_CHARS = 256; - - private: - GlyphData ** data; - Rasterizer * raster; - }; -} // font -} // love - -#endif // LOVE_FONT_FONT_DATA_H \ No newline at end of file diff --git a/src/modules/font/GlyphData.cpp b/src/modules/font/GlyphData.cpp index 1f9f16944..a688038da 100644 --- a/src/modules/font/GlyphData.cpp +++ b/src/modules/font/GlyphData.cpp @@ -28,7 +28,7 @@ namespace font { GlyphData::GlyphData(unsigned short glyph, GlyphMetrics glyphMetrics, GlyphData::Format f) - : glyph(glyph), metrics(glyphMetrics), data(0), format(f), padded(false) + : glyph(glyph), metrics(glyphMetrics), data(0), format(f) { if (metrics.width && metrics.height) { switch (f) { @@ -69,12 +69,12 @@ namespace font int GlyphData::getHeight() const { - return (padded ? getPaddedHeight() : metrics.height); + return metrics.height; } int GlyphData::getWidth() const { - return (padded ? getPaddedWidth() : metrics.width); + return metrics.width; } int GlyphData::getAdvance() const @@ -116,71 +116,6 @@ namespace font { return format; } - - void GlyphData::pad() - { - if (data == 0) - return; - int w = getWidth(); - int h = getHeight(); - int pw = next_p2(w); - int ph = next_p2(h); - unsigned char * d = new unsigned char[pw * ph * (format == GlyphData::FORMAT_LUMINANCE_ALPHA ? 2 : 4)]; - for (int j = 0; j < ph; j++) { - for (int i = 0; i < pw; i++) { - int n = i+j*w; - int p = i+j*pw; - if (i < w && j < h) { - if (format == GlyphData::FORMAT_LUMINANCE_ALPHA) { - p *= 2; - n *= 2; - d[p] = data[n]; - d[p+1] = data[n+1]; - } else { - p *= 4; - n *= 4; - d[p] = data[n]; - d[p+1] = data[n+1]; - d[p+2] = data[n+2]; - d[p+3] = data[n+3]; - } - } else { - if (format == GlyphData::FORMAT_LUMINANCE_ALPHA) { - p *= 2; - d[p] = d[p+1] = 0; - } else { - p *= 4; - d[p] = d[p+1] = d[p+2] = d[p+3] = 0; - } - } - } - } - delete[] data; - data = d; - padded = true; - } - - bool GlyphData::isPadded() const - { - return padded; - } - - int GlyphData::getPaddedWidth() const - { - return next_p2(metrics.width); - } - - int GlyphData::getPaddedHeight() const - { - return next_p2(metrics.height); - } - - inline int GlyphData::next_p2(int num) const - { - int powered = 2; - while(powered < num) powered <<= 1; - return powered; - } - + } // font } // love diff --git a/src/modules/font/GlyphData.h b/src/modules/font/GlyphData.h index 440e00fb4..bc8e4b031 100644 --- a/src/modules/font/GlyphData.h +++ b/src/modules/font/GlyphData.h @@ -112,33 +112,6 @@ namespace font **/ Format getFormat() const; - /** - * Returns the closest number to num which is a power of two. - * - * @param num The number to be 2powered. - **/ - inline int next_p2(int num) const; - - /** - * Pads the data to fit into a power-of-2 texture. - **/ - void pad(); - - /** - * Returns whether the data has been padded. - **/ - bool isPadded() const; - - /** - * Returns the padded width. - **/ - int getPaddedWidth() const; - - /** - * Returns the padded height. - **/ - int getPaddedHeight() const; - private: // The glyph itself unsigned short glyph; @@ -151,9 +124,6 @@ namespace font // The format the data's in Format format; - - // Padded? - bool padded; }; // GlyphData diff --git a/src/modules/font/ImageRasterizer.cpp b/src/modules/font/ImageRasterizer.cpp index 94cca67b6..cfa222a20 100644 --- a/src/modules/font/ImageRasterizer.cpp +++ b/src/modules/font/ImageRasterizer.cpp @@ -79,7 +79,6 @@ namespace font gd[i*4+2] = p.b; gd[i*4+3] = p.a; } - g->pad(); return g; } diff --git a/src/modules/font/freetype/Font.cpp b/src/modules/font/freetype/Font.cpp index ac87570f9..ddab69450 100644 --- a/src/modules/font/freetype/Font.cpp +++ b/src/modules/font/freetype/Font.cpp @@ -66,11 +66,6 @@ namespace freetype { return r->getGlyphData(glyph); } - - FontData * Font::newFontData(Rasterizer * r) - { - return new FontData(r); - } const char * Font::getName() const { diff --git a/src/modules/font/freetype/Font.h b/src/modules/font/freetype/Font.h index a98778f23..f8dfa6231 100644 --- a/src/modules/font/freetype/Font.h +++ b/src/modules/font/freetype/Font.h @@ -63,7 +63,6 @@ namespace freetype Rasterizer * newRasterizer(love::image::ImageData * data, std::string glyphs); Rasterizer * newRasterizer(love::image::ImageData * data, unsigned short * glyphs, int length); GlyphData * newGlyphData(Rasterizer * r, unsigned short glyph); - FontData * newFontData(Rasterizer * r); // Implement Module const char * getName() const; diff --git a/src/modules/font/freetype/TrueTypeRasterizer.cpp b/src/modules/font/freetype/TrueTypeRasterizer.cpp index cf0cc0dd5..ce5a0e2a1 100644 --- a/src/modules/font/freetype/TrueTypeRasterizer.cpp +++ b/src/modules/font/freetype/TrueTypeRasterizer.cpp @@ -104,9 +104,6 @@ namespace freetype // Having copied the data over, we can destroy the glyph FT_Done_Glyph(ftglyph); - - // Pad the GlyphData for graphics cards that don't support npo2 textures - glyphData->pad(); // Return data return glyphData; diff --git a/src/modules/font/freetype/wrap_Font.cpp b/src/modules/font/freetype/wrap_Font.cpp index 207c49092..e04d52978 100644 --- a/src/modules/font/freetype/wrap_Font.cpp +++ b/src/modules/font/freetype/wrap_Font.cpp @@ -22,7 +22,6 @@ #include "Font.h" -#include #include #include @@ -64,25 +63,15 @@ namespace freetype luax_newtype(L, "GlyphData", FONT_GLYPH_DATA_T, t); return 1; } - - int w_newFontData(lua_State * L) - { - Rasterizer * r = luax_checkrasterizer(L, 1); - FontData * f = instance->newFontData(r); - luax_newtype(L, "FontData", FONT_FONT_DATA_T, (void*)f); - return 1; - } // List of functions to wrap. static const luaL_Reg functions[] = { { "newRasterizer", w_newRasterizer }, { "newGlyphData", w_newGlyphData }, - { "newFontData", w_newFontData }, { 0, 0 } }; static const lua_CFunction types[] = { - luaopen_fontdata, luaopen_glyphdata, luaopen_rasterizer, 0 diff --git a/src/modules/font/wrap_FontData.cpp b/src/modules/font/wrap_FontData.cpp deleted file mode 100644 index 2d4da4fc9..000000000 --- a/src/modules/font/wrap_FontData.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/** -* Copyright (c) 2006-2011 LOVE Development Team -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -**/ - -#include "wrap_FontData.h" - -#include - -namespace love -{ -namespace font -{ - FontData * luax_checkfontdata(lua_State * L, int idx) - { - return luax_checktype(L, idx, "FontData", FONT_FONT_DATA_T); - } - - static const luaL_Reg functions[] = { - { "getPointer", w_Data_getPointer }, - { "getSize", w_Data_getSize }, - { 0, 0 } - }; - - int luaopen_fontdata(lua_State * L) - { - return luax_register_type(L, "FontData", functions); - } - -} // font -} // love diff --git a/src/modules/font/wrap_FontData.h b/src/modules/font/wrap_FontData.h deleted file mode 100644 index 7e5ef649d..000000000 --- a/src/modules/font/wrap_FontData.h +++ /dev/null @@ -1,39 +0,0 @@ -/** -* Copyright (c) 2006-2011 LOVE Development Team -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -**/ - -#ifndef LOVE_FONT_WRAP_FONT_DATA_H -#define LOVE_FONT_WRAP_FONT_DATA_H - -// LOVE -#include - -#include "FontData.h" - -namespace love -{ -namespace font -{ - FontData * luax_checkfontdata(lua_State * L, int idx); - int luaopen_fontdata(lua_State * L); - -} // font -} // love - -#endif // LOVE_FONT_WRAP_FONT_DATA_H diff --git a/src/modules/graphics/opengl/Font.cpp b/src/modules/graphics/opengl/Font.cpp index 4d1fa06ef..40ef5b392 100644 --- a/src/modules/graphics/opengl/Font.cpp +++ b/src/modules/graphics/opengl/Font.cpp @@ -20,10 +20,13 @@ #include "Font.h" #include +#include "Quad.h" #include #include +#include // for max + namespace love { namespace graphics @@ -31,33 +34,102 @@ namespace graphics namespace opengl { - Font::Font(love::font::FontData * data, const Image::Filter& filter) - : height(data->getHeight()), lineHeight(1), mSpacing(1) + Font::Font(love::font::Rasterizer * r, const Image::Filter& filter) + : rasterizer(r), height(r->getHeight()), lineHeight(1), mSpacing(1), filter(filter) { - glyphs = new Glyph*[MAX_CHARS]; - type = FONT_UNKNOWN; - love::font::GlyphData * gd; - - for(unsigned int i = 0; i < MAX_CHARS; i++) - { - gd = data->getGlyphData(i); - glyphs[i] = new Glyph(gd, filter); - glyphs[i]->load(); - widths[i] = gd->getWidth(); - spacing[i] = gd->getAdvance(); - bearingX[i] = gd->getBearingX(); - bearingY[i] = gd->getBearingY(); - if (type == FONT_UNKNOWN) type = (gd->getFormat() == love::font::GlyphData::FORMAT_LUMINANCE_ALPHA ? FONT_TRUETYPE : FONT_IMAGE); - } + love::font::GlyphData * gd = r->getGlyphData(32); + type = (gd->getFormat() == love::font::GlyphData::FORMAT_LUMINANCE_ALPHA ? FONT_TRUETYPE : FONT_IMAGE); + delete gd; + createTexture(); } Font::~Font() { - for(unsigned int i = 0; i < MAX_CHARS; i++) - { - glyphs[i]->release(); + unloadVolatile(); + } + + void Font::createTexture() + { + texture_x = texture_y = rowHeight = 0; + GLuint t; + glGenTextures(1, &t); + textures.push_back(t); + glBindTexture(GL_TEXTURE_2D, t); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, + (filter.mag == Image::FILTER_LINEAR) ? GL_LINEAR : GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, + (filter.min == Image::FILTER_LINEAR) ? GL_LINEAR : GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + GLint format = (type == FONT_TRUETYPE ? GL_LUMINANCE_ALPHA : GL_RGBA); + glTexImage2D(GL_TEXTURE_2D, + 0, + GL_RGBA, + (GLsizei)TEXTURE_WIDTH, + (GLsizei)TEXTURE_HEIGHT, + 0, + format, + GL_UNSIGNED_BYTE, + NULL); + } + + Font::Glyph * Font::addGlyph(int glyph) + { + Glyph * g = new Glyph; + g->list = glGenLists(1); + if (g->list == 0) { // opengl failed to generate the list + delete g; + return NULL; } - delete[] glyphs; + love::font::GlyphData *gd = rasterizer->getGlyphData(glyph); + g->spacing = gd->getAdvance(); + int w = gd->getWidth(); + int h = gd->getHeight(); + if (texture_x + w > TEXTURE_WIDTH) { // out of space - new row! + texture_x = 0; + texture_y += rowHeight; + rowHeight = 0; + } + if (texture_y + h > TEXTURE_HEIGHT) { // totally out of space - new texture! + createTexture(); + } + GLuint t = textures.back(); + glBindTexture(GL_TEXTURE_2D, t); + glTexSubImage2D(GL_TEXTURE_2D, 0, texture_x, texture_y, w, h, (type == FONT_TRUETYPE ? GL_LUMINANCE_ALPHA : GL_RGBA), GL_UNSIGNED_BYTE, gd->getData()); + + Quad::Viewport v; + v.x = texture_x; + v.y = texture_y; + v.w = w; + v.h = h; + Quad * q = new Quad(v, TEXTURE_WIDTH, TEXTURE_HEIGHT); + const vertex * verts = q->getVertices(); + + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glVertexPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid *)&verts[0].x); + glTexCoordPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid *)&verts[0].s); + + glNewList(g->list, GL_COMPILE); + glBindTexture(GL_TEXTURE_2D, t); + glPushMatrix(); + glTranslatef(static_cast(gd->getBearingX()), static_cast(-gd->getBearingY()), 0.0f); + glDrawArrays(GL_QUADS, 0, 4); + glPopMatrix(); + glEndList(); + + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + glDisableClientState(GL_VERTEX_ARRAY); + + delete q; + delete gd; + + texture_x += w; + rowHeight = std::max(rowHeight, h); + + glyphs[glyph] = g; + return g; } float Font::getHeight() const @@ -65,7 +137,7 @@ namespace opengl return static_cast(height); } - void Font::print(std::string text, float x, float y, float angle, float sx, float sy) const + void Font::print(std::string text, float x, float y, float angle, float sx, float sy) { float dx = 0.0f; // spacing counter for newline handling glPushMatrix(); @@ -80,57 +152,66 @@ namespace opengl dx = 0.0f; continue; } - if (!glyphs[g]) g = 32; // space + Glyph * glyph = glyphs[g]; + if (!glyph) glyph = addGlyph(g); glPushMatrix(); // 1.25 is magic line height for true type fonts if (type == FONT_TRUETYPE) glTranslatef(0, floor(getHeight() / 1.25f + 0.5f), 0); - glyphs[g]->draw(0, 0, 0, 1, 1, 0, 0); + glCallList(glyph->list); glPopMatrix(); - glTranslatef(static_cast(spacing[g]), 0, 0); - dx += spacing[g]; + glTranslatef(static_cast(glyph->spacing), 0, 0); + dx += glyph->spacing; } glPopMatrix(); } - void Font::print(char character, float x, float y) const + void Font::print(char character, float x, float y) { - if (!glyphs[(int)character]) character = ' '; + Glyph * glyph = glyphs[character]; + if (!glyph) glyph = addGlyph(character); glPushMatrix(); glTranslatef(x, floor(y+getHeight() + 0.5f), 0.0f); - glCallList(list+character); + glCallList(glyph->list); glPopMatrix(); } - int Font::getWidth(const std::string & line) const + int Font::getWidth(const std::string & line) { if(line.size() == 0) return 0; int temp = 0; + + Glyph * g; for(unsigned int i = 0; i < line.size(); i++) { - temp += static_cast((spacing[(int)line[i]] * mSpacing)); + g = glyphs[line[i]]; + if (!g) g = addGlyph(line[i]); + temp += static_cast(g->spacing * mSpacing); } return temp; } - int Font::getWidth(const char * line) const + int Font::getWidth(const char * line) { return this->getWidth(std::string(line)); } - int Font::getWidth(const char character) const + int Font::getWidth(const char character) { - return spacing[(int)character]; + Glyph * g = glyphs[character]; + if (!g) g = addGlyph(character); + return g->spacing; } - int Font::getWrap(const std::string & line, float wrap, int * lines) const + int Font::getWrap(const std::string & line, float wrap, int * lines) { if(line.size() == 0) return 0; int maxw = 0; int linen = 1; int temp = 0; std::string text; + Glyph * g; for(unsigned int i = 0; i < line.size(); i++) { @@ -144,7 +225,9 @@ namespace opengl temp = getWidth(text); linen++; } - temp += static_cast((spacing[(int)line[i]] * mSpacing)); + g = glyphs[line[i]]; + if (!g) g = addGlyph(line[i]); + temp += static_cast(g->spacing * mSpacing); text += line[i]; } @@ -154,7 +237,7 @@ namespace opengl return maxw; } - int Font::getWrap(const char * line, float wrap, int * lines) const + int Font::getWrap(const char * line, float wrap, int * lines) { return getWrap(std::string(line), wrap, lines); } @@ -181,21 +264,26 @@ namespace opengl bool Font::loadVolatile() { - // reload all glyphs - for(unsigned int i = 0; i < MAX_CHARS; i++) - { - glyphs[i]->load(); - glNewList(list + i, GL_COMPILE); - glyphs[i]->draw(0, 0, 0, 1, 1, 0, 0); - glEndList(); - } - return true; + createTexture(); } void Font::unloadVolatile() { - // delete the glyphs - glDeleteLists(list, MAX_CHARS); + // nuke everything from orbit + std::map::iterator it = glyphs.begin(); + Glyph * g; + while (it != glyphs.end()) { + g = it->second; + glDeleteLists(g->list, 1); + delete g; + glyphs.erase(it++); + } + std::vector::iterator iter = textures.begin(); + while (iter != textures.end()) { + glDeleteTextures(1, (GLuint*)&*iter); + iter++; + } + textures.clear(); } } // opengl diff --git a/src/modules/graphics/opengl/Font.h b/src/modules/graphics/opengl/Font.h index 1cdbe9160..fe597e26a 100644 --- a/src/modules/graphics/opengl/Font.h +++ b/src/modules/graphics/opengl/Font.h @@ -22,13 +22,16 @@ #define LOVE_GRAPHICS_OPENGL_FONT_H // STD +#include #include +#include // LOVE #include -#include +#include #include -#include "Glyph.h" + +#include "GLee.h" namespace love { @@ -46,31 +49,40 @@ namespace opengl FONT_IMAGE, FONT_UNKNOWN }; + + struct Glyph + { + GLuint list; + int spacing; + }; + + love::font::Rasterizer * rasterizer; int height; float lineHeight; float mSpacing; // modifies the spacing by multiplying it with this value - Glyph ** glyphs; - GLuint list; // the list of glyphs, for quicker drawing + std::vector textures; // vector of packed textures + std::map glyphs; // maps glyphs to display lists FontType type; + Image::Filter filter; + + static const int TEXTURE_WIDTH = 512; + static const int TEXTURE_HEIGHT = 512; + + int texture_x, texture_y; + int rowHeight; + + void createTexture(); + Glyph * addGlyph(int glyph); public: - static const unsigned int MAX_CHARS = 256; - // The widths of each character. - int widths[MAX_CHARS]; - // The spacing of each character. - int spacing[MAX_CHARS]; - // The X-bearing of each character. - int bearingX[MAX_CHARS]; - // The Y-bearing of each character. - int bearingY[MAX_CHARS]; /** * Default constructor. * * @param data The font data to construct from. **/ - Font(love::font::FontData * data, const Image::Filter& filter = Image::Filter()); + Font(love::font::Rasterizer * r, const Image::Filter& filter = Image::Filter()); virtual ~Font(); @@ -82,7 +94,7 @@ namespace opengl * @param y The y-coordinate. * @param angle The amount of rotation. **/ - void print(std::string text, float x, float y, float angle = 0.0f, float sx = 1.0f, float sy = 1.0f) const; + void print(std::string text, float x, float y, float angle = 0.0f, float sx = 1.0f, float sy = 1.0f); /** * Prints the character at the designated position. @@ -91,7 +103,7 @@ namespace opengl * @param x The x-coordinate. * @param y The y-coordinate. **/ - void print(char character, float x, float y) const; + void print(char character, float x, float y); /** * Returns the height of the font. @@ -103,15 +115,15 @@ namespace opengl * * @param line A line of text. **/ - int getWidth(const std::string & line) const; - int getWidth(const char * line) const; + int getWidth(const std::string & line); + int getWidth(const char * line); /** * Returns the width of the passed character. * * @param character A character. **/ - int getWidth(const char character) const; + int getWidth(const char character); /** * Returns the maximal width of a wrapped string @@ -121,8 +133,8 @@ namespace opengl * @param wrap The number of pixels to wrap at * @param lines Optional output of the number of lines needed **/ - int getWrap(const std::string & line, float wrap, int *lines = 0) const; - int getWrap(const char * line, float wrap, int *lines = 0) const; + int getWrap(const std::string & line, float wrap, int *lines = 0); + int getWrap(const char * line, float wrap, int *lines = 0); /** * Sets the line height (which should be a number to multiply the font size by, diff --git a/src/modules/graphics/opengl/Glyph.cpp b/src/modules/graphics/opengl/Glyph.cpp deleted file mode 100644 index 4304040ce..000000000 --- a/src/modules/graphics/opengl/Glyph.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/** -* Copyright (c) 2006-2011 LOVE Development Team -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -**/ - -#include "Glyph.h" - -// STD -#include // For memcpy - -namespace love -{ -namespace graphics -{ -namespace opengl -{ - - Glyph::Glyph(love::font::GlyphData * data, const Image::Filter& filter_) - : data(data), - width((float)data->getWidth()), height((float)data->getHeight()), - texture(0), filter(filter_) - { - data->retain(); - - memset(vertices, 255, sizeof(vertex)*4); - - vertices[0].x = 0; vertices[0].y = 0; - vertices[1].x = 0; vertices[1].y = height; - vertices[2].x = width; vertices[2].y = height; - vertices[3].x = width; vertices[3].y = 0; - - vertices[0].s = 0; vertices[0].t = 0; - vertices[1].s = 0; vertices[1].t = 1; - vertices[2].s = 1; vertices[2].t = 1; - vertices[3].s = 1; vertices[3].t = 0; - - } - - Glyph::~Glyph() - { - if(data != 0) - data->release(); - unload(); - } - - void Glyph::draw(float x, float y, float angle, float sx, float sy, float ox, float oy) const - { - static Matrix t; - - t.setTransformation(x, y, angle, sx, sy, ox, oy); - - if(texture != 0) - glBindTexture(GL_TEXTURE_2D,texture); - - glPushMatrix(); - - glMultMatrixf((const GLfloat*)t.getElements()); - glTranslatef(static_cast(data->getBearingX()), static_cast(-data->getBearingY()), 0.0f); - - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glVertexPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid*)&vertices[0].x); - glTexCoordPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid*)&vertices[0].s); - glDrawArrays(GL_QUADS, 0, 4); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - glDisableClientState(GL_VERTEX_ARRAY); - - glPopMatrix(); - - } - - bool Glyph::load() - { - return loadVolatile(); - } - - void Glyph::unload() - { - unloadVolatile(); - } - - bool Glyph::loadVolatile() - { - GLint format = GL_RGBA; - if (data->getFormat() == love::font::GlyphData::FORMAT_LUMINANCE_ALPHA) format = GL_LUMINANCE_ALPHA; - - glGenTextures(1,&texture); - glBindTexture(GL_TEXTURE_2D, texture); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, - (filter.mag == Image::FILTER_LINEAR) ? GL_LINEAR : GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, - (filter.min == Image::FILTER_LINEAR) ? GL_LINEAR : GL_NEAREST); - - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - - glTexImage2D(GL_TEXTURE_2D, - 0, - GL_RGBA, - (GLsizei)width, - (GLsizei)height, - 0, - format, - GL_UNSIGNED_BYTE, - data->getData()); - - return true; - } - - void Glyph::unloadVolatile() - { - // Delete the hardware texture. - if(texture != 0) - { - glDeleteTextures(1, (GLuint*)&texture); - texture = 0; - } - } - - float Glyph::getWidth() const - { - return width; - } - - float Glyph::getHeight() const - { - return height; - } - -} // opengl -} // graphics -} // love diff --git a/src/modules/graphics/opengl/Glyph.h b/src/modules/graphics/opengl/Glyph.h deleted file mode 100644 index 1ffbe279c..000000000 --- a/src/modules/graphics/opengl/Glyph.h +++ /dev/null @@ -1,82 +0,0 @@ -/** -* Copyright (c) 2006-2011 LOVE Development Team -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -**/ - -#ifndef LOVE_GRAPHICS_OPENGL_GLYPH_H -#define LOVE_GRAPHICS_OPENGL_GLYPH_H - -// LOVE -#include -#include -#include -#include -#include -#include -#include - -// OpenGL -#include "GLee.h" -#include - -namespace love -{ -namespace graphics -{ -namespace opengl -{ - - class Glyph : public Drawable, public Volatile - { - private: - - love::font::GlyphData * data; - - float width, height; - - GLuint texture; - - vertex vertices[4]; - - Image::Filter filter; - - public: - - - Glyph(love::font::GlyphData * data, const Image::Filter& filter_ = Image::Filter()); - virtual ~Glyph(); - - bool load(); - void unload(); - - // Implements Volatile. - bool loadVolatile(); - void unloadVolatile(); - - float getWidth() const; - float getHeight() const; - - void draw(float x, float y, float angle, float sx, float sy, float ox, float oy) const; - - }; // Glyph - -} // opengl -} // graphics -} // love - -#endif // LOVE_GRAPHICS_OPENGL_GLYPH_H diff --git a/src/modules/graphics/opengl/Graphics.cpp b/src/modules/graphics/opengl/Graphics.cpp index 65cf30a0b..0efcb9c1e 100644 --- a/src/modules/graphics/opengl/Graphics.cpp +++ b/src/modules/graphics/opengl/Graphics.cpp @@ -281,6 +281,9 @@ namespace opengl // Reset modelview matrix glMatrixMode(GL_MODELVIEW); glLoadIdentity(); + + // Set pixel row alignment + glPixelStorei(GL_UNPACK_ALIGNMENT, 2); // Set the new display mode as the current display mode. currentMode.width = width; @@ -472,9 +475,9 @@ namespace opengl return new Quad(v, sw, sh); } - Font * Graphics::newFont(love::font::FontData * data, const Image::Filter& filter) + Font * Graphics::newFont(love::font::Rasterizer * r, const Image::Filter& filter) { - Font * font = new Font(data, filter); + Font * font = new Font(r, filter); // Load it and check for errors. if(!font) diff --git a/src/modules/graphics/opengl/Graphics.h b/src/modules/graphics/opengl/Graphics.h index e0cec246b..551701737 100644 --- a/src/modules/graphics/opengl/Graphics.h +++ b/src/modules/graphics/opengl/Graphics.h @@ -33,8 +33,6 @@ // LOVE #include -#include - #include #include @@ -261,7 +259,7 @@ namespace opengl /** * Creates a Font object. **/ - Font * newFont(love::font::FontData * data, const Image::Filter& filter = Image::Filter()); + Font * newFont(love::font::Rasterizer * data, const Image::Filter& filter = Image::Filter()); SpriteBatch * newSpriteBatch(Image * image, int size, int usage); diff --git a/src/modules/graphics/opengl/wrap_Glyph.cpp b/src/modules/graphics/opengl/wrap_Glyph.cpp deleted file mode 100644 index fd448f67a..000000000 --- a/src/modules/graphics/opengl/wrap_Glyph.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/** -* Copyright (c) 2006-2011 LOVE Development Team -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -**/ - -// LOVE -#include "wrap_Glyph.h" - -namespace love -{ -namespace graphics -{ -namespace opengl -{ - Glyph * luax_checkglyph(lua_State * L, int idx) - { - return luax_checktype(L, idx, "Glyph", GRAPHICS_GLYPH_T); - } - - static const luaL_Reg functions[] = { - { 0, 0 } - }; - - int luaopen_glyph(lua_State * L) - { - luax_register_type(L, "Glyph", functions); - return 0; - } - -} // opengl -} // graphics -} // love diff --git a/src/modules/graphics/opengl/wrap_Glyph.h b/src/modules/graphics/opengl/wrap_Glyph.h deleted file mode 100644 index 3ae352f9d..000000000 --- a/src/modules/graphics/opengl/wrap_Glyph.h +++ /dev/null @@ -1,41 +0,0 @@ -/** -* Copyright (c) 2006-2011 LOVE Development Team -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -**/ - -#ifndef LOVE_GRAPHICS_OPENGL_WRAP_GLYPH_H -#define LOVE_GRAPHICS_OPENGL_WRAP_GLYPH_H - -// LOVE -#include -#include "Glyph.h" - -namespace love -{ -namespace graphics -{ -namespace opengl -{ - Glyph * luax_checkglyph(lua_State * L, int idx); - int luaopen_glyph(lua_State * L); - -} // opengl -} // graphics -} // love - -#endif // LOVE_GRAPHICS_OPENGL_WRAP_GLYPH_H diff --git a/src/modules/graphics/opengl/wrap_Graphics.cpp b/src/modules/graphics/opengl/wrap_Graphics.cpp index aded2d049..31326bda9 100644 --- a/src/modules/graphics/opengl/wrap_Graphics.cpp +++ b/src/modules/graphics/opengl/wrap_Graphics.cpp @@ -22,7 +22,6 @@ #include #include -#include #include @@ -175,20 +174,6 @@ namespace opengl return 1; } - int w_newGlyph(lua_State * L) - { - love::font::GlyphData * data = luax_checktype(L, 1, "GlyphData", FONT_GLYPH_DATA_T); - - // Create the image. - Glyph * t = new Glyph(data); - t->load(); - - // Push the type. - luax_newtype(L, "Glyph", GRAPHICS_GLYPH_T, (void*)t); - - return 1; - } - int w_newQuad(lua_State * L) { int x = luaL_checkint(L, 1); @@ -234,14 +219,10 @@ namespace opengl luax_convobj(L, idxs, 2, "font", "newRasterizer"); } - // Convert to FontData, if necessary. - if(luax_istype(L, 1, FONT_RASTERIZER_T)) - luax_convobj(L, 1, "font", "newFontData"); - - love::font::FontData * data = luax_checktype(L, 1, "FontData", FONT_FONT_DATA_T); + love::font::Rasterizer * rasterizer = luax_checktype(L, 1, "Rasterizer", FONT_RASTERIZER_T); // Create the font. - Font * font = instance->newFont(data); + Font * font = instance->newFont(rasterizer); if(font == 0) return luaL_error(L, "Could not load font."); @@ -274,14 +255,10 @@ namespace opengl luax_convobj(L, idxs, 2, "font", "newRasterizer"); } - // Convert to FontData, if necessary. - if(luax_istype(L, 1, FONT_RASTERIZER_T)) - luax_convobj(L, 1, "font", "newFontData"); - - love::font::FontData * data = luax_checktype(L, 1, "FontData", FONT_FONT_DATA_T); + love::font::Rasterizer * rasterizer = luax_checktype(L, 1, "Rasterizer", FONT_RASTERIZER_T); // Create the font. - Font * font = instance->newFont(data, img_filter); + Font * font = instance->newFont(rasterizer, img_filter); if(font == 0) return luaL_error(L, "Could not load font."); @@ -469,14 +446,10 @@ namespace opengl luax_convobj(L, idxs, 2, "font", "newRasterizer"); } - // Convert to FontData, if necessary. - if(luax_istype(L, 1, FONT_RASTERIZER_T)) - luax_convobj(L, 1, "font", "newFontData"); - - love::font::FontData * data = luax_checktype(L, 1, "FontData", FONT_FONT_DATA_T); + love::font::Rasterizer * rasterizer = luax_checktype(L, 1, "Rasterizer", FONT_RASTERIZER_T); // Create the font. - font = instance->newFont(data); + font = instance->newFont(rasterizer); if(font == 0) return luaL_error(L, "Could not load font."); @@ -934,7 +907,6 @@ namespace opengl { "present", w_present }, { "newImage", w_newImage }, - { "newGlyph", w_newGlyph }, { "newQuad", w_newQuad }, { "newFont1", w_newFont1 }, { "newImageFont", w_newImageFont }, @@ -1017,7 +989,6 @@ namespace opengl static const lua_CFunction types[] = { luaopen_font, luaopen_image, - luaopen_glyph, luaopen_frame, luaopen_spritebatch, luaopen_particlesystem, diff --git a/src/modules/graphics/opengl/wrap_Graphics.h b/src/modules/graphics/opengl/wrap_Graphics.h index 0c5fb1163..e6b1a635a 100644 --- a/src/modules/graphics/opengl/wrap_Graphics.h +++ b/src/modules/graphics/opengl/wrap_Graphics.h @@ -24,7 +24,6 @@ // LOVE #include "wrap_Font.h" #include "wrap_Image.h" -#include "wrap_Glyph.h" #include "wrap_Quad.h" #include "wrap_SpriteBatch.h" #include "wrap_ParticleSystem.h" @@ -52,7 +51,6 @@ namespace opengl int w_setScissor(lua_State * L); int w_getScissor(lua_State * L); int w_newImage(lua_State * L); - int w_newGlyph(lua_State * L); int w_newQuad(lua_State * L); int w_newFrame(lua_State * L); int w_newFont1(lua_State * L);