View Full Version : Copy Color data
08-04-2009, 05:08 AM
Hey, i've just started using opengl and i was wondering if there is a way to copy the color buffer content to an array of colors.
I'm using a grayscale image, so I don't need to copy the 3 RGB values for each pixel, instead i just need one.
08-04-2009, 05:24 AM
You could render to a fbo.
08-04-2009, 07:33 AM
and as Roest said render to fbo (IMHO best)
08-05-2009, 12:42 AM
do you mean VBO?
If so please explain how.
08-05-2009, 12:48 AM
btw i'm a real beginner. SO if you could show me an example.
08-05-2009, 02:02 AM
He is talking about FBO. VBO is different from FBO. FBO is used for writing to texture.
Once you attach a texture to COLOR_ATTACHMENT, then inside fragment shader add:
Color = texture2D(<sampler2D> , <coord>)
glColor = Color; //Sends color info to all buffers
//gl_FragData[n] = Color; //sends data to specified aux buffer
//you can use GL_BACK , GL_FRONT buffers also.
To attach and use texture at FBO, refer to tutorial on FBO (google search) . Official document would be technical and uninteresting at first.
08-07-2009, 01:48 AM
Thx Awhig for the explanation, but there's something that's still not clear to me.
In my project, i have to take an image and calculate 2 gradients Gx and Gy (sobel edge detection). Then, i must use these 2 color gradients to calculate G and Theta which are defined as followed:
G=sqrt(Gx^2 + Gy^2)
so i thought about rendereing two VBO, one for Gx and the other for Gy, but how could i use the resulting buffers to calculate G and Theta?
One more thing, is there a way to access a random pixel's color?
08-11-2009, 05:18 AM
i meant FBO
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.