From: Laura Ekstrand Date: Sat, 24 Jan 2015 00:38:36 +0000 (-0800) Subject: main: Add utility function _mesa_lookup_renderbuffer_err. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2bb138e7ec24b9e56715a53f9c4e911b99d4a97b;p=mesa.git main: Add utility function _mesa_lookup_renderbuffer_err. [Fredrik: Generate an error for non-existent renderbuffers] Reviewed-by: Fredrik Höglund Signed-off-by: Fredrik Höglund --- diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index e4cb8cc71b6..adadf3c980b 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -120,6 +120,27 @@ _mesa_lookup_renderbuffer(struct gl_context *ctx, GLuint id) } +/** + * A convenience function for direct state access that throws + * GL_INVALID_OPERATION if the renderbuffer doesn't exist. + */ +struct gl_renderbuffer * +_mesa_lookup_renderbuffer_err(struct gl_context *ctx, GLuint id, + const char *func) +{ + struct gl_renderbuffer *rb; + + rb = _mesa_lookup_renderbuffer(ctx, id); + if (!rb || rb == &DummyRenderbuffer) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "%s(non-existent renderbuffer %u)", func, id); + return NULL; + } + + return rb; +} + + /** * Helper routine for getting a gl_framebuffer. */ diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h index 37d9535018b..6ac16fca241 100644 --- a/src/mesa/main/fbobject.h +++ b/src/mesa/main/fbobject.h @@ -64,6 +64,10 @@ _mesa_get_incomplete_framebuffer(void); extern struct gl_renderbuffer * _mesa_lookup_renderbuffer(struct gl_context *ctx, GLuint id); +extern struct gl_renderbuffer * +_mesa_lookup_renderbuffer_err(struct gl_context *ctx, GLuint id, + const char *func); + extern struct gl_framebuffer * _mesa_lookup_framebuffer(struct gl_context *ctx, GLuint id);