Browse Source

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

tags/Debug_refactor_merge_to_master
Sam Hocevar sam 15 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_BEFORE = 0,
GROUP_DEFAULT, GROUP_DEFAULT,
GROUP_AFTER, GROUP_AFTER,
GROUP_RENDER_CAPTURE,
// Must be the last element
GROUP_COUNT GROUP_COUNT
} }
Group; Group;


+ 20
- 0
src/video.cpp View File

@@ -55,6 +55,26 @@ void Video::Clear()
glLoadIdentity(); 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() int Video::GetWidth()
{ {
GLint v[4]; GLint v[4];


+ 1
- 0
src/video.h View File

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


Loading…
Cancel
Save