Re: [PyOpenGL-Users] Texture mapped font. Improve antialiasing
Brought to you by:
mcfletch
From: Black <py...@bl...> - 2008-07-11 16:36:43
|
As a side note, this probably has little to do with PyOpenGL and you might get more responses form a list more dedicated to OpenGL debugging.... That said, it is not clear what you mean by "not looking as smooth as it has to" and you don't include anything about what the texture looks like, where it came from or how you are using it, so it is hard to know what you are doing "wrong". It is slightly suspicious to me that you are using an RGBA texture for fonts, but maybe that is just me. The one generic piece of advice I can give you about choppy looking texture mapped fonts is that I found that on some systems I had problems if the quads I was mapping the texture to weren't pixel aligned to the display (i.e., placed in such a way that the vertices of the quad didn't correspond to actual pixels). On Jul 11, 2008, at 12:14 PM, Prashant Saxena wrote: > 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) > > ------------------------------------------------------------------------- > Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! > Studies have shown that voting for your favorite open source project, > along with a healthy diet, reduces your potential for chronic lameness > and boredom. Vote Now athttp://www.sourceforge.net/community/cca08_______________________________________________ > PyOpenGL Homepage > http://pyopengl.sourceforge.net > _______________________________________________ > PyOpenGL-Users mailing list > PyO...@li... > https://lists.sourceforge.net/lists/listinfo/pyopengl-users |