Thread: OpenGL Screenies, How To?

  1. #1
    #junkie
    Join Date
    Oct 2004
    Posts
    240

    Lightbulb OpenGL Screenies, How To?

    Ok, this next bit is going to sound strange, so bare with me please.

    I am trying to capture every frame of a OpenGL program in jpg/gif/tga format (pref jpg/gif). I am going to be using these to shrink down, and import into a flash website, FRAME BY FRAME... to horribly and painstakingly create the opengl animation in flash.

    What i do not know how to do, is any commands to capture a frame and print it in a specific format. My texture image data is all TGA, so i can live with that, however i REALLY need to make OpenGL save each frame.

    So, can anyone tell me how to do this? Links are much appreciated, explanations with those are awesome.
    I am a total nub so please spell it out as if i were 5, and if you know of any better ways please enlighten me. I think flash can take movie formats, but i am just concerned with getting it done in a manner i know how to, i dont know how well flash likes movie formats and how the quality will be.


    Thanks to any replies!
    01110111011000010110110001100100011011110010000001 11000101110101011010010111010000100000011011000110 10010110011001100101001000000111100101101111011101 0100100000011011100111010101100010

  2. #2
    Registered User MathFan's Avatar
    Join Date
    Apr 2002
    Posts
    190
    The OS requirements were Windows Vista Ultimate or better, so we used Linux.

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    580
    I don't exactly know how to do it, and I don't know where on that page you were linked to it explains how to do it.

    However, I know it has something to do with glReadPixels, which captures the color buffer and stores it. Then, when you have that data, you can theoretically write it to a file. However, I do not know if OpenGL or the OpenGL auxiliary library has any commands to write to any specific file. Subsequently, even if you can capture the current color buffer (the pixels you see on the screen) you might have to manually write it to a .tga format (and you'd have to be exact otherwise the resulting file is about as useful as pea soup).

    EDIT:
    whenever you have a function name, msdn is absolutely the best thing in the universe. It explains glReadPixels as well as the other pertinent functions. I don't know if there's an easier way, but this certainly is one way of doing what you want:

    http://msdn.microsoft.com/library/de...unc03_8m7n.asp
    Last edited by Darkness; 01-07-2005 at 10:36 AM.
    See you in 13

  4. #4
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    I was going to suggest creating a buffer and getting a pointer to the OpenGL buffer - if possible. Once you get the pointer to the GL buffer and have established a valid pointer to another buffer...the rest is easy.

    Code:
    void Copy32(DWORD *pSource,DWORD *pDest,DWORD dwSize)
    {
      asm {
        cld 
        mov  esi,[pSource]
        mov  edi,[pDest]
        mov  ecx,dwSize
        rep stosd
        and ecx,03h
        rep stosb
      }
    }
    This will copy Source to Dest 32-bits at a time - or one pixel per iteration in 32-bit color. pDest will be an exact copy of pSource. Write pDest to a file using any format you like. It is up to you to encode the format for the file. But getting the raw data is quite simple.

  5. #5
    Registered User
    Join Date
    Aug 2003
    Posts
    1,218
    As darkness said you will have to use glReadPixels, search on google for info.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linking OpenGL in Dev-C++
    By linkofazeroth in forum Game Programming
    Replies: 4
    Last Post: 09-13-2005, 10:17 AM
  2. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  3. OpenGL .dll vs video card dll
    By Silvercord in forum Game Programming
    Replies: 14
    Last Post: 02-12-2003, 07:57 PM
  4. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 10:14 PM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 10:01 PM