PDA

View Full Version : Confused about blending !



FrimaMichael
04-09-2010, 09:23 AM
Hello all,

I'm working with OpenGL ES 1.1 so keep that in mind while reading :P

I'm trying to get a font to render to a specified color, and it actually works but not for transparency. What I mean is if I want the font to be red, it's working but red with alpha at 50% juste shows like red with 100% alpha.

Here is a code example, there I'm trying to get a grey tint with 50% alpha but only gets the grey tint with no alpha.



glColor4f(0.8f, 0.8f, 0.8f, 0.5f);
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);


Since I'm in OpenGL ES 1.1 I can't change the blend equation. So its blending with the default SrcColor*SrcFactor + DstColor*DstFactor.

Also I only have these two state enable :



glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);


So no color array ( does that make all vertex take the glColor* color ???)

Well I think I understand blending but cant figure this out lol

Also my font texture is White or tint of grey where text is and black elsewhere. So basically using glBlendFunc(GL_ONE, GL_ZERO); Makes the text the color specified by glColor* and the rest is perfect black.

Well I would be thankful if anyone could help me with this !

Thanks!

Mick

Aeluned
04-09-2010, 12:15 PM
have you allocated bits for alpha in your pixel format descriptor?

FrimaMichael
04-09-2010, 12:19 PM
I'm currently reading the red book so I'm not familiar with all the terms. Do you mean the way I generate my font texture ?

If so here it is :



glGenTextures(1, &(aDataHolder.textureID));
glBindTexture(GL_TEXTURE_2D, aDataHolder.textureID);
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA,aDataHolder.textureSize, aDataHolder.textureSize, 0,GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR);

Alfonse Reinheart
04-09-2010, 12:34 PM
He's talking about how you create your OpenGL context. Are you using self-written code to initialize OpenGL, or are you using a toolkit like FreeGLUT or SDL or something?

FrimaMichael
04-09-2010, 12:45 PM
I'm using an EGL implentation on top of OpenKODE window system.