woops.. forgot to mention, before that render is called, these are called:
glEnable(GL_BLEND);
//Regular: GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA
//Additive: GL_SRC_ALPHA, GL_ONE or GL_DST_ALPHA
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA);
//glBlendFunc(GL_SRC_ALPHA, GL_ONE);
Transparency blending
Quote:Original post by EvilKnuckles666
ok... not even that is working.. so, here's my entire code for loading and rendering a texture.. what could be wrong?
*** Source Snippet Removed ***
Quote:Original post by EvilKnuckles666Hmm... I don't see you enabling texturing, you are doing that right?
woops.. forgot to mention, before that render is called, these are called:
glEnable(GL_BLEND);
//Regular: GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA
//Additive: GL_SRC_ALPHA, GL_ONE or GL_DST_ALPHA
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA);
//glBlendFunc(GL_SRC_ALPHA, GL_ONE);
One other thing I noticed is that you use GL_RGBA as the internalformat parameter to glTexImage2D. This is usually fine but if you want a specific bit depth for the texture, you should use one of the formats that specify bit depth, such as GL_RGBA8 for a 32-bit texture. This is because if you just use GL_RGBA, your drivers are free to return any RGBA format. When the quality settings in the drivers aren't set to the highest quality they usually create a 16-bit texture if you just ask for GL_RGBA, and you will get significant banding on most of your textures. This certainly shouldn't be causing your problem though.
Speaking of which, what exactly is your problem? Is it that the texture isn't being created at all? Is it just not being rendered properly? Is it a blending issue? We need a little more description of what's going wrong, and possibly a screenshot.
This is what's happening:
I want this effect to happen:
^This WAS my engine when i was using DirectX but now i'm switching to OpenGL
In the first image, see how the particle is being rendered without any blending? And it looks like the alpha isn't even being rendered either because the image looks like it's all black and gets slowly white as it gets to the center, but it's actually all white and the alpha gets more full as it gets to the center. I don't know why it's being drawn black and now blending like it should..
I want this effect to happen:
^This WAS my engine when i was using DirectX but now i'm switching to OpenGL
In the first image, see how the particle is being rendered without any blending? And it looks like the alpha isn't even being rendered either because the image looks like it's all black and gets slowly white as it gets to the center, but it's actually all white and the alpha gets more full as it gets to the center. I don't know why it's being drawn black and now blending like it should..
i thought depth testing needed to be on in order for blending to work?? people kept telling me that...
Quote:Original post by EvilKnuckles666Depth testing should be kept on so that you don't see the particles through walls and other opaque objects. Depth writing should be turned off for all transparent objects. Use glDepthMask to turn on/off depth writing.
i thought depth testing needed to be on in order for blending to work?? people kept telling me that...
EDIT: So the order of operations for a basic scene is this...
- enable depth writing and depth testing - render all opaque objects - disable depth writing only - render all transparent objects from back to front
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement