-
/*
* Mesa 3-D graphics library
* Version: 5.1
cl->Ptr = (void *) ctx->Current.Attrib[VERT_ATTRIB_NORMAL];
cl->Enabled = 1;
cl->Flags = CA_CLIENT_DATA; /* hack */
+#if FEATURE_ARB_vertex_buffer_object
+ cl->BufferObj = ctx->Array.NullBufferObj;
+#endif
cl = &ac->Fallback.Color;
cl->Size = 4;
cl->Ptr = (void *) ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
cl->Enabled = 1;
cl->Flags = CA_CLIENT_DATA; /* hack */
+#if FEATURE_ARB_vertex_buffer_object
+ cl->BufferObj = ctx->Array.NullBufferObj;
+#endif
cl = &ac->Fallback.SecondaryColor;
cl->Size = 3;
cl->Ptr = (void *) ctx->Current.Attrib[VERT_ATTRIB_COLOR1];
cl->Enabled = 1;
cl->Flags = CA_CLIENT_DATA; /* hack */
+#if FEATURE_ARB_vertex_buffer_object
+ cl->BufferObj = ctx->Array.NullBufferObj;
+#endif
cl = &ac->Fallback.FogCoord;
cl->Size = 1;
cl->Ptr = (void *) &ctx->Current.Attrib[VERT_ATTRIB_FOG];
cl->Enabled = 1;
cl->Flags = CA_CLIENT_DATA; /* hack */
+#if FEATURE_ARB_vertex_buffer_object
+ cl->BufferObj = ctx->Array.NullBufferObj;
+#endif
cl = &ac->Fallback.Index;
cl->Size = 1;
cl->Ptr = (void *) &ctx->Current.Index;
cl->Enabled = 1;
cl->Flags = CA_CLIENT_DATA; /* hack */
+#if FEATURE_ARB_vertex_buffer_object
+ cl->BufferObj = ctx->Array.NullBufferObj;
+#endif
for (i = 0 ; i < MAX_TEXTURE_COORD_UNITS ; i++) {
cl = &ac->Fallback.TexCoord[i];
cl->Ptr = (void *) ctx->Current.Attrib[VERT_ATTRIB_TEX0 + i];
cl->Enabled = 1;
cl->Flags = CA_CLIENT_DATA; /* hack */
+#if FEATURE_ARB_vertex_buffer_object
+ cl->BufferObj = ctx->Array.NullBufferObj;
+#endif
}
cl = &ac->Fallback.EdgeFlag;
cl->Ptr = (void *) &ctx->Current.EdgeFlag;
cl->Enabled = 1;
cl->Flags = CA_CLIENT_DATA; /* hack */
+#if FEATURE_ARB_vertex_buffer_object
+ cl->BufferObj = ctx->Array.NullBufferObj;
+#endif
for (i = 0; i < VERT_ATTRIB_MAX; i++) {
cl = &ac->Fallback.Attrib[i];
cl->Ptr = (void *) ctx->Current.Attrib[i];
cl->Enabled = 1;
cl->Flags = CA_CLIENT_DATA; /* hack */
+#if FEATURE_ARB_vertex_buffer_object
+ cl->BufferObj = ctx->Array.NullBufferObj;
+#endif
}
}
cl->Ptr = MALLOC( cl->StrideB * size );
cl->Enabled = 1;
cl->Flags = 0;
+#if FEATURE_ARB_vertex_buffer_object
+ cl->BufferObj = ctx->Array.NullBufferObj;
+#endif
cl = &ac->Cache.Normal;
cl->Size = 3;
cl->Ptr = MALLOC( cl->StrideB * size );
cl->Enabled = 1;
cl->Flags = 0;
+#if FEATURE_ARB_vertex_buffer_object
+ cl->BufferObj = ctx->Array.NullBufferObj;
+#endif
cl = &ac->Cache.Color;
cl->Size = 4;
cl->Ptr = MALLOC( cl->StrideB * size );
cl->Enabled = 1;
cl->Flags = 0;
+#if FEATURE_ARB_vertex_buffer_object
+ cl->BufferObj = ctx->Array.NullBufferObj;
+#endif
cl = &ac->Cache.SecondaryColor;
cl->Size = 3;
cl->Ptr = MALLOC( cl->StrideB * size );
cl->Enabled = 1;
cl->Flags = 0;
+#if FEATURE_ARB_vertex_buffer_object
+ cl->BufferObj = ctx->Array.NullBufferObj;
+#endif
cl = &ac->Cache.FogCoord;
cl->Size = 1;
cl->Ptr = MALLOC( cl->StrideB * size );
cl->Enabled = 1;
cl->Flags = 0;
+#if FEATURE_ARB_vertex_buffer_object
+ cl->BufferObj = ctx->Array.NullBufferObj;
+#endif
cl = &ac->Cache.Index;
cl->Size = 1;
cl->Ptr = MALLOC( cl->StrideB * size );
cl->Enabled = 1;
cl->Flags = 0;
+#if FEATURE_ARB_vertex_buffer_object
+ cl->BufferObj = ctx->Array.NullBufferObj;
+#endif
for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
cl = &ac->Cache.TexCoord[i];
cl->Ptr = MALLOC( cl->StrideB * size );
cl->Enabled = 1;
cl->Flags = 0;
+#if FEATURE_ARB_vertex_buffer_object
+ cl->BufferObj = ctx->Array.NullBufferObj;
+#endif
}
cl = &ac->Cache.EdgeFlag;
cl->Ptr = MALLOC( cl->StrideB * size );
cl->Enabled = 1;
cl->Flags = 0;
+#if FEATURE_ARB_vertex_buffer_object
+ cl->BufferObj = ctx->Array.NullBufferObj;
+#endif
for (i = 0 ; i < VERT_ATTRIB_MAX; i++) {
cl = &ac->Cache.Attrib[i];
cl->Ptr = MALLOC( cl->StrideB * size );
cl->Enabled = 1;
cl->Flags = 0;
+#if FEATURE_ARB_vertex_buffer_object
+ cl->BufferObj = ctx->Array.NullBufferObj;
+#endif
}
}
#define STRIDE_ARRAY( array, offset ) \
do { \
- char *tmp = (char *) (array).Ptr; \
+ GLubyte *tmp = (array).Ptr; \
tmp += (offset) * (array).StrideB; \
(array).Ptr = tmp; \
} while (0)
_mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribfvARB(pname)");
return;
}
- params[0] = (GLfloat) ctx->Array.VertexAttrib[index].BufferBinding;
+ params[0] = (GLfloat) ctx->Array.VertexAttrib[index].BufferObj->Name;
default:
_mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribfvARB(pname)");
return;
#include "bufferobj.h"
-struct gl_buffer_object {
- GLint RefCount;
- GLuint Name;
- GLenum Target;
-
- GLenum usage;
- GLenum access;
- GLvoid * pointer;
- GLuint size;
-
- void * data;
-};
-
-
/**
* Get the buffer object bound to the specified target in a GL context.
*
switch (target) {
case GL_ARRAY_BUFFER_ARB:
- bufObj = ctx->ArrayBuffer;
+ bufObj = ctx->Array.ArrayBufferObj;
break;
case GL_ELEMENT_ARRAY_BUFFER_ARB:
- bufObj = ctx->ElementArrayBuffer;
+ bufObj = ctx->Array.ElementArrayBufferObj;
break;
default:
_mesa_error(ctx, GL_INVALID_ENUM, "gl%s(target)", str);
break;
}
-
+
+ if (bufObj->Name == 0)
+ return NULL;
+
return bufObj;
}
return NULL;
}
- if ( (offset + size) > bufObj->size ) {
+ if ( (offset + size) > bufObj->Size ) {
_mesa_error(ctx, GL_INVALID_VALUE,
"gl%s(size + offset > buffer size)", str);
return NULL;
}
- if ( bufObj->pointer != NULL ) {
+ if ( bufObj->Pointer != NULL ) {
_mesa_error(ctx, GL_INVALID_OPERATION, "gl%s", str);
return NULL;
}
}
+/**
+ * Delete a buffer object.
+ *
+ * This function is intended to be called via
+ * \c dd_function_table::DeleteBufferObject.
+ */
+void
+_mesa_delete_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj )
+{
+ if (bufObj->Data)
+ _mesa_free(bufObj->Data);
+ _mesa_free(bufObj);
+}
+
+
/**
* Initialize a buffer object to default values.
*/
(void) target;
- new_data = _mesa_realloc( bufObj->data, bufObj->size, size );
+ new_data = _mesa_realloc( bufObj->Data, bufObj->Size, size );
if ( new_data != NULL ) {
- bufObj->data = new_data;
- bufObj->size = size;
- bufObj->usage = usage;
+ bufObj->Data = new_data;
+ bufObj->Size = size;
+ bufObj->Usage = usage;
if ( data != NULL ) {
- _mesa_memcpy( bufObj->data, data, size );
+ _mesa_memcpy( bufObj->Data, data, size );
}
}
}
GLsizeiptrARB size, const GLvoid * data,
struct gl_buffer_object * bufObj )
{
- if ( (bufObj->data != NULL)
- && ((size + offset) <= bufObj->size) ) {
- _mesa_memcpy( (GLubyte *) bufObj->data + offset, data, size );
+ if ( (bufObj->Data != NULL)
+ && ((size + offset) <= bufObj->Size) ) {
+ _mesa_memcpy( (GLubyte *) bufObj->Data + offset, data, size );
}
}
GLsizeiptrARB size, GLvoid * data,
struct gl_buffer_object * bufObj )
{
- if ( (bufObj->data != NULL)
- && ((size + offset) <= bufObj->size) ) {
- _mesa_memcpy( data, (GLubyte *) bufObj->data + offset, size );
+ if ( (bufObj->Data != NULL)
+ && ((size + offset) <= bufObj->Size) ) {
+ _mesa_memcpy( data, (GLubyte *) bufObj->Data + offset, size );
}
}
_mesa_buffer_map( GLcontext *ctx, GLenum target, GLenum access,
struct gl_buffer_object * bufObj )
{
- return bufObj->data;
+ return bufObj->Data;
+}
+
+
+/**
+ * Initialize the state associated with buffer objects
+ */
+void
+_mesa_init_buffer_objects( GLcontext *ctx )
+{
+ GLuint i;
+
+ ctx->Array.NullBufferObj = _mesa_new_buffer_object(ctx, 0, 0);
+ ctx->Array.ArrayBufferObj = ctx->Array.NullBufferObj;
+ ctx->Array.ElementArrayBufferObj = ctx->Array.NullBufferObj;
+
+ /* Vertex array buffers */
+ ctx->Array.Vertex.BufferObj = ctx->Array.NullBufferObj;
+ ctx->Array.Normal.BufferObj = ctx->Array.NullBufferObj;
+ ctx->Array.Color.BufferObj = ctx->Array.NullBufferObj;
+ ctx->Array.SecondaryColor.BufferObj = ctx->Array.NullBufferObj;
+ ctx->Array.FogCoord.BufferObj = ctx->Array.NullBufferObj;
+ ctx->Array.Index.BufferObj = ctx->Array.NullBufferObj;
+ for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
+ ctx->Array.TexCoord[i].BufferObj = ctx->Array.NullBufferObj;
+ }
+ ctx->Array.EdgeFlag.BufferObj = ctx->Array.NullBufferObj;
+ for (i = 0; i < VERT_ATTRIB_MAX; i++) {
+ ctx->Array.VertexAttrib[i].BufferObj = ctx->Array.NullBufferObj;
+ }
}
+
+/**********************************************************************/
+/* API Functions */
+/**********************************************************************/
+
void
_mesa_BindBufferARB(GLenum target, GLuint buffer)
{
* Get pointer to new buffer object (newBufObj)
*/
if ( buffer == 0 ) {
- newBufObj = NULL;
+ /* The spec says there's not a buffer object named 0, but we use
+ * one internally because it simplifies things.
+ */
+ newBufObj = ctx->Array.NullBufferObj;
}
else {
/* non-default buffer object */
switch (target) {
case GL_ARRAY_BUFFER_ARB:
- ctx->ArrayBuffer = newBufObj;
+ ctx->Array.ArrayBufferObj = newBufObj;
break;
case GL_ELEMENT_ARRAY_BUFFER_ARB:
- ctx->ElementArrayBuffer = newBufObj;
+ ctx->Array.ElementArrayBufferObj = newBufObj;
break;
}
GLuint name = first + i;
GLenum target = 0;
bufObj = (*ctx->Driver.NewBufferObject)( ctx, name, target );
- if ( bufObj != NULL ) {
+ if (!bufObj) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenBuffersARB");
return;
}
return NULL;
}
- if ( bufObj->pointer != NULL ) {
+ if ( bufObj->Pointer != NULL ) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glMapBufferARB");
return NULL;
}
ASSERT(ctx->Driver.MapBuffer);
- bufObj->pointer = (*ctx->Driver.MapBuffer)( ctx, target, access, bufObj );
- if ( bufObj->pointer == NULL ) {
+ bufObj->Pointer = (*ctx->Driver.MapBuffer)( ctx, target, access, bufObj );
+ if ( bufObj->Pointer == NULL ) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glMapBufferARB(access)");
}
- return bufObj->pointer;
+ return bufObj->Pointer;
}
bufObj = buffer_object_get_target( ctx, target, "UnmapBufferARB" );
if ( bufObj == NULL ) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glBufferSubDataARB" );
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glUnmapBufferARB" );
return GL_FALSE;
}
- if ( bufObj->pointer == NULL ) {
+ if ( bufObj->Pointer == NULL ) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glUnmapBufferARB");
return GL_FALSE;
}
status = (*ctx->Driver.UnmapBuffer)( ctx, target, bufObj );
}
- bufObj->pointer = NULL;
+ bufObj->Pointer = NULL;
return status;
}
switch (pname) {
case GL_BUFFER_SIZE_ARB:
- *params = bufObj->size;
+ *params = bufObj->Size;
break;
case GL_BUFFER_USAGE_ARB:
- *params = bufObj->usage;
+ *params = bufObj->Usage;
break;
case GL_BUFFER_ACCESS_ARB:
- *params = bufObj->access;
+ *params = bufObj->Access;
break;
case GL_BUFFER_MAPPED_ARB:
- *params = (bufObj->pointer != NULL);
+ *params = (bufObj->Pointer != NULL);
break;
default:
_mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferParameterivARB(pname)");
return;
}
- *params = bufObj->pointer;
+ *params = bufObj->Pointer;
}
#define BUFFEROBJ_H
+#include "context.h"
+
+
/*
* Internal functions
*/
+extern void
+_mesa_init_buffer_objects( GLcontext *ctx );
+
extern void
_mesa_initialize_buffer_object( struct gl_buffer_object *obj,
GLuint name, GLenum target );
extern struct gl_buffer_object *
_mesa_new_buffer_object( GLcontext *ctx, GLuint name, GLenum target );
+extern void
+_mesa_delete_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj );
+
extern void
_mesa_initialize_buffer_object( struct gl_buffer_object *obj,
GLuint name, GLenum target );
#include "attrib.h"
#include "blend.h"
#include "buffers.h"
+#include "bufferobj.h"
#include "colortab.h"
#include "context.h"
#include "debug.h"
_mesa_init_accum( ctx );
_mesa_init_attrib( ctx );
_mesa_init_buffers( ctx );
+ _mesa_init_buffer_objects( ctx );
_mesa_init_color( ctx );
_mesa_init_colortables( ctx );
_mesa_init_current( ctx );
#if FEATURE_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);
+ *params = INT_TO_BOOL(ctx->Array.ArrayBufferObj->Name);
break;
case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_B(ARB_vertex_buffer_object, pname);
- *params = INT_TO_BOOL(ctx->Array.Vertex.BufferBinding);
+ *params = INT_TO_BOOL(ctx->Array.Vertex.BufferObj->Name);
break;
case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_B(ARB_vertex_buffer_object, pname);
- *params = INT_TO_BOOL(ctx->Array.Normal.BufferBinding);
+ *params = INT_TO_BOOL(ctx->Array.Normal.BufferObj->Name);
break;
case GL_COLOR_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_B(ARB_vertex_buffer_object, pname);
- *params = INT_TO_BOOL(ctx->Array.Color.BufferBinding);
+ *params = INT_TO_BOOL(ctx->Array.Color.BufferObj->Name);
break;
case GL_INDEX_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_B(ARB_vertex_buffer_object, pname);
- *params = INT_TO_BOOL(ctx->Array.Index.BufferBinding);
+ *params = INT_TO_BOOL(ctx->Array.Index.BufferObj->Name);
break;
case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_B(ARB_vertex_buffer_object, pname);
- *params = INT_TO_BOOL(ctx->Array.TexCoord[clientUnit].BufferBinding);
+ *params = INT_TO_BOOL(ctx->Array.TexCoord[clientUnit].BufferObj->Name);
break;
case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_B(ARB_vertex_buffer_object, pname);
- *params = INT_TO_BOOL(ctx->Array.EdgeFlag.BufferBinding);
+ *params = INT_TO_BOOL(ctx->Array.EdgeFlag.BufferObj->Name);
break;
case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_B(ARB_vertex_buffer_object, pname);
- *params = INT_TO_BOOL(ctx->Array.SecondaryColor.BufferBinding);
+ *params = INT_TO_BOOL(ctx->Array.SecondaryColor.BufferObj->Name);
break;
case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_B(ARB_vertex_buffer_object, pname);
- *params = INT_TO_BOOL(ctx->Array.FogCoord.BufferBinding);
+ *params = INT_TO_BOOL(ctx->Array.FogCoord.BufferObj->Name);
break;
/*case GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB: - not supported */
case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_B(ARB_vertex_buffer_object, pname);
- *params = INT_TO_BOOL(ctx->Array.ElementArrayBufferBinding);
+ *params = INT_TO_BOOL(ctx->Array.ElementArrayBufferObj->Name);
break;
#endif
#if FEATURE_ARB_vertex_buffer_object
case GL_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_D(ARB_vertex_buffer_object, pname);
- *params = (GLdouble) ctx->Array.ArrayBufferBinding;
+ *params = (GLdouble) ctx->Array.ArrayBufferObj->Name;
break;
case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_D(ARB_vertex_buffer_object, pname);
- *params = (GLdouble) ctx->Array.Vertex.BufferBinding;
+ *params = (GLdouble) ctx->Array.Vertex.BufferObj->Name;
break;
case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_D(ARB_vertex_buffer_object, pname);
- *params = (GLdouble) ctx->Array.Normal.BufferBinding;
+ *params = (GLdouble) ctx->Array.Normal.BufferObj->Name;
break;
case GL_COLOR_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_D(ARB_vertex_buffer_object, pname);
- *params = (GLdouble) ctx->Array.Color.BufferBinding;
+ *params = (GLdouble) ctx->Array.Color.BufferObj->Name;
break;
case GL_INDEX_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_D(ARB_vertex_buffer_object, pname);
- *params = (GLdouble) ctx->Array.Index.BufferBinding;
+ *params = (GLdouble) ctx->Array.Index.BufferObj->Name;
break;
case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_D(ARB_vertex_buffer_object, pname);
- *params = (GLdouble) ctx->Array.TexCoord[clientUnit].BufferBinding;
+ *params = (GLdouble) ctx->Array.TexCoord[clientUnit].BufferObj->Name;
break;
case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_D(ARB_vertex_buffer_object, pname);
- *params = (GLdouble) ctx->Array.EdgeFlag.BufferBinding;
+ *params = (GLdouble) ctx->Array.EdgeFlag.BufferObj->Name;
break;
case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_D(ARB_vertex_buffer_object, pname);
- *params = (GLdouble) ctx->Array.SecondaryColor.BufferBinding;
+ *params = (GLdouble) ctx->Array.SecondaryColor.BufferObj->Name;
break;
case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_D(ARB_vertex_buffer_object, pname);
- *params = (GLdouble) ctx->Array.FogCoord.BufferBinding;
+ *params = (GLdouble) ctx->Array.FogCoord.BufferObj->Name;
break;
/*case GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB: - not supported */
case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_D(ARB_vertex_buffer_object, pname);
- *params = (GLdouble) ctx->Array.ElementArrayBufferBinding;
+ *params = (GLdouble) ctx->Array.ElementArrayBufferObj->Name;
break;
#endif
#if FEATURE_ARB_vertex_buffer_object
case GL_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_F(ARB_vertex_buffer_object, pname);
- *params = (GLfloat) ctx->Array.ArrayBufferBinding;
+ *params = (GLfloat) ctx->Array.ArrayBufferObj->Name;
break;
case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_F(ARB_vertex_buffer_object, pname);
- *params = (GLfloat) ctx->Array.Vertex.BufferBinding;
+ *params = (GLfloat) ctx->Array.Vertex.BufferObj->Name;
break;
case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_F(ARB_vertex_buffer_object, pname);
- *params = (GLfloat) ctx->Array.Normal.BufferBinding;
+ *params = (GLfloat) ctx->Array.Normal.BufferObj->Name;
break;
case GL_COLOR_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_F(ARB_vertex_buffer_object, pname);
- *params = (GLfloat) ctx->Array.Color.BufferBinding;
+ *params = (GLfloat) ctx->Array.Color.BufferObj->Name;
break;
case GL_INDEX_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_F(ARB_vertex_buffer_object, pname);
- *params = (GLfloat) ctx->Array.Index.BufferBinding;
+ *params = (GLfloat) ctx->Array.Index.BufferObj->Name;
break;
case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_F(ARB_vertex_buffer_object, pname);
- *params = (GLfloat) ctx->Array.TexCoord[clientUnit].BufferBinding;
+ *params = (GLfloat) ctx->Array.TexCoord[clientUnit].BufferObj->Name;
break;
case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_F(ARB_vertex_buffer_object, pname);
- *params = (GLfloat) ctx->Array.EdgeFlag.BufferBinding;
+ *params = (GLfloat) ctx->Array.EdgeFlag.BufferObj->Name;
break;
case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_F(ARB_vertex_buffer_object, pname);
- *params = (GLfloat) ctx->Array.SecondaryColor.BufferBinding;
+ *params = (GLfloat) ctx->Array.SecondaryColor.BufferObj->Name;
break;
case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_F(ARB_vertex_buffer_object, pname);
- *params = (GLfloat) ctx->Array.FogCoord.BufferBinding;
+ *params = (GLfloat) ctx->Array.FogCoord.BufferObj->Name;
break;
/*case GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB: - not supported */
case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_F(ARB_vertex_buffer_object, pname);
- *params = (GLfloat) ctx->Array.ElementArrayBufferBinding;
+ *params = (GLfloat) ctx->Array.ElementArrayBufferObj->Name;
break;
#endif
#if FEATURE_ARB_vertex_buffer_object
case GL_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_I(ARB_vertex_buffer_object, pname);
- *params = (GLint) ctx->Array.ArrayBufferBinding;
+ *params = (GLint) ctx->Array.ArrayBufferObj->Name;
break;
case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_I(ARB_vertex_buffer_object, pname);
- *params = (GLint) ctx->Array.Vertex.BufferBinding;
+ *params = (GLint) ctx->Array.Vertex.BufferObj->Name;
break;
case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_I(ARB_vertex_buffer_object, pname);
- *params = (GLint) ctx->Array.Normal.BufferBinding;
+ *params = (GLint) ctx->Array.Normal.BufferObj->Name;
break;
case GL_COLOR_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_I(ARB_vertex_buffer_object, pname);
- *params = (GLint) ctx->Array.Color.BufferBinding;
+ *params = (GLint) ctx->Array.Color.BufferObj->Name;
break;
case GL_INDEX_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_I(ARB_vertex_buffer_object, pname);
- *params = (GLint) ctx->Array.Index.BufferBinding;
+ *params = (GLint) ctx->Array.Index.BufferObj->Name;
break;
case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_I(ARB_vertex_buffer_object, pname);
- *params = (GLint) ctx->Array.TexCoord[clientUnit].BufferBinding;
+ *params = (GLint) ctx->Array.TexCoord[clientUnit].BufferObj->Name;
break;
case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_I(ARB_vertex_buffer_object, pname);
- *params = (GLint) ctx->Array.EdgeFlag.BufferBinding;
+ *params = (GLint) ctx->Array.EdgeFlag.BufferObj->Name;
break;
case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_I(ARB_vertex_buffer_object, pname);
- *params = (GLint) ctx->Array.SecondaryColor.BufferBinding;
+ *params = (GLint) ctx->Array.SecondaryColor.BufferObj->Name;
break;
case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_I(ARB_vertex_buffer_object, pname);
- *params = (GLint) ctx->Array.FogCoord.BufferBinding;
+ *params = (GLint) ctx->Array.FogCoord.BufferObj->Name;
break;
/*case GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB: - not supported */
case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB:
CHECK_EXTENSION_I(ARB_vertex_buffer_object, pname);
- *params = (GLint) ctx->Array.ElementArrayBufferBinding;
+ *params = (GLint) ctx->Array.ElementArrayBufferObj->Name;
break;
#endif
};
+/**
+ * GL_ARB_vertex_buffer_object buffer object
+ */
+struct gl_buffer_object {
+ GLint RefCount;
+ GLuint Name;
+ GLenum Target;
+ GLenum Usage;
+ GLenum Access;
+ GLvoid *Pointer; /**< Only valid while buffer is mapped */
+ GLuint Size; /**< Size of data array in bytes */
+ GLubyte *Data; /**< The storage */
+};
+
+
+
/**
* Client pixel packing/unpacking attributes
*/
GLenum Type;
GLsizei Stride; /**< user-specified stride */
GLsizei StrideB; /**< actual stride in bytes */
- void *Ptr;
+ GLubyte *Ptr;
GLuint Flags;
GLuint Enabled; /**< one of the _NEW_ARRAY_ bits */
GLboolean Normalized; /**< GL_ARB_vertex_program */
- GLuint BufferBinding; /**< GL_ARB_vertex_buffer_object */
+
+ /**< GL_ARB_vertex_buffer_object */
+ struct gl_buffer_object *BufferObj;
};
GLint TexCoordInterleaveFactor;
GLint ActiveTexture; /**< Client Active Texture */
- GLuint LockFirst;
- GLuint LockCount;
+ GLuint LockFirst; /**< GL_EXT_compiled_vertex_array */
+ GLuint LockCount; /**< GL_EXT_compiled_vertex_array */
GLuint _Enabled; /**< _NEW_ARRAY_* - bit set if array enabled */
GLuint NewState; /**< _NEW_ARRAY_* */
- /* GL_ARB_vertex_buffer_object */
- GLuint ArrayBufferBinding;
- GLuint ElementArrayBufferBinding;
+#if FEATURE_ARB_vertex_buffer_object
+ struct gl_buffer_object *NullBufferObj;
+ struct gl_buffer_object *ArrayBufferObj;
+ struct gl_buffer_object *ElementArrayBufferObj;
+#endif
};
#endif
/*@}*/
- /** GL_ARB_vertex_buffer_objects */
+#if FEATURE_ARB_vertex_buffer_object
struct _mesa_HashTable *BufferObjects;
+#endif
void *DriverData; /**< Device driver shared state */
};
/* This has to be included here. */
-struct gl_buffer_object;
#include "dd.h"
/** Core tnl module support */
struct gl_tnl_module TnlModule;
- /**
- * \name GL_ARB_vertex_buffer_object state
- *
- * These pointers track the buffer objects last bound via
- * \c glBindBufferObjectARB. If it the last bound object ID was 0 for a
- * given target, the pointer will be \c NULL.
- */
- /*@{*/
- struct gl_buffer_object * ArrayBuffer;
- struct gl_buffer_object * ElementArrayBuffer;
- /*@}*/
-
/**
* \name Hooks for module contexts.
*
_mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribdvNV");
return;
}
- params[0] = ctx->Array.VertexAttrib[index].BufferBinding;
+ params[0] = ctx->Array.VertexAttrib[index].BufferObj->Name;
break;
default:
_mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribdvNV");
#include "glheader.h"
+#include "imports.h"
#include "context.h"
#include "enable.h"
#include "enums.h"
#include "dlist.h"
-#include "light.h"
-#include "macros.h"
-#include "state.h"
#include "texstate.h"
#include "mtypes.h"
#include "varray.h"
-#include "math/m_translate.h"
void
ctx->Array.Vertex.Type = type;
ctx->Array.Vertex.Stride = stride;
ctx->Array.Vertex.Ptr = (void *) ptr;
+#if FEATURE_ARB_vertex_buffer_object
+ ctx->Array.Vertex.BufferObj = ctx->Array.ArrayBufferObj;
+#endif
ctx->NewState |= _NEW_ARRAY;
ctx->Array.NewState |= _NEW_ARRAY_VERTEX;
}
-
-
void
_mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr )
{
ctx->Array.Normal.Type = type;
ctx->Array.Normal.Stride = stride;
ctx->Array.Normal.Ptr = (void *) ptr;
+#if FEATURE_ARB_vertex_buffer_object
+ ctx->Array.Normal.BufferObj = ctx->Array.ArrayBufferObj;
+#endif
ctx->NewState |= _NEW_ARRAY;
ctx->Array.NewState |= _NEW_ARRAY_NORMAL;
}
-
void
_mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
{
ctx->Array.Color.Type = type;
ctx->Array.Color.Stride = stride;
ctx->Array.Color.Ptr = (void *) ptr;
+#if FEATURE_ARB_vertex_buffer_object
+ ctx->Array.Color.BufferObj = ctx->Array.ArrayBufferObj;
+#endif
ctx->NewState |= _NEW_ARRAY;
ctx->Array.NewState |= _NEW_ARRAY_COLOR0;
}
-
void
_mesa_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr)
{
ctx->Array.FogCoord.Type = type;
ctx->Array.FogCoord.Stride = stride;
ctx->Array.FogCoord.Ptr = (void *) ptr;
+#if FEATURE_ARB_vertex_buffer_object
+ ctx->Array.FogCoord.BufferObj = ctx->Array.ArrayBufferObj;
+#endif
ctx->NewState |= _NEW_ARRAY;
ctx->Array.NewState |= _NEW_ARRAY_FOGCOORD;
ctx->Array.Index.Type = type;
ctx->Array.Index.Stride = stride;
ctx->Array.Index.Ptr = (void *) ptr;
+#if FEATURE_ARB_vertex_buffer_object
+ ctx->Array.Index.BufferObj = ctx->Array.ArrayBufferObj;
+#endif
ctx->NewState |= _NEW_ARRAY;
ctx->Array.NewState |= _NEW_ARRAY_INDEX;
ctx->Array.SecondaryColor.Type = type;
ctx->Array.SecondaryColor.Stride = stride;
ctx->Array.SecondaryColor.Ptr = (void *) ptr;
+#if FEATURE_ARB_vertex_buffer_object
+ ctx->Array.SecondaryColor.BufferObj = ctx->Array.ArrayBufferObj;
+#endif
ctx->NewState |= _NEW_ARRAY;
ctx->Array.NewState |= _NEW_ARRAY_COLOR1;
}
-
void
_mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride,
const GLvoid *ptr)
ctx->Array.TexCoord[texUnit].Type = type;
ctx->Array.TexCoord[texUnit].Stride = stride;
ctx->Array.TexCoord[texUnit].Ptr = (void *) ptr;
+#if FEATURE_ARB_vertex_buffer_object
+ ctx->Array.TexCoord[texUnit].BufferObj = ctx->Array.ArrayBufferObj;
+#endif
ctx->NewState |= _NEW_ARRAY;
ctx->Array.NewState |= _NEW_ARRAY_TEXCOORD(texUnit);
ctx->Array.EdgeFlag.Stride = stride;
ctx->Array.EdgeFlag.StrideB = stride ? stride : sizeof(GLboolean);
ctx->Array.EdgeFlag.Ptr = (GLboolean *) ptr;
+#if FEATURE_ARB_vertex_buffer_object
+ ctx->Array.EdgeFlag.BufferObj = ctx->Array.ArrayBufferObj;
+#endif
ctx->NewState |= _NEW_ARRAY;
ctx->Array.NewState |= _NEW_ARRAY_EDGEFLAG;
}
+#if FEATURE_NV_vertex_program
void
_mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type,
GLsizei stride, const GLvoid *ptr)
ctx->Array.VertexAttrib[index].Size = size;
ctx->Array.VertexAttrib[index].Type = type;
ctx->Array.VertexAttrib[index].Ptr = (void *) ptr;
-
+#if FEATURE_ARB_vertex_buffer_object
+ ctx->Array.VertexAttrib[index].BufferObj = ctx->Array.ArrayBufferObj;
+#endif
ctx->NewState |= _NEW_ARRAY;
ctx->Array.NewState |= _NEW_ARRAY_ATTRIB(index);
if (ctx->Driver.VertexAttribPointer)
ctx->Driver.VertexAttribPointer( ctx, index, size, type, stride, ptr );
}
+#endif
+#if FEATURE_ARB_vertex_program
void
_mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type,
GLboolean normalized,
ctx->Array.VertexAttrib[index].Type = type;
ctx->Array.VertexAttrib[index].Normalized = normalized;
ctx->Array.VertexAttrib[index].Ptr = (void *) ptr;
-
+#if FEATURE_ARB_vertex_buffer_object
+ ctx->Array.VertexAttrib[index].BufferObj = ctx->Array.ArrayBufferObj;
+#endif
ctx->NewState |= _NEW_ARRAY;
ctx->Array.NewState |= _NEW_ARRAY_ATTRIB(index);
ctx->Driver.VertexAttribPointer( ctx, index, size, type, stride, ptr );
*/
}
-
+#endif
void
}
-
-
void
_mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer)
{
}
-
void
_mesa_LockArraysEXT(GLint first, GLsizei count)
{
}
-
/* GL_EXT_multi_draw_arrays */
/* Somebody forgot to spec the first and count parameters as const! <sigh> */
void
/***** Initialization *****/
/**********************************************************************/
-void _mesa_init_varray( GLcontext * ctx )
+void
+_mesa_init_varray( GLcontext * ctx )
{
- int i;
+ GLuint i;
/* Vertex arrays */
ctx->Array.Vertex.Size = 4;
ctx->Array.EdgeFlag.Enabled = GL_FALSE;
ctx->Array.EdgeFlag.Flags = CA_CLIENT_DATA;
ctx->Array.ActiveTexture = 0; /* GL_ARB_multitexture */
+ for (i = 0; i < VERT_ATTRIB_MAX; i++) {
+ ctx->Array.TexCoord[i].Size = 4;
+ ctx->Array.TexCoord[i].Type = GL_FLOAT;
+ ctx->Array.TexCoord[i].Stride = 0;
+ ctx->Array.TexCoord[i].StrideB = 0;
+ ctx->Array.TexCoord[i].Ptr = NULL;
+ ctx->Array.TexCoord[i].Enabled = GL_FALSE;
+ ctx->Array.TexCoord[i].Flags = CA_CLIENT_DATA;
+ }
}
}
if (inputs & VERT_BIT_COLOR1) {
- tmp->SecondaryColor.Ptr = IM->Attrib[VERT_ATTRIB_COLOR1] + start;
+ tmp->SecondaryColor.Ptr = (GLubyte *) (IM->Attrib[VERT_ATTRIB_COLOR1] + start);
VB->SecondaryColorPtr[0] = &tmp->SecondaryColor;
}
if (inputs & VERT_BIT_COLOR0) {
if (IM->CopyOrFlag & VERT_BIT_COLOR0) {
- tmp->Color.Ptr = IM->Attrib[VERT_ATTRIB_COLOR0] + start;
+ tmp->Color.Ptr = (GLubyte *) (IM->Attrib[VERT_ATTRIB_COLOR0] + start);
tmp->Color.StrideB = 4 * sizeof(GLfloat);
tmp->Color.Flags = 0;
}
else {
- tmp->Color.Ptr = ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
+ tmp->Color.Ptr = (GLubyte *) ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
tmp->Color.StrideB = 0;
tmp->Color.Flags = CA_CLIENT_DATA; /* hack */
VB->import_source = IM;
*/
static void init_color_array( struct gl_client_array *a, GLvector4f *vec )
{
- a->Ptr = vec->data;
+ a->Ptr = (GLubyte *) vec->data;
a->Size = 4;
a->Type = GL_FLOAT;
a->Stride = 0;