[PyOpenGL-Users] Texture mapped font. Improve antialiasing
Brought to you by:
mcfletch
From: Prashant S. <ani...@ya...> - 2008-07-11 16:14:37
|
Hi, I am using texture mapped polygon technique to display strings on canvas. The texture is in 'tiff' format with alpha channel. Problem is that the font is not looking as smooth as it has to. This is my 'init' function: def InitGL(self): self.size = self.GetClientSize() glEnable(GL_BLEND) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) glEnable(GL_TEXTURE_2D) glEnable(GL_LINE_SMOOTH) glHint(GL_LINE_SMOOTH_HINT, GL_NICEST) glClearColor(0.5, 0.5, 0.5, 0.0) glDisable(GL_DEPTH_TEST) glShadeModel(GL_SMOOTH) glMatrixMode(GL_PROJECTION) glLoadIdentity() glOrtho( 0.0, self.size.width, self.size.height, 0.0, -1.0, 1.0 ) glMatrixMode(GL_MODELVIEW) This is my font texture file loader: textureSurface = Image.open(textureFile) textureData = textureSurface.convert( "RGBA").tostring() width, height = textureSurface.size[0], textureSurface.size[1] #Bind it to a texture textureId = glGenTextures(1) fontTexture[0] = textureId glBindTexture(GL_TEXTURE_2D, textureId) glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureData ) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR) |