diff options
author | Jelle Raaijmakers <jelle@gmta.nl> | 2022-08-24 23:47:49 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-08-27 12:28:05 +0200 |
commit | eb7c3d16fbfd805f9fbb3b819a661db10088fb56 (patch) | |
tree | 51e65bff9fead51d7c8f367d5e522d2f24deec31 /Tests/LibGL/TestRender.cpp | |
parent | d7cfdfe6335de83f25d205cd9863fc18e2854763 (diff) | |
download | serenity-eb7c3d16fbfd805f9fbb3b819a661db10088fb56.zip |
LibGL+LibGPU+LibSoftGPU: Implement flexible pixel format conversion
A GPU (driver) is now responsible for reading and writing pixels from
and to user data. The client (LibGL) is responsible for specifying how
the user data must be interpreted or written to.
This allows us to centralize all pixel format conversion in one class,
`LibSoftGPU::PixelConverter`. For both the input and output image, it
takes a specification containing the image dimensions, the pixel type
and the selection (basically a clipping rect), and converts the pixels
from the input image to the output image.
Effectively this means we now support almost all OpenGL 1.5 formats,
and all custom logic has disappeared from:
- `glDrawPixels`
- `glReadPixels`
- `glTexImage2D`
- `glTexSubImage2D`
The new logic is still unoptimized, but on my machine I experienced no
noticeable slowdown. :^)
Diffstat (limited to 'Tests/LibGL/TestRender.cpp')
-rw-r--r-- | Tests/LibGL/TestRender.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Tests/LibGL/TestRender.cpp b/Tests/LibGL/TestRender.cpp index 4d5448bb49..73c287cf51 100644 --- a/Tests/LibGL/TestRender.cpp +++ b/Tests/LibGL/TestRender.cpp @@ -169,3 +169,33 @@ TEST_CASE(0005_lines_antialiased) context->present(); expect_bitmap_equals_reference(context->frontbuffer(), "0005_lines"sv); } + +TEST_CASE(0006_test_rgb565_texture) +{ + auto context = create_testing_context(64, 64); + + GLuint texture_id; + glGenTextures(1, &texture_id); + glBindTexture(GL_TEXTURE_2D, texture_id); + u16 texture_data[] = { 0xF800, 0xC000, 0x8000, 0x07E0, 0x0600, 0x0400, 0x001F, 0x0018, 0x0010 }; + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 3, 3, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, texture_data); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + glEnable(GL_TEXTURE_2D); + glBegin(GL_QUADS); + glTexCoord2i(0, 0); + glVertex2i(-1, 1); + glTexCoord2i(0, 1); + glVertex2i(-1, -1); + glTexCoord2i(1, 1); + glVertex2i(1, -1); + glTexCoord2i(1, 0); + glVertex2i(1, 1); + glEnd(); + + EXPECT_EQ(glGetError(), 0u); + + context->present(); + expect_bitmap_equals_reference(context->frontbuffer(), "0006_test_rgb565_texture"sv); +} |