glGenTextures(1, &font.tex);
glBindTexture(GL_TEXTURE_2D, font.tex);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, width, height,
- 0, GL_RED, GL_UNSIGNED_BYTE, 0);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_INTENSITY8, width, height,
+ 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, 0);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
auto* g = face->glyph;
glTexSubImage2D(GL_TEXTURE_2D, 0, offsetX, offsetY,
g->bitmap.width, g->bitmap.rows,
- GL_RED, GL_UNSIGNED_BYTE,
+ GL_LUMINANCE, GL_UNSIGNED_BYTE,
g->bitmap.buffer);
auto& d = font.data[c-32];
{
if (fontData.find(font) == fontData.end())
return;
-
- y += fontData[font].fontSize;
-
auto& vector = fontData[font].text;
- if (auto i = std::find_if(vector.begin(), vector.end(), [&x, &y](const Text& t) {
- return t.x == x && t.y == y; }); i != vector.end()) {
- vector.erase(i);
+
+ y = -(y + fontData[font].fontSize);
+
+ const auto it = std::find_if(vector.begin(), vector.end(),
+ [&x, &y](const Text& t) {
+ return t.x == static_cast<int>(x) && t.y == static_cast<int>(y);
+ });
+ if (it != vector.end()) {
+ *it = Text(text, x, y);
+ } else {
+ // Invert y axis so positive grows south.
+ fontData[font].text.emplace_back(text, x, y);
}
- // Invert y axis so positive grows south.
- fontData[font].text.emplace_back(text, x, -y, -9.0f);
shouldUpdateVBOs = true;
}
#include <string>
static NewRenderEvent NRE (0, 0, 0, 0);
-static const unsigned int NRE_TEX_DATA = 0xFF0000FF;
+static const unsigned int NRE_TEX_DATA = 0xBBBBBBBB;
static std::basic_string<TextMeshData> buffer;
void UISystem::configure(entityx::EntityManager&, entityx::EventManager&)
glGenTextures(1, &NRE.tex);
glBindTexture(GL_TEXTURE_2D, NRE.tex);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, &NRE_TEX_DATA);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &NRE_TEX_DATA);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- buffer += { 30, -50, -8, 0, 0, 1 };
- buffer += { 160, -50, -8, 0, 0, 1 };
- buffer += { 160, -10, -8, 0, 0, 1 };
- buffer += { 160, -10, -8, 0, 0, 1 };
- buffer += { 30, -10, -8, 0, 0, 1 };
- buffer += { 30, -50, -8, 0, 0, 1 };
+ buffer += { 30, -50, -5, 0, 0, 1 };
+ buffer += { 160, -50, -5, 0, 0, 1 };
+ buffer += { 160, -10, -5, 0, 0, 1 };
+ buffer += { 160, -10, -5, 0, 0, 1 };
+ buffer += { 30, -10, -5, 0, 0, 1 };
+ buffer += { 30, -50, -5, 0, 0, 1 };
glBindBuffer(GL_ARRAY_BUFFER, NRE.vbo);
glBufferData(GL_ARRAY_BUFFER,