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
);
126 elementSize
= size
* sizeof(GLfixed
);
129 #if FEATURE_vertex_array_byte
131 elementSize
= size
* sizeof(GLbyte
);
135 _mesa_error( ctx
, GL_INVALID_ENUM
, "glVertexPointer(type)" );
139 update_array(ctx
, &ctx
->Array
.ArrayObj
->Vertex
, _NEW_ARRAY_VERTEX
,
140 elementSize
, size
, type
, stride
, GL_FALSE
, ptr
);
142 if (ctx
->Driver
.VertexPointer
)
143 ctx
->Driver
.VertexPointer( ctx
, size
, type
, stride
, ptr
);
148 _mesa_NormalPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
151 GET_CURRENT_CONTEXT(ctx
);
152 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
155 _mesa_error( ctx
, GL_INVALID_VALUE
, "glNormalPointer(stride)" );
159 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
160 _mesa_debug(ctx
, "glNormalPointer( type %s stride %d )\n",
161 _mesa_lookup_enum_by_nr( type
), stride
);
165 elementSize
= 3 * sizeof(GLbyte
);
168 elementSize
= 3 * sizeof(GLshort
);
171 elementSize
= 3 * sizeof(GLint
);
174 elementSize
= 3 * sizeof(GLfloat
);
177 elementSize
= 3 * sizeof(GLdouble
);
181 elementSize
= 3 * sizeof(GLfixed
);
185 _mesa_error( ctx
, GL_INVALID_ENUM
, "glNormalPointer(type)" );
189 update_array(ctx
, &ctx
->Array
.ArrayObj
->Normal
, _NEW_ARRAY_NORMAL
,
190 elementSize
, 3, type
, stride
, GL_TRUE
, ptr
);
192 if (ctx
->Driver
.NormalPointer
)
193 ctx
->Driver
.NormalPointer( ctx
, type
, stride
, ptr
);
198 _mesa_ColorPointer(GLint size
, GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
201 GET_CURRENT_CONTEXT(ctx
);
202 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
204 if (size
< 3 || size
> 4) {
205 _mesa_error( ctx
, GL_INVALID_VALUE
, "glColorPointer(size)" );
209 _mesa_error( ctx
, GL_INVALID_VALUE
, "glColorPointer(stride)" );
213 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
214 _mesa_debug(ctx
, "glColorPointer( sz %d type %s stride %d )\n", size
,
215 _mesa_lookup_enum_by_nr( type
), stride
);
219 elementSize
= size
* sizeof(GLbyte
);
221 case GL_UNSIGNED_BYTE
:
222 elementSize
= size
* sizeof(GLubyte
);
225 elementSize
= size
* sizeof(GLshort
);
227 case GL_UNSIGNED_SHORT
:
228 elementSize
= size
* sizeof(GLushort
);
231 elementSize
= size
* sizeof(GLint
);
233 case GL_UNSIGNED_INT
:
234 elementSize
= size
* sizeof(GLuint
);
237 elementSize
= size
* sizeof(GLfloat
);
240 elementSize
= size
* sizeof(GLdouble
);
244 elementSize
= size
* sizeof(GLfixed
);
248 _mesa_error( ctx
, GL_INVALID_ENUM
, "glColorPointer(type)" );
252 update_array(ctx
, &ctx
->Array
.ArrayObj
->Color
, _NEW_ARRAY_COLOR0
,
253 elementSize
, size
, type
, stride
, GL_TRUE
, ptr
);
255 if (ctx
->Driver
.ColorPointer
)
256 ctx
->Driver
.ColorPointer( ctx
, size
, type
, stride
, ptr
);
261 _mesa_FogCoordPointerEXT(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
264 GET_CURRENT_CONTEXT(ctx
);
265 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
268 _mesa_error( ctx
, GL_INVALID_VALUE
, "glFogCoordPointer(stride)" );
274 elementSize
= sizeof(GLfloat
);
277 elementSize
= sizeof(GLdouble
);
280 _mesa_error( ctx
, GL_INVALID_ENUM
, "glFogCoordPointer(type)" );
284 update_array(ctx
, &ctx
->Array
.ArrayObj
->FogCoord
, _NEW_ARRAY_FOGCOORD
,
285 elementSize
, 1, type
, stride
, GL_FALSE
, ptr
);
287 if (ctx
->Driver
.FogCoordPointer
)
288 ctx
->Driver
.FogCoordPointer( ctx
, type
, stride
, ptr
);
293 _mesa_IndexPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
296 GET_CURRENT_CONTEXT(ctx
);
297 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
300 _mesa_error( ctx
, GL_INVALID_VALUE
, "glIndexPointer(stride)" );
305 case GL_UNSIGNED_BYTE
:
306 elementSize
= sizeof(GLubyte
);
309 elementSize
= sizeof(GLshort
);
312 elementSize
= sizeof(GLint
);
315 elementSize
= sizeof(GLfloat
);
318 elementSize
= sizeof(GLdouble
);
321 _mesa_error( ctx
, GL_INVALID_ENUM
, "glIndexPointer(type)" );
325 update_array(ctx
, &ctx
->Array
.ArrayObj
->Index
, _NEW_ARRAY_INDEX
,
326 elementSize
, 1, type
, stride
, GL_FALSE
, ptr
);
328 if (ctx
->Driver
.IndexPointer
)
329 ctx
->Driver
.IndexPointer( ctx
, type
, stride
, ptr
);
334 _mesa_SecondaryColorPointerEXT(GLint size
, GLenum type
,
335 GLsizei stride
, const GLvoid
*ptr
)
338 GET_CURRENT_CONTEXT(ctx
);
339 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
341 if (size
!= 3 && size
!= 4) {
342 _mesa_error( ctx
, GL_INVALID_VALUE
, "glSecondaryColorPointer(size)" );
346 _mesa_error( ctx
, GL_INVALID_VALUE
, "glSecondaryColorPointer(stride)" );
350 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
351 _mesa_debug(ctx
, "glSecondaryColorPointer( sz %d type %s stride %d )\n",
352 size
, _mesa_lookup_enum_by_nr( type
), stride
);
356 elementSize
= size
* sizeof(GLbyte
);
358 case GL_UNSIGNED_BYTE
:
359 elementSize
= size
* sizeof(GLubyte
);
362 elementSize
= size
* sizeof(GLshort
);
364 case GL_UNSIGNED_SHORT
:
365 elementSize
= size
* sizeof(GLushort
);
368 elementSize
= size
* sizeof(GLint
);
370 case GL_UNSIGNED_INT
:
371 elementSize
= size
* sizeof(GLuint
);
374 elementSize
= size
* sizeof(GLfloat
);
377 elementSize
= size
* sizeof(GLdouble
);
380 _mesa_error( ctx
, GL_INVALID_ENUM
, "glSecondaryColorPointer(type)" );
384 update_array(ctx
, &ctx
->Array
.ArrayObj
->SecondaryColor
, _NEW_ARRAY_COLOR1
,
385 elementSize
, size
, type
, stride
, GL_TRUE
, ptr
);
387 if (ctx
->Driver
.SecondaryColorPointer
)
388 ctx
->Driver
.SecondaryColorPointer( ctx
, size
, type
, stride
, ptr
);
393 _mesa_TexCoordPointer(GLint size
, GLenum type
, GLsizei stride
,
397 GET_CURRENT_CONTEXT(ctx
);
398 const GLuint unit
= ctx
->Array
.ActiveTexture
;
399 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
401 if (size
< 1 || size
> 4) {
402 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexCoordPointer(size)" );
406 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexCoordPointer(stride)" );
410 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
411 _mesa_debug(ctx
, "glTexCoordPointer(unit %u sz %d type %s stride %d)\n",
412 unit
, size
, _mesa_lookup_enum_by_nr( type
), stride
);
414 /* always need to check that <type> is legal */
417 elementSize
= size
* sizeof(GLshort
);
420 elementSize
= size
* sizeof(GLint
);
423 elementSize
= size
* sizeof(GLfloat
);
426 elementSize
= size
* sizeof(GLdouble
);
430 elementSize
= size
* sizeof(GLfixed
);
433 #if FEATURE_vertex_array_byte
435 elementSize
= size
* sizeof(GLbyte
);
439 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexCoordPointer(type)" );
443 update_array(ctx
, &ctx
->Array
.ArrayObj
->TexCoord
[unit
],
444 _NEW_ARRAY_TEXCOORD(unit
),
445 elementSize
, size
, type
, stride
, GL_FALSE
, ptr
);
447 if (ctx
->Driver
.TexCoordPointer
)
448 ctx
->Driver
.TexCoordPointer( ctx
, size
, type
, stride
, ptr
);
453 _mesa_EdgeFlagPointer(GLsizei stride
, const GLvoid
*ptr
)
455 GET_CURRENT_CONTEXT(ctx
);
456 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
459 _mesa_error( ctx
, GL_INVALID_VALUE
, "glEdgeFlagPointer(stride)" );
463 update_array(ctx
, &ctx
->Array
.ArrayObj
->EdgeFlag
, _NEW_ARRAY_EDGEFLAG
,
464 sizeof(GLboolean
), 1, GL_UNSIGNED_BYTE
, stride
, GL_FALSE
, ptr
);
466 if (ctx
->Driver
.EdgeFlagPointer
)
467 ctx
->Driver
.EdgeFlagPointer( ctx
, stride
, ptr
);
471 #if FEATURE_NV_vertex_program
473 _mesa_VertexAttribPointerNV(GLuint index
, GLint size
, GLenum type
,
474 GLsizei stride
, const GLvoid
*ptr
)
476 const GLboolean normalized
= GL_FALSE
;
478 GET_CURRENT_CONTEXT(ctx
);
479 ASSERT_OUTSIDE_BEGIN_END(ctx
);
481 if (index
>= MAX_VERTEX_PROGRAM_ATTRIBS
) {
482 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(index)");
486 if (size
< 1 || size
> 4) {
487 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(size)");
492 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(stride)");
496 if (type
== GL_UNSIGNED_BYTE
&& size
!= 4) {
497 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(size!=4)");
501 /* check for valid 'type' and compute StrideB right away */
503 case GL_UNSIGNED_BYTE
:
504 elementSize
= size
* sizeof(GLubyte
);
507 elementSize
= size
* sizeof(GLshort
);
510 elementSize
= size
* sizeof(GLfloat
);
513 elementSize
= size
* sizeof(GLdouble
);
516 _mesa_error( ctx
, GL_INVALID_ENUM
, "glVertexAttribPointerNV(type)" );
520 update_array(ctx
, &ctx
->Array
.ArrayObj
->VertexAttrib
[index
],
521 _NEW_ARRAY_ATTRIB(index
),
522 elementSize
, size
, type
, stride
, normalized
, ptr
);
524 if (ctx
->Driver
.VertexAttribPointer
)
525 ctx
->Driver
.VertexAttribPointer( ctx
, index
, size
, type
, stride
, ptr
);
530 #if FEATURE_ARB_vertex_program
532 _mesa_VertexAttribPointerARB(GLuint index
, GLint size
, GLenum type
,
533 GLboolean normalized
,
534 GLsizei stride
, const GLvoid
*ptr
)
537 GET_CURRENT_CONTEXT(ctx
);
538 ASSERT_OUTSIDE_BEGIN_END(ctx
);
540 if (index
>= ctx
->Const
.VertexProgram
.MaxAttribs
) {
541 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(index)");
545 if (size
< 1 || size
> 4) {
546 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(size)");
551 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(stride)");
555 if (type
== GL_UNSIGNED_BYTE
&& size
!= 4) {
556 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(size!=4)");
560 /* check for valid 'type' and compute StrideB right away */
561 /* NOTE: more types are supported here than in the NV extension */
564 elementSize
= size
* sizeof(GLbyte
);
566 case GL_UNSIGNED_BYTE
:
567 elementSize
= size
* sizeof(GLubyte
);
570 elementSize
= size
* sizeof(GLshort
);
572 case GL_UNSIGNED_SHORT
:
573 elementSize
= size
* sizeof(GLushort
);
576 elementSize
= size
* sizeof(GLint
);
578 case GL_UNSIGNED_INT
:
579 elementSize
= size
* sizeof(GLuint
);
582 elementSize
= size
* sizeof(GLfloat
);
585 elementSize
= size
* sizeof(GLdouble
);
588 _mesa_error( ctx
, GL_INVALID_ENUM
, "glVertexAttribPointerARB(type)" );
592 update_array(ctx
, &ctx
->Array
.ArrayObj
->VertexAttrib
[index
],
593 _NEW_ARRAY_ATTRIB(index
),
594 elementSize
, size
, type
, stride
, normalized
, ptr
);
596 if (ctx
->Driver
.VertexAttribPointer
)
597 ctx
->Driver
.VertexAttribPointer(ctx
, index
, size
, type
, stride
, ptr
);
603 _mesa_VertexPointerEXT(GLint size
, GLenum type
, GLsizei stride
,
604 GLsizei count
, const GLvoid
*ptr
)
607 _mesa_VertexPointer(size
, type
, stride
, ptr
);
612 _mesa_NormalPointerEXT(GLenum type
, GLsizei stride
, GLsizei count
,
616 _mesa_NormalPointer(type
, stride
, ptr
);
621 _mesa_ColorPointerEXT(GLint size
, GLenum type
, GLsizei stride
, GLsizei count
,
625 _mesa_ColorPointer(size
, type
, stride
, ptr
);
630 _mesa_IndexPointerEXT(GLenum type
, GLsizei stride
, GLsizei count
,
634 _mesa_IndexPointer(type
, stride
, ptr
);
639 _mesa_TexCoordPointerEXT(GLint size
, GLenum type
, GLsizei stride
,
640 GLsizei count
, const GLvoid
*ptr
)
643 _mesa_TexCoordPointer(size
, type
, stride
, ptr
);
648 _mesa_EdgeFlagPointerEXT(GLsizei stride
, GLsizei count
, const GLboolean
*ptr
)
651 _mesa_EdgeFlagPointer(stride
, ptr
);
656 _mesa_InterleavedArrays(GLenum format
, GLsizei stride
, const GLvoid
*pointer
)
658 GET_CURRENT_CONTEXT(ctx
);
659 GLboolean tflag
, cflag
, nflag
; /* enable/disable flags */
660 GLint tcomps
, ccomps
, vcomps
; /* components per texcoord, color, vertex */
661 GLenum ctype
= 0; /* color type */
662 GLint coffset
= 0, noffset
= 0, voffset
;/* color, normal, vertex offsets */
663 const GLint toffset
= 0; /* always zero */
664 GLint defstride
; /* default stride */
667 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
670 c
= f
* ((4 * sizeof(GLubyte
) + (f
- 1)) / f
);
673 _mesa_error( ctx
, GL_INVALID_VALUE
, "glInterleavedArrays(stride)" );
679 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
680 tcomps
= 0; ccomps
= 0; vcomps
= 2;
685 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
686 tcomps
= 0; ccomps
= 0; vcomps
= 3;
691 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
692 tcomps
= 0; ccomps
= 4; vcomps
= 2;
693 ctype
= GL_UNSIGNED_BYTE
;
699 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
700 tcomps
= 0; ccomps
= 4; vcomps
= 3;
701 ctype
= GL_UNSIGNED_BYTE
;
707 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
708 tcomps
= 0; ccomps
= 3; vcomps
= 3;
715 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_TRUE
;
716 tcomps
= 0; ccomps
= 0; vcomps
= 3;
722 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
723 tcomps
= 0; ccomps
= 4; vcomps
= 3;
731 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
732 tcomps
= 2; ccomps
= 0; vcomps
= 3;
737 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
738 tcomps
= 4; ccomps
= 0; vcomps
= 4;
742 case GL_T2F_C4UB_V3F
:
743 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
744 tcomps
= 2; ccomps
= 4; vcomps
= 3;
745 ctype
= GL_UNSIGNED_BYTE
;
751 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
752 tcomps
= 2; ccomps
= 3; vcomps
= 3;
759 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_TRUE
;
760 tcomps
= 2; ccomps
= 0; vcomps
= 3;
765 case GL_T2F_C4F_N3F_V3F
:
766 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
767 tcomps
= 2; ccomps
= 4; vcomps
= 3;
774 case GL_T4F_C4F_N3F_V4F
:
775 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
776 tcomps
= 4; ccomps
= 4; vcomps
= 4;
784 _mesa_error( ctx
, GL_INVALID_ENUM
, "glInterleavedArrays(format)" );
792 _mesa_DisableClientState( GL_EDGE_FLAG_ARRAY
);
793 _mesa_DisableClientState( GL_INDEX_ARRAY
);
794 /* XXX also disable secondary color and generic arrays? */
798 _mesa_EnableClientState( GL_TEXTURE_COORD_ARRAY
);
799 _mesa_TexCoordPointer( tcomps
, GL_FLOAT
, stride
,
800 (GLubyte
*) pointer
+ toffset
);
803 _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY
);
808 _mesa_EnableClientState( GL_COLOR_ARRAY
);
809 _mesa_ColorPointer( ccomps
, ctype
, stride
,
810 (GLubyte
*) pointer
+ coffset
);
813 _mesa_DisableClientState( GL_COLOR_ARRAY
);
819 _mesa_EnableClientState( GL_NORMAL_ARRAY
);
820 _mesa_NormalPointer( GL_FLOAT
, stride
, (GLubyte
*) pointer
+ noffset
);
823 _mesa_DisableClientState( GL_NORMAL_ARRAY
);
827 _mesa_EnableClientState( GL_VERTEX_ARRAY
);
828 _mesa_VertexPointer( vcomps
, GL_FLOAT
, stride
,
829 (GLubyte
*) pointer
+ voffset
);
834 _mesa_LockArraysEXT(GLint first
, GLsizei count
)
836 GET_CURRENT_CONTEXT(ctx
);
837 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
839 if (MESA_VERBOSE
& VERBOSE_API
)
840 _mesa_debug(ctx
, "glLockArrays %d %d\n", first
, count
);
842 if (first
== 0 && count
> 0 &&
843 count
<= (GLint
) ctx
->Const
.MaxArrayLockSize
) {
844 ctx
->Array
.LockFirst
= first
;
845 ctx
->Array
.LockCount
= count
;
848 ctx
->Array
.LockFirst
= 0;
849 ctx
->Array
.LockCount
= 0;
852 ctx
->NewState
|= _NEW_ARRAY
;
853 ctx
->Array
.NewState
|= _NEW_ARRAY_ALL
;
855 if (ctx
->Driver
.LockArraysEXT
)
856 ctx
->Driver
.LockArraysEXT( ctx
, first
, count
);
861 _mesa_UnlockArraysEXT( void )
863 GET_CURRENT_CONTEXT(ctx
);
864 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
866 if (MESA_VERBOSE
& VERBOSE_API
)
867 _mesa_debug(ctx
, "glUnlockArrays\n");
869 ctx
->Array
.LockFirst
= 0;
870 ctx
->Array
.LockCount
= 0;
871 ctx
->NewState
|= _NEW_ARRAY
;
872 ctx
->Array
.NewState
|= _NEW_ARRAY_ALL
;
874 if (ctx
->Driver
.UnlockArraysEXT
)
875 ctx
->Driver
.UnlockArraysEXT( ctx
);
879 /* GL_EXT_multi_draw_arrays */
880 /* Somebody forgot to spec the first and count parameters as const! <sigh> */
882 _mesa_MultiDrawArraysEXT( GLenum mode
, GLint
*first
,
883 GLsizei
*count
, GLsizei primcount
)
885 GET_CURRENT_CONTEXT(ctx
);
888 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
890 for (i
= 0; i
< primcount
; i
++) {
892 CALL_DrawArrays(ctx
->Exec
, (mode
, first
[i
], count
[i
]));
898 /* GL_EXT_multi_draw_arrays */
900 _mesa_MultiDrawElementsEXT( GLenum mode
, const GLsizei
*count
, GLenum type
,
901 const GLvoid
**indices
, GLsizei primcount
)
903 GET_CURRENT_CONTEXT(ctx
);
906 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
908 for (i
= 0; i
< primcount
; i
++) {
910 CALL_DrawElements(ctx
->Exec
, (mode
, count
[i
], type
, indices
[i
]));
916 /* GL_IBM_multimode_draw_arrays */
918 _mesa_MultiModeDrawArraysIBM( const GLenum
* mode
, const GLint
* first
,
919 const GLsizei
* count
,
920 GLsizei primcount
, GLint modestride
)
922 GET_CURRENT_CONTEXT(ctx
);
925 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
927 for ( i
= 0 ; i
< primcount
; i
++ ) {
928 if ( count
[i
] > 0 ) {
929 GLenum m
= *((GLenum
*) ((GLubyte
*) mode
+ i
* modestride
));
930 CALL_DrawArrays(ctx
->Exec
, ( m
, first
[i
], count
[i
] ));
936 /* GL_IBM_multimode_draw_arrays */
938 _mesa_MultiModeDrawElementsIBM( const GLenum
* mode
, const GLsizei
* count
,
939 GLenum type
, const GLvoid
* const * indices
,
940 GLsizei primcount
, GLint modestride
)
942 GET_CURRENT_CONTEXT(ctx
);
945 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
947 /* XXX not sure about ARB_vertex_buffer_object handling here */
949 for ( i
= 0 ; i
< primcount
; i
++ ) {
950 if ( count
[i
] > 0 ) {
951 GLenum m
= *((GLenum
*) ((GLubyte
*) mode
+ i
* modestride
));
952 CALL_DrawElements(ctx
->Exec
, ( m
, count
[i
], type
, indices
[i
] ));
959 * Initialize vertex array state for given context.
962 _mesa_init_varray(GLcontext
*ctx
)
964 ctx
->Array
.DefaultArrayObj
= _mesa_new_array_object(ctx
, 0);
965 ctx
->Array
.ArrayObj
= ctx
->Array
.DefaultArrayObj
;
967 ctx
->Array
.ActiveTexture
= 0; /* GL_ARB_multitexture */