Skip to main content
GameDev.net gamedev.net
🔒 Locked

Offset problem with OpenGL implementation of Angelcode bitmap font

Started by Byron Dec 23, 2008 at 4:18 PM 0 replies 1.6k views
Original Post
Byron
Byron
I am having a slight problem with my implementation of the Angelcode bitmap font code. I am seeing slight offsets in some of the glyphs. I have an example here: http://www.xiotexstudios.com/xiotex-day-2-on-christmas-windows-textures-and-fonts/ click on the image to get a bigger version. If you look at the window titled 'World map' the 'or' is slightly lower than the 'W' I am more used to coding in DirectX - is this a similar issue to the texel centre problem? The code is here (it's drawn using GL_QUADS):


		fCharX = m_pGlyphPages->m_Glyphs[iChar].m_fX;
		fCharY = m_pGlyphPages->m_Glyphs[iChar].m_fY;
		fWidth = m_pGlyphPages->m_Glyphs[iChar].m_fWidth;
		fHeight = m_pGlyphPages->m_Glyphs[iChar].m_fHeight;
		fOffsetX = m_pGlyphPages->m_Glyphs[iChar].m_fXOffset;
		fOffsetY = m_pGlyphPages->m_Glyphs[iChar].m_fYOffset;
		
		float fLeft = fCursorX + fOffsetX;
		float fTop = fY + fOffsetY;
		float fRight = fLeft + fWidth;
		float fBottom = fTop + fHeight;
				
		fCursorX += fKerning;
		
		// Create the UV's
		fU0 = ((fCharX) / m_pGlyphPages->m_fWidth);
		fU1 = ((fCharX + fWidth) / m_pGlyphPages->m_fWidth);
		fV1 = ((fCharY) / m_pGlyphPages->m_fHeight);
		fV0 = ((fCharY + fHeight) / m_pGlyphPages->m_fHeight);

		
		glTexCoord2f(fU0,fV1);		
		glVertex3f(fLeft,fTop,0.0f);
		
		glTexCoord2f(fU1,fV1);
		glVertex3f(fRight,fTop,0.0f);

		glTexCoord2f(fU1,fV0);
		glVertex3f(fRight,fBottom,0.0f);

		glTexCoord2f(fU0,fV0);
		glVertex3f(fLeft,fBottom,0.0f);
		
	
		
		fCursorX += m_pGlyphPages->m_Glyphs[iChar].m_fAdvance;

Any ideas?
ByronBoxes
Byron
Byron
Found the problem - there is a bug in the latest version of the Bitmap font generator. I went back to an older version and the problem goes away.

ByronBoxes

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.