[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Public WebGL] Error catching with getBufferSubData
If an error occurs, glMapBufferRange returns a NULL pointer.
Looking at errors:
- GL_INVALID_VALUE is generated if either of offset or length is negative, or if offset + length is greater than the value of GL_BUFFER_SIZE.
- GL_INVALID_VALUE is generated if access has any bits set other than those defined above.
- GL_INVALID_OPERATION is generated for any of the following conditions:
- The buffer is already in a mapped state.
- Neither GL_MAP_READ_BIT or GL_MAP_WRITE_BIT is set.
- GL_MAP_READ_BIT is set and any of GL_MAP_INVALIDATE_RANGE_BIT, GL_MAP_INVALIDATE_BUFFER_BIT, or GL_MAP_UNSYNCHRONIZED_BIT is set.
- GL_MAP_FLUSH_EXPLICIT_BIT is set and GL_MAP_WRITE_BIT is not set.
- GL_OUT_OF_MEMORY is generated if glMapBufferRange fails because memory for the mapping could not be obtained.
All of these errors indicate that your program is faulty.
When using gl.mapBufferRange there are two use-cases. Either you are checking for errors, or you are not.
- If you are checking for errors, you are doing so using gl.getError. This will reliably indicate an error in your invocation of gl.mapBufferRange without consulting a hypothetical return boolean.
- If you are not checking for errors, you are not using gl.getError, and you will also not consult the hypothetical gl.mapBufferRange return boolean.
Since neither usecase would rely as a best practice on the gl.mapBufferRange return value, I conclude that this return value would be superfluous and not necessary.