diff options
author | Jelle Raaijmakers <jelle@gmta.nl> | 2022-04-18 10:57:45 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-04-20 14:12:56 +0200 |
commit | 65d4fb7649db44ec362e353738f1e7d8ea5f2cdc (patch) | |
tree | 36937f382113642ea9c77a76463601d2ab60b567 /Tests | |
parent | e1a6966863b4f8b038bbb7925391a817b2377211 (diff) | |
download | serenity-65d4fb7649db44ec362e353738f1e7d8ea5f2cdc.zip |
LibGL: Set W-coordinate to 1 in `glRect*`
According to the spec, these calls should be identical to an invocation
of `glVertex2*`, which sets the W-coordinate to 1 by default.
This fixes the credits sequence rendering of Tux Racer.
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/LibGL/TestRender.cpp | 46 | ||||
-rw-r--r-- | Tests/LibGL/reference-images/0003_rect_w_coordinate_regression.qoi | bin | 0 -> 344 bytes |
2 files changed, 32 insertions, 14 deletions
diff --git a/Tests/LibGL/TestRender.cpp b/Tests/LibGL/TestRender.cpp index 7c67097b07..640c54252f 100644 --- a/Tests/LibGL/TestRender.cpp +++ b/Tests/LibGL/TestRender.cpp @@ -26,6 +26,15 @@ static NonnullOwnPtr<GL::GLContext> create_testing_context(int width, int height auto bitmap = MUST(Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRx8888, { width, height })); auto context = GL::create_context(*bitmap); GL::make_context_current(context); + + // Assume some defaults for our testing contexts + glFrontFace(GL_CCW); + glCullFace(GL_BACK); + glEnable(GL_CULL_FACE); + + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + glClear(GL_COLOR_BUFFER_BIT); + return context; } @@ -51,13 +60,6 @@ TEST_CASE(0001_simple_triangle) { auto context = create_testing_context(64, 64); - glFrontFace(GL_CCW); - glCullFace(GL_BACK); - glEnable(GL_CULL_FACE); - - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT); - glBegin(GL_TRIANGLES); glColor3f(1, 1, 1); glVertex2f(0, 1); @@ -75,13 +77,6 @@ TEST_CASE(0002_quad_color_interpolation) { auto context = create_testing_context(64, 64); - glFrontFace(GL_CCW); - glCullFace(GL_BACK); - glEnable(GL_CULL_FACE); - - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT); - glBegin(GL_QUADS); glColor3f(1, 0, 0); @@ -99,3 +94,26 @@ TEST_CASE(0002_quad_color_interpolation) context->present(); expect_bitmap_equals_reference(context->frontbuffer(), "0002_quad_color_interpolation"); } + +TEST_CASE(0003_rect_w_coordinate_regression) +{ + auto context = create_testing_context(64, 64); + + glEnable(GL_DEPTH_TEST); + glClear(GL_DEPTH_BUFFER_BIT); + + glColor3f(0, 1, 0); + glRectf(-0.5f, -0.5f, 0.5f, 0.5f); + + glBegin(GL_TRIANGLES); + glColor3f(1, 0, 0); + glVertex2i(-1, -1); + glVertex2i(1, -1); + glVertex2i(-1, 1); + glEnd(); + + EXPECT_EQ(glGetError(), 0u); + + context->present(); + expect_bitmap_equals_reference(context->frontbuffer(), "0003_rect_w_coordinate_regression"); +} diff --git a/Tests/LibGL/reference-images/0003_rect_w_coordinate_regression.qoi b/Tests/LibGL/reference-images/0003_rect_w_coordinate_regression.qoi Binary files differnew file mode 100644 index 0000000000..262ab88039 --- /dev/null +++ b/Tests/LibGL/reference-images/0003_rect_w_coordinate_regression.qoi |