diff options
-rw-r--r-- | src/mesa/main/bufferobj.c | 186 | ||||
-rw-r--r-- | src/mesa/main/get.c | 186 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 18 | ||||
-rw-r--r-- | src/mesa/main/nvprogram.c | 7 |
4 files changed, 389 insertions, 8 deletions
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 7742e29a8b3..3a7a413e973 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; + } } diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index cbbc0d60d02..7b7d00800ce 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -1,5 +1,3 @@ -/* $Id: get.c,v 1.110 2003/04/01 19:07:35 brianp Exp $ */ - /* * Mesa 3-D graphics library * Version: 5.1 @@ -1519,6 +1517,52 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) *params = ENUM_TO_BOOL(ctx->Stencil.ActiveFace ? GL_BACK : GL_FRONT); break; + /* GL_ARB_vertex_buffer_object */ + case GL_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_B(ARB_vertex_buffer_object, pname); + *params = INT_TO_BOOL(ctx->Array.ArrayBufferBinding); + break; + case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_B(ARB_vertex_buffer_object, pname); + *params = INT_TO_BOOL(ctx->Array.VertexArrayBufferBinding); + break; + case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_B(ARB_vertex_buffer_object, pname); + *params = INT_TO_BOOL(ctx->Array.NormalArrayBufferBinding); + break; + case GL_COLOR_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_B(ARB_vertex_buffer_object, pname); + *params = INT_TO_BOOL(ctx->Array.ColorArrayBufferBinding); + break; + case GL_INDEX_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_B(ARB_vertex_buffer_object, pname); + *params = INT_TO_BOOL(ctx->Array.IndexArrayBufferBinding); + break; + case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_B(ARB_vertex_buffer_object, pname); + *params = INT_TO_BOOL(ctx->Array.TextureArrayBufferBinding); + break; + case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_B(ARB_vertex_buffer_object, pname); + *params = INT_TO_BOOL(ctx->Array.EdgeFlagArrayBufferBinding); + break; + case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_B(ARB_vertex_buffer_object, pname); + *params = INT_TO_BOOL(ctx->Array.SecondaryColorArrayBufferBinding); + break; + case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_B(ARB_vertex_buffer_object, pname); + *params = INT_TO_BOOL(ctx->Array.FogCoordArrayBufferBinding); + break; + case GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_B(ARB_vertex_buffer_object, pname); + *params = INT_TO_BOOL(ctx->Array.WeightArrayBufferBinding); + break; + case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_B(ARB_vertex_buffer_object, pname); + *params = INT_TO_BOOL(ctx->Array.ElementArrayBufferBinding); + break; + default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetBooleanv(pname=0x%x)", pname); } @@ -2929,6 +2973,52 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params ) *params = (GLdouble) (ctx->Stencil.ActiveFace ? GL_BACK : GL_FRONT); break; + /* GL_ARB_vertex_buffer_object */ + case GL_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_D(ARB_vertex_buffer_object, pname); + *params = (GLdouble) ctx->Array.ArrayBufferBinding; + break; + case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_D(ARB_vertex_buffer_object, pname); + *params = (GLdouble) ctx->Array.VertexArrayBufferBinding; + break; + case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_D(ARB_vertex_buffer_object, pname); + *params = (GLdouble) ctx->Array.NormalArrayBufferBinding; + break; + case GL_COLOR_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_D(ARB_vertex_buffer_object, pname); + *params = (GLdouble) ctx->Array.ColorArrayBufferBinding; + break; + case GL_INDEX_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_D(ARB_vertex_buffer_object, pname); + *params = (GLdouble) ctx->Array.IndexArrayBufferBinding; + break; + case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_D(ARB_vertex_buffer_object, pname); + *params = (GLdouble) ctx->Array.TextureArrayBufferBinding; + break; + case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_D(ARB_vertex_buffer_object, pname); + *params = (GLdouble) ctx->Array.EdgeFlagArrayBufferBinding; + break; + case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_D(ARB_vertex_buffer_object, pname); + *params = (GLdouble) ctx->Array.SecondaryColorArrayBufferBinding; + break; + case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_D(ARB_vertex_buffer_object, pname); + *params = (GLdouble) ctx->Array.FogCoordArrayBufferBinding; + break; + case GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_D(ARB_vertex_buffer_object, pname); + *params = (GLdouble) ctx->Array.WeightArrayBufferBinding; + break; + case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_D(ARB_vertex_buffer_object, pname); + *params = (GLdouble) ctx->Array.ElementArrayBufferBinding; + break; + default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetDoublev(pname=0x%x)", pname); } @@ -4315,6 +4405,52 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) *params = (GLfloat) (ctx->Stencil.ActiveFace ? GL_BACK : GL_FRONT); break; + /* GL_ARB_vertex_buffer_object */ + case GL_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_F(ARB_vertex_buffer_object, pname); + *params = (GLfloat) ctx->Array.ArrayBufferBinding; + break; + case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_F(ARB_vertex_buffer_object, pname); + *params = (GLfloat) ctx->Array.VertexArrayBufferBinding; + break; + case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_F(ARB_vertex_buffer_object, pname); + *params = (GLfloat) ctx->Array.NormalArrayBufferBinding; + break; + case GL_COLOR_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_F(ARB_vertex_buffer_object, pname); + *params = (GLfloat) ctx->Array.ColorArrayBufferBinding; + break; + case GL_INDEX_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_F(ARB_vertex_buffer_object, pname); + *params = (GLfloat) ctx->Array.IndexArrayBufferBinding; + break; + case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_F(ARB_vertex_buffer_object, pname); + *params = (GLfloat) ctx->Array.TextureArrayBufferBinding; + break; + case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_F(ARB_vertex_buffer_object, pname); + *params = (GLfloat) ctx->Array.EdgeFlagArrayBufferBinding; + break; + case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_F(ARB_vertex_buffer_object, pname); + *params = (GLfloat) ctx->Array.SecondaryColorArrayBufferBinding; + break; + case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_F(ARB_vertex_buffer_object, pname); + *params = (GLfloat) ctx->Array.FogCoordArrayBufferBinding; + break; + case GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_F(ARB_vertex_buffer_object, pname); + *params = (GLfloat) ctx->Array.WeightArrayBufferBinding; + break; + case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_F(ARB_vertex_buffer_object, pname); + *params = (GLfloat) ctx->Array.ElementArrayBufferBinding; + break; + default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetFloatv(0x%x)", pname); } @@ -5739,6 +5875,52 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) *params = (GLint) (ctx->Stencil.ActiveFace ? GL_BACK : GL_FRONT); break; + /* GL_ARB_vertex_buffer_object */ + case GL_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_I(ARB_vertex_buffer_object, pname); + *params = (GLint) ctx->Array.ArrayBufferBinding; + break; + case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_I(ARB_vertex_buffer_object, pname); + *params = (GLint) ctx->Array.VertexArrayBufferBinding; + break; + case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_I(ARB_vertex_buffer_object, pname); + *params = (GLint) ctx->Array.NormalArrayBufferBinding; + break; + case GL_COLOR_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_I(ARB_vertex_buffer_object, pname); + *params = (GLint) ctx->Array.ColorArrayBufferBinding; + break; + case GL_INDEX_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_I(ARB_vertex_buffer_object, pname); + *params = (GLint) ctx->Array.IndexArrayBufferBinding; + break; + case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_I(ARB_vertex_buffer_object, pname); + *params = (GLint) ctx->Array.TextureArrayBufferBinding; + break; + case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_I(ARB_vertex_buffer_object, pname); + *params = (GLint) ctx->Array.EdgeFlagArrayBufferBinding; + break; + case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_I(ARB_vertex_buffer_object, pname); + *params = (GLint) ctx->Array.SecondaryColorArrayBufferBinding; + break; + case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_I(ARB_vertex_buffer_object, pname); + *params = (GLint) ctx->Array.FogCoordArrayBufferBinding; + break; + case GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_I(ARB_vertex_buffer_object, pname); + *params = (GLint) ctx->Array.WeightArrayBufferBinding; + break; + case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB: + CHECK_EXTENSION_I(ARB_vertex_buffer_object, pname); + *params = (GLint) ctx->Array.ElementArrayBufferBinding; + break; + default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetIntegerv(pname=0x%x)", pname); } diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 8935f0ad737..bd12e772a6f 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1093,8 +1093,8 @@ struct gl_array_attrib { struct gl_client_array Index; struct gl_client_array TexCoord[MAX_TEXTURE_COORD_UNITS]; struct gl_client_array EdgeFlag; - - struct gl_client_array VertexAttrib[16]; /* GL_NV_vertex_program */ + /* GL_NV_vertex_program */ + struct gl_client_array VertexAttrib[VERT_ATTRIB_MAX]; GLint TexCoordInterleaveFactor; GLint ActiveTexture; /* Client Active Texture */ @@ -1103,6 +1103,20 @@ struct gl_array_attrib { GLuint _Enabled; /* _NEW_ARRAY_* - bit set if array enabled */ GLuint NewState; /* _NEW_ARRAY_* */ + + /* GL_ARB_vertex_buffer_object */ + GLuint ArrayBufferBinding; + GLuint VertexArrayBufferBinding; + GLuint NormalArrayBufferBinding; + GLuint ColorArrayBufferBinding; + GLuint IndexArrayBufferBinding; + GLuint TextureArrayBufferBinding; + GLuint EdgeFlagArrayBufferBinding; + GLuint SecondaryColorArrayBufferBinding; + GLuint FogCoordArrayBufferBinding; + GLuint WeightArrayBufferBinding; + GLuint ElementArrayBufferBinding; + GLuint VertexAttribArrayBufferBinding[VERT_ATTRIB_MAX]; }; diff --git a/src/mesa/main/nvprogram.c b/src/mesa/main/nvprogram.c index fa125c40992..584b5ad40f8 100644 --- a/src/mesa/main/nvprogram.c +++ b/src/mesa/main/nvprogram.c @@ -723,6 +723,13 @@ _mesa_GetVertexAttribivNV(GLuint index, GLenum pname, GLint *params) case GL_CURRENT_ATTRIB_NV: COPY_4V_CAST(params, ctx->Current.Attrib[index], GLint); break; + case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB: + if (!ctx->Extensions.ARB_vertex_buffer_object) { + _mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribdvNV"); + return; + } + params[0] = ctx->Array.VertexAttribArrayBufferBinding[index]; + break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribdvNV"); return; |