Please, I need some help!!!!

Hi,

Well, I need to do the following steps:

1º I will load a 3D Object and rotate it three times in different directions, then I’ll save the buffers A, B and C ( A= Rotation 1, B= Rotation 2 and C= Rotation 3)… at buffer “A” I’ll only let the RED Channel active (i.e. if the pixel “x” is 101,011,111 - it’ll change to 101,000,000 ), at buffer “B” only GREEN channel… and so on;

2º Now, I need to do an OR operation between the RGB Channels from the buffers ( A,B and C) for each pixel and save the result:

Pixel X in Buffer A: R -> (101,000,000)
Pixel X in Buffer B: G -> (000,110,000)
Pixel X in Buffer C: B -> (000,000,010)

Pixel X in Buffer R: RGB -> (101,110,010)

3º Show at screen

Well, the result is a Stereogram of the original 3D Object

=>Is there any other function besides glReadPixels() that will help me doing this?

[This message has been edited by ArkAnjo (edited 12-05-2002).]

glColorMask()

You need to stop thinking at the pixels level. You can’t access the frame buffer directly, and if you do it indirectly with glReadPixels, chances are it will be extremely slow (unless you only do it for a small window) due to the video memory read back.

You can use the color mask; an alternative would be to use a pure red light in a first pass, render A; clear ZBuffer; then do again with a green light and B; clear and finally with a blue light and C.

Y.

[This message has been edited by ArkAnjo (edited 12-06-2002).]

Originally posted by Ysaneya:
“chances are it will be extremely slow”

Ysaneya: I know that if I do this operantion between pixels it 'll be really slow ( O n²) but at this moment it isn’t important in my work. I’ll try the way you suggest too (Color Mask), Tks for your attention.

PS.: I’ve already think in this alternative that you suggest -> “using a pure red light in a first pass, render A; clear ZBuffer; then do again with a green light and B; clear and finally with a blue light and C”… but if I do this, it’ll be a fake stereogram , because in any moment I did the operation between the channels color, the result is 3 frames rendering extremely fast that give the impression of a stereogram.

[This message has been edited by ArkAnjo (edited 12-06-2002).]

Originally posted by rgpc:
glColorMask()

Tks for your help.

but if I do this, it’ll be a fake stereogram , because in any moment I did the operation between the channels color, the result is 3 frames rendering extremely fast that give the impression of a stereogram.

I’m not sure to understand you well here :slight_smile: Do you mean you’re not using double-buffering, and you can see in “live” the objects being painted on screen ?

Y.

ahem

glColorMask(true,true,true,true); //make sure we clear all colors
glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
glColorMask(true,false,false,true);
render_thingy();    //will only go to red channel
glClear(GL_DEPTH_BUFFER_BIT);
jitter_a_bit();
glColorMask(false,true,false,true);
render_thingy();    //will only go to green channel
glClear(GL_DEPTH_BUFFER_BIT);
jitter_a_bit_more();
glColorMask(false,false,true,true);
render_thingy();    //will only go to blue channel
SwapBuffers(blabla);

Rinse, wash, repeat.

Originally posted by Ysaneya:
[b] I’m not sure to understand you well here Do you mean you’re not using double-buffering, and you can see in “live” the objects being painted on screen ?

Y.[/b]

I’ll try to explain… err let see…

When you told to me:

“using a pure red light in a first pass, render A; clear ZBuffer; then do again with a green light and B; clear and finally with a blue light and C”…

Did you mean that every time that I clear the ZBuffer I’ll show it before clear, then do again with green light… show and clear… and finally with a blue light… show and clear… or am I wrong?

if I’m right, then… this process didn’t create a true stereogram, because it’ll be showing the object in Red … then Green and Blue ( 3 frames )… and i need all these frames in one

Well, if I’m wrong… heheh I didn’t understand what did you try to explain to me before…

PS.: I need to use a Double Buffering… or I 'll never find a way to create my stereogram

Originally posted by zeckensack:
[b]ahem[quote]

glColorMask(true,true,true,true); //make sure we clear all colors
glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
glColorMask(true,false,false,true);
render_thingy();    //will only go to red channel
glClear(GL_DEPTH_BUFFER_BIT);
jitter_a_bit();
glColorMask(false,true,false,true);
render_thingy();    //will only go to green channel
glClear(GL_DEPTH_BUFFER_BIT);
jitter_a_bit_more();
glColorMask(false,false,true,true);
render_thingy();    //will only go to blue channel
SwapBuffers(blabla);

Rinse, wash, repeat.[/b][/QUOTE]

Tks man… I’ll try it…

Did you mean that every time that I clear the ZBuffer I’ll show it before clear, then do again with green light… show and clear… and finally with a blue light… show and clear… or am I wrong?

Nah, you’re reading more than i wrote You don’t display a ZBuffer (how can you do? it stores depth values, not colors!), you display a color buffer; you can clear the ZBuffer without having to render a new image in the color buffer. So basically, you clear the color buffer once, do the 3 rendering steps with the ZBuffer clear, THEN display the color buffer at the end.

This is kindda equivalent to the glColorMask method, except using lights instead of a mask. Probably no speed difference between the two (but anyway you’re not worried with that!).

Y.

[This message has been edited by Ysaneya (edited 12-06-2002).]

Originally posted by Ysaneya:
[b] Nah, you’re reading more than i wrote You don’t display a ZBuffer (how can you do? it stores depth values, not colors!), you display a color buffer; you can clear the ZBuffer without having to render a new image in the color buffer. So basically, you clear the color buffer once, do the 3 rendering steps with the ZBuffer clear, THEN display the color buffer at the end.

This is kindda equivalent to the glColorMask method, except using lights instead of a mask. Probably no speed difference between the two (but anyway you’re not worried with that!).

Y.

[This message has been edited by Ysaneya (edited 12-06-2002).][/b]

hehehehe well, know it’s clear… hehehe… I’ll try both … tks very much