Browse Source

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

legacy
Sam Hocevar sam 14 years ago
parent
commit
29bebc3e53
3 changed files with 23 additions and 0 deletions
  1. +2
    -0
      src/asset.h
  2. +20
    -0
      src/video.cpp
  3. +1
    -0
      src/video.h

+ 2
- 0
src/asset.h View File

@@ -31,6 +31,8 @@ protected:
GROUP_BEFORE = 0,
GROUP_DEFAULT,
GROUP_AFTER,
GROUP_RENDER_CAPTURE,
// Must be the last element
GROUP_COUNT
}
Group;


+ 20
- 0
src/video.cpp View File

@@ -55,6 +55,26 @@ void Video::Clear()
glLoadIdentity();
}

void Video::Capture(uint32_t *buffer)
{
GLint v[4];
glGetIntegerv(GL_VIEWPORT, v);
int width = v[2], height = v[3];

glPixelStorei(GL_PACK_ROW_LENGTH, 0);
glPixelStorei(GL_PACK_ALIGNMENT, 1);

glReadPixels(0, 0, width, height, GL_BGRA, GL_UNSIGNED_BYTE, buffer);

for (int j = 0; j < height / 2; j++)
for (int i = 0; i < width; i++)
{
uint32_t tmp = buffer[j * width + i];
buffer[j * width + i] = buffer[(height - j - 1) * width + i];
buffer[(height - j - 1) * width + i] = tmp;
}
}

int Video::GetWidth()
{
GLint v[4];


+ 1
- 0
src/video.h View File

@@ -17,6 +17,7 @@ class Video
public:
static void Setup(int width, int height);
static void Clear();
static void Capture(uint32_t *buffer);
static int GetWidth();
static int GetHeight();
};


Loading…
Cancel
Save