summaryrefslogtreecommitdiff
path: root/src/lib/dump_gl_screen.c
blob: c4cc2102fb50209f109286fdc2ff1d293b8319e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "dump_gl_screen.h"
#include "write_bmp.h"

#include <stdlib.h>

void dump_gl_screen(const char *filename, GLsizei width, GLsizei height)
{
    void *data;

    if(width==0 || height==0)
        return;

    data = malloc(width * height * 4);
    if(!data)
        return;
    
    glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data);

    bmp_dump32((char*)data, width, height, false, filename);
    free(data);
}