PDA

View Full Version : Strange glColorf alpha value, texture interaction



Matt Phillips
03-27-2010, 06:32 PM
Hi,

The issue here is probably pretty basic but I couldn't find a solution in my books. I want to draw a shape (glRect, gluDisk, polygon--same for all) on top of a texture, and have the shape blend in. So for a glRect I have


glColor4f(1, 1, 1, 0.33);
glRectf(-5, -5, 5, 5);


When I do this, the alpha value gets applied to the entire texture, and only partially to the rectangle. I.e., the entire texture is blended with an alpha of 0.33 into the background, and the rectangle on top of it is partially blended in but not as much as the alpha value would imply. Different alpha values produce correspondingly different results. I have earlier in the program


glEnable(GL_DEPTH_TEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);


The projection is orthogonal; the texture has a z value of 0, the rectangle 0.1. I get the same problem on different platforms (Ubuntu, Mac OSX). Does anybody know what's going on? Thank you--

Matt

ZbuffeR
03-28-2010, 01:42 AM
draw a shape (glRect, gluDisk, polygon--same for all) on top of a texture
And how do you draw the texture itself ? Make sure you do it with gl color 1 1 1 1.

Matt Phillips
03-28-2010, 08:18 AM
Thank you very much, that was it!

Best,
Matt