core | glapi | vbo | math | shader | swrast | swrast_setup | tnl | tnl_dd

arrayobj.c File Reference


Detailed Description

Functions for the GL_APPLE_vertex_array_object extension.

Todo:
The code in this file borrows a lot from bufferobj.c. There's a certain amount of cruft left over from that origin that may be unnecessary.
Author:
Ian Romanick <idr@us.ibm.com>

Brian Paul

#include "glheader.h"
#include "hash.h"
#include "imports.h"
#include "context.h"
#include "arrayobj.h"
#include "macros.h"
#include "glapi/dispatch.h"

Functions

static INLINE struct
gl_array_object
lookup_arrayobj (GLcontext *ctx, GLuint id)
 Look up the array object for the given ID.
static void unbind_array_object_vbos (GLcontext *ctx, struct gl_array_object *obj)
 For all the vertex arrays in the array object, unbind any pointers to any buffer objects (VBOs).
struct gl_array_object_mesa_new_array_object (GLcontext *ctx, GLuint name)
 Allocate and initialize a new vertex array object.
void _mesa_delete_array_object (GLcontext *ctx, struct gl_array_object *obj)
 Delete an array object.
void _mesa_reference_array_object (GLcontext *ctx, struct gl_array_object **ptr, struct gl_array_object *arrayObj)
 Set ptr to arrayObj w/ reference counting.
static void init_array (GLcontext *ctx, struct gl_client_array *array, GLint size, GLint type)
void _mesa_initialize_array_object (GLcontext *ctx, struct gl_array_object *obj, GLuint name)
 Initialize a gl_array_object's arrays.
static void save_array_object (GLcontext *ctx, struct gl_array_object *obj)
 Add the given array object to the array object pool.
static void remove_array_object (GLcontext *ctx, struct gl_array_object *obj)
 Remove the given array object from the array object pool.
static void compute_max_element (struct gl_client_array *array)
 Compute the index of the last array element that can be safely accessed in a vertex array.
static GLuint update_min (GLuint min, struct gl_client_array *array)
 Helper for update_arrays().
void _mesa_update_array_object_max_element (GLcontext *ctx, struct gl_array_object *arrayObj)
 Examine vertex arrays to update the gl_array_object::_MaxElement field.
static void bind_vertex_array (GLcontext *ctx, GLuint id, GLboolean genRequired)
 Helper for _mesa_BindVertexArray() and _mesa_BindVertexArrayAPPLE().
void GLAPIENTRY _mesa_BindVertexArray (GLuint id)
 ARB version of glBindVertexArray() This function behaves differently from glBindVertexArrayAPPLE() in that this function requires all ids to have been previously generated by glGenVertexArrays[APPLE]().
void GLAPIENTRY _mesa_BindVertexArrayAPPLE (GLuint id)
 Bind a new array.
void GLAPIENTRY _mesa_DeleteVertexArraysAPPLE (GLsizei n, const GLuint *ids)
 Delete a set of array objects.
static void gen_vertex_arrays (GLcontext *ctx, GLsizei n, GLuint *arrays, GLboolean vboOnly)
 Generate a set of unique array object IDs and store them in arrays.
void GLAPIENTRY _mesa_GenVertexArrays (GLsizei n, GLuint *arrays)
 ARB version of glGenVertexArrays() All arrays will be required to live in VBOs.
void GLAPIENTRY _mesa_GenVertexArraysAPPLE (GLsizei n, GLuint *arrays)
 APPLE version of glGenVertexArraysAPPLE() Arrays may live in VBOs or ordinary memory.
GLboolean GLAPIENTRY _mesa_IsVertexArrayAPPLE (GLuint id)
 Determine if ID is the name of an array object.


Function Documentation

void GLAPIENTRY _mesa_BindVertexArray ( GLuint  id  ) 

ARB version of glBindVertexArray() This function behaves differently from glBindVertexArrayAPPLE() in that this function requires all ids to have been previously generated by glGenVertexArrays[APPLE]().

void GLAPIENTRY _mesa_BindVertexArrayAPPLE ( GLuint  id  ) 

Bind a new array.

Todo:
The binding could be done more efficiently by comparing the non-NULL pointers in the old and new objects. The only arrays that are "dirty" are the ones that are non-NULL in either object.

void _mesa_delete_array_object ( GLcontext ctx,
struct gl_array_object obj 
)

Delete an array object.

This function is intended to be called via dd_function_table::DeleteArrayObject.

void GLAPIENTRY _mesa_DeleteVertexArraysAPPLE ( GLsizei  n,
const GLuint *  ids 
)

Delete a set of array objects.

Parameters:
n Number of array objects to delete.
ids Array of n array object IDs.

void GLAPIENTRY _mesa_GenVertexArrays ( GLsizei  n,
GLuint *  arrays 
)

ARB version of glGenVertexArrays() All arrays will be required to live in VBOs.

void GLAPIENTRY _mesa_GenVertexArraysAPPLE ( GLsizei  n,
GLuint *  arrays 
)

APPLE version of glGenVertexArraysAPPLE() Arrays may live in VBOs or ordinary memory.

void _mesa_initialize_array_object ( GLcontext ctx,
struct gl_array_object obj,
GLuint  name 
)

Initialize a gl_array_object's arrays.

GLboolean GLAPIENTRY _mesa_IsVertexArrayAPPLE ( GLuint  id  ) 

Determine if ID is the name of an array object.

Parameters:
id ID of the potential array object.
Returns:
GL_TRUE if id is the name of a array object, GL_FALSE otherwise.

struct gl_array_object* _mesa_new_array_object ( GLcontext ctx,
GLuint  name 
) [read]

Allocate and initialize a new vertex array object.

This function is intended to be called via dd_function_table::NewArrayObject.

void _mesa_reference_array_object ( GLcontext ctx,
struct gl_array_object **  ptr,
struct gl_array_object arrayObj 
)

Set ptr to arrayObj w/ reference counting.

void _mesa_update_array_object_max_element ( GLcontext ctx,
struct gl_array_object arrayObj 
)

Examine vertex arrays to update the gl_array_object::_MaxElement field.

static void bind_vertex_array ( GLcontext ctx,
GLuint  id,
GLboolean  genRequired 
) [static]

Helper for _mesa_BindVertexArray() and _mesa_BindVertexArrayAPPLE().

Parameters:
genRequired specifies behavour when id was not generated with glGenVertexArrays().

static void compute_max_element ( struct gl_client_array array  )  [static]

Compute the index of the last array element that can be safely accessed in a vertex array.

We can really only do this when the array lives in a VBO. The array->_MaxElement field will be updated. Later in glDrawArrays/Elements/etc we can do some bounds checking.

static void gen_vertex_arrays ( GLcontext ctx,
GLsizei  n,
GLuint *  arrays,
GLboolean  vboOnly 
) [static]

Generate a set of unique array object IDs and store them in arrays.

Helper for _mesa_GenVertexArrays[APPLE]() functions below.

Parameters:
n Number of IDs to generate.
arrays Array of n locations to store the IDs.
vboOnly Will arrays have to reside in VBOs?

static void init_array ( GLcontext ctx,
struct gl_client_array array,
GLint  size,
GLint  type 
) [static]

static INLINE struct gl_array_object* lookup_arrayobj ( GLcontext ctx,
GLuint  id 
) [static, read]

Look up the array object for the given ID.

Returns:
Either a pointer to the array object with the specified ID or NULL for a non-existent ID. The spec defines ID 0 as being technically non-existent.

static void remove_array_object ( GLcontext ctx,
struct gl_array_object obj 
) [static]

Remove the given array object from the array object pool.

Do not deallocate the array object though.

static void save_array_object ( GLcontext ctx,
struct gl_array_object obj 
) [static]

Add the given array object to the array object pool.

static void unbind_array_object_vbos ( GLcontext ctx,
struct gl_array_object obj 
) [static]

For all the vertex arrays in the array object, unbind any pointers to any buffer objects (VBOs).

This is done just prior to array object destruction.

static GLuint update_min ( GLuint  min,
struct gl_client_array array 
) [static]

Helper for update_arrays().

Returns:
min(current min, array->_MaxElement).


Generated on Sun Sep 27 06:47:45 2009 for Mesa Main by  doxygen 1.5.4