PDA

View Full Version : Color Space



dpsv
12-27-2001, 12:42 PM
Hi ,
Trying to draw 3 polygons (Red , Green , Blue) overlapping each other to get the RGB color space using blending but cant get it to work. Any ideas. I am using
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);

50% Alpha values for each polygon color.

Thanks


DP

Lev
12-27-2001, 03:44 PM
Do you render back-to-front, front-to-back or unsorted? you _must_ (back to front) sort the polys to get the correct results.

And if you are rendering 3 polys you also must set the alpha to 0.33 and not to 0.5.

-Lev

[This message has been edited by Lev (edited 12-27-2001).]

Korval
12-27-2001, 08:51 PM
There are far easier ways to compute the colorspace than using alpha blending. Computing it directly, for example, is much simpler, and it doesn't rely on rendering. You can simply create a bitmap and fill it with the appropriate colors.

dpsv
12-28-2001, 07:21 AM
Hi,
Thanks for the replies...
Yes,I was drawing from back to front and still I cannot get the colorspace to work even with 0.33 .

Here is the figure that i want to achieve

.........<--Green Poly->
<--Red Poly-->
------------------------
|........|.....|........|
|........|.....|........|
|.....---------------...|
|.....|..|.....|....|...|
|.....|..|..W..|....|...|
------|-------------|----
......|.............|....
......|.............|....
......---------------....
......<--Blue Poly-->....

consider dots(.) as white spaces and horizontal and vertical lines as polygon boundary lines.

I need the zone denoted by 'W' in figure to be white when I do blending.

What value of alpha should I use in glclearcolor. Seems it does not matter. I am using :
glClearColor(1.0,1.0,1.0,1.0);

When I set white background with alpha value 0 or 1 , and blending is turned ON, why does Red not Red anymore, it brightens. I would think that blending would work only when a polygon is being drawn above some other polygon. Is there a way to control this behaviour. Am I confusing this with shineness ?

Thanks

DPS

[This message has been edited by dpsv (edited 12-28-2001).]

[This message has been edited by dpsv (edited 12-28-2001).]

dpsv
12-28-2001, 08:05 AM
Hi ,
Just figured out that using blending I can never get a white color , which means I cannot create a color space. Its because the value of RGB colors will keep on decreasing and will make a black color eventually.

Thanks

DPS

Serge K
12-29-2001, 03:27 PM
how about glBlendFunc( GL_ONE, GL_ONE ) ?