1

I'm developing a movie player and I'm using OpenGL to draw frames and On Screen Messages.

To draw the frame I use:

glBegin(GL_QUADS);
// Draw the quads
glTexCoord2f(0.0f, 0.0f); 
glVertex2f (_movieRect.origin.x,_movieRect.origin.y + _movieRect.size.height); 

glTexCoord2f(0.0f, _imageRect.size.height);
glVertex2f (_movieRect.origin.x, _movieRect.origin.y );

glTexCoord2f(_imageRect.size.width, _imageRect.size.height);
glVertex2f (_movieRect.origin.x + _movieRect.size.width,_movieRect.origin.y); 

glTexCoord2f(_imageRect.size.width, 0.0f);
glVertex2f (_movieRect.origin.x + _movieRect.size.width, _movieRect.origin.y + _movieRect.size.height);

glEnd();

while to draw the On Screen Message I draw a rectangle which contains the representation of the text that I'm going to show. To handle transparency I do this before drawing text message:

glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);

I want now to give the option to modify brightness in real-time. To achieve this I'm using:

double t = _brightnessValue;

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
if (t > 1.0f)
{
    glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB,      GL_ADD);
    glColor4f(t-1, t-1, t-1, t-1);
}
else
{
    glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB,      GL_SUBTRACT);
    glColor4f(1-t, 1-t, 1-t, 1-t);
}
glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_RGB,         GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_SRC1_RGB,         GL_PRIMARY_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA,    GL_REPLACE);
glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_ALPHA,       GL_TEXTURE);

The brightness is modified correctly but now text messages are wrong. The rectangle around the text is transparent only when brightness has its default value and even text is affected by the brightness correction. (i.e. the text is white as default and it becomes more and more gray as I reduce brightness).

Does the brightness regulation change the alpha spectrum outside 0-1? How can I solve this problem?

I'm sorry if this sounds stupid but it's the first time that I'm using OpenGL

Andrea3000
  • 1,018
  • 1
  • 11
  • 26
  • Sorry..I'm not english and I thought that OSD was the right term.. When I modify brightness I show a text message on screen that say "Brightness = xx " That message is an image that I create from rich text and it's similar to subtitle messages (i.e. it has a transparent background) – Andrea3000 Sep 25 '11 at 09:49

1 Answers1

1

Remember, OpenGL is a state machine. You can set your TexEnv state, draw the frame, then change the TexEnv state back to normal, and draw your OSD.

Mark F
  • 457
  • 2
  • 6