Skip to content

Commit

Permalink
gl: improve error messages for invalid IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
rasky committed Jun 21, 2023
1 parent 279fdc2 commit cf5ba23
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/GL/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,8 @@ void glDeleteVertexArrays(GLsizei n, const GLuint *arrays)

for (GLsizei i = 0; i < n; i++)
{
assertf(arrays[i] == 0 || is_valid_object_id(arrays[i]), "Not a valid array object: %#lx", arrays[i]);
assertf(arrays[i] == 0 || is_valid_object_id(arrays[i]),
"Not a valid array object: %#lx. Make sure to allocate IDs via glGenVertexArray", arrays[i]);

gl_array_object_t *obj = (gl_array_object_t*)arrays[i];
if (obj == NULL) {
Expand All @@ -425,7 +426,8 @@ void glDeleteVertexArrays(GLsizei n, const GLuint *arrays)
void glBindVertexArray(GLuint array)
{
if (!gl_ensure_no_immediate()) return;
assertf(array == 0 || is_valid_object_id(array), "Not a valid array object: %#lx", array);
assertf(array == 0 || is_valid_object_id(array),
"Not a valid array object: %#lx. Make sure to allocate IDs via glGenVertexArray", array);

gl_array_object_t *obj = (gl_array_object_t*)array;

Expand Down
6 changes: 4 additions & 2 deletions src/GL/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ GLboolean glIsBufferARB(GLuint buffer)
void glBindBufferARB(GLenum target, GLuint buffer)
{
if (!gl_ensure_no_immediate()) return;
assertf(buffer == 0 || is_valid_object_id(buffer), "Not a valid buffer object: %#lx", buffer);
assertf(buffer == 0 || is_valid_object_id(buffer),
"Not a valid buffer object: %#lx. Make sure to allocate IDs via glGenBuffersARB", buffer);

gl_buffer_object_t *obj = (gl_buffer_object_t*)buffer;

Expand Down Expand Up @@ -47,7 +48,8 @@ void glDeleteBuffersARB(GLsizei n, const GLuint *buffers)

for (GLsizei i = 0; i < n; i++)
{
assertf(buffers[i] == 0 || is_valid_object_id(buffers[i]), "Not a valid buffer object: %#lx", buffers[i]);
assertf(buffers[i] == 0 || is_valid_object_id(buffers[i]),
"Not a valid buffer object: %#lx. Make sure to allocate IDs via glGenBuffersARB", buffers[i]);

gl_buffer_object_t *obj = (gl_buffer_object_t*)buffers[i];
if (obj == NULL) {
Expand Down
6 changes: 4 additions & 2 deletions src/GL/texture.c
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,8 @@ GLboolean glIsTexture(GLuint texture)
void glBindTexture(GLenum target, GLuint texture)
{
if (!gl_ensure_no_immediate()) return;
assertf(texture == 0 || is_valid_object_id(texture), "Not a valid texture object: %#lx", texture);
assertf(texture == 0 || is_valid_object_id(texture),
"Not a valid texture object: %#lx. Make sure to allocate IDs via glGenTextures", texture);

gl_texture_object_t **target_obj = NULL;

Expand Down Expand Up @@ -625,7 +626,8 @@ void glDeleteTextures(GLsizei n, const GLuint *textures)

for (uint32_t i = 0; i < n; i++)
{
assertf(textures[i] == 0 || is_valid_object_id(textures[i]), "Not a valid texture object: %#lx", textures[i]);
assertf(textures[i] == 0 || is_valid_object_id(textures[i]),
"Not a valid texture object: %#lx. Make sure to allocate IDs via glGenTextures", textures[i]);

gl_texture_object_t *obj = (gl_texture_object_t*)textures[i];
if (obj == NULL) {
Expand Down

0 comments on commit cf5ba23

Please sign in to comment.