I posted about this subject before, I got some good tips, but I can’t get it running.
I have a font-rendering routine written with pyOpenGL. The font is a bitmap with luminance/alpha. I would like to show this bitmap (font) in the colour of my choice.
The actula rendering code looks like this:
(Python code!)
When I remove the blending part (glBlendFunc,glBlendColorEXT, glEnable) I get a fine font in white. The code above gives me red squares with the size of the bitmap. The really puzzeling thing is that this even happens with an alpha of 0.0.
I contacted the maintainer of pyOpenGL, and he can’t explain this behaviour either. Does anyone have a suggestion how to solve the problem?
It would mean that I remove the display-list code that I use. At the moment I call glRasterPos2f( x,y ) and the display-list. This can not be done if I would use textures. A complete rewrite would be necessary. Apart from bandwidth considerations, are there other weighty arguments to prefer textures over bitmaps?
If the raster position gets clipped, then glDrawPixels won’t have any effect, even if part of the text is inside the viewport.
It won’t be a total rewrite. Just put your pixels in textures. Use rect textures instead of 2D.
>>>When I remove the blending part (glBlendFunc,glBlendColorEXT, glEnable) I get a fine font in white. The code above gives me red squares with the size of the bitmap. The really puzzeling thing is that this even happens with an alpha of 0.0<<<
I beleive that is the correct behavior.
What were you expecting?
>If the raster position gets clipped, then
> glDrawPixels won’t have any effect, even if
> part of the text is inside the viewport.
I’m sorry, but I don’t understand what you refer to.
>It won’t be a total rewrite. Just put your pixels
> in textures. Use rect textures instead of 2D.
I went through the OpenGL PG forward and backward. Unfortunately there was no mention of rect textures. glBindTexture has no such thing, and I don’t know another way to put them back.
>>>When I remove the blending part (glBlendFunc,glBlendColorEXT, glEnable) I get a fine font in white. The code above gives me red squares with the size of the bitmap. The really puzzeling thing is that this even happens with an alpha of 0.0<<<
> I beleive that is the correct behavior.
I see your point: the alpha has no effect.
> What were you expecting?
I expected that the luminance data in my bitmap would be replaced by the colour of my choice, and the alpha would remain as it was.
The NeHe lesson is usable on MS-Windows only, which I dont’ use. Concerning the bitmaps/textures: NeHe shows the use of bitmaps, similar to my approach.
Originally posted by fwest:
[b]>If the raster position gets clipped, then
> glDrawPixels won’t have any effect, even if
> part of the text is inside the viewport.
I’m sorry, but I don’t understand what you refer to.
>It won’t be a total rewrite. Just put your pixels
> in textures. Use rect textures instead of 2D.
I went through the OpenGL PG forward and backward. Unfortunately there was no mention of rect textures. glBindTexture has no such thing, and I don’t know another way to put them back.
[/b]
In a previous post, you said :
Apart from bandwidth considerations, are there other weighty arguments to prefer textures over bitmaps?
so I gave a “weighty arguments to prefer textures over bitmaps.”
By rect texture, I mean GL_NV_texture_rectangle / GL_EXT_texture_rectangle / GL_ARB_texture_rectangle