PDA

View Full Version : Clearest method of drawing a texture to 2D screen



Kiamo
04-28-2005, 06:36 AM
Hello, I have a font system using FreeType to rasterize TrueType fonts to textures, which I then draw to the screen on tri strips to display text. The problem with this is it seems that the text could be clearer if I was drawing it with some form of raster copy to get a 1:1 copy and have no filtering blurring it.

So I was wondering what is the best method of drawing a texture to the screen to prevent any sort of filtering and just get a 1:1 copy? I know of glDrawPixels, but I'd like to use a texture so I don't have to copy the image data over the bus every single time.

Thanks for any help!

yooyo
04-28-2005, 08:04 AM
Easy...
1. Disable filtering (use GL_NEAREST)
2. Setup correct matrices:

// Code below "switch" OPenGL to 2D mode.
// Upper left corner is (0,0).
// Provide size as size of your viewport
void Begin2DMode(vec2i size)
{
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0.0, size.x, size.y, 0.0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
}

void End2DMode()
{
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix());
glMatrixMode(GL_MODELVIEW);
}
// Example of usage
void Render()
{
// render 3d stuff
Begin2DMode(viewport_size);
// render text and other 2d stuff here
End2DMode();
}yooyo