LibGL: Add some tests for the buffer API

This commit is contained in:
cflip 2022-11-14 17:02:53 -07:00 committed by Andreas Kling
parent b83181ef93
commit bad3e2a089
3 changed files with 38 additions and 0 deletions

View file

@ -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));
}

View file

@ -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);
}