Fixed font textures in OpenGL returning black RGB values when a shader is active (reverts changeset 69b0b4e)

This commit is contained in:
Alex Szpakowski
2013-12-31 22:09:04 -04:00
parent 90f4dea4ab
commit 98b258b75f
4 changed files with 19 additions and 15 deletions
+6 -6
View File
@@ -73,7 +73,7 @@ Font::Font(love::font::Rasterizer *r, const Image::Filter &filter)
try
{
gd = r->getGlyphData(32);
type = (gd->getFormat() == love::font::GlyphData::FORMAT_ALPHA) ? FONT_TRUETYPE : FONT_IMAGE;
type = (gd->getFormat() == love::font::GlyphData::FORMAT_LUMINANCE_ALPHA) ? FONT_TRUETYPE : FONT_IMAGE;
loadVolatile();
}
@@ -96,7 +96,7 @@ Font::~Font()
bool Font::initializeTexture(GLenum format)
{
GLint internalformat = (format == GL_ALPHA) ? GL_ALPHA8 : GL_RGBA8;
GLint internalformat = (format == GL_LUMINANCE_ALPHA) ? GL_LUMINANCE8_ALPHA8 : GL_RGBA8;
// clear errors before initializing
while (glGetError() != GL_NO_ERROR);
@@ -130,7 +130,7 @@ void Font::createTexture()
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
GLenum format = (type == FONT_TRUETYPE ? GL_ALPHA : GL_RGBA);
GLenum format = (type == FONT_TRUETYPE ? GL_LUMINANCE_ALPHA : GL_RGBA);
// Initialize the texture, attempting smaller sizes if initialization fails.
bool initialized = false;
@@ -156,9 +156,9 @@ void Font::createTexture()
throw love::Exception("Could not create font texture!");
}
// Fill the texture with transparent black.
std::vector<GLubyte> emptyData(textureWidth * textureHeight * (type == FONT_TRUETYPE ? 1 : 4), 0);
std::vector<GLubyte> emptyData(textureWidth * textureHeight * (type == FONT_TRUETYPE ? 2 : 4), 0);
glTexSubImage2D(GL_TEXTURE_2D,
0,
0, 0,
@@ -208,7 +208,7 @@ Font::Glyph *Font::addGlyph(uint32 glyph)
textureX,
textureY,
w, h,
(type == FONT_TRUETYPE ? GL_ALPHA : GL_RGBA),
(type == FONT_TRUETYPE ? GL_LUMINANCE_ALPHA : GL_RGBA),
GL_UNSIGNED_BYTE,
gd->getData());