Take the 2-minute tour ×

With OpenGL, is there any way to render two textures at the same position and blend them together with alpha blending so that one appears on top of the other? I am trying to make it so that my back-texture can be dynamic on the secondary texture will have a 'window' that will show the texture 'behind' it. I have done quite a bit of research and have tried several combinations of glDepthFunc, glBlendFunc, etc. and have not found any combination that works. I am guessing that this is possible, but just haven't found the trick.

share|improve this question
add comment

1 Answer

its been awhile, but ill try to help some?

first you have to have GL_BLEND enabled


and then i usually have to follow that with a


But i usually use delphi so not sure how closely this will help you..

share|improve this answer
That's pretty much the same use as in what I'm using (Java), but I still end up with z-fights when trying that one. –  Matchlighter Feb 4 '13 at 8:31
um not sure what you mean by zfights, but the farther one should have a less alpha then the front one. and less diffusion alpha.. Sorry not more help :/ –  Glen Morse Feb 4 '13 at 8:48
Spatially, there is no back and front. (there is one rendered first and one second, but they are occupying the same space.) I am sure (in fact I know) that the method you have given works when they aren't in the same space, but... –  Matchlighter Feb 4 '13 at 9:05
Ahh , so the objects are exactly the same x,y,z and you what the two colors to blend...like one color is red , one is blue . you expect to see a purpleish color..? –  Glen Morse Feb 4 '13 at 9:09
Sort of, but only when transparent. So, if A is blue and B is red, red will be the only color, unless B is transparent, then it alpha blends. –  Matchlighter Feb 4 '13 at 9:14
add comment

Your Answer


