Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 8 of 8

Thread: Copy Color data

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2009
    Posts
    8

    Copy Color data

    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.
    Thank you

  2. #2
    Junior Member Newbie
    Join Date
    Mar 2007
    Posts
    24

    Re: Copy Color data

    You could render to a fbo.

  3. #3
    Junior Member Regular Contributor
    Join Date
    Aug 2009
    Location
    Poland
    Posts
    111

    Re: Copy Color data

    glReadPixels (slow)
    glCopyTexImage
    and as Roest said render to fbo (IMHO best)

  4. #4
    Junior Member Newbie
    Join Date
    Jul 2009
    Posts
    8

    Re: Copy Color data

    do you mean VBO?
    If so please explain how.

  5. #5
    Junior Member Newbie
    Join Date
    Jul 2009
    Posts
    8

    Re: Copy Color data

    btw i'm a real beginner. SO if you could show me an example.

  6. #6
    Junior Member Regular Contributor
    Join Date
    Jun 2009
    Location
    FL , USA
    Posts
    192

    Re: Copy Color data

    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:

    [CODE]
    Color = texture2D(<sampler2D> , <coord>)

    glColor = Color; //Sends color info to all buffers

    OR

    //gl_FragData[n] = Color; //sends data to specified aux buffer

    //you can use GL_BACK , GL_FRONT buffers also.
    [CODE]

    To attach and use texture at FBO, refer to tutorial on FBO (google search) . Official document would be technical and uninteresting at first.

  7. #7
    Junior Member Newbie
    Join Date
    Jul 2009
    Posts
    8

    Re: Copy Color data

    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)
    Theta= invtan(Gy/Gx)

    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?

  8. #8
    Junior Member Newbie
    Join Date
    Jul 2009
    Posts
    8

    Re: Copy Color data

    i meant FBO

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •