2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2006 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 array
->BufferObj
->RefCount
--;
66 if (array
->BufferObj
->RefCount
<= 0) {
67 ASSERT(array
->BufferObj
->Name
);
68 _mesa_remove_buffer_object( ctx
, array
->BufferObj
);
69 (*ctx
->Driver
.DeleteBuffer
)( ctx
, array
->BufferObj
);
71 array
->BufferObj
= ctx
->Array
.ArrayBufferObj
;
72 array
->BufferObj
->RefCount
++;
73 /* Compute the index of the last array element that's inside the buffer.
74 * Later in glDrawArrays we'll check if start + count > _MaxElement to
75 * be sure we won't go out of bounds.
77 if (ctx
->Array
.ArrayBufferObj
->Name
)
78 array
->_MaxElement
= ((GLsizeiptrARB
) ctx
->Array
.ArrayBufferObj
->Size
79 - (GLsizeiptrARB
) array
->Ptr
+ array
->StrideB
80 - elementSize
) / array
->StrideB
;
83 array
->_MaxElement
= 2 * 1000 * 1000 * 1000; /* just a big number */
85 ctx
->NewState
|= _NEW_ARRAY
;
86 ctx
->Array
.NewState
|= dirtyBit
;
91 _mesa_VertexPointer(GLint size
, GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
94 GET_CURRENT_CONTEXT(ctx
);
95 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
97 if (size
< 2 || size
> 4) {
98 _mesa_error( ctx
, GL_INVALID_VALUE
, "glVertexPointer(size)" );
102 _mesa_error( ctx
, GL_INVALID_VALUE
, "glVertexPointer(stride)" );
106 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
107 _mesa_debug(ctx
, "glVertexPointer( sz %d type %s stride %d )\n", size
,
108 _mesa_lookup_enum_by_nr( type
), stride
);
110 /* always need to check that <type> is legal */
113 elementSize
= size
* sizeof(GLshort
);
116 elementSize
= size
* sizeof(GLint
);
119 elementSize
= size
* sizeof(GLfloat
);
122 elementSize
= size
* sizeof(GLdouble
);
125 _mesa_error( ctx
, GL_INVALID_ENUM
, "glVertexPointer(type)" );
129 update_array(ctx
, &ctx
->Array
.ArrayObj
->Vertex
, _NEW_ARRAY_VERTEX
,
130 elementSize
, size
, type
, stride
, GL_FALSE
, ptr
);
132 if (ctx
->Driver
.VertexPointer
)
133 ctx
->Driver
.VertexPointer( ctx
, size
, type
, stride
, ptr
);
138 _mesa_NormalPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
141 GET_CURRENT_CONTEXT(ctx
);
142 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
145 _mesa_error( ctx
, GL_INVALID_VALUE
, "glNormalPointer(stride)" );
149 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
150 _mesa_debug(ctx
, "glNormalPointer( type %s stride %d )\n",
151 _mesa_lookup_enum_by_nr( type
), stride
);
155 elementSize
= 3 * sizeof(GLbyte
);
158 elementSize
= 3 * sizeof(GLshort
);
161 elementSize
= 3 * sizeof(GLint
);
164 elementSize
= 3 * sizeof(GLfloat
);
167 elementSize
= 3 * sizeof(GLdouble
);
170 _mesa_error( ctx
, GL_INVALID_ENUM
, "glNormalPointer(type)" );
174 update_array(ctx
, &ctx
->Array
.ArrayObj
->Normal
, _NEW_ARRAY_NORMAL
,
175 elementSize
, 3, type
, stride
, GL_TRUE
, ptr
);
177 if (ctx
->Driver
.NormalPointer
)
178 ctx
->Driver
.NormalPointer( ctx
, type
, stride
, ptr
);
183 _mesa_ColorPointer(GLint size
, GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
186 GET_CURRENT_CONTEXT(ctx
);
187 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
189 if (size
< 3 || size
> 4) {
190 _mesa_error( ctx
, GL_INVALID_VALUE
, "glColorPointer(size)" );
194 _mesa_error( ctx
, GL_INVALID_VALUE
, "glColorPointer(stride)" );
198 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
199 _mesa_debug(ctx
, "glColorPointer( sz %d type %s stride %d )\n", size
,
200 _mesa_lookup_enum_by_nr( type
), stride
);
204 elementSize
= size
* sizeof(GLbyte
);
206 case GL_UNSIGNED_BYTE
:
207 elementSize
= size
* sizeof(GLubyte
);
210 elementSize
= size
* sizeof(GLshort
);
212 case GL_UNSIGNED_SHORT
:
213 elementSize
= size
* sizeof(GLushort
);
216 elementSize
= size
* sizeof(GLint
);
218 case GL_UNSIGNED_INT
:
219 elementSize
= size
* sizeof(GLuint
);
222 elementSize
= size
* sizeof(GLfloat
);
225 elementSize
= size
* sizeof(GLdouble
);
228 _mesa_error( ctx
, GL_INVALID_ENUM
, "glColorPointer(type)" );
232 update_array(ctx
, &ctx
->Array
.ArrayObj
->Color
, _NEW_ARRAY_COLOR0
,
233 elementSize
, size
, type
, stride
, GL_TRUE
, ptr
);
235 if (ctx
->Driver
.ColorPointer
)
236 ctx
->Driver
.ColorPointer( ctx
, size
, type
, stride
, ptr
);
241 _mesa_FogCoordPointerEXT(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
244 GET_CURRENT_CONTEXT(ctx
);
245 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
248 _mesa_error( ctx
, GL_INVALID_VALUE
, "glFogCoordPointer(stride)" );
254 elementSize
= sizeof(GLfloat
);
257 elementSize
= sizeof(GLdouble
);
260 _mesa_error( ctx
, GL_INVALID_ENUM
, "glFogCoordPointer(type)" );
264 update_array(ctx
, &ctx
->Array
.ArrayObj
->FogCoord
, _NEW_ARRAY_FOGCOORD
,
265 elementSize
, 1, type
, stride
, GL_FALSE
, ptr
);
267 if (ctx
->Driver
.FogCoordPointer
)
268 ctx
->Driver
.FogCoordPointer( ctx
, type
, stride
, ptr
);
273 _mesa_IndexPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
276 GET_CURRENT_CONTEXT(ctx
);
277 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
280 _mesa_error( ctx
, GL_INVALID_VALUE
, "glIndexPointer(stride)" );
285 case GL_UNSIGNED_BYTE
:
286 elementSize
= sizeof(GLubyte
);
289 elementSize
= sizeof(GLshort
);
292 elementSize
= sizeof(GLint
);
295 elementSize
= sizeof(GLfloat
);
298 elementSize
= sizeof(GLdouble
);
301 _mesa_error( ctx
, GL_INVALID_ENUM
, "glIndexPointer(type)" );
305 update_array(ctx
, &ctx
->Array
.ArrayObj
->Index
, _NEW_ARRAY_INDEX
,
306 elementSize
, 1, type
, stride
, GL_FALSE
, ptr
);
308 if (ctx
->Driver
.IndexPointer
)
309 ctx
->Driver
.IndexPointer( ctx
, type
, stride
, ptr
);
314 _mesa_SecondaryColorPointerEXT(GLint size
, GLenum type
,
315 GLsizei stride
, const GLvoid
*ptr
)
318 GET_CURRENT_CONTEXT(ctx
);
319 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
321 if (size
!= 3 && size
!= 4) {
322 _mesa_error( ctx
, GL_INVALID_VALUE
, "glSecondaryColorPointer(size)" );
326 _mesa_error( ctx
, GL_INVALID_VALUE
, "glSecondaryColorPointer(stride)" );
330 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
331 _mesa_debug(ctx
, "glSecondaryColorPointer( sz %d type %s stride %d )\n",
332 size
, _mesa_lookup_enum_by_nr( type
), stride
);
336 elementSize
= size
* sizeof(GLbyte
);
338 case GL_UNSIGNED_BYTE
:
339 elementSize
= size
* sizeof(GLubyte
);
342 elementSize
= size
* sizeof(GLshort
);
344 case GL_UNSIGNED_SHORT
:
345 elementSize
= size
* sizeof(GLushort
);
348 elementSize
= size
* sizeof(GLint
);
350 case GL_UNSIGNED_INT
:
351 elementSize
= size
* sizeof(GLuint
);
354 elementSize
= size
* sizeof(GLfloat
);
357 elementSize
= size
* sizeof(GLdouble
);
360 _mesa_error( ctx
, GL_INVALID_ENUM
, "glSecondaryColorPointer(type)" );
364 update_array(ctx
, &ctx
->Array
.ArrayObj
->SecondaryColor
, _NEW_ARRAY_COLOR1
,
365 elementSize
, size
, type
, stride
, GL_TRUE
, ptr
);
367 if (ctx
->Driver
.SecondaryColorPointer
)
368 ctx
->Driver
.SecondaryColorPointer( ctx
, size
, type
, stride
, ptr
);
373 _mesa_TexCoordPointer(GLint size
, GLenum type
, GLsizei stride
,
377 GET_CURRENT_CONTEXT(ctx
);
378 const GLuint unit
= ctx
->Array
.ActiveTexture
;
379 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
381 if (size
< 1 || size
> 4) {
382 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexCoordPointer(size)" );
386 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexCoordPointer(stride)" );
390 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
391 _mesa_debug(ctx
, "glTexCoordPointer(unit %u sz %d type %s stride %d)\n",
392 unit
, size
, _mesa_lookup_enum_by_nr( type
), stride
);
394 /* always need to check that <type> is legal */
397 elementSize
= size
* sizeof(GLshort
);
400 elementSize
= size
* sizeof(GLint
);
403 elementSize
= size
* sizeof(GLfloat
);
406 elementSize
= size
* sizeof(GLdouble
);
409 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexCoordPointer(type)" );
413 update_array(ctx
, &ctx
->Array
.ArrayObj
->TexCoord
[unit
],
414 _NEW_ARRAY_TEXCOORD(unit
),
415 elementSize
, size
, type
, stride
, GL_FALSE
, ptr
);
417 if (ctx
->Driver
.TexCoordPointer
)
418 ctx
->Driver
.TexCoordPointer( ctx
, size
, type
, stride
, ptr
);
423 _mesa_EdgeFlagPointer(GLsizei stride
, const GLvoid
*ptr
)
425 GET_CURRENT_CONTEXT(ctx
);
426 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
429 _mesa_error( ctx
, GL_INVALID_VALUE
, "glEdgeFlagPointer(stride)" );
433 update_array(ctx
, &ctx
->Array
.ArrayObj
->EdgeFlag
, _NEW_ARRAY_EDGEFLAG
,
434 sizeof(GLboolean
), 1, GL_UNSIGNED_BYTE
, stride
, GL_FALSE
, ptr
);
436 if (ctx
->Driver
.EdgeFlagPointer
)
437 ctx
->Driver
.EdgeFlagPointer( ctx
, stride
, ptr
);
441 #if FEATURE_NV_vertex_program
443 _mesa_VertexAttribPointerNV(GLuint index
, GLint size
, GLenum type
,
444 GLsizei stride
, const GLvoid
*ptr
)
446 GLboolean normalized
= GL_FALSE
;
448 GET_CURRENT_CONTEXT(ctx
);
449 ASSERT_OUTSIDE_BEGIN_END(ctx
);
451 if (index
>= MAX_VERTEX_PROGRAM_ATTRIBS
) {
452 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(index)");
456 if (size
< 1 || size
> 4) {
457 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(size)");
462 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(stride)");
466 if (type
== GL_UNSIGNED_BYTE
&& size
!= 4) {
467 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(size!=4)");
471 /* check for valid 'type' and compute StrideB right away */
473 case GL_UNSIGNED_BYTE
:
474 normalized
= GL_TRUE
;
475 elementSize
= size
* sizeof(GLubyte
);
478 elementSize
= size
* sizeof(GLshort
);
481 elementSize
= size
* sizeof(GLfloat
);
484 elementSize
= size
* sizeof(GLdouble
);
487 _mesa_error( ctx
, GL_INVALID_ENUM
, "glVertexAttribPointerNV(type)" );
491 update_array(ctx
, &ctx
->Array
.ArrayObj
->VertexAttrib
[index
],
492 _NEW_ARRAY_ATTRIB(index
),
493 elementSize
, size
, type
, stride
, normalized
, ptr
);
495 if (ctx
->Driver
.VertexAttribPointer
)
496 ctx
->Driver
.VertexAttribPointer( ctx
, index
, size
, type
, stride
, ptr
);
501 #if FEATURE_ARB_vertex_program
503 _mesa_VertexAttribPointerARB(GLuint index
, GLint size
, GLenum type
,
504 GLboolean normalized
,
505 GLsizei stride
, const GLvoid
*ptr
)
508 GET_CURRENT_CONTEXT(ctx
);
509 ASSERT_OUTSIDE_BEGIN_END(ctx
);
511 if (index
>= ctx
->Const
.VertexProgram
.MaxAttribs
) {
512 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(index)");
516 if (size
< 1 || size
> 4) {
517 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(size)");
522 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(stride)");
526 if (type
== GL_UNSIGNED_BYTE
&& size
!= 4) {
527 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(size!=4)");
531 /* check for valid 'type' and compute StrideB right away */
532 /* NOTE: more types are supported here than in the NV extension */
535 elementSize
= size
* sizeof(GLbyte
);
537 case GL_UNSIGNED_BYTE
:
538 elementSize
= size
* sizeof(GLubyte
);
541 elementSize
= size
* sizeof(GLshort
);
543 case GL_UNSIGNED_SHORT
:
544 elementSize
= size
* sizeof(GLushort
);
547 elementSize
= size
* sizeof(GLint
);
549 case GL_UNSIGNED_INT
:
550 elementSize
= size
* sizeof(GLuint
);
553 elementSize
= size
* sizeof(GLfloat
);
556 elementSize
= size
* sizeof(GLdouble
);
559 _mesa_error( ctx
, GL_INVALID_ENUM
, "glVertexAttribPointerARB(type)" );
563 update_array(ctx
, &ctx
->Array
.ArrayObj
->VertexAttrib
[index
],
564 _NEW_ARRAY_ATTRIB(index
),
565 elementSize
, size
, type
, stride
, normalized
, ptr
);
567 if (ctx
->Driver
.VertexAttribPointer
)
568 ctx
->Driver
.VertexAttribPointer(ctx
, index
, size
, type
, stride
, ptr
);
574 _mesa_VertexPointerEXT(GLint size
, GLenum type
, GLsizei stride
,
575 GLsizei count
, const GLvoid
*ptr
)
578 _mesa_VertexPointer(size
, type
, stride
, ptr
);
583 _mesa_NormalPointerEXT(GLenum type
, GLsizei stride
, GLsizei count
,
587 _mesa_NormalPointer(type
, stride
, ptr
);
592 _mesa_ColorPointerEXT(GLint size
, GLenum type
, GLsizei stride
, GLsizei count
,
596 _mesa_ColorPointer(size
, type
, stride
, ptr
);
601 _mesa_IndexPointerEXT(GLenum type
, GLsizei stride
, GLsizei count
,
605 _mesa_IndexPointer(type
, stride
, ptr
);
610 _mesa_TexCoordPointerEXT(GLint size
, GLenum type
, GLsizei stride
,
611 GLsizei count
, const GLvoid
*ptr
)
614 _mesa_TexCoordPointer(size
, type
, stride
, ptr
);
619 _mesa_EdgeFlagPointerEXT(GLsizei stride
, GLsizei count
, const GLboolean
*ptr
)
622 _mesa_EdgeFlagPointer(stride
, ptr
);
627 _mesa_InterleavedArrays(GLenum format
, GLsizei stride
, const GLvoid
*pointer
)
629 GET_CURRENT_CONTEXT(ctx
);
630 GLboolean tflag
, cflag
, nflag
; /* enable/disable flags */
631 GLint tcomps
, ccomps
, vcomps
; /* components per texcoord, color, vertex */
632 GLenum ctype
= 0; /* color type */
633 GLint coffset
= 0, noffset
= 0, voffset
;/* color, normal, vertex offsets */
634 const GLint toffset
= 0; /* always zero */
635 GLint defstride
; /* default stride */
638 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
641 c
= f
* ((4 * sizeof(GLubyte
) + (f
- 1)) / f
);
644 _mesa_error( ctx
, GL_INVALID_VALUE
, "glInterleavedArrays(stride)" );
650 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
651 tcomps
= 0; ccomps
= 0; vcomps
= 2;
656 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
657 tcomps
= 0; ccomps
= 0; vcomps
= 3;
662 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
663 tcomps
= 0; ccomps
= 4; vcomps
= 2;
664 ctype
= GL_UNSIGNED_BYTE
;
670 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
671 tcomps
= 0; ccomps
= 4; vcomps
= 3;
672 ctype
= GL_UNSIGNED_BYTE
;
678 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
679 tcomps
= 0; ccomps
= 3; vcomps
= 3;
686 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_TRUE
;
687 tcomps
= 0; ccomps
= 0; vcomps
= 3;
693 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
694 tcomps
= 0; ccomps
= 4; vcomps
= 3;
702 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
703 tcomps
= 2; ccomps
= 0; vcomps
= 3;
708 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
709 tcomps
= 4; ccomps
= 0; vcomps
= 4;
713 case GL_T2F_C4UB_V3F
:
714 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
715 tcomps
= 2; ccomps
= 4; vcomps
= 3;
716 ctype
= GL_UNSIGNED_BYTE
;
722 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
723 tcomps
= 2; ccomps
= 3; vcomps
= 3;
730 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_TRUE
;
731 tcomps
= 2; ccomps
= 0; vcomps
= 3;
736 case GL_T2F_C4F_N3F_V3F
:
737 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
738 tcomps
= 2; ccomps
= 4; vcomps
= 3;
745 case GL_T4F_C4F_N3F_V4F
:
746 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
747 tcomps
= 4; ccomps
= 4; vcomps
= 4;
755 _mesa_error( ctx
, GL_INVALID_ENUM
, "glInterleavedArrays(format)" );
763 _mesa_DisableClientState( GL_EDGE_FLAG_ARRAY
);
764 _mesa_DisableClientState( GL_INDEX_ARRAY
);
765 /* XXX also disable secondary color and generic arrays? */
769 _mesa_EnableClientState( GL_TEXTURE_COORD_ARRAY
);
770 _mesa_TexCoordPointer( tcomps
, GL_FLOAT
, stride
,
771 (GLubyte
*) pointer
+ toffset
);
774 _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY
);
779 _mesa_EnableClientState( GL_COLOR_ARRAY
);
780 _mesa_ColorPointer( ccomps
, ctype
, stride
,
781 (GLubyte
*) pointer
+ coffset
);
784 _mesa_DisableClientState( GL_COLOR_ARRAY
);
790 _mesa_EnableClientState( GL_NORMAL_ARRAY
);
791 _mesa_NormalPointer( GL_FLOAT
, stride
, (GLubyte
*) pointer
+ noffset
);
794 _mesa_DisableClientState( GL_NORMAL_ARRAY
);
798 _mesa_EnableClientState( GL_VERTEX_ARRAY
);
799 _mesa_VertexPointer( vcomps
, GL_FLOAT
, stride
,
800 (GLubyte
*) pointer
+ voffset
);
805 _mesa_LockArraysEXT(GLint first
, GLsizei count
)
807 GET_CURRENT_CONTEXT(ctx
);
808 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
810 if (MESA_VERBOSE
& VERBOSE_API
)
811 _mesa_debug(ctx
, "glLockArrays %d %d\n", first
, count
);
814 _mesa_error( ctx
, GL_INVALID_VALUE
, "glLockArraysEXT(first)" );
818 _mesa_error( ctx
, GL_INVALID_VALUE
, "glLockArraysEXT(count)" );
821 if (ctx
->Array
.LockCount
!= 0) {
822 _mesa_error( ctx
, GL_INVALID_OPERATION
, "glLockArraysEXT(reentry)" );
826 ctx
->Array
.LockFirst
= first
;
827 ctx
->Array
.LockCount
= count
;
829 ctx
->NewState
|= _NEW_ARRAY
;
830 ctx
->Array
.NewState
|= _NEW_ARRAY_ALL
;
832 if (ctx
->Driver
.LockArraysEXT
)
833 ctx
->Driver
.LockArraysEXT( ctx
, first
, count
);
838 _mesa_UnlockArraysEXT( void )
840 GET_CURRENT_CONTEXT(ctx
);
841 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
843 if (MESA_VERBOSE
& VERBOSE_API
)
844 _mesa_debug(ctx
, "glUnlockArrays\n");
846 if (ctx
->Array
.LockCount
== 0) {
847 _mesa_error( ctx
, GL_INVALID_OPERATION
, "glUnlockArraysEXT(reexit)" );
851 ctx
->Array
.LockFirst
= 0;
852 ctx
->Array
.LockCount
= 0;
853 ctx
->NewState
|= _NEW_ARRAY
;
854 ctx
->Array
.NewState
|= _NEW_ARRAY_ALL
;
856 if (ctx
->Driver
.UnlockArraysEXT
)
857 ctx
->Driver
.UnlockArraysEXT( ctx
);
861 /* GL_EXT_multi_draw_arrays */
862 /* Somebody forgot to spec the first and count parameters as const! <sigh> */
864 _mesa_MultiDrawArraysEXT( GLenum mode
, GLint
*first
,
865 GLsizei
*count
, GLsizei primcount
)
867 GET_CURRENT_CONTEXT(ctx
);
870 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
872 for (i
= 0; i
< primcount
; i
++) {
874 CALL_DrawArrays(ctx
->Exec
, (mode
, first
[i
], count
[i
]));
880 /* GL_EXT_multi_draw_arrays */
882 _mesa_MultiDrawElementsEXT( GLenum mode
, const GLsizei
*count
, GLenum type
,
883 const GLvoid
**indices
, GLsizei primcount
)
885 GET_CURRENT_CONTEXT(ctx
);
888 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
890 for (i
= 0; i
< primcount
; i
++) {
892 CALL_DrawElements(ctx
->Exec
, (mode
, count
[i
], type
, indices
[i
]));
898 /* GL_IBM_multimode_draw_arrays */
900 _mesa_MultiModeDrawArraysIBM( const GLenum
* mode
, const GLint
* first
,
901 const GLsizei
* count
,
902 GLsizei primcount
, GLint modestride
)
904 GET_CURRENT_CONTEXT(ctx
);
907 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
909 for ( i
= 0 ; i
< primcount
; i
++ ) {
910 if ( count
[i
] > 0 ) {
911 GLenum m
= *((GLenum
*) ((GLubyte
*) mode
+ i
* modestride
));
912 CALL_DrawArrays(ctx
->Exec
, ( m
, first
[i
], count
[i
] ));
918 /* GL_IBM_multimode_draw_arrays */
920 _mesa_MultiModeDrawElementsIBM( const GLenum
* mode
, const GLsizei
* count
,
921 GLenum type
, const GLvoid
* const * indices
,
922 GLsizei primcount
, GLint modestride
)
924 GET_CURRENT_CONTEXT(ctx
);
927 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
929 /* XXX not sure about ARB_vertex_buffer_object handling here */
931 for ( i
= 0 ; i
< primcount
; i
++ ) {
932 if ( count
[i
] > 0 ) {
933 GLenum m
= *((GLenum
*) ((GLubyte
*) mode
+ i
* modestride
));
934 CALL_DrawElements(ctx
->Exec
, ( m
, count
[i
], type
, indices
[i
] ));
941 * Initialize vertex array state for given context.
944 _mesa_init_varray(GLcontext
*ctx
)
946 ctx
->Array
.DefaultArrayObj
= _mesa_new_array_object(ctx
, 0);
947 ctx
->Array
.ArrayObj
= ctx
->Array
.DefaultArrayObj
;
949 ctx
->Array
.ActiveTexture
= 0; /* GL_ARB_multitexture */