Results 1 to 3 of 3

Thread: screen shot

  1. #1
    Member Newbie
    Join Date
    Nov 2002
    Location
    bucharest, romania
    Posts
    35

    screen shot

    I'm a totally OpenGL beginner so I don't know how rgb and alpha values are stored in OpenGL's
    buffers.So, let's suppose I have something on screen and I want to save the screen or a portion of the screen in a raw format.How can I do this?Does anybody know of a good tutorial targeted to this thing?
    I think is rather simple, but I am a newbie and it doesn't say how to do it in the Red Book.

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: screen shot

    Taking a screen shot is actually quite simple. You read the pixels with glReadPixels into your own buffer and then save it. For a 800x600 window, it looks something like this.
    Code :
    unsigned char *buf = new unsigned char[600*800*3]; // 3 for RGB, change to 4 for RGBA
    glReadPixels(0, 0, 800, 600, GL_RGB, GL_UNSIGNED_BYTE, buf); // change RGB to RGBA if you want the alpha channel.
    buf is now filled with whatever was in buffer set for reading in OpenGL. You have to be carefull with what buffer is actually set for reading. The default read buffer in a double buffered application is the back buffer. That means, if you want to read the contents of the screen, you have to change the read buffer to the front buffer.
    Code :
    glReadBuffer(GL_FRONT);

  3. #3
    Member Newbie
    Join Date
    Nov 2002
    Location
    bucharest, romania
    Posts
    35

    Re: screen shot

    Thanks! It works!

Similar Threads

  1. [C#] Screen shot of OpenGL game (Counter-Strike 1.6).
    By Nak100 in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 11-29-2018, 03:07 AM
  2. Screen Shot and Question
    By asaslow in forum OpenGL ES
    Replies: 6
    Last Post: 05-30-2005, 06:46 PM
  3. Strange Graphics Problem (Screen Shot)...
    By brispace in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 05-01-2005, 04:11 AM
  4. problems getting a screen shot
    By mithun_daa in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 11-25-2003, 05:34 AM
  5. Alphatest and MT with GF2 - Screen shot included!
    By Robbo in forum OpenGL: Advanced Coding
    Replies: 8
    Last Post: 04-17-2002, 05:41 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean