mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:57:35 +00:00
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.
This commit is contained in:
parent
e1a6966863
commit
65d4fb7649
3 changed files with 36 additions and 18 deletions
|
@ -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 bitmap = MUST(Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRx8888, { width, height }));
|
||||||
auto context = GL::create_context(*bitmap);
|
auto context = GL::create_context(*bitmap);
|
||||||
GL::make_context_current(context);
|
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;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,13 +60,6 @@ TEST_CASE(0001_simple_triangle)
|
||||||
{
|
{
|
||||||
auto context = create_testing_context(64, 64);
|
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);
|
glBegin(GL_TRIANGLES);
|
||||||
glColor3f(1, 1, 1);
|
glColor3f(1, 1, 1);
|
||||||
glVertex2f(0, 1);
|
glVertex2f(0, 1);
|
||||||
|
@ -75,13 +77,6 @@ TEST_CASE(0002_quad_color_interpolation)
|
||||||
{
|
{
|
||||||
auto context = create_testing_context(64, 64);
|
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);
|
glBegin(GL_QUADS);
|
||||||
|
|
||||||
glColor3f(1, 0, 0);
|
glColor3f(1, 0, 0);
|
||||||
|
@ -99,3 +94,26 @@ TEST_CASE(0002_quad_color_interpolation)
|
||||||
context->present();
|
context->present();
|
||||||
expect_bitmap_equals_reference(context->frontbuffer(), "0002_quad_color_interpolation");
|
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");
|
||||||
|
}
|
||||||
|
|
Binary file not shown.
|
@ -2878,10 +2878,10 @@ void GLContext::gl_rect(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2)
|
||||||
RETURN_WITH_ERROR_IF(m_in_draw_state, GL_INVALID_OPERATION);
|
RETURN_WITH_ERROR_IF(m_in_draw_state, GL_INVALID_OPERATION);
|
||||||
|
|
||||||
gl_begin(GL_POLYGON);
|
gl_begin(GL_POLYGON);
|
||||||
gl_vertex(x1, y1, 0.0, 0.0);
|
gl_vertex(x1, y1, 0.0, 1.0);
|
||||||
gl_vertex(x2, y1, 0.0, 0.0);
|
gl_vertex(x2, y1, 0.0, 1.0);
|
||||||
gl_vertex(x2, y2, 0.0, 0.0);
|
gl_vertex(x2, y2, 0.0, 1.0);
|
||||||
gl_vertex(x1, y2, 0.0, 0.0);
|
gl_vertex(x1, y2, 0.0, 1.0);
|
||||||
gl_end();
|
gl_end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue