Convert code to a more readable format
This commit is contained in:
parent
1cc8371ac5
commit
71c14ff0b3
@ -204,6 +204,7 @@ void FontWithFace::insertGlyph(wchar_t c, const GlyphInfo& gi)
|
|||||||
#ifndef SERVER_ONLY
|
#ifndef SERVER_ONLY
|
||||||
video::ITexture* tex = m_spritebank->getTexture(cur_tex);
|
video::ITexture* tex = m_spritebank->getTexture(cur_tex);
|
||||||
glBindTexture(GL_TEXTURE_2D, tex->getOpenGLTextureName());
|
glBindTexture(GL_TEXTURE_2D, tex->getOpenGLTextureName());
|
||||||
|
assert(bits->pixel_mode == FT_PIXEL_MODE_GRAY);
|
||||||
if (CVS->isARBTextureSwizzleUsable())
|
if (CVS->isARBTextureSwizzleUsable())
|
||||||
{
|
{
|
||||||
glTexSubImage2D(GL_TEXTURE_2D, 0, m_used_width, m_used_height,
|
glTexSubImage2D(GL_TEXTURE_2D, 0, m_used_width, m_used_height,
|
||||||
@ -211,37 +212,14 @@ void FontWithFace::insertGlyph(wchar_t c, const GlyphInfo& gi)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::vector<uint32_t> image_data;
|
const unsigned int size = bits->width * bits->rows;
|
||||||
image_data.resize(texture_size.Width * texture_size.Height,
|
uint8_t* image_data = new uint8_t[size * 4];
|
||||||
video::SColor(0, 255, 255, 255).color);
|
memset(image_data, 255, size * 4);
|
||||||
switch (bits->pixel_mode)
|
for (unsigned int i = 0; i < size; i++)
|
||||||
{
|
image_data[4 * i + 3] = bits->buffer[i];
|
||||||
case FT_PIXEL_MODE_GRAY:
|
|
||||||
{
|
|
||||||
// Load the grayscale data in.
|
|
||||||
const float gray_count = static_cast<float>(bits->num_grays);
|
|
||||||
const unsigned int image_pitch =
|
|
||||||
4 * texture_size.Width / sizeof(unsigned int);
|
|
||||||
uint8_t* glyph_data = bits->buffer;
|
|
||||||
for (unsigned int y = 0; y < (unsigned)bits->rows; y++)
|
|
||||||
{
|
|
||||||
uint8_t* row = glyph_data;
|
|
||||||
for (unsigned int x = 0; x < (unsigned)bits->width; x++)
|
|
||||||
{
|
|
||||||
image_data.data()[y * image_pitch + x] |=
|
|
||||||
static_cast<uint32_t>(255.0f *
|
|
||||||
(static_cast<float>(*row++) / gray_count)) << 24;
|
|
||||||
}
|
|
||||||
glyph_data += bits->pitch;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
glTexSubImage2D(GL_TEXTURE_2D, 0, m_used_width, m_used_height,
|
glTexSubImage2D(GL_TEXTURE_2D, 0, m_used_width, m_used_height,
|
||||||
texture_size.Width, texture_size.Height, GL_BGRA, GL_UNSIGNED_BYTE,
|
bits->width, bits->rows, GL_BGRA, GL_UNSIGNED_BYTE, image_data);
|
||||||
image_data.data());
|
delete[] image_data;
|
||||||
}
|
}
|
||||||
if (tex->hasMipMaps())
|
if (tex->hasMipMaps())
|
||||||
glGenerateMipmap(GL_TEXTURE_2D);
|
glGenerateMipmap(GL_TEXTURE_2D);
|
||||||
|
@ -67,12 +67,6 @@
|
|||||||
#include "utils/vs.hpp"
|
#include "utils/vs.hpp"
|
||||||
|
|
||||||
#include <irrlicht.h>
|
#include <irrlicht.h>
|
||||||
#if defined(USE_GLES2)
|
|
||||||
#define _IRR_COMPILE_WITH_OGLES2_
|
|
||||||
#include "../../lib/irrlicht/source/Irrlicht/COGLES2Texture.h"
|
|
||||||
#else
|
|
||||||
#include "../../lib/irrlicht/source/Irrlicht/COpenGLTexture.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Build-time check that the Irrlicht we're building against works for us.
|
/* Build-time check that the Irrlicht we're building against works for us.
|
||||||
* Should help prevent distros building against an incompatible library.
|
* Should help prevent distros building against an incompatible library.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user