Commit f11dbdb3 by Geoff Lang

Added a read pixels test.

Change-Id: Ia4c5a0290e62e2c312d86fa18ef4e76d782a4a41 Reviewed-on: https://chromium-review.googlesource.com/179357Reviewed-by: 's avatarNicolas Capens <nicolascapens@chromium.org> Commit-Queue: Nicolas Capens <nicolascapens@chromium.org> Tested-by: 's avatarNicolas Capens <nicolascapens@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 066230a8
#include "ANGLETest.h"
class ReadPixelsTest : public ANGLETest
{
protected:
ReadPixelsTest()
{
setWindowWidth(32);
setWindowHeight(32);
setConfigRedBits(8);
setConfigGreenBits(8);
setConfigBlueBits(8);
setConfigAlphaBits(8);
}
};
TEST_F(ReadPixelsTest, out_of_bounds)
{
glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
EXPECT_GL_NO_ERROR();
GLsizei pixelsWidth = 32;
GLsizei pixelsHeight = 32;
std::vector<GLubyte> pixels(pixelsWidth * pixelsHeight * 4);
glReadPixels(-pixelsWidth / 2, -pixelsHeight / 2, pixelsWidth, pixelsHeight, GL_RGBA, GL_UNSIGNED_BYTE, pixels.data());
EXPECT_GL_NO_ERROR();
for (int y = pixelsHeight / 2; y < pixelsHeight; y++)
{
for (int x = pixelsWidth / 2; x < pixelsWidth; x++)
{
const GLubyte* pixel = pixels.data() + ((y * pixelsWidth + x) * 4);
// Expect that all pixels which fell within the framebuffer are red
EXPECT_EQ(pixel[0], 255);
EXPECT_EQ(pixel[1], 0);
EXPECT_EQ(pixel[2], 0);
EXPECT_EQ(pixel[3], 255);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment