Commit b5420664 by Luc Ferron Committed by Commit Bot

Add end2end test for GL_TRIANGLE_FAN in SimpleOperationTest

Bug: angleproject:2334 Change-Id: Idb4d651ade139372f40d690e523c43b20e859a5e Reviewed-on: https://chromium-review.googlesource.com/899024 Commit-Queue: Luc Ferron <lucferron@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 7b7ada6a
...@@ -233,6 +233,11 @@ TEST_P(SimpleOperationTest, DrawQuad) ...@@ -233,6 +233,11 @@ TEST_P(SimpleOperationTest, DrawQuad)
// Simple line test. // Simple line test.
TEST_P(SimpleOperationTest, DrawLine) TEST_P(SimpleOperationTest, DrawLine)
{ {
// We assume in the test the width and height are equal and we are tracing
// the line from bottom left to top right. Verify that all pixels along that line
// have been traced with green.
ASSERT_EQ(getWindowWidth(), getWindowHeight());
ANGLE_GL_PROGRAM(program, kBasicVertexShader, kGreenFragmentShader); ANGLE_GL_PROGRAM(program, kBasicVertexShader, kGreenFragmentShader);
glUseProgram(program); glUseProgram(program);
...@@ -255,11 +260,6 @@ TEST_P(SimpleOperationTest, DrawLine) ...@@ -255,11 +260,6 @@ TEST_P(SimpleOperationTest, DrawLine)
ASSERT_GL_NO_ERROR(); ASSERT_GL_NO_ERROR();
// We assume in the test the width and height are equal and we are tracing
// the line from bottom left to top right. Verify that all pixels along that line
// have been traced with green.
ASSERT_EQ(getWindowWidth(), getWindowHeight());
for (auto x = 0; x < getWindowWidth(); x++) for (auto x = 0; x < getWindowWidth(); x++)
{ {
EXPECT_PIXEL_COLOR_EQ(x, x, GLColor::green); EXPECT_PIXEL_COLOR_EQ(x, x, GLColor::green);
...@@ -269,6 +269,11 @@ TEST_P(SimpleOperationTest, DrawLine) ...@@ -269,6 +269,11 @@ TEST_P(SimpleOperationTest, DrawLine)
// Simple line strip test. // Simple line strip test.
TEST_P(SimpleOperationTest, DrawLineStrip) TEST_P(SimpleOperationTest, DrawLineStrip)
{ {
// We assume in the test the width and height are equal and we are tracing
// the line from bottom left to center, then from center to bottom right.
// Verify that all pixels along these lines have been traced with green.
ASSERT_EQ(getWindowWidth(), getWindowHeight());
ANGLE_GL_PROGRAM(program, kBasicVertexShader, kGreenFragmentShader); ANGLE_GL_PROGRAM(program, kBasicVertexShader, kGreenFragmentShader);
glUseProgram(program); glUseProgram(program);
...@@ -291,11 +296,6 @@ TEST_P(SimpleOperationTest, DrawLineStrip) ...@@ -291,11 +296,6 @@ TEST_P(SimpleOperationTest, DrawLineStrip)
ASSERT_GL_NO_ERROR(); ASSERT_GL_NO_ERROR();
// We assume in the test the width and height are equal and we are tracing
// the line from bottom left to center, then from center to bottom right.
// Verify that all pixels along these lines have been traced with green.
ASSERT_EQ(getWindowWidth(), getWindowHeight());
const auto centerX = getWindowWidth() / 2; const auto centerX = getWindowWidth() / 2;
const auto centerY = getWindowHeight() / 2; const auto centerY = getWindowHeight() / 2;
...@@ -310,6 +310,59 @@ TEST_P(SimpleOperationTest, DrawLineStrip) ...@@ -310,6 +310,59 @@ TEST_P(SimpleOperationTest, DrawLineStrip)
} }
} }
// Simple triangle fans test.
TEST_P(SimpleOperationTest, DrawTriangleFan)
{
// We assume in the test the width and height are equal and we are tracing
// 2 triangles to cover half the surface like this:
ASSERT_EQ(getWindowWidth(), getWindowHeight());
ANGLE_GL_PROGRAM(program, kBasicVertexShader, kGreenFragmentShader);
glUseProgram(program);
auto vertices = std::vector<Vector3>{
{-1.0f, -1.0f, 0.0f}, {0.0f, 0.0f, 0.0f}, {1.0f, -1.0f, 0.0f}, {1.0f, 1.0f, 0.0f}};
const GLint positionLocation = glGetAttribLocation(program, "position");
ASSERT_NE(-1, positionLocation);
GLBuffer vertexBuffer;
glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer.get());
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices[0]) * vertices.size(), vertices.data(),
GL_STATIC_DRAW);
glVertexAttribPointer(positionLocation, 3, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(positionLocation);
glClear(GL_COLOR_BUFFER_BIT);
glDrawArrays(GL_TRIANGLE_FAN, 0, static_cast<GLsizei>(vertices.size()));
glDisableVertexAttribArray(positionLocation);
EXPECT_GL_NO_ERROR();
// Check 4 lines accross de triangles to make sure we filled it.
// Don't check every pixel as it would slow down our tests.
for (auto x = 0; x < getWindowWidth(); x++)
{
EXPECT_PIXEL_COLOR_EQ(x, x, GLColor::green);
}
for (auto x = getWindowWidth() / 3, y = 0; x < getWindowWidth(); x++, y++)
{
EXPECT_PIXEL_COLOR_EQ(x, y, GLColor::green);
}
for (auto x = getWindowWidth() / 2, y = 0; x < getWindowWidth(); x++, y++)
{
EXPECT_PIXEL_COLOR_EQ(x, y, GLColor::green);
}
for (auto x = (getWindowWidth() / 4) * 3, y = 0; x < getWindowWidth(); x++, y++)
{
EXPECT_PIXEL_COLOR_EQ(x, y, GLColor::green);
}
}
// Simple repeated draw and swap test. // Simple repeated draw and swap test.
TEST_P(SimpleOperationTest, DrawQuadAndSwap) TEST_P(SimpleOperationTest, DrawQuadAndSwap)
{ {
......
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