OpenGL - Freetype-GL Issues

Soldato
Joined
8 Jan 2012
Posts
2,802
So I've been following a series of youtube videos for a while to create an OpenGL graphics engine. I'm using the FreeType and FreeTypeGL libraries to render text to the screen.

However, for whatever reason... Text just doesn't render!

The font atlas exists, the font exists and a glyph IS loaded in. All of the memory checks out fine.. I can't think of any reason as to why it's just like "Yeah no not doing it"

The video I followed was this one:

https://youtu.be/Rsdc6I80aFQ?list=PLlrATfBNZ98fqE45g3jZA_hLGUrD4bo6_&t=2237

If you rewind a few minutes you'll see the atlas/font being created etc in the init function. My codes literally word for word perfect as far as I can see. BUT just to make sure, I'll include it here.

The batch renderer draw string code:

Code:
void BatchRenderer2D::drawString(const std::string& text, const maths::vec3& position, const maths::vec4& color)
		{
			using namespace ftgl;

			float ts = 0.0f;

			bool found = false;

			for (int i = 0; i < m_TextureSlots.size(); i++)
			{
				if (m_TextureSlots[i] == m_FTAtlas->id)
				{
					ts = (float)(i + 1);
					found = true;
					break;
				}

			}

			if (!found)
			{
				if (m_TextureSlots.size() >= 32)
				{
					end();
					flush();
					begin();
				}
				m_TextureSlots.push_back(m_FTAtlas->id);
				ts = (float)(m_TextureSlots.size());
			}

			m_Buffer->vertex = maths::vec3(-8, -8, 0);
			m_Buffer->uv = maths::vec2(0, 1);
			m_Buffer->tid = ts;
			m_Buffer++;

			m_Buffer->vertex = maths::vec3(-8, 8, 0);
			m_Buffer->uv = maths::vec2(0, 0);
			m_Buffer->tid = ts;
			m_Buffer++;

			m_Buffer->vertex = maths::vec3(8, 8, 0);
			m_Buffer->uv = maths::vec2(1, 0);
			m_Buffer->tid = ts;
			m_Buffer++;

			m_Buffer->vertex = maths::vec3(8, -8, 0);
			m_Buffer->uv = maths::vec2(1, 1);
			m_Buffer->tid = ts;
			m_Buffer++;

			m_IndexCount += 6;
			
		}

The init function with the atlas/font created only (snipped code out):

Code:
void BatchRenderer2D::init()
		{

			m_FTAtlas = ftgl::texture_atlas_new(512, 512, 1);
			m_FTFont = ftgl::texture_font_new_from_file(m_FTAtlas, 20, "arial.ttf");

			ftgl::texture_font_get_glyph(m_FTFont, 'A');
		}

I can't think of anything else that would be useful to include. But if there is anything. The help would be greatly appreciated (as would some fresh eyes incase I've missed something glaringly obvious!)
 
Back
Top Bottom