| 126 | } |
| 127 | |
| 128 | void Verify() { |
| 129 | unsigned char *data = malloc(width*height*4 + 16); |
| 130 | int *last = (int*)(data + width*height*4 - 4); |
| 131 | int *after = (int*)(data + width*height*4); |
| 132 | *last = 0xdeadbeef; |
| 133 | *after = 0x12345678; |
| 134 | glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data); |
| 135 | assert(*last != 0xdeadbeef); // should overwrite the buffer to the end |
| 136 | assert(*after == 0x12345678); // nothing should be written afterwards! |
| 137 | // Should see some blue, and nothing else |
| 138 | int seen = 0; |
| 139 | int ok = 1; |
| 140 | for (int x = 0; x < width*height; x++) { |
| 141 | seen = seen || data[x*4+2] != 0; |
| 142 | ok = ok && (data[x*4+0] == 0); |
| 143 | ok = ok && (data[x*4+1] == 0); |
| 144 | } |
| 145 | assert(seen); |
| 146 | assert(ok); |
| 147 | } |
| 148 | |
| 149 | int main(int argc, char *argv[]) |
| 150 | { |