Texture questions...

I have 2 skin texturing questions…

  1. Is there any way to use GL_NEAREST filtering on my texture, and then limit the alpha channel to 0 or 1 when rendering to the frame buffer? My render is not depth-sorted, so to allow reasonable rendering, my textures are clamped to alpha channel = 0 or 1 during loading of the textures, providing masking textures. However, there are still problems at edges when using GL_NEAREST filtering, where the alpha channel is interpolated. GL_LINEAR is fine, just a bit blocky. So, if I can use GL_NEAREST, and then set a threshold alpha level after the texture interpolation, and the pixel can be rendered with alpha 0 or 1, this would give a smoother edge, and also allow the rest of my texture to be GL_NEAREST.

(Maybe I should bite the bullet and depth-sort everything, but rendering speed is more important than perfect transparency, and depth-sorting is also going to add a lot of complexity to my application, so I really don’t want to do this.)

  1. What is the best way to share textures between windows of an MDI application. Should I be sharing display lists and textures between rendering contexts, or should I be writing my app with one display context and using the one context across mutiple MDI windows?

yes, it’s called alpha testing and is pretty simple to set up.



Thanks for the reply. However, this isn’t quite what I’m after. This will suppress output of pixels that are less than the threshold, but will render any pixels above the threshold at their original alpha value, so pixels at .51 will be rendered at partial opacity. I already had an AlphaFunc limiting to 0.05.

But, I now realise that this is half the solution. Adding a special blend mode of glBlend(SRC_ONE, SRC_ZERO) should complete the picture. Thanks for your help. :slight_smile:

(BTW, I’ve already solved #2 by adding a dummy gl context to my MainFrame window, and this context just stores all the texture maps. All the child windows glShareList() to this parent context. It works well, and pre-binding the textures is a great performance improvement.)