* Get the buffer object bound to the specified target in a GL context.
* \param ctx the GL context
* \param target the buffer object target to be retrieved.
+ * \param error the GL error to record if target is illegal.
* \return pointer to the buffer object bound to \c target in the
* specified context or \c NULL if \c target is invalid.
*/
static inline struct gl_buffer_object *
-get_buffer(struct gl_context *ctx, const char *func, GLenum target)
+get_buffer(struct gl_context *ctx, const char *func, GLenum target,
+ GLenum error)
{
struct gl_buffer_object **bufObj = get_buffer_target(ctx, target);
}
if (!_mesa_is_bufferobj(*bufObj)) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "%s(buffer 0)", func);
+ _mesa_error(ctx, error, "%s(no buffer bound)", func);
return NULL;
}
* \param size Size, in bytes, of the subdata range.
* \param mappedRange If true, checks if an overlapping range is mapped.
* If false, checks if buffer is mapped.
+ * \param errorNoBuffer Error code if no buffer is bound to target.
* \param caller Name of calling function for recording errors.
* \return A pointer to the buffer object bound to \c target in the
* specified context or \c NULL if any of the parameter or state
static struct gl_buffer_object *
buffer_object_subdata_range_good(struct gl_context * ctx, GLenum target,
GLintptrARB offset, GLsizeiptrARB size,
- bool mappedRange, const char *caller)
+ bool mappedRange, GLenum errorNoBuffer,
+ const char *caller)
{
struct gl_buffer_object *bufObj;
return NULL;
}
- bufObj = get_buffer(ctx, caller, target);
+ bufObj = get_buffer(ctx, caller, target, errorNoBuffer);
if (!bufObj)
return NULL;
return;
}
- bufObj = get_buffer(ctx, "glBufferDataARB", target);
+ bufObj = get_buffer(ctx, "glBufferDataARB", target, GL_INVALID_OPERATION);
if (!bufObj)
return;
struct gl_buffer_object *bufObj;
bufObj = buffer_object_subdata_range_good( ctx, target, offset, size,
- false, "glBufferSubDataARB");
+ false, GL_INVALID_OPERATION,
+ "glBufferSubDataARB" );
if (!bufObj) {
/* error already recorded */
return;
struct gl_buffer_object *bufObj;
bufObj = buffer_object_subdata_range_good(ctx, target, offset, size,
- false, "glGetBufferSubDataARB");
+ false, GL_INVALID_OPERATION,
+ "glGetBufferSubDataARB");
if (!bufObj) {
/* error already recorded */
return;
return NULL;
}
- bufObj = get_buffer(ctx, "glMapBufferARB", target);
+ bufObj = get_buffer(ctx, "glMapBufferARB", target, GL_INVALID_OPERATION);
if (!bufObj)
return NULL;
GLboolean status = GL_TRUE;
ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
- bufObj = get_buffer(ctx, "glUnmapBufferARB", target);
+ bufObj = get_buffer(ctx, "glUnmapBufferARB", target, GL_INVALID_OPERATION);
if (!bufObj)
return GL_FALSE;
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
- bufObj = get_buffer(ctx, "glGetBufferParameterivARB", target);
+ bufObj = get_buffer(ctx, "glGetBufferParameterivARB", target,
+ GL_INVALID_OPERATION);
if (!bufObj)
return;
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
- bufObj = get_buffer(ctx, "glGetBufferParameteri64v", target);
+ bufObj = get_buffer(ctx, "glGetBufferParameteri64v", target,
+ GL_INVALID_OPERATION);
if (!bufObj)
return;
return;
}
- bufObj = get_buffer(ctx, "glGetBufferPointervARB", target);
+ bufObj = get_buffer(ctx, "glGetBufferPointervARB", target,
+ GL_INVALID_OPERATION);
if (!bufObj)
return;
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *src, *dst;
- src = get_buffer(ctx, "glCopyBufferSubData", readTarget);
+ src = get_buffer(ctx, "glCopyBufferSubData", readTarget,
+ GL_INVALID_OPERATION);
if (!src)
return;
- dst = get_buffer(ctx, "glCopyBufferSubData", writeTarget);
+ dst = get_buffer(ctx, "glCopyBufferSubData", writeTarget,
+ GL_INVALID_OPERATION);
if (!dst)
return;
return NULL;
}
- bufObj = get_buffer(ctx, "glMapBufferRange", target);
+ bufObj = get_buffer(ctx, "glMapBufferRange", target, GL_INVALID_OPERATION);
if (!bufObj)
return NULL;
return;
}
- bufObj = get_buffer(ctx, "glFlushMappedBufferRange", target);
+ bufObj = get_buffer(ctx, "glFlushMappedBufferRange", target,
+ GL_INVALID_OPERATION);
if (!bufObj)
return;