OpenGL Functions
by Daniel Ly · in Torque Game Engine · 07/07/2006 (12:10 pm) · 3 replies
Hey,
I've been trying to blend only the alpha maps of textures using OpenGL's glBlendFunc. The function is supposed to be blending both the colours and the alpha channels according to the inputs. Unfortunately, it appears that its only blending the RGB channels without paying any contributions of the alphas. When I looked into it a bit deeper, it appears that the glBlendFunc is being referenced to the OpenGL2D3D libraries (which transform the glBlendFunc into Direct3D functions) and not the actual OpenGL libraries.
Also, the glBlendFunc is not the function I should be using; I actually should be using glBlendFuncSeparate which allows me to blend the colour and alpha maps separately. Unforuntely, when I call it, the compiler can't even find the definition for it, even though its a standard function in OpenGL.
Anyone know what's going on with the OpenGL library? Either finding a way to get glBlendFunc affect the alpha channels or how I can get the glBlendFuncSeparate function working would be a great help!
Thanks,
Daniel
I've been trying to blend only the alpha maps of textures using OpenGL's glBlendFunc. The function is supposed to be blending both the colours and the alpha channels according to the inputs. Unfortunately, it appears that its only blending the RGB channels without paying any contributions of the alphas. When I looked into it a bit deeper, it appears that the glBlendFunc is being referenced to the OpenGL2D3D libraries (which transform the glBlendFunc into Direct3D functions) and not the actual OpenGL libraries.
Also, the glBlendFunc is not the function I should be using; I actually should be using glBlendFuncSeparate which allows me to blend the colour and alpha maps separately. Unforuntely, when I call it, the compiler can't even find the definition for it, even though its a standard function in OpenGL.
Anyone know what's going on with the OpenGL library? Either finding a way to get glBlendFunc affect the alpha channels or how I can get the glBlendFuncSeparate function working would be a great help!
Thanks,
Daniel
About the author
#2
Also, you're trying to blend two textures together, yes? glBlendFunc doesn't do that. glBlendFunc blends the final rasterized textured pixels into the framebuffer. For blending textures you need to use texture combiners.
Finally, if you're trying to use destination alpha (or the alpha buffer) you must specifically request it on nVidia cards.
07/07/2006 (12:46 pm)
On a side note, glBlendFuncSeparate is only supported on the Radeon 8500/GeForce FX 5200 and up, so you may not want to use it depending on your target market.Also, you're trying to blend two textures together, yes? glBlendFunc doesn't do that. glBlendFunc blends the final rasterized textured pixels into the framebuffer. For blending textures you need to use texture combiners.
Finally, if you're trying to use destination alpha (or the alpha buffer) you must specifically request it on nVidia cards.
#3
Thanks a lot for the help!
@Robert
The game is running OpenGL upon start up, I was just having problems getting VS .NET to find the OpenGL library for some reason. But since its working just fine, I guess that'll do. Thanks for the Primer, I'll look into it.
@Alex
Thanks for the clarification about glBlendFuncSeparate; I was able to get the job done with glBlendFunc (although its sort of a work around).
07/13/2006 (3:10 pm)
AhThanks a lot for the help!
@Robert
The game is running OpenGL upon start up, I was just having problems getting VS .NET to find the OpenGL library for some reason. But since its working just fine, I guess that'll do. Thanks for the Primer, I'll look into it.
@Alex
Thanks for the clarification about glBlendFuncSeparate; I was able to get the job done with glBlendFunc (although its sort of a work around).
Torque 3D Owner Robert Blanchet Jr.
The case may be it either is defaulting to using D3D first, even though it found an OpenGL device, in which case you can just switch it to OpenGL in the preferences. Or, it couldn't find an OpenGL device but found a D3D device and used that instead.
Now, regarding glBlendFuncSeperate, it is not an OpenGL extension that the engine binds to from the OpenGL libraries, and it isn't even implemented in the OpenGL2D3D wrapper. To support the extension, you should read this primer on how to add new extensions to the engine. Also, if you want the OpenGL2D3D wrapper to support it, you will have to add the appropriate functionality there as well.