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
);
130 _mesa_error( ctx
, GL_INVALID_ENUM
, "glVertexPointer(type)" );
134 update_array(ctx
, &ctx
->Array
.ArrayObj
->Vertex
, _NEW_ARRAY_VERTEX
,
135 elementSize
, size
, type
, stride
, GL_FALSE
, ptr
);
137 if (ctx
->Driver
.VertexPointer
)
138 ctx
->Driver
.VertexPointer( ctx
, size
, type
, stride
, ptr
);
143 _mesa_NormalPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
146 GET_CURRENT_CONTEXT(ctx
);
147 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
150 _mesa_error( ctx
, GL_INVALID_VALUE
, "glNormalPointer(stride)" );
154 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
155 _mesa_debug(ctx
, "glNormalPointer( type %s stride %d )\n",
156 _mesa_lookup_enum_by_nr( type
), stride
);
160 elementSize
= 3 * sizeof(GLbyte
);
163 elementSize
= 3 * sizeof(GLshort
);
166 elementSize
= 3 * sizeof(GLint
);
169 elementSize
= 3 * sizeof(GLfloat
);
172 elementSize
= 3 * sizeof(GLdouble
);
176 elementSize
= 3 * sizeof(GLfixed
);
180 _mesa_error( ctx
, GL_INVALID_ENUM
, "glNormalPointer(type)" );
184 update_array(ctx
, &ctx
->Array
.ArrayObj
->Normal
, _NEW_ARRAY_NORMAL
,
185 elementSize
, 3, type
, stride
, GL_TRUE
, ptr
);
187 if (ctx
->Driver
.NormalPointer
)
188 ctx
->Driver
.NormalPointer( ctx
, type
, stride
, ptr
);
193 _mesa_ColorPointer(GLint size
, GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
196 GET_CURRENT_CONTEXT(ctx
);
197 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
199 if (size
< 3 || size
> 4) {
200 _mesa_error( ctx
, GL_INVALID_VALUE
, "glColorPointer(size)" );
204 _mesa_error( ctx
, GL_INVALID_VALUE
, "glColorPointer(stride)" );
208 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
209 _mesa_debug(ctx
, "glColorPointer( sz %d type %s stride %d )\n", size
,
210 _mesa_lookup_enum_by_nr( type
), stride
);
214 elementSize
= size
* sizeof(GLbyte
);
216 case GL_UNSIGNED_BYTE
:
217 elementSize
= size
* sizeof(GLubyte
);
220 elementSize
= size
* sizeof(GLshort
);
222 case GL_UNSIGNED_SHORT
:
223 elementSize
= size
* sizeof(GLushort
);
226 elementSize
= size
* sizeof(GLint
);
228 case GL_UNSIGNED_INT
:
229 elementSize
= size
* sizeof(GLuint
);
232 elementSize
= size
* sizeof(GLfloat
);
235 elementSize
= size
* sizeof(GLdouble
);
239 elementSize
= size
* sizeof(GLfixed
);
243 _mesa_error( ctx
, GL_INVALID_ENUM
, "glColorPointer(type)" );
247 update_array(ctx
, &ctx
->Array
.ArrayObj
->Color
, _NEW_ARRAY_COLOR0
,
248 elementSize
, size
, type
, stride
, GL_TRUE
, ptr
);
250 if (ctx
->Driver
.ColorPointer
)
251 ctx
->Driver
.ColorPointer( ctx
, size
, type
, stride
, ptr
);
256 _mesa_FogCoordPointerEXT(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
259 GET_CURRENT_CONTEXT(ctx
);
260 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
263 _mesa_error( ctx
, GL_INVALID_VALUE
, "glFogCoordPointer(stride)" );
269 elementSize
= sizeof(GLfloat
);
272 elementSize
= sizeof(GLdouble
);
275 _mesa_error( ctx
, GL_INVALID_ENUM
, "glFogCoordPointer(type)" );
279 update_array(ctx
, &ctx
->Array
.ArrayObj
->FogCoord
, _NEW_ARRAY_FOGCOORD
,
280 elementSize
, 1, type
, stride
, GL_FALSE
, ptr
);
282 if (ctx
->Driver
.FogCoordPointer
)
283 ctx
->Driver
.FogCoordPointer( ctx
, type
, stride
, ptr
);
288 _mesa_IndexPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
291 GET_CURRENT_CONTEXT(ctx
);
292 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
295 _mesa_error( ctx
, GL_INVALID_VALUE
, "glIndexPointer(stride)" );
300 case GL_UNSIGNED_BYTE
:
301 elementSize
= sizeof(GLubyte
);
304 elementSize
= sizeof(GLshort
);
307 elementSize
= sizeof(GLint
);
310 elementSize
= sizeof(GLfloat
);
313 elementSize
= sizeof(GLdouble
);
316 _mesa_error( ctx
, GL_INVALID_ENUM
, "glIndexPointer(type)" );
320 update_array(ctx
, &ctx
->Array
.ArrayObj
->Index
, _NEW_ARRAY_INDEX
,
321 elementSize
, 1, type
, stride
, GL_FALSE
, ptr
);
323 if (ctx
->Driver
.IndexPointer
)
324 ctx
->Driver
.IndexPointer( ctx
, type
, stride
, ptr
);
329 _mesa_SecondaryColorPointerEXT(GLint size
, GLenum type
,
330 GLsizei stride
, const GLvoid
*ptr
)
333 GET_CURRENT_CONTEXT(ctx
);
334 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
336 if (size
!= 3 && size
!= 4) {
337 _mesa_error( ctx
, GL_INVALID_VALUE
, "glSecondaryColorPointer(size)" );
341 _mesa_error( ctx
, GL_INVALID_VALUE
, "glSecondaryColorPointer(stride)" );
345 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
346 _mesa_debug(ctx
, "glSecondaryColorPointer( sz %d type %s stride %d )\n",
347 size
, _mesa_lookup_enum_by_nr( type
), stride
);
351 elementSize
= size
* sizeof(GLbyte
);
353 case GL_UNSIGNED_BYTE
:
354 elementSize
= size
* sizeof(GLubyte
);
357 elementSize
= size
* sizeof(GLshort
);
359 case GL_UNSIGNED_SHORT
:
360 elementSize
= size
* sizeof(GLushort
);
363 elementSize
= size
* sizeof(GLint
);
365 case GL_UNSIGNED_INT
:
366 elementSize
= size
* sizeof(GLuint
);
369 elementSize
= size
* sizeof(GLfloat
);
372 elementSize
= size
* sizeof(GLdouble
);
375 _mesa_error( ctx
, GL_INVALID_ENUM
, "glSecondaryColorPointer(type)" );
379 update_array(ctx
, &ctx
->Array
.ArrayObj
->SecondaryColor
, _NEW_ARRAY_COLOR1
,
380 elementSize
, size
, type
, stride
, GL_TRUE
, ptr
);
382 if (ctx
->Driver
.SecondaryColorPointer
)
383 ctx
->Driver
.SecondaryColorPointer( ctx
, size
, type
, stride
, ptr
);
388 _mesa_TexCoordPointer(GLint size
, GLenum type
, GLsizei stride
,
392 GET_CURRENT_CONTEXT(ctx
);
393 const GLuint unit
= ctx
->Array
.ActiveTexture
;
394 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
396 if (size
< 1 || size
> 4) {
397 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexCoordPointer(size)" );
401 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexCoordPointer(stride)" );
405 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
406 _mesa_debug(ctx
, "glTexCoordPointer(unit %u sz %d type %s stride %d)\n",
407 unit
, size
, _mesa_lookup_enum_by_nr( type
), stride
);
409 /* always need to check that <type> is legal */
412 elementSize
= size
* sizeof(GLshort
);
415 elementSize
= size
* sizeof(GLint
);
418 elementSize
= size
* sizeof(GLfloat
);
421 elementSize
= size
* sizeof(GLdouble
);
425 elementSize
= size
* sizeof(GLfixed
);
429 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexCoordPointer(type)" );
433 update_array(ctx
, &ctx
->Array
.ArrayObj
->TexCoord
[unit
],
434 _NEW_ARRAY_TEXCOORD(unit
),
435 elementSize
, size
, type
, stride
, GL_FALSE
, ptr
);
437 if (ctx
->Driver
.TexCoordPointer
)
438 ctx
->Driver
.TexCoordPointer( ctx
, size
, type
, stride
, ptr
);
443 _mesa_EdgeFlagPointer(GLsizei stride
, const GLvoid
*ptr
)
445 GET_CURRENT_CONTEXT(ctx
);
446 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
449 _mesa_error( ctx
, GL_INVALID_VALUE
, "glEdgeFlagPointer(stride)" );
453 update_array(ctx
, &ctx
->Array
.ArrayObj
->EdgeFlag
, _NEW_ARRAY_EDGEFLAG
,
454 sizeof(GLboolean
), 1, GL_UNSIGNED_BYTE
, stride
, GL_FALSE
, ptr
);
456 if (ctx
->Driver
.EdgeFlagPointer
)
457 ctx
->Driver
.EdgeFlagPointer( ctx
, stride
, ptr
);
461 #if FEATURE_NV_vertex_program
463 _mesa_VertexAttribPointerNV(GLuint index
, GLint size
, GLenum type
,
464 GLsizei stride
, const GLvoid
*ptr
)
466 const GLboolean normalized
= GL_FALSE
;
468 GET_CURRENT_CONTEXT(ctx
);
469 ASSERT_OUTSIDE_BEGIN_END(ctx
);
471 if (index
>= MAX_VERTEX_PROGRAM_ATTRIBS
) {
472 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(index)");
476 if (size
< 1 || size
> 4) {
477 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(size)");
482 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(stride)");
486 if (type
== GL_UNSIGNED_BYTE
&& size
!= 4) {
487 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(size!=4)");
491 /* check for valid 'type' and compute StrideB right away */
493 case GL_UNSIGNED_BYTE
:
494 elementSize
= size
* sizeof(GLubyte
);
497 elementSize
= size
* sizeof(GLshort
);
500 elementSize
= size
* sizeof(GLfloat
);
503 elementSize
= size
* sizeof(GLdouble
);
506 _mesa_error( ctx
, GL_INVALID_ENUM
, "glVertexAttribPointerNV(type)" );
510 update_array(ctx
, &ctx
->Array
.ArrayObj
->VertexAttrib
[index
],
511 _NEW_ARRAY_ATTRIB(index
),
512 elementSize
, size
, type
, stride
, normalized
, ptr
);
514 if (ctx
->Driver
.VertexAttribPointer
)
515 ctx
->Driver
.VertexAttribPointer( ctx
, index
, size
, type
, stride
, ptr
);
520 #if FEATURE_ARB_vertex_program
522 _mesa_VertexAttribPointerARB(GLuint index
, GLint size
, GLenum type
,
523 GLboolean normalized
,
524 GLsizei stride
, const GLvoid
*ptr
)
527 GET_CURRENT_CONTEXT(ctx
);
528 ASSERT_OUTSIDE_BEGIN_END(ctx
);
530 if (index
>= ctx
->Const
.VertexProgram
.MaxAttribs
) {
531 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(index)");
535 if (size
< 1 || size
> 4) {
536 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(size)");
541 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(stride)");
545 if (type
== GL_UNSIGNED_BYTE
&& size
!= 4) {
546 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(size!=4)");
550 /* check for valid 'type' and compute StrideB right away */
551 /* NOTE: more types are supported here than in the NV extension */
554 elementSize
= size
* sizeof(GLbyte
);
556 case GL_UNSIGNED_BYTE
:
557 elementSize
= size
* sizeof(GLubyte
);
560 elementSize
= size
* sizeof(GLshort
);
562 case GL_UNSIGNED_SHORT
:
563 elementSize
= size
* sizeof(GLushort
);
566 elementSize
= size
* sizeof(GLint
);
568 case GL_UNSIGNED_INT
:
569 elementSize
= size
* sizeof(GLuint
);
572 elementSize
= size
* sizeof(GLfloat
);
575 elementSize
= size
* sizeof(GLdouble
);
578 _mesa_error( ctx
, GL_INVALID_ENUM
, "glVertexAttribPointerARB(type)" );
582 update_array(ctx
, &ctx
->Array
.ArrayObj
->VertexAttrib
[index
],
583 _NEW_ARRAY_ATTRIB(index
),
584 elementSize
, size
, type
, stride
, normalized
, ptr
);
586 if (ctx
->Driver
.VertexAttribPointer
)
587 ctx
->Driver
.VertexAttribPointer(ctx
, index
, size
, type
, stride
, ptr
);
593 _mesa_VertexPointerEXT(GLint size
, GLenum type
, GLsizei stride
,
594 GLsizei count
, const GLvoid
*ptr
)
597 _mesa_VertexPointer(size
, type
, stride
, ptr
);
602 _mesa_NormalPointerEXT(GLenum type
, GLsizei stride
, GLsizei count
,
606 _mesa_NormalPointer(type
, stride
, ptr
);
611 _mesa_ColorPointerEXT(GLint size
, GLenum type
, GLsizei stride
, GLsizei count
,
615 _mesa_ColorPointer(size
, type
, stride
, ptr
);
620 _mesa_IndexPointerEXT(GLenum type
, GLsizei stride
, GLsizei count
,
624 _mesa_IndexPointer(type
, stride
, ptr
);
629 _mesa_TexCoordPointerEXT(GLint size
, GLenum type
, GLsizei stride
,
630 GLsizei count
, const GLvoid
*ptr
)
633 _mesa_TexCoordPointer(size
, type
, stride
, ptr
);
638 _mesa_EdgeFlagPointerEXT(GLsizei stride
, GLsizei count
, const GLboolean
*ptr
)
641 _mesa_EdgeFlagPointer(stride
, ptr
);
646 _mesa_InterleavedArrays(GLenum format
, GLsizei stride
, const GLvoid
*pointer
)
648 GET_CURRENT_CONTEXT(ctx
);
649 GLboolean tflag
, cflag
, nflag
; /* enable/disable flags */
650 GLint tcomps
, ccomps
, vcomps
; /* components per texcoord, color, vertex */
651 GLenum ctype
= 0; /* color type */
652 GLint coffset
= 0, noffset
= 0, voffset
;/* color, normal, vertex offsets */
653 const GLint toffset
= 0; /* always zero */
654 GLint defstride
; /* default stride */
657 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
660 c
= f
* ((4 * sizeof(GLubyte
) + (f
- 1)) / f
);
663 _mesa_error( ctx
, GL_INVALID_VALUE
, "glInterleavedArrays(stride)" );
669 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
670 tcomps
= 0; ccomps
= 0; vcomps
= 2;
675 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
676 tcomps
= 0; ccomps
= 0; vcomps
= 3;
681 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
682 tcomps
= 0; ccomps
= 4; vcomps
= 2;
683 ctype
= GL_UNSIGNED_BYTE
;
689 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
690 tcomps
= 0; ccomps
= 4; vcomps
= 3;
691 ctype
= GL_UNSIGNED_BYTE
;
697 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
698 tcomps
= 0; ccomps
= 3; vcomps
= 3;
705 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_TRUE
;
706 tcomps
= 0; ccomps
= 0; vcomps
= 3;
712 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
713 tcomps
= 0; ccomps
= 4; vcomps
= 3;
721 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
722 tcomps
= 2; ccomps
= 0; vcomps
= 3;
727 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
728 tcomps
= 4; ccomps
= 0; vcomps
= 4;
732 case GL_T2F_C4UB_V3F
:
733 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
734 tcomps
= 2; ccomps
= 4; vcomps
= 3;
735 ctype
= GL_UNSIGNED_BYTE
;
741 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
742 tcomps
= 2; ccomps
= 3; vcomps
= 3;
749 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_TRUE
;
750 tcomps
= 2; ccomps
= 0; vcomps
= 3;
755 case GL_T2F_C4F_N3F_V3F
:
756 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
757 tcomps
= 2; ccomps
= 4; vcomps
= 3;
764 case GL_T4F_C4F_N3F_V4F
:
765 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
766 tcomps
= 4; ccomps
= 4; vcomps
= 4;
774 _mesa_error( ctx
, GL_INVALID_ENUM
, "glInterleavedArrays(format)" );
782 _mesa_DisableClientState( GL_EDGE_FLAG_ARRAY
);
783 _mesa_DisableClientState( GL_INDEX_ARRAY
);
784 /* XXX also disable secondary color and generic arrays? */
788 _mesa_EnableClientState( GL_TEXTURE_COORD_ARRAY
);
789 _mesa_TexCoordPointer( tcomps
, GL_FLOAT
, stride
,
790 (GLubyte
*) pointer
+ toffset
);
793 _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY
);
798 _mesa_EnableClientState( GL_COLOR_ARRAY
);
799 _mesa_ColorPointer( ccomps
, ctype
, stride
,
800 (GLubyte
*) pointer
+ coffset
);
803 _mesa_DisableClientState( GL_COLOR_ARRAY
);
809 _mesa_EnableClientState( GL_NORMAL_ARRAY
);
810 _mesa_NormalPointer( GL_FLOAT
, stride
, (GLubyte
*) pointer
+ noffset
);
813 _mesa_DisableClientState( GL_NORMAL_ARRAY
);
817 _mesa_EnableClientState( GL_VERTEX_ARRAY
);
818 _mesa_VertexPointer( vcomps
, GL_FLOAT
, stride
,
819 (GLubyte
*) pointer
+ voffset
);
824 _mesa_LockArraysEXT(GLint first
, GLsizei count
)
826 GET_CURRENT_CONTEXT(ctx
);
827 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
829 if (MESA_VERBOSE
& VERBOSE_API
)
830 _mesa_debug(ctx
, "glLockArrays %d %d\n", first
, count
);
832 if (first
== 0 && count
> 0 &&
833 count
<= (GLint
) ctx
->Const
.MaxArrayLockSize
) {
834 ctx
->Array
.LockFirst
= first
;
835 ctx
->Array
.LockCount
= count
;
838 ctx
->Array
.LockFirst
= 0;
839 ctx
->Array
.LockCount
= 0;
842 ctx
->NewState
|= _NEW_ARRAY
;
843 ctx
->Array
.NewState
|= _NEW_ARRAY_ALL
;
845 if (ctx
->Driver
.LockArraysEXT
)
846 ctx
->Driver
.LockArraysEXT( ctx
, first
, count
);
851 _mesa_UnlockArraysEXT( void )
853 GET_CURRENT_CONTEXT(ctx
);
854 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
856 if (MESA_VERBOSE
& VERBOSE_API
)
857 _mesa_debug(ctx
, "glUnlockArrays\n");
859 ctx
->Array
.LockFirst
= 0;
860 ctx
->Array
.LockCount
= 0;
861 ctx
->NewState
|= _NEW_ARRAY
;
862 ctx
->Array
.NewState
|= _NEW_ARRAY_ALL
;
864 if (ctx
->Driver
.UnlockArraysEXT
)
865 ctx
->Driver
.UnlockArraysEXT( ctx
);
869 /* GL_EXT_multi_draw_arrays */
870 /* Somebody forgot to spec the first and count parameters as const! <sigh> */
872 _mesa_MultiDrawArraysEXT( GLenum mode
, GLint
*first
,
873 GLsizei
*count
, GLsizei primcount
)
875 GET_CURRENT_CONTEXT(ctx
);
878 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
880 for (i
= 0; i
< primcount
; i
++) {
882 CALL_DrawArrays(ctx
->Exec
, (mode
, first
[i
], count
[i
]));
888 /* GL_EXT_multi_draw_arrays */
890 _mesa_MultiDrawElementsEXT( GLenum mode
, const GLsizei
*count
, GLenum type
,
891 const GLvoid
**indices
, GLsizei primcount
)
893 GET_CURRENT_CONTEXT(ctx
);
896 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
898 for (i
= 0; i
< primcount
; i
++) {
900 CALL_DrawElements(ctx
->Exec
, (mode
, count
[i
], type
, indices
[i
]));
906 /* GL_IBM_multimode_draw_arrays */
908 _mesa_MultiModeDrawArraysIBM( const GLenum
* mode
, const GLint
* first
,
909 const GLsizei
* count
,
910 GLsizei primcount
, GLint modestride
)
912 GET_CURRENT_CONTEXT(ctx
);
915 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
917 for ( i
= 0 ; i
< primcount
; i
++ ) {
918 if ( count
[i
] > 0 ) {
919 GLenum m
= *((GLenum
*) ((GLubyte
*) mode
+ i
* modestride
));
920 CALL_DrawArrays(ctx
->Exec
, ( m
, first
[i
], count
[i
] ));
926 /* GL_IBM_multimode_draw_arrays */
928 _mesa_MultiModeDrawElementsIBM( const GLenum
* mode
, const GLsizei
* count
,
929 GLenum type
, const GLvoid
* const * indices
,
930 GLsizei primcount
, GLint modestride
)
932 GET_CURRENT_CONTEXT(ctx
);
935 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
937 /* XXX not sure about ARB_vertex_buffer_object handling here */
939 for ( i
= 0 ; i
< primcount
; i
++ ) {
940 if ( count
[i
] > 0 ) {
941 GLenum m
= *((GLenum
*) ((GLubyte
*) mode
+ i
* modestride
));
942 CALL_DrawElements(ctx
->Exec
, ( m
, count
[i
], type
, indices
[i
] ));
949 * Initialize vertex array state for given context.
952 _mesa_init_varray(GLcontext
*ctx
)
954 ctx
->Array
.DefaultArrayObj
= _mesa_new_array_object(ctx
, 0);
955 ctx
->Array
.ArrayObj
= ctx
->Array
.DefaultArrayObj
;
957 ctx
->Array
.ActiveTexture
= 0; /* GL_ARB_multitexture */