2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 #include "bufferobj.h"
35 #include "glapi/dispatch.h"
39 * Update the fields of a vertex array object.
40 * We need to do a few special things for arrays that live in
41 * vertex buffer objects.
43 * \param array the array to update
44 * \param dirtyBit which bit to set in ctx->Array.NewState for this array
45 * \param elementSize size of each array element, in bytes
46 * \param size components per element (1, 2, 3 or 4)
47 * \param type datatype of each component (GL_FLOAT, GL_INT, etc)
48 * \param stride stride between elements, in elements
49 * \param normalized are integer types converted to floats in [-1, 1]?
50 * \param ptr the address (or offset inside VBO) of the array data
53 update_array(GLcontext
*ctx
, struct gl_client_array
*array
,
54 GLbitfield dirtyBit
, GLsizei elementSize
,
55 GLint size
, GLenum type
,
56 GLsizei stride
, GLboolean normalized
, const GLvoid
*ptr
)
60 array
->Stride
= stride
;
61 array
->StrideB
= stride
? stride
: elementSize
;
62 array
->Normalized
= normalized
;
63 array
->Ptr
= (const GLubyte
*) ptr
;
64 #if FEATURE_ARB_vertex_buffer_object
65 _mesa_reference_buffer_object(ctx
, &array
->BufferObj
,
66 ctx
->Array
.ArrayBufferObj
);
68 /* Compute the index of the last array element that's inside the buffer.
69 * Later in glDrawArrays we'll check if start + count > _MaxElement to
70 * be sure we won't go out of bounds.
72 if (ctx
->Array
.ArrayBufferObj
->Name
)
73 array
->_MaxElement
= ((GLsizeiptrARB
) ctx
->Array
.ArrayBufferObj
->Size
74 - (GLsizeiptrARB
) array
->Ptr
+ array
->StrideB
75 - elementSize
) / array
->StrideB
;
78 array
->_MaxElement
= 2 * 1000 * 1000 * 1000; /* just a big number */
80 ctx
->NewState
|= _NEW_ARRAY
;
81 ctx
->Array
.NewState
|= dirtyBit
;
86 _mesa_VertexPointer(GLint size
, GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
89 GET_CURRENT_CONTEXT(ctx
);
90 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
92 if (size
< 2 || size
> 4) {
93 _mesa_error( ctx
, GL_INVALID_VALUE
, "glVertexPointer(size)" );
97 _mesa_error( ctx
, GL_INVALID_VALUE
, "glVertexPointer(stride)" );
101 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
102 _mesa_debug(ctx
, "glVertexPointer( sz %d type %s stride %d )\n", size
,
103 _mesa_lookup_enum_by_nr( type
), stride
);
105 /* always need to check that <type> is legal */
108 elementSize
= size
* sizeof(GLshort
);
111 elementSize
= size
* sizeof(GLint
);
114 elementSize
= size
* sizeof(GLfloat
);
117 elementSize
= size
* sizeof(GLdouble
);
120 _mesa_error( ctx
, GL_INVALID_ENUM
, "glVertexPointer(type)" );
124 update_array(ctx
, &ctx
->Array
.ArrayObj
->Vertex
, _NEW_ARRAY_VERTEX
,
125 elementSize
, size
, type
, stride
, GL_FALSE
, ptr
);
127 if (ctx
->Driver
.VertexPointer
)
128 ctx
->Driver
.VertexPointer( ctx
, size
, type
, stride
, ptr
);
133 _mesa_NormalPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
136 GET_CURRENT_CONTEXT(ctx
);
137 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
140 _mesa_error( ctx
, GL_INVALID_VALUE
, "glNormalPointer(stride)" );
144 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
145 _mesa_debug(ctx
, "glNormalPointer( type %s stride %d )\n",
146 _mesa_lookup_enum_by_nr( type
), stride
);
150 elementSize
= 3 * sizeof(GLbyte
);
153 elementSize
= 3 * sizeof(GLshort
);
156 elementSize
= 3 * sizeof(GLint
);
159 elementSize
= 3 * sizeof(GLfloat
);
162 elementSize
= 3 * sizeof(GLdouble
);
165 _mesa_error( ctx
, GL_INVALID_ENUM
, "glNormalPointer(type)" );
169 update_array(ctx
, &ctx
->Array
.ArrayObj
->Normal
, _NEW_ARRAY_NORMAL
,
170 elementSize
, 3, type
, stride
, GL_TRUE
, ptr
);
172 if (ctx
->Driver
.NormalPointer
)
173 ctx
->Driver
.NormalPointer( ctx
, type
, stride
, ptr
);
178 _mesa_ColorPointer(GLint size
, GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
181 GET_CURRENT_CONTEXT(ctx
);
182 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
184 if (size
< 3 || size
> 4) {
185 _mesa_error( ctx
, GL_INVALID_VALUE
, "glColorPointer(size)" );
189 _mesa_error( ctx
, GL_INVALID_VALUE
, "glColorPointer(stride)" );
193 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
194 _mesa_debug(ctx
, "glColorPointer( sz %d type %s stride %d )\n", size
,
195 _mesa_lookup_enum_by_nr( type
), stride
);
199 elementSize
= size
* sizeof(GLbyte
);
201 case GL_UNSIGNED_BYTE
:
202 elementSize
= size
* sizeof(GLubyte
);
205 elementSize
= size
* sizeof(GLshort
);
207 case GL_UNSIGNED_SHORT
:
208 elementSize
= size
* sizeof(GLushort
);
211 elementSize
= size
* sizeof(GLint
);
213 case GL_UNSIGNED_INT
:
214 elementSize
= size
* sizeof(GLuint
);
217 elementSize
= size
* sizeof(GLfloat
);
220 elementSize
= size
* sizeof(GLdouble
);
223 _mesa_error( ctx
, GL_INVALID_ENUM
, "glColorPointer(type)" );
227 update_array(ctx
, &ctx
->Array
.ArrayObj
->Color
, _NEW_ARRAY_COLOR0
,
228 elementSize
, size
, type
, stride
, GL_TRUE
, ptr
);
230 if (ctx
->Driver
.ColorPointer
)
231 ctx
->Driver
.ColorPointer( ctx
, size
, type
, stride
, ptr
);
236 _mesa_FogCoordPointerEXT(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
239 GET_CURRENT_CONTEXT(ctx
);
240 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
243 _mesa_error( ctx
, GL_INVALID_VALUE
, "glFogCoordPointer(stride)" );
249 elementSize
= sizeof(GLfloat
);
252 elementSize
= sizeof(GLdouble
);
255 _mesa_error( ctx
, GL_INVALID_ENUM
, "glFogCoordPointer(type)" );
259 update_array(ctx
, &ctx
->Array
.ArrayObj
->FogCoord
, _NEW_ARRAY_FOGCOORD
,
260 elementSize
, 1, type
, stride
, GL_FALSE
, ptr
);
262 if (ctx
->Driver
.FogCoordPointer
)
263 ctx
->Driver
.FogCoordPointer( ctx
, type
, stride
, ptr
);
268 _mesa_IndexPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
271 GET_CURRENT_CONTEXT(ctx
);
272 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
275 _mesa_error( ctx
, GL_INVALID_VALUE
, "glIndexPointer(stride)" );
280 case GL_UNSIGNED_BYTE
:
281 elementSize
= sizeof(GLubyte
);
284 elementSize
= sizeof(GLshort
);
287 elementSize
= sizeof(GLint
);
290 elementSize
= sizeof(GLfloat
);
293 elementSize
= sizeof(GLdouble
);
296 _mesa_error( ctx
, GL_INVALID_ENUM
, "glIndexPointer(type)" );
300 update_array(ctx
, &ctx
->Array
.ArrayObj
->Index
, _NEW_ARRAY_INDEX
,
301 elementSize
, 1, type
, stride
, GL_FALSE
, ptr
);
303 if (ctx
->Driver
.IndexPointer
)
304 ctx
->Driver
.IndexPointer( ctx
, type
, stride
, ptr
);
309 _mesa_SecondaryColorPointerEXT(GLint size
, GLenum type
,
310 GLsizei stride
, const GLvoid
*ptr
)
313 GET_CURRENT_CONTEXT(ctx
);
314 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
316 if (size
!= 3 && size
!= 4) {
317 _mesa_error( ctx
, GL_INVALID_VALUE
, "glSecondaryColorPointer(size)" );
321 _mesa_error( ctx
, GL_INVALID_VALUE
, "glSecondaryColorPointer(stride)" );
325 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
326 _mesa_debug(ctx
, "glSecondaryColorPointer( sz %d type %s stride %d )\n",
327 size
, _mesa_lookup_enum_by_nr( type
), stride
);
331 elementSize
= size
* sizeof(GLbyte
);
333 case GL_UNSIGNED_BYTE
:
334 elementSize
= size
* sizeof(GLubyte
);
337 elementSize
= size
* sizeof(GLshort
);
339 case GL_UNSIGNED_SHORT
:
340 elementSize
= size
* sizeof(GLushort
);
343 elementSize
= size
* sizeof(GLint
);
345 case GL_UNSIGNED_INT
:
346 elementSize
= size
* sizeof(GLuint
);
349 elementSize
= size
* sizeof(GLfloat
);
352 elementSize
= size
* sizeof(GLdouble
);
355 _mesa_error( ctx
, GL_INVALID_ENUM
, "glSecondaryColorPointer(type)" );
359 update_array(ctx
, &ctx
->Array
.ArrayObj
->SecondaryColor
, _NEW_ARRAY_COLOR1
,
360 elementSize
, size
, type
, stride
, GL_TRUE
, ptr
);
362 if (ctx
->Driver
.SecondaryColorPointer
)
363 ctx
->Driver
.SecondaryColorPointer( ctx
, size
, type
, stride
, ptr
);
368 _mesa_TexCoordPointer(GLint size
, GLenum type
, GLsizei stride
,
372 GET_CURRENT_CONTEXT(ctx
);
373 const GLuint unit
= ctx
->Array
.ActiveTexture
;
374 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
376 if (size
< 1 || size
> 4) {
377 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexCoordPointer(size)" );
381 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexCoordPointer(stride)" );
385 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
386 _mesa_debug(ctx
, "glTexCoordPointer(unit %u sz %d type %s stride %d)\n",
387 unit
, size
, _mesa_lookup_enum_by_nr( type
), stride
);
389 /* always need to check that <type> is legal */
392 elementSize
= size
* sizeof(GLshort
);
395 elementSize
= size
* sizeof(GLint
);
398 elementSize
= size
* sizeof(GLfloat
);
401 elementSize
= size
* sizeof(GLdouble
);
404 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexCoordPointer(type)" );
408 update_array(ctx
, &ctx
->Array
.ArrayObj
->TexCoord
[unit
],
409 _NEW_ARRAY_TEXCOORD(unit
),
410 elementSize
, size
, type
, stride
, GL_FALSE
, ptr
);
412 if (ctx
->Driver
.TexCoordPointer
)
413 ctx
->Driver
.TexCoordPointer( ctx
, size
, type
, stride
, ptr
);
418 _mesa_EdgeFlagPointer(GLsizei stride
, const GLvoid
*ptr
)
420 GET_CURRENT_CONTEXT(ctx
);
421 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
424 _mesa_error( ctx
, GL_INVALID_VALUE
, "glEdgeFlagPointer(stride)" );
428 update_array(ctx
, &ctx
->Array
.ArrayObj
->EdgeFlag
, _NEW_ARRAY_EDGEFLAG
,
429 sizeof(GLboolean
), 1, GL_UNSIGNED_BYTE
, stride
, GL_FALSE
, ptr
);
431 if (ctx
->Driver
.EdgeFlagPointer
)
432 ctx
->Driver
.EdgeFlagPointer( ctx
, stride
, ptr
);
436 #if FEATURE_NV_vertex_program
438 _mesa_VertexAttribPointerNV(GLuint index
, GLint size
, GLenum type
,
439 GLsizei stride
, const GLvoid
*ptr
)
441 GLboolean normalized
= GL_FALSE
;
443 GET_CURRENT_CONTEXT(ctx
);
444 ASSERT_OUTSIDE_BEGIN_END(ctx
);
446 if (index
>= MAX_VERTEX_PROGRAM_ATTRIBS
) {
447 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(index)");
451 if (size
< 1 || size
> 4) {
452 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(size)");
457 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(stride)");
461 if (type
== GL_UNSIGNED_BYTE
&& size
!= 4) {
462 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(size!=4)");
466 /* check for valid 'type' and compute StrideB right away */
468 case GL_UNSIGNED_BYTE
:
469 normalized
= GL_TRUE
;
470 elementSize
= size
* sizeof(GLubyte
);
473 elementSize
= size
* sizeof(GLshort
);
476 elementSize
= size
* sizeof(GLfloat
);
479 elementSize
= size
* sizeof(GLdouble
);
482 _mesa_error( ctx
, GL_INVALID_ENUM
, "glVertexAttribPointerNV(type)" );
486 update_array(ctx
, &ctx
->Array
.ArrayObj
->VertexAttrib
[index
],
487 _NEW_ARRAY_ATTRIB(index
),
488 elementSize
, size
, type
, stride
, normalized
, ptr
);
490 if (ctx
->Driver
.VertexAttribPointer
)
491 ctx
->Driver
.VertexAttribPointer( ctx
, index
, size
, type
, stride
, ptr
);
496 #if FEATURE_ARB_vertex_program
498 _mesa_VertexAttribPointerARB(GLuint index
, GLint size
, GLenum type
,
499 GLboolean normalized
,
500 GLsizei stride
, const GLvoid
*ptr
)
503 GET_CURRENT_CONTEXT(ctx
);
504 ASSERT_OUTSIDE_BEGIN_END(ctx
);
506 if (index
>= ctx
->Const
.VertexProgram
.MaxAttribs
) {
507 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(index)");
511 if (size
< 1 || size
> 4) {
512 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(size)");
517 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(stride)");
521 /* check for valid 'type' and compute StrideB right away */
522 /* NOTE: more types are supported here than in the NV extension */
525 elementSize
= size
* sizeof(GLbyte
);
527 case GL_UNSIGNED_BYTE
:
528 elementSize
= size
* sizeof(GLubyte
);
531 elementSize
= size
* sizeof(GLshort
);
533 case GL_UNSIGNED_SHORT
:
534 elementSize
= size
* sizeof(GLushort
);
537 elementSize
= size
* sizeof(GLint
);
539 case GL_UNSIGNED_INT
:
540 elementSize
= size
* sizeof(GLuint
);
543 elementSize
= size
* sizeof(GLfloat
);
546 elementSize
= size
* sizeof(GLdouble
);
549 _mesa_error( ctx
, GL_INVALID_ENUM
, "glVertexAttribPointerARB(type)" );
553 update_array(ctx
, &ctx
->Array
.ArrayObj
->VertexAttrib
[index
],
554 _NEW_ARRAY_ATTRIB(index
),
555 elementSize
, size
, type
, stride
, normalized
, ptr
);
557 if (ctx
->Driver
.VertexAttribPointer
)
558 ctx
->Driver
.VertexAttribPointer(ctx
, index
, size
, type
, stride
, ptr
);
564 _mesa_VertexPointerEXT(GLint size
, GLenum type
, GLsizei stride
,
565 GLsizei count
, const GLvoid
*ptr
)
568 _mesa_VertexPointer(size
, type
, stride
, ptr
);
573 _mesa_NormalPointerEXT(GLenum type
, GLsizei stride
, GLsizei count
,
577 _mesa_NormalPointer(type
, stride
, ptr
);
582 _mesa_ColorPointerEXT(GLint size
, GLenum type
, GLsizei stride
, GLsizei count
,
586 _mesa_ColorPointer(size
, type
, stride
, ptr
);
591 _mesa_IndexPointerEXT(GLenum type
, GLsizei stride
, GLsizei count
,
595 _mesa_IndexPointer(type
, stride
, ptr
);
600 _mesa_TexCoordPointerEXT(GLint size
, GLenum type
, GLsizei stride
,
601 GLsizei count
, const GLvoid
*ptr
)
604 _mesa_TexCoordPointer(size
, type
, stride
, ptr
);
609 _mesa_EdgeFlagPointerEXT(GLsizei stride
, GLsizei count
, const GLboolean
*ptr
)
612 _mesa_EdgeFlagPointer(stride
, ptr
);
617 _mesa_InterleavedArrays(GLenum format
, GLsizei stride
, const GLvoid
*pointer
)
619 GET_CURRENT_CONTEXT(ctx
);
620 GLboolean tflag
, cflag
, nflag
; /* enable/disable flags */
621 GLint tcomps
, ccomps
, vcomps
; /* components per texcoord, color, vertex */
622 GLenum ctype
= 0; /* color type */
623 GLint coffset
= 0, noffset
= 0, voffset
;/* color, normal, vertex offsets */
624 const GLint toffset
= 0; /* always zero */
625 GLint defstride
; /* default stride */
628 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
631 c
= f
* ((4 * sizeof(GLubyte
) + (f
- 1)) / f
);
634 _mesa_error( ctx
, GL_INVALID_VALUE
, "glInterleavedArrays(stride)" );
640 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
641 tcomps
= 0; ccomps
= 0; vcomps
= 2;
646 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
647 tcomps
= 0; ccomps
= 0; vcomps
= 3;
652 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
653 tcomps
= 0; ccomps
= 4; vcomps
= 2;
654 ctype
= GL_UNSIGNED_BYTE
;
660 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
661 tcomps
= 0; ccomps
= 4; vcomps
= 3;
662 ctype
= GL_UNSIGNED_BYTE
;
668 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
669 tcomps
= 0; ccomps
= 3; vcomps
= 3;
676 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_TRUE
;
677 tcomps
= 0; ccomps
= 0; vcomps
= 3;
683 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
684 tcomps
= 0; ccomps
= 4; vcomps
= 3;
692 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
693 tcomps
= 2; ccomps
= 0; vcomps
= 3;
698 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
699 tcomps
= 4; ccomps
= 0; vcomps
= 4;
703 case GL_T2F_C4UB_V3F
:
704 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
705 tcomps
= 2; ccomps
= 4; vcomps
= 3;
706 ctype
= GL_UNSIGNED_BYTE
;
712 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
713 tcomps
= 2; ccomps
= 3; vcomps
= 3;
720 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_TRUE
;
721 tcomps
= 2; ccomps
= 0; vcomps
= 3;
726 case GL_T2F_C4F_N3F_V3F
:
727 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
728 tcomps
= 2; ccomps
= 4; vcomps
= 3;
735 case GL_T4F_C4F_N3F_V4F
:
736 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
737 tcomps
= 4; ccomps
= 4; vcomps
= 4;
745 _mesa_error( ctx
, GL_INVALID_ENUM
, "glInterleavedArrays(format)" );
753 _mesa_DisableClientState( GL_EDGE_FLAG_ARRAY
);
754 _mesa_DisableClientState( GL_INDEX_ARRAY
);
755 /* XXX also disable secondary color and generic arrays? */
759 _mesa_EnableClientState( GL_TEXTURE_COORD_ARRAY
);
760 _mesa_TexCoordPointer( tcomps
, GL_FLOAT
, stride
,
761 (GLubyte
*) pointer
+ toffset
);
764 _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY
);
769 _mesa_EnableClientState( GL_COLOR_ARRAY
);
770 _mesa_ColorPointer( ccomps
, ctype
, stride
,
771 (GLubyte
*) pointer
+ coffset
);
774 _mesa_DisableClientState( GL_COLOR_ARRAY
);
780 _mesa_EnableClientState( GL_NORMAL_ARRAY
);
781 _mesa_NormalPointer( GL_FLOAT
, stride
, (GLubyte
*) pointer
+ noffset
);
784 _mesa_DisableClientState( GL_NORMAL_ARRAY
);
788 _mesa_EnableClientState( GL_VERTEX_ARRAY
);
789 _mesa_VertexPointer( vcomps
, GL_FLOAT
, stride
,
790 (GLubyte
*) pointer
+ voffset
);
795 _mesa_LockArraysEXT(GLint first
, GLsizei count
)
797 GET_CURRENT_CONTEXT(ctx
);
798 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
800 if (MESA_VERBOSE
& VERBOSE_API
)
801 _mesa_debug(ctx
, "glLockArrays %d %d\n", first
, count
);
804 _mesa_error( ctx
, GL_INVALID_VALUE
, "glLockArraysEXT(first)" );
808 _mesa_error( ctx
, GL_INVALID_VALUE
, "glLockArraysEXT(count)" );
811 if (ctx
->Array
.LockCount
!= 0) {
812 _mesa_error( ctx
, GL_INVALID_OPERATION
, "glLockArraysEXT(reentry)" );
816 ctx
->Array
.LockFirst
= first
;
817 ctx
->Array
.LockCount
= count
;
819 ctx
->NewState
|= _NEW_ARRAY
;
820 ctx
->Array
.NewState
|= _NEW_ARRAY_ALL
;
822 if (ctx
->Driver
.LockArraysEXT
)
823 ctx
->Driver
.LockArraysEXT( ctx
, first
, count
);
828 _mesa_UnlockArraysEXT( void )
830 GET_CURRENT_CONTEXT(ctx
);
831 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
833 if (MESA_VERBOSE
& VERBOSE_API
)
834 _mesa_debug(ctx
, "glUnlockArrays\n");
836 if (ctx
->Array
.LockCount
== 0) {
837 _mesa_error( ctx
, GL_INVALID_OPERATION
, "glUnlockArraysEXT(reexit)" );
841 ctx
->Array
.LockFirst
= 0;
842 ctx
->Array
.LockCount
= 0;
843 ctx
->NewState
|= _NEW_ARRAY
;
844 ctx
->Array
.NewState
|= _NEW_ARRAY_ALL
;
846 if (ctx
->Driver
.UnlockArraysEXT
)
847 ctx
->Driver
.UnlockArraysEXT( ctx
);
851 /* GL_EXT_multi_draw_arrays */
852 /* Somebody forgot to spec the first and count parameters as const! <sigh> */
854 _mesa_MultiDrawArraysEXT( GLenum mode
, GLint
*first
,
855 GLsizei
*count
, GLsizei primcount
)
857 GET_CURRENT_CONTEXT(ctx
);
860 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
862 for (i
= 0; i
< primcount
; i
++) {
864 CALL_DrawArrays(ctx
->Exec
, (mode
, first
[i
], count
[i
]));
870 /* GL_EXT_multi_draw_arrays */
872 _mesa_MultiDrawElementsEXT( GLenum mode
, const GLsizei
*count
, GLenum type
,
873 const GLvoid
**indices
, GLsizei primcount
)
875 GET_CURRENT_CONTEXT(ctx
);
878 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
880 for (i
= 0; i
< primcount
; i
++) {
882 CALL_DrawElements(ctx
->Exec
, (mode
, count
[i
], type
, indices
[i
]));
888 /* GL_IBM_multimode_draw_arrays */
890 _mesa_MultiModeDrawArraysIBM( const GLenum
* mode
, const GLint
* first
,
891 const GLsizei
* count
,
892 GLsizei primcount
, GLint modestride
)
894 GET_CURRENT_CONTEXT(ctx
);
897 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
899 for ( i
= 0 ; i
< primcount
; i
++ ) {
900 if ( count
[i
] > 0 ) {
901 GLenum m
= *((GLenum
*) ((GLubyte
*) mode
+ i
* modestride
));
902 CALL_DrawArrays(ctx
->Exec
, ( m
, first
[i
], count
[i
] ));
908 /* GL_IBM_multimode_draw_arrays */
910 _mesa_MultiModeDrawElementsIBM( const GLenum
* mode
, const GLsizei
* count
,
911 GLenum type
, const GLvoid
* const * indices
,
912 GLsizei primcount
, GLint modestride
)
914 GET_CURRENT_CONTEXT(ctx
);
917 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
919 /* XXX not sure about ARB_vertex_buffer_object handling here */
921 for ( i
= 0 ; i
< primcount
; i
++ ) {
922 if ( count
[i
] > 0 ) {
923 GLenum m
= *((GLenum
*) ((GLubyte
*) mode
+ i
* modestride
));
924 CALL_DrawElements(ctx
->Exec
, ( m
, count
[i
], type
, indices
[i
] ));
931 * Initialize vertex array state for given context.
934 _mesa_init_varray(GLcontext
*ctx
)
936 ctx
->Array
.DefaultArrayObj
= _mesa_new_array_object(ctx
, 0);
937 ctx
->Array
.ArrayObj
= ctx
->Array
.DefaultArrayObj
;
939 ctx
->Array
.ActiveTexture
= 0; /* GL_ARB_multitexture */