summaryrefslogtreecommitdiff
path: root/Tests/LibGL
diff options
context:
space:
mode:
authorcflip <cflip@cflip.net>2022-11-14 17:02:53 -0700
committerAndreas Kling <kling@serenityos.org>2022-11-26 09:38:13 +0100
commitbad3e2a089bc6dae9c33426a5370c225d8b6139d (patch)
tree947f4bf774d216c28c61c2e5f7e431c34954edf3 /Tests/LibGL
parentb83181ef93402b18151267907b5ceb9ef00a4fb6 (diff)
downloadserenity-bad3e2a089bc6dae9c33426a5370c225d8b6139d.zip
LibGL: Add some tests for the buffer API
Diffstat (limited to 'Tests/LibGL')
-rw-r--r--Tests/LibGL/TestAPI.cpp8
-rw-r--r--Tests/LibGL/TestRender.cpp30
-rw-r--r--Tests/LibGL/reference-images/0010_test_store_data_in_buffer.qoibin0 -> 184 bytes
3 files changed, 38 insertions, 0 deletions
diff --git a/Tests/LibGL/TestAPI.cpp b/Tests/LibGL/TestAPI.cpp
index b539c5db88..d5ec47631c 100644
--- a/Tests/LibGL/TestAPI.cpp
+++ b/Tests/LibGL/TestAPI.cpp
@@ -53,3 +53,11 @@ TEST_CASE(0002_gl_cull_face_does_not_accept_left_and_right)
glCullFace(GL_RIGHT);
EXPECT_EQ(glGetError(), static_cast<GLenum>(GL_INVALID_ENUM));
}
+
+TEST_CASE(0003_gl_bind_buffer_names_must_be_allocated)
+{
+ auto context = create_testing_context();
+
+ glBindBuffer(GL_ARRAY_BUFFER, 123);
+ EXPECT_EQ(glGetError(), static_cast<GLenum>(GL_INVALID_VALUE));
+}
diff --git a/Tests/LibGL/TestRender.cpp b/Tests/LibGL/TestRender.cpp
index b4a80c3ea1..8300eab515 100644
--- a/Tests/LibGL/TestRender.cpp
+++ b/Tests/LibGL/TestRender.cpp
@@ -269,3 +269,33 @@ TEST_CASE(0009_test_draw_elements_in_display_list)
context->present();
expect_bitmap_equals_reference(context->frontbuffer(), "0009_test_draw_elements_in_display_list"sv);
}
+
+TEST_CASE(0010_test_store_data_in_buffer)
+{
+ auto context = create_testing_context(64, 64);
+
+ glColor3f(1.f, 0.f, 0.f);
+ glEnableClientState(GL_VERTEX_ARRAY);
+
+ float vertices[] = { 0.f, .5f, -.5f, -.5f, .5f, -.5f };
+ u8 indices[] = { 0, 1, 2 };
+
+ GLuint buffers[2];
+ glGenBuffers(2, buffers);
+
+ glBindBuffer(GL_ARRAY_BUFFER, buffers[0]);
+ glBufferData(GL_ARRAY_BUFFER, 6 * sizeof(float), vertices, GL_STATIC_DRAW);
+
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffers[1]);
+ glBufferData(GL_ELEMENT_ARRAY_BUFFER, 3, indices, GL_STATIC_DRAW);
+
+ glVertexPointer(2, GL_FLOAT, 0, 0);
+ glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_BYTE, 0);
+
+ glDeleteBuffers(2, buffers);
+
+ EXPECT_EQ(glGetError(), 0u);
+
+ context->present();
+ expect_bitmap_equals_reference(context->frontbuffer(), "0010_test_store_data_in_buffer"sv);
+}
diff --git a/Tests/LibGL/reference-images/0010_test_store_data_in_buffer.qoi b/Tests/LibGL/reference-images/0010_test_store_data_in_buffer.qoi
new file mode 100644
index 0000000000..2acb27277f
--- /dev/null
+++ b/Tests/LibGL/reference-images/0010_test_store_data_in_buffer.qoi
Binary files differ