mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +02:00
Fixed font textures in OpenGL returning black RGB values when a shader is active (reverts changeset 69b0b4e)
This commit is contained in:
@@ -43,8 +43,8 @@ GlyphData::GlyphData(uint32 glyph, GlyphMetrics glyphMetrics, GlyphData::Format
|
||||
{
|
||||
switch (f)
|
||||
{
|
||||
case GlyphData::FORMAT_ALPHA:
|
||||
data = new unsigned char[metrics.width * metrics.height];
|
||||
case GlyphData::FORMAT_LUMINANCE_ALPHA:
|
||||
data = new unsigned char[metrics.width * metrics.height * 2];
|
||||
break;
|
||||
case GlyphData::FORMAT_RGBA:
|
||||
default:
|
||||
@@ -68,8 +68,8 @@ int GlyphData::getSize() const
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case GlyphData::FORMAT_ALPHA:
|
||||
return getWidth() * getHeight();
|
||||
case GlyphData::FORMAT_LUMINANCE_ALPHA:
|
||||
return getWidth() * getHeight() * 2;
|
||||
break;
|
||||
case GlyphData::FORMAT_RGBA:
|
||||
default:
|
||||
@@ -168,7 +168,7 @@ bool GlyphData::getConstant(GlyphData::Format in, const char *&out)
|
||||
|
||||
StringMap<GlyphData::Format, GlyphData::FORMAT_MAX_ENUM>::Entry GlyphData::formatEntries[] =
|
||||
{
|
||||
{"alpha", GlyphData::FORMAT_ALPHA},
|
||||
{"luminance alpha", GlyphData::FORMAT_LUMINANCE_ALPHA},
|
||||
{"rgba", GlyphData::FORMAT_RGBA},
|
||||
};
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
|
||||
enum Format
|
||||
{
|
||||
FORMAT_ALPHA,
|
||||
FORMAT_LUMINANCE_ALPHA,
|
||||
FORMAT_RGBA,
|
||||
FORMAT_MAX_ENUM
|
||||
};
|
||||
|
||||
@@ -86,7 +86,7 @@ GlyphData *TrueTypeRasterizer::getGlyphData(uint32 glyph) const
|
||||
glyphMetrics.width = bitmap.width;
|
||||
glyphMetrics.advance = face->glyph->metrics.horiAdvance >> 6;
|
||||
|
||||
GlyphData *glyphData = new GlyphData(glyph, glyphMetrics, GlyphData::FORMAT_ALPHA);
|
||||
GlyphData *glyphData = new GlyphData(glyph, glyphMetrics, GlyphData::FORMAT_LUMINANCE_ALPHA);
|
||||
|
||||
const uint8 *pixels = bitmap.buffer;
|
||||
uint8 *dest = (uint8 *) glyphData->getData();
|
||||
@@ -100,7 +100,8 @@ GlyphData *TrueTypeRasterizer::getGlyphData(uint32 glyph) const
|
||||
{
|
||||
// Extract the 1-bit value and convert it to uint8.
|
||||
uint8 v = ((pixels[x / 8]) & (1 << (7 - (x % 8)))) ? 255 : 0;
|
||||
dest[y * bitmap.width + x] = v;
|
||||
dest[2 * (y * bitmap.width + x) + 0] = 255;
|
||||
dest[2 * (y * bitmap.width + x) + 1] = v;
|
||||
}
|
||||
|
||||
pixels += bitmap.pitch;
|
||||
@@ -111,7 +112,10 @@ GlyphData *TrueTypeRasterizer::getGlyphData(uint32 glyph) const
|
||||
for (int y = 0; y < bitmap.rows; y++)
|
||||
{
|
||||
for (int x = 0; x < bitmap.width; x++)
|
||||
dest[y * bitmap.width + x] = pixels[x];
|
||||
{
|
||||
dest[2 * (y * bitmap.width + x) + 0] = 255;
|
||||
dest[2 * (y * bitmap.width + x) + 1] = pixels[x];
|
||||
}
|
||||
|
||||
pixels += bitmap.pitch;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user