Another update on FTGL texture fonts drawing. Added the same floor() trick

to precisely align the glyphs to pixel coordinates as used in the Pixmap
version. It now looks fully identical here.
This commit is contained in:
Ton Roosendaal 2005-05-11 21:09:13 +00:00
parent 6bc1dd4665
commit 884c94500b
2 changed files with 11 additions and 6 deletions

@ -54,27 +54,32 @@ FTTextureGlyph::FTTextureGlyph( FT_GlyphSlot glyph, int id, int xOffset, int yOf
FTTextureGlyph::~FTTextureGlyph() FTTextureGlyph::~FTTextureGlyph()
{} {}
#include <math.h>
float FTTextureGlyph::Render( const FTPoint& pen) float FTTextureGlyph::Render( const FTPoint& pen)
{ {
float dx;
glGetIntegerv( GL_TEXTURE_2D_BINDING_EXT, &activeTextureID); glGetIntegerv( GL_TEXTURE_2D_BINDING_EXT, &activeTextureID);
if( activeTextureID != glTextureID) if( activeTextureID != glTextureID)
{ {
glBindTexture( GL_TEXTURE_2D, (GLuint)glTextureID); glBindTexture( GL_TEXTURE_2D, (GLuint)glTextureID);
} }
dx= floor( (pen.x + pos.x ) );
glBegin( GL_QUADS); glBegin( GL_QUADS);
glTexCoord2f( uv[0].x, uv[0].y); glTexCoord2f( uv[0].x, uv[0].y);
glVertex2f( pen.x + pos.x, pen.y + pos.y); glVertex2f( dx, pen.y + pos.y);
glTexCoord2f( uv[0].x, uv[1].y); glTexCoord2f( uv[0].x, uv[1].y);
glVertex2f( pen.x + pos.x, pen.y + pos.y - destHeight); glVertex2f( dx, pen.y + pos.y - destHeight);
glTexCoord2f( uv[1].x, uv[1].y); glTexCoord2f( uv[1].x, uv[1].y);
glVertex2f( pen.x + destWidth + pos.x, pen.y + pos.y - destHeight); glVertex2f( dx + destWidth, pen.y + pos.y - destHeight);
glTexCoord2f( uv[1].x, uv[0].y); glTexCoord2f( uv[1].x, uv[0].y);
glVertex2f( pen.x + destWidth + pos.x, pen.y + pos.y); glVertex2f( dx + destWidth, pen.y + pos.y);
glEnd(); glEnd();
return advance; return advance;

@ -2281,10 +2281,10 @@ void drawinfospace(ScrArea *sa, void *spacedata)
if(curarea->winx<=1280.0) { if(curarea->winx<=1280.0) {
fac= ((float)curarea->winx)/1280.0f; fac= ((float)curarea->winx)/1280.0f;
myortho2(0.0, 1280.0, 0.0, curarea->winy/fac); myortho2(0.375, 1280.375, 0.375, curarea->winy/fac + 0.375);
} }
else { else {
myortho2(0.0, (float)curarea->winx, 0.0, (float)curarea->winy); myortho2(0.375, (float)curarea->winx + 0.375, 0.375, (float)curarea->winy + 0.375);
} }
sprintf(naam, "infowin %d", curarea->win); sprintf(naam, "infowin %d", curarea->win);