Geoff Lang | f11dbdb | 2013-10-23 14:37:58 -0400 | [diff] [blame] | 1 | #include "ANGLETest.h" |
| 2 | |
| 3 | class ReadPixelsTest : public ANGLETest |
| 4 | { |
| 5 | protected: |
| 6 | ReadPixelsTest() |
| 7 | { |
| 8 | setWindowWidth(32); |
| 9 | setWindowHeight(32); |
| 10 | setConfigRedBits(8); |
| 11 | setConfigGreenBits(8); |
| 12 | setConfigBlueBits(8); |
| 13 | setConfigAlphaBits(8); |
| 14 | } |
| 15 | }; |
| 16 | |
| 17 | TEST_F(ReadPixelsTest, out_of_bounds) |
| 18 | { |
| 19 | glClearColor(1.0f, 0.0f, 0.0f, 1.0f); |
| 20 | glClear(GL_COLOR_BUFFER_BIT); |
| 21 | EXPECT_GL_NO_ERROR(); |
| 22 | |
| 23 | GLsizei pixelsWidth = 32; |
| 24 | GLsizei pixelsHeight = 32; |
| 25 | std::vector<GLubyte> pixels(pixelsWidth * pixelsHeight * 4); |
| 26 | |
| 27 | glReadPixels(-pixelsWidth / 2, -pixelsHeight / 2, pixelsWidth, pixelsHeight, GL_RGBA, GL_UNSIGNED_BYTE, pixels.data()); |
| 28 | EXPECT_GL_NO_ERROR(); |
| 29 | |
| 30 | for (int y = pixelsHeight / 2; y < pixelsHeight; y++) |
| 31 | { |
| 32 | for (int x = pixelsWidth / 2; x < pixelsWidth; x++) |
| 33 | { |
| 34 | const GLubyte* pixel = pixels.data() + ((y * pixelsWidth + x) * 4); |
| 35 | |
| 36 | // Expect that all pixels which fell within the framebuffer are red |
| 37 | EXPECT_EQ(pixel[0], 255); |
| 38 | EXPECT_EQ(pixel[1], 0); |
| 39 | EXPECT_EQ(pixel[2], 0); |
| 40 | EXPECT_EQ(pixel[3], 255); |
| 41 | } |
| 42 | } |
| 43 | } |