mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
Font texture atlases can be created in Core Profile GL3.
--HG-- branch : minor
This commit is contained in:
@@ -85,6 +85,14 @@ void Font::createTexture()
|
||||
bool sRGB = isGammaCorrect();
|
||||
OpenGL::TextureFormat fmt = gl.convertPixelFormat(pixelFormat, false, sRGB);
|
||||
|
||||
if (fmt.swizzled)
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, fmt.swizzle[0]);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, fmt.swizzle[1]);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, fmt.swizzle[2]);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, fmt.swizzle[3]);
|
||||
}
|
||||
|
||||
// Initialize the texture with transparent black.
|
||||
std::vector<GLubyte> emptydata(size.width * size.height * bpp, 0);
|
||||
|
||||
|
||||
@@ -868,9 +868,21 @@ OpenGL::TextureFormat OpenGL::convertPixelFormat(PixelFormat pixelformat, bool r
|
||||
break;
|
||||
|
||||
case PIXELFORMAT_LA8:
|
||||
f.internalformat = GL_LUMINANCE8_ALPHA8;
|
||||
f.externalformat = GL_LUMINANCE_ALPHA;
|
||||
f.type = GL_UNSIGNED_BYTE;
|
||||
if (gl.isCoreProfile() || GLAD_ES_VERSION_3_0)
|
||||
{
|
||||
f.internalformat = GL_RG8;
|
||||
f.externalformat = GL_RG;
|
||||
f.type = GL_UNSIGNED_BYTE;
|
||||
f.swizzled = true;
|
||||
f.swizzle[0] = f.swizzle[1] = f.swizzle[2] = GL_RED;
|
||||
f.swizzle[3] = GL_GREEN;
|
||||
}
|
||||
else
|
||||
{
|
||||
f.internalformat = GL_LUMINANCE8_ALPHA8;
|
||||
f.externalformat = GL_LUMINANCE_ALPHA;
|
||||
f.type = GL_UNSIGNED_BYTE;
|
||||
}
|
||||
break;
|
||||
|
||||
case PIXELFORMAT_RGBA4:
|
||||
|
||||
@@ -92,6 +92,9 @@ public:
|
||||
GLenum internalformat = 0;
|
||||
GLenum externalformat = 0;
|
||||
GLenum type = 0;
|
||||
|
||||
bool swizzled = false;
|
||||
GLint swizzle[4];
|
||||
};
|
||||
|
||||
class TempDebugGroup
|
||||
|
||||
Reference in New Issue
Block a user