diff options
Diffstat (limited to 'src/mesa/main/bufferobj.c')
-rw-r--r-- | src/mesa/main/bufferobj.c | 186 |
1 files changed, 182 insertions, 4 deletions
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 7742e29a8b..3a7a413e97 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -1,5 +1,3 @@ -/* $Id: bufferobj.c,v 1.1 2003/03/29 17:01:00 brianp Exp $ */ - /* * Mesa 3-D graphics library * Version: 5.1 @@ -34,22 +32,51 @@ #include "glheader.h" #include "imports.h" +#include "context.h" #include "bufferobj.h" void _mesa_BindBufferARB(GLenum target, GLuint buffer) { + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (target == GL_ARRAY_BUFFER_ARB) { + + } + else if (target == GL_ELEMENT_ARRAY_BUFFER_ARB) { + + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferARB(target)"); + return; + } } void -_mesa_DeleteBuffersARB(GLsizei n, const GLuint * buffer) +_mesa_DeleteBuffersARB(GLsizei n, const GLuint *buffer) { + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (n < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteBuffersARB(n)"); + return; + } + } void -_mesa_GenBuffersARB(GLsizei n, GLuint * buffer) +_mesa_GenBuffersARB(GLsizei n, GLuint *buffer) { + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (n < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGenBuffersARB(n)"); + return; + } } GLboolean @@ -62,37 +89,188 @@ void _mesa_BufferDataARB(GLenum target, GLsizeiptrARB size, const GLvoid * data, GLenum usage) { + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (size < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glBufferDataARB(size < 0)"); + return; + } + + switch (usage) { + case GL_STREAM_DRAW_ARB: + case GL_STREAM_READ_ARB: + case GL_STREAM_COPY_ARB: + case GL_STATIC_DRAW_ARB: + case GL_STATIC_READ_ARB: + case GL_STATIC_COPY_ARB: + case GL_DYNAMIC_DRAW_ARB: + case GL_DYNAMIC_READ_ARB: + case GL_DYNAMIC_COPY_ARB: + /* OK */ + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glBufferDataARB(usage)"); + return; + } + + if (target == GL_ARRAY_BUFFER_ARB) { + + } + else if (target == GL_ELEMENT_ARRAY_BUFFER_ARB) { + + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glBufferDataARB(target)"); + return; + } } void _mesa_BufferSubDataARB(GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid * data) { + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (size < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glBufferSubDataARB(size < 0)"); + return; + } + + if (target == GL_ARRAY_BUFFER_ARB) { + + } + else if (target == GL_ELEMENT_ARRAY_BUFFER_ARB) { + + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glBufferSubDataARB(target)"); + return; + } } void _mesa_GetBufferSubDataARB(GLenum target, GLintptrARB offset, GLsizeiptrARB size, void * data) { + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (size < 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetBufferSubDataARB(size < 0)"); + return; + } + + if (target == GL_ARRAY_BUFFER_ARB) { + + } + else if (target == GL_ELEMENT_ARRAY_BUFFER_ARB) { + + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferSubDataARB(target)"); + return; + } } void _mesa_MapBufferARB(GLenum target, GLenum access) { + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + switch (access) { + case GL_READ_ONLY_ARB: + case GL_WRITE_ONLY_ARB: + case GL_READ_WRITE_ARB: + /* OK */ + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glMapBufferARB(access)"); + return; + } + + if (target == GL_ARRAY_BUFFER_ARB) { + + } + else if (target == GL_ELEMENT_ARRAY_BUFFER_ARB) { + + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glMapBufferARB(target)"); + return; + } } GLboolean _mesa_UnmapBufferARB(GLenum target) { + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); + + if (target == GL_ARRAY_BUFFER_ARB) { + + } + else if (target == GL_ELEMENT_ARRAY_BUFFER_ARB) { + + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glUnmapBufferARB(target)"); + return GL_FALSE; + } return GL_FALSE; } void _mesa_GetBufferParameterivARB(GLenum target, GLenum pname, GLint *params) { + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + switch (pname) { + case GL_BUFFER_SIZE_ARB: + case GL_BUFFER_USAGE_ARB: + case GL_BUFFER_ACCESS_ARB: + case GL_BUFFER_MAPPED_ARB: + /* ok */ + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferParameterivARB(pname)"); + return; + } + + if (target == GL_ARRAY_BUFFER_ARB) { + + } + else if (target == GL_ELEMENT_ARRAY_BUFFER_ARB) { + + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferParameterARB(target)"); + return; + } } void _mesa_GetBufferPointervARB(GLenum target, GLenum pname, GLvoid **params) { + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + if (pname != GL_BUFFER_MAP_POINTER_ARB) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferPointervARB(pname)"); + return; + } + + if (target == GL_ARRAY_BUFFER_ARB) { + + } + else if (target == GL_ELEMENT_ARRAY_BUFFER_ARB) { + + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferPointervARB(target)"); + return; + } } |