Changeset 140


Ignore:
Timestamp:
Aug 19, 2010, 2:58:30 AM (10 years ago)
Author:
sam
Message:

Implement Video::Capture and create a GROUP_RENDER_CAPTURE tick group.

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/asset.h

    r130 r140  
    3232        GROUP_DEFAULT,
    3333        GROUP_AFTER,
     34        GROUP_RENDER_CAPTURE,
     35        // Must be the last element
    3436        GROUP_COUNT
    3537    }
  • trunk/src/video.cpp

    r139 r140  
    5656}
    5757
     58void Video::Capture(uint32_t *buffer)
     59{
     60    GLint v[4];
     61    glGetIntegerv(GL_VIEWPORT, v);
     62    int width = v[2], height = v[3];
     63
     64    glPixelStorei(GL_PACK_ROW_LENGTH, 0);
     65    glPixelStorei(GL_PACK_ALIGNMENT, 1);
     66
     67    glReadPixels(0, 0, width, height, GL_BGRA, GL_UNSIGNED_BYTE, buffer);
     68
     69    for (int j = 0; j < height / 2; j++)
     70        for (int i = 0; i < width; i++)
     71        {
     72            uint32_t tmp = buffer[j * width + i];
     73            buffer[j * width + i] = buffer[(height - j - 1) * width + i];
     74            buffer[(height - j - 1) * width + i] = tmp;
     75        }
     76}
     77
    5878int Video::GetWidth()
    5979{
  • trunk/src/video.h

    r139 r140  
    1818    static void Setup(int width, int height);
    1919    static void Clear();
     20    static void Capture(uint32_t *buffer);
    2021    static int GetWidth();
    2122    static int GetHeight();
Note: See TracChangeset for help on using the changeset viewer.