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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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{
Note: See TracChangeset for help on using the changeset viewer.