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 5 of 5

Thread: reading and writing to the video frame buffer

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2006
    Posts
    3

    reading and writing to the video frame buffer

    I'm on Windows XP using Visual C++ 6.0.

    I need to capture the image in the video frame buffer, modify it by putting a small graphic along the bottom sixteenth of the image, and write it back to the video frame buffer for display in somewhat real time.

    Any leads to working code or function calls in openML, openGL, or other would be most appreciated. A solution comparable to the openGL DMbuffer extensions for XFree86 and IRIX operating systems would also work perfectly.
    Thank you -

  2. #2
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,421

    Re: reading and writing to the video frame buffer

    If you are using OpenGL,

    glClear(...)
    //Render you stuff

    //Read from back buffer
    glReadPixels(...)

    //Modify pixels

    glLoadIdentity();
    glRasterPos2i(0, 0);
    glDrawPixels(...);

    SwapBuffers();

    For best performance, use the same format as the backbuffer.
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

  3. #3
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,655

    Re: reading and writing to the video frame buffer

    Maybe PBO can help, performance wise :
    http://oss.sgi.com/projects/ogl-samp...fer_object.txt

    EDIT: Do you have a real reason to bring back the frame buffer (saving to disk, whatever) ?
    Else, why not adding your small graphics directly at the right place using opengl ? That would be much MUCH faster.

  4. #4
    Advanced Member Frequent Contributor yooyo's Avatar
    Join Date
    Apr 2003
    Location
    Belgrade, Serbia
    Posts
    883

    Re: reading and writing to the video frame buffer

    You have two frame buffers:
    - video FB
    - OpenGL FB

    If I understand corectly, you want to grab frame from video FB add some graphics and write back to video FB. For such action, you don't need OpenGL and you must do all this things on CPU. Even more.. just grab 1/16 part of screen and modify it's content.

    If you want to use OpenGL, you must grab frame, upload as OpenGL texture, render frame using OpenGL then render additional graphics, readback result from OpenGL and copy to video FB.

    in short... video FB -> system memory -> OGL texture -> OGL FB -> render additional graphics -> system memory -> video FB

    It will be much easier to use for example Quadro card with SDI output and pipeline will be:
    video FB -> OpenGL texture -> OpenGL FB -> render additional graphics -> output to SDI. NVidia deliver additional OpenGL extenstion that expose interface to video frame buffer on Quadro card.
    In this case you can apply any effect on incoming video stream using OpenGL and deliver proffesional quality output (key & fill).

    yooyo

  5. #5
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,655

    Re: reading and writing to the video frame buffer

    dduran, the whole desktop framebuffer is not the OpenGL framebuffer.

Posting Permissions

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