Home | History | Annotate | Download | only in main
      1 /*
      2  * Mesa 3-D graphics library
      3  * Version:  7.6
      4  *
      5  * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
      6  * Copyright (C) 2009  VMware, Inc.  All Rights Reserved.
      7  *
      8  * Permission is hereby granted, free of charge, to any person obtaining a
      9  * copy of this software and associated documentation files (the "Software"),
     10  * to deal in the Software without restriction, including without limitation
     11  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
     12  * and/or sell copies of the Software, and to permit persons to whom the
     13  * Software is furnished to do so, subject to the following conditions:
     14  *
     15  * The above copyright notice and this permission notice shall be included
     16  * in all copies or substantial portions of the Software.
     17  *
     18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
     19  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     21  * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
     22  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
     23  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     24  */
     25 
     26 
     27 #ifndef VARRAY_H
     28 #define VARRAY_H
     29 
     30 
     31 #include "glheader.h"
     32 #include "mfeatures.h"
     33 
     34 struct gl_client_array;
     35 struct gl_context;
     36 
     37 
     38 /**
     39  * Compute the index of the last array element that can be safely accessed in
     40  * a vertex array.  We can really only do this when the array lives in a VBO.
     41  * The array->_MaxElement field will be updated.
     42  * Later in glDrawArrays/Elements/etc we can do some bounds checking.
     43  */
     44 static inline void
     45 _mesa_update_array_max_element(struct gl_client_array *array)
     46 {
     47    assert(array->Enabled);
     48 
     49    if (array->BufferObj->Name) {
     50       GLsizeiptrARB offset = (GLsizeiptrARB) array->Ptr;
     51       GLsizeiptrARB bufSize = (GLsizeiptrARB) array->BufferObj->Size;
     52 
     53       if (offset < bufSize) {
     54 	 array->_MaxElement = (bufSize - offset + array->StrideB
     55                                - array->_ElementSize) / array->StrideB;
     56       }
     57       else {
     58 	 array->_MaxElement = 0;
     59       }
     60    }
     61    else {
     62       /* user-space array, no idea how big it is */
     63       array->_MaxElement = 2 * 1000 * 1000 * 1000; /* just a big number */
     64    }
     65 }
     66 
     67 
     68 #if _HAVE_FULL_GL
     69 
     70 extern void GLAPIENTRY
     71 _mesa_VertexPointer(GLint size, GLenum type, GLsizei stride,
     72                     const GLvoid *ptr);
     73 
     74 extern void GLAPIENTRY
     75 _mesa_UnlockArraysEXT( void );
     76 
     77 extern void GLAPIENTRY
     78 _mesa_LockArraysEXT(GLint first, GLsizei count);
     79 
     80 
     81 extern void GLAPIENTRY
     82 _mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr);
     83 
     84 
     85 extern void GLAPIENTRY
     86 _mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
     87 
     88 
     89 extern void GLAPIENTRY
     90 _mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr);
     91 
     92 
     93 extern void GLAPIENTRY
     94 _mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride,
     95                       const GLvoid *ptr);
     96 
     97 
     98 extern void GLAPIENTRY
     99 _mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *ptr);
    100 
    101 
    102 extern void GLAPIENTRY
    103 _mesa_VertexPointerEXT(GLint size, GLenum type, GLsizei stride,
    104                        GLsizei count, const GLvoid *ptr);
    105 
    106 
    107 extern void GLAPIENTRY
    108 _mesa_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count,
    109                        const GLvoid *ptr);
    110 
    111 
    112 extern void GLAPIENTRY
    113 _mesa_ColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count,
    114                       const GLvoid *ptr);
    115 
    116 
    117 extern void GLAPIENTRY
    118 _mesa_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count,
    119                       const GLvoid *ptr);
    120 
    121 
    122 extern void GLAPIENTRY
    123 _mesa_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride,
    124                          GLsizei count, const GLvoid *ptr);
    125 
    126 
    127 extern void GLAPIENTRY
    128 _mesa_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr);
    129 
    130 
    131 extern void GLAPIENTRY
    132 _mesa_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr);
    133 
    134 
    135 extern void GLAPIENTRY
    136 _mesa_SecondaryColorPointerEXT(GLint size, GLenum type,
    137 			       GLsizei stride, const GLvoid *ptr);
    138 
    139 
    140 extern void GLAPIENTRY
    141 _mesa_PointSizePointer(GLenum type, GLsizei stride, const GLvoid *ptr);
    142 
    143 
    144 extern void GLAPIENTRY
    145 _mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type,
    146                             GLsizei stride, const GLvoid *pointer);
    147 
    148 
    149 extern void GLAPIENTRY
    150 _mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type,
    151                              GLboolean normalized, GLsizei stride,
    152                              const GLvoid *pointer);
    153 
    154 void GLAPIENTRY
    155 _mesa_VertexAttribIPointer(GLuint index, GLint size, GLenum type,
    156                            GLsizei stride, const GLvoid *ptr);
    157 
    158 
    159 extern void GLAPIENTRY
    160 _mesa_EnableVertexAttribArrayARB(GLuint index);
    161 
    162 
    163 extern void GLAPIENTRY
    164 _mesa_DisableVertexAttribArrayARB(GLuint index);
    165 
    166 
    167 extern void GLAPIENTRY
    168 _mesa_GetVertexAttribdvARB(GLuint index, GLenum pname, GLdouble *params);
    169 
    170 
    171 extern void GLAPIENTRY
    172 _mesa_GetVertexAttribfvARB(GLuint index, GLenum pname, GLfloat *params);
    173 
    174 
    175 extern void GLAPIENTRY
    176 _mesa_GetVertexAttribivARB(GLuint index, GLenum pname, GLint *params);
    177 
    178 
    179 extern void GLAPIENTRY
    180 _mesa_GetVertexAttribIiv(GLuint index, GLenum pname, GLint *params);
    181 
    182 
    183 extern void GLAPIENTRY
    184 _mesa_GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint *params);
    185 
    186 
    187 extern void GLAPIENTRY
    188 _mesa_GetVertexAttribPointervARB(GLuint index, GLenum pname, GLvoid **pointer);
    189 
    190 
    191 extern void GLAPIENTRY
    192 _mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer);
    193 
    194 
    195 extern void GLAPIENTRY
    196 _mesa_MultiDrawArraysEXT( GLenum mode, const GLint *first,
    197                           const GLsizei *count, GLsizei primcount );
    198 
    199 extern void GLAPIENTRY
    200 _mesa_MultiDrawElementsEXT( GLenum mode, const GLsizei *count, GLenum type,
    201                             const GLvoid **indices, GLsizei primcount );
    202 
    203 extern void GLAPIENTRY
    204 _mesa_MultiDrawElementsBaseVertex( GLenum mode,
    205 				   const GLsizei *count, GLenum type,
    206 				   const GLvoid **indices, GLsizei primcount,
    207 				   const GLint *basevertex);
    208 
    209 extern void GLAPIENTRY
    210 _mesa_MultiModeDrawArraysIBM( const GLenum * mode, const GLint * first,
    211 			      const GLsizei * count,
    212 			      GLsizei primcount, GLint modestride );
    213 
    214 
    215 extern void GLAPIENTRY
    216 _mesa_MultiModeDrawElementsIBM( const GLenum * mode, const GLsizei * count,
    217 				GLenum type, const GLvoid * const * indices,
    218 				GLsizei primcount, GLint modestride );
    219 
    220 extern void GLAPIENTRY
    221 _mesa_LockArraysEXT(GLint first, GLsizei count);
    222 
    223 extern void GLAPIENTRY
    224 _mesa_UnlockArraysEXT( void );
    225 
    226 
    227 extern void GLAPIENTRY
    228 _mesa_DrawArrays(GLenum mode, GLint first, GLsizei count);
    229 
    230 extern void GLAPIENTRY
    231 _mesa_DrawElements(GLenum mode, GLsizei count, GLenum type,
    232                    const GLvoid *indices);
    233 
    234 extern void GLAPIENTRY
    235 _mesa_DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count,
    236                         GLenum type, const GLvoid *indices);
    237 
    238 extern void GLAPIENTRY
    239 _mesa_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type,
    240 			     const GLvoid *indices, GLint basevertex);
    241 
    242 extern void GLAPIENTRY
    243 _mesa_DrawRangeElementsBaseVertex(GLenum mode, GLuint start, GLuint end,
    244 				  GLsizei count, GLenum type,
    245 				  const GLvoid *indices,
    246 				  GLint basevertex);
    247 
    248 #if FEATURE_EXT_transform_feedback
    249 
    250 extern void GLAPIENTRY
    251 _mesa_DrawTransformFeedback(GLenum mode, GLuint name);
    252 
    253 #endif
    254 
    255 extern void GLAPIENTRY
    256 _mesa_PrimitiveRestartIndex(GLuint index);
    257 
    258 
    259 extern void GLAPIENTRY
    260 _mesa_VertexAttribDivisor(GLuint index, GLuint divisor);
    261 
    262 
    263 extern void
    264 _mesa_copy_client_array(struct gl_context *ctx,
    265                         struct gl_client_array *dst,
    266                         struct gl_client_array *src);
    267 
    268 
    269 extern void
    270 _mesa_print_arrays(struct gl_context *ctx);
    271 
    272 extern void
    273 _mesa_init_varray( struct gl_context * ctx );
    274 
    275 extern void
    276 _mesa_free_varray_data(struct gl_context *ctx);
    277 
    278 #else
    279 
    280 /** No-op */
    281 #define _mesa_init_varray( c )  ((void)0)
    282 #define _mesa_free_varray_data( c )  ((void)0)
    283 
    284 #endif
    285 
    286 #endif
    287