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"
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
;
82 array
->_MaxElement
= 2 * 1000 * 1000 * 1000; /* just a big number */
84 ctx
->NewState
|= _NEW_ARRAY
;
85 ctx
->Array
.NewState
|= dirtyBit
;
90 _mesa_VertexPointer(GLint size
, GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
93 GET_CURRENT_CONTEXT(ctx
);
94 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
96 if (size
< 2 || size
> 4) {
97 _mesa_error( ctx
, GL_INVALID_VALUE
, "glVertexPointer(size)" );
101 _mesa_error( ctx
, GL_INVALID_VALUE
, "glVertexPointer(stride)" );
105 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
106 _mesa_debug(ctx
, "glVertexPointer( sz %d type %s stride %d )\n", size
,
107 _mesa_lookup_enum_by_nr( type
), stride
);
109 /* always need to check that <type> is legal */
112 elementSize
= size
* sizeof(GLshort
);
115 elementSize
= size
* sizeof(GLint
);
118 elementSize
= size
* sizeof(GLfloat
);
121 elementSize
= size
* sizeof(GLdouble
);
124 _mesa_error( ctx
, GL_INVALID_ENUM
, "glVertexPointer(type)" );
128 update_array(ctx
, &ctx
->Array
.ArrayObj
->Vertex
, _NEW_ARRAY_VERTEX
,
129 elementSize
, size
, type
, stride
, GL_FALSE
, ptr
);
131 if (ctx
->Driver
.VertexPointer
)
132 ctx
->Driver
.VertexPointer( ctx
, size
, type
, stride
, ptr
);
137 _mesa_NormalPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
140 GET_CURRENT_CONTEXT(ctx
);
141 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
144 _mesa_error( ctx
, GL_INVALID_VALUE
, "glNormalPointer(stride)" );
148 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
149 _mesa_debug(ctx
, "glNormalPointer( type %s stride %d )\n",
150 _mesa_lookup_enum_by_nr( type
), stride
);
154 elementSize
= 3 * sizeof(GLbyte
);
157 elementSize
= 3 * sizeof(GLshort
);
160 elementSize
= 3 * sizeof(GLint
);
163 elementSize
= 3 * sizeof(GLfloat
);
166 elementSize
= 3 * sizeof(GLdouble
);
169 _mesa_error( ctx
, GL_INVALID_ENUM
, "glNormalPointer(type)" );
173 update_array(ctx
, &ctx
->Array
.ArrayObj
->Normal
, _NEW_ARRAY_NORMAL
,
174 elementSize
, 3, type
, stride
, GL_TRUE
, ptr
);
176 if (ctx
->Driver
.NormalPointer
)
177 ctx
->Driver
.NormalPointer( ctx
, type
, stride
, ptr
);
182 _mesa_ColorPointer(GLint size
, GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
185 GET_CURRENT_CONTEXT(ctx
);
186 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
188 if (size
< 3 || size
> 4) {
189 _mesa_error( ctx
, GL_INVALID_VALUE
, "glColorPointer(size)" );
193 _mesa_error( ctx
, GL_INVALID_VALUE
, "glColorPointer(stride)" );
197 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
198 _mesa_debug(ctx
, "glColorPointer( sz %d type %s stride %d )\n", size
,
199 _mesa_lookup_enum_by_nr( type
), stride
);
203 elementSize
= size
* sizeof(GLbyte
);
205 case GL_UNSIGNED_BYTE
:
206 elementSize
= size
* sizeof(GLubyte
);
209 elementSize
= size
* sizeof(GLshort
);
211 case GL_UNSIGNED_SHORT
:
212 elementSize
= size
* sizeof(GLushort
);
215 elementSize
= size
* sizeof(GLint
);
217 case GL_UNSIGNED_INT
:
218 elementSize
= size
* sizeof(GLuint
);
221 elementSize
= size
* sizeof(GLfloat
);
224 elementSize
= size
* sizeof(GLdouble
);
227 _mesa_error( ctx
, GL_INVALID_ENUM
, "glColorPointer(type)" );
231 update_array(ctx
, &ctx
->Array
.ArrayObj
->Color
, _NEW_ARRAY_COLOR0
,
232 elementSize
, size
, type
, stride
, GL_TRUE
, ptr
);
234 if (ctx
->Driver
.ColorPointer
)
235 ctx
->Driver
.ColorPointer( ctx
, size
, type
, stride
, ptr
);
240 _mesa_FogCoordPointerEXT(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
243 GET_CURRENT_CONTEXT(ctx
);
244 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
247 _mesa_error( ctx
, GL_INVALID_VALUE
, "glFogCoordPointer(stride)" );
253 elementSize
= sizeof(GLfloat
);
256 elementSize
= sizeof(GLdouble
);
259 _mesa_error( ctx
, GL_INVALID_ENUM
, "glFogCoordPointer(type)" );
263 update_array(ctx
, &ctx
->Array
.ArrayObj
->FogCoord
, _NEW_ARRAY_FOGCOORD
,
264 elementSize
, 1, type
, stride
, GL_FALSE
, ptr
);
266 if (ctx
->Driver
.FogCoordPointer
)
267 ctx
->Driver
.FogCoordPointer( ctx
, type
, stride
, ptr
);
272 _mesa_IndexPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
275 GET_CURRENT_CONTEXT(ctx
);
276 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
279 _mesa_error( ctx
, GL_INVALID_VALUE
, "glIndexPointer(stride)" );
284 case GL_UNSIGNED_BYTE
:
285 elementSize
= sizeof(GLubyte
);
288 elementSize
= sizeof(GLshort
);
291 elementSize
= sizeof(GLint
);
294 elementSize
= sizeof(GLfloat
);
297 elementSize
= sizeof(GLdouble
);
300 _mesa_error( ctx
, GL_INVALID_ENUM
, "glIndexPointer(type)" );
304 update_array(ctx
, &ctx
->Array
.ArrayObj
->Index
, _NEW_ARRAY_INDEX
,
305 elementSize
, 1, type
, stride
, GL_FALSE
, ptr
);
307 if (ctx
->Driver
.IndexPointer
)
308 ctx
->Driver
.IndexPointer( ctx
, type
, stride
, ptr
);
313 _mesa_SecondaryColorPointerEXT(GLint size
, GLenum type
,
314 GLsizei stride
, const GLvoid
*ptr
)
317 GET_CURRENT_CONTEXT(ctx
);
318 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
320 if (size
!= 3 && size
!= 4) {
321 _mesa_error( ctx
, GL_INVALID_VALUE
, "glSecondaryColorPointer(size)" );
325 _mesa_error( ctx
, GL_INVALID_VALUE
, "glSecondaryColorPointer(stride)" );
329 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
330 _mesa_debug(ctx
, "glSecondaryColorPointer( sz %d type %s stride %d )\n",
331 size
, _mesa_lookup_enum_by_nr( type
), stride
);
335 elementSize
= size
* sizeof(GLbyte
);
337 case GL_UNSIGNED_BYTE
:
338 elementSize
= size
* sizeof(GLubyte
);
341 elementSize
= size
* sizeof(GLshort
);
343 case GL_UNSIGNED_SHORT
:
344 elementSize
= size
* sizeof(GLushort
);
347 elementSize
= size
* sizeof(GLint
);
349 case GL_UNSIGNED_INT
:
350 elementSize
= size
* sizeof(GLuint
);
353 elementSize
= size
* sizeof(GLfloat
);
356 elementSize
= size
* sizeof(GLdouble
);
359 _mesa_error( ctx
, GL_INVALID_ENUM
, "glSecondaryColorPointer(type)" );
363 update_array(ctx
, &ctx
->Array
.ArrayObj
->SecondaryColor
, _NEW_ARRAY_COLOR1
,
364 elementSize
, size
, type
, stride
, GL_TRUE
, ptr
);
366 if (ctx
->Driver
.SecondaryColorPointer
)
367 ctx
->Driver
.SecondaryColorPointer( ctx
, size
, type
, stride
, ptr
);
372 _mesa_TexCoordPointer(GLint size
, GLenum type
, GLsizei stride
,
376 GET_CURRENT_CONTEXT(ctx
);
377 const GLuint unit
= ctx
->Array
.ActiveTexture
;
378 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
380 if (size
< 1 || size
> 4) {
381 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexCoordPointer(size)" );
385 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexCoordPointer(stride)" );
389 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
390 _mesa_debug(ctx
, "glTexCoordPointer(unit %u sz %d type %s stride %d)\n",
391 unit
, size
, _mesa_lookup_enum_by_nr( type
), stride
);
393 /* always need to check that <type> is legal */
396 elementSize
= size
* sizeof(GLshort
);
399 elementSize
= size
* sizeof(GLint
);
402 elementSize
= size
* sizeof(GLfloat
);
405 elementSize
= size
* sizeof(GLdouble
);
408 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexCoordPointer(type)" );
412 update_array(ctx
, &ctx
->Array
.ArrayObj
->TexCoord
[unit
],
413 _NEW_ARRAY_TEXCOORD(unit
),
414 elementSize
, size
, type
, stride
, GL_FALSE
, ptr
);
416 if (ctx
->Driver
.TexCoordPointer
)
417 ctx
->Driver
.TexCoordPointer( ctx
, size
, type
, stride
, ptr
);
422 _mesa_EdgeFlagPointer(GLsizei stride
, const GLvoid
*ptr
)
424 GET_CURRENT_CONTEXT(ctx
);
425 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
428 _mesa_error( ctx
, GL_INVALID_VALUE
, "glEdgeFlagPointer(stride)" );
432 update_array(ctx
, &ctx
->Array
.ArrayObj
->EdgeFlag
, _NEW_ARRAY_EDGEFLAG
,
433 sizeof(GLboolean
), 1, GL_UNSIGNED_BYTE
, stride
, GL_FALSE
, ptr
);
435 if (ctx
->Driver
.EdgeFlagPointer
)
436 ctx
->Driver
.EdgeFlagPointer( ctx
, stride
, ptr
);
440 #if FEATURE_NV_vertex_program
442 _mesa_VertexAttribPointerNV(GLuint index
, GLint size
, GLenum type
,
443 GLsizei stride
, const GLvoid
*ptr
)
445 const GLboolean normalized
= GL_FALSE
;
447 GET_CURRENT_CONTEXT(ctx
);
448 ASSERT_OUTSIDE_BEGIN_END(ctx
);
450 if (index
>= MAX_VERTEX_PROGRAM_ATTRIBS
) {
451 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(index)");
455 if (size
< 1 || size
> 4) {
456 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(size)");
461 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(stride)");
465 if (type
== GL_UNSIGNED_BYTE
&& size
!= 4) {
466 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(size!=4)");
470 /* check for valid 'type' and compute StrideB right away */
472 case GL_UNSIGNED_BYTE
:
473 elementSize
= size
* sizeof(GLubyte
);
476 elementSize
= size
* sizeof(GLshort
);
479 elementSize
= size
* sizeof(GLfloat
);
482 elementSize
= size
* sizeof(GLdouble
);
485 _mesa_error( ctx
, GL_INVALID_ENUM
, "glVertexAttribPointerNV(type)" );
489 update_array(ctx
, &ctx
->Array
.ArrayObj
->VertexAttrib
[index
],
490 _NEW_ARRAY_ATTRIB(index
),
491 elementSize
, size
, type
, stride
, normalized
, ptr
);
493 if (ctx
->Driver
.VertexAttribPointer
)
494 ctx
->Driver
.VertexAttribPointer( ctx
, index
, size
, type
, stride
, ptr
);
499 #if FEATURE_ARB_vertex_program
501 _mesa_VertexAttribPointerARB(GLuint index
, GLint size
, GLenum type
,
502 GLboolean normalized
,
503 GLsizei stride
, const GLvoid
*ptr
)
506 GET_CURRENT_CONTEXT(ctx
);
507 ASSERT_OUTSIDE_BEGIN_END(ctx
);
509 if (index
>= ctx
->Const
.VertexProgram
.MaxAttribs
) {
510 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(index)");
514 if (size
< 1 || size
> 4) {
515 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(size)");
520 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(stride)");
524 if (type
== GL_UNSIGNED_BYTE
&& size
!= 4) {
525 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(size!=4)");
529 /* check for valid 'type' and compute StrideB right away */
530 /* NOTE: more types are supported here than in the NV extension */
533 elementSize
= size
* sizeof(GLbyte
);
535 case GL_UNSIGNED_BYTE
:
536 elementSize
= size
* sizeof(GLubyte
);
539 elementSize
= size
* sizeof(GLshort
);
541 case GL_UNSIGNED_SHORT
:
542 elementSize
= size
* sizeof(GLushort
);
545 elementSize
= size
* sizeof(GLint
);
547 case GL_UNSIGNED_INT
:
548 elementSize
= size
* sizeof(GLuint
);
551 elementSize
= size
* sizeof(GLfloat
);
554 elementSize
= size
* sizeof(GLdouble
);
557 _mesa_error( ctx
, GL_INVALID_ENUM
, "glVertexAttribPointerARB(type)" );
561 update_array(ctx
, &ctx
->Array
.ArrayObj
->VertexAttrib
[index
],
562 _NEW_ARRAY_ATTRIB(index
),
563 elementSize
, size
, type
, stride
, normalized
, ptr
);
565 if (ctx
->Driver
.VertexAttribPointer
)
566 ctx
->Driver
.VertexAttribPointer(ctx
, index
, size
, type
, stride
, ptr
);
572 _mesa_VertexPointerEXT(GLint size
, GLenum type
, GLsizei stride
,
573 GLsizei count
, const GLvoid
*ptr
)
576 _mesa_VertexPointer(size
, type
, stride
, ptr
);
581 _mesa_NormalPointerEXT(GLenum type
, GLsizei stride
, GLsizei count
,
585 _mesa_NormalPointer(type
, stride
, ptr
);
590 _mesa_ColorPointerEXT(GLint size
, GLenum type
, GLsizei stride
, GLsizei count
,
594 _mesa_ColorPointer(size
, type
, stride
, ptr
);
599 _mesa_IndexPointerEXT(GLenum type
, GLsizei stride
, GLsizei count
,
603 _mesa_IndexPointer(type
, stride
, ptr
);
608 _mesa_TexCoordPointerEXT(GLint size
, GLenum type
, GLsizei stride
,
609 GLsizei count
, const GLvoid
*ptr
)
612 _mesa_TexCoordPointer(size
, type
, stride
, ptr
);
617 _mesa_EdgeFlagPointerEXT(GLsizei stride
, GLsizei count
, const GLboolean
*ptr
)
620 _mesa_EdgeFlagPointer(stride
, ptr
);
625 _mesa_InterleavedArrays(GLenum format
, GLsizei stride
, const GLvoid
*pointer
)
627 GET_CURRENT_CONTEXT(ctx
);
628 GLboolean tflag
, cflag
, nflag
; /* enable/disable flags */
629 GLint tcomps
, ccomps
, vcomps
; /* components per texcoord, color, vertex */
630 GLenum ctype
= 0; /* color type */
631 GLint coffset
= 0, noffset
= 0, voffset
;/* color, normal, vertex offsets */
632 const GLint toffset
= 0; /* always zero */
633 GLint defstride
; /* default stride */
636 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
639 c
= f
* ((4 * sizeof(GLubyte
) + (f
- 1)) / f
);
642 _mesa_error( ctx
, GL_INVALID_VALUE
, "glInterleavedArrays(stride)" );
648 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
649 tcomps
= 0; ccomps
= 0; vcomps
= 2;
654 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
655 tcomps
= 0; ccomps
= 0; vcomps
= 3;
660 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
661 tcomps
= 0; ccomps
= 4; vcomps
= 2;
662 ctype
= GL_UNSIGNED_BYTE
;
668 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
669 tcomps
= 0; ccomps
= 4; vcomps
= 3;
670 ctype
= GL_UNSIGNED_BYTE
;
676 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
677 tcomps
= 0; ccomps
= 3; vcomps
= 3;
684 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_TRUE
;
685 tcomps
= 0; ccomps
= 0; vcomps
= 3;
691 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
692 tcomps
= 0; ccomps
= 4; vcomps
= 3;
700 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
701 tcomps
= 2; ccomps
= 0; vcomps
= 3;
706 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
707 tcomps
= 4; ccomps
= 0; vcomps
= 4;
711 case GL_T2F_C4UB_V3F
:
712 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
713 tcomps
= 2; ccomps
= 4; vcomps
= 3;
714 ctype
= GL_UNSIGNED_BYTE
;
720 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
721 tcomps
= 2; ccomps
= 3; vcomps
= 3;
728 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_TRUE
;
729 tcomps
= 2; ccomps
= 0; vcomps
= 3;
734 case GL_T2F_C4F_N3F_V3F
:
735 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
736 tcomps
= 2; ccomps
= 4; vcomps
= 3;
743 case GL_T4F_C4F_N3F_V4F
:
744 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
745 tcomps
= 4; ccomps
= 4; vcomps
= 4;
753 _mesa_error( ctx
, GL_INVALID_ENUM
, "glInterleavedArrays(format)" );
761 _mesa_DisableClientState( GL_EDGE_FLAG_ARRAY
);
762 _mesa_DisableClientState( GL_INDEX_ARRAY
);
763 /* XXX also disable secondary color and generic arrays? */
767 _mesa_EnableClientState( GL_TEXTURE_COORD_ARRAY
);
768 _mesa_TexCoordPointer( tcomps
, GL_FLOAT
, stride
,
769 (GLubyte
*) pointer
+ toffset
);
772 _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY
);
777 _mesa_EnableClientState( GL_COLOR_ARRAY
);
778 _mesa_ColorPointer( ccomps
, ctype
, stride
,
779 (GLubyte
*) pointer
+ coffset
);
782 _mesa_DisableClientState( GL_COLOR_ARRAY
);
788 _mesa_EnableClientState( GL_NORMAL_ARRAY
);
789 _mesa_NormalPointer( GL_FLOAT
, stride
, (GLubyte
*) pointer
+ noffset
);
792 _mesa_DisableClientState( GL_NORMAL_ARRAY
);
796 _mesa_EnableClientState( GL_VERTEX_ARRAY
);
797 _mesa_VertexPointer( vcomps
, GL_FLOAT
, stride
,
798 (GLubyte
*) pointer
+ voffset
);
803 _mesa_LockArraysEXT(GLint first
, GLsizei count
)
805 GET_CURRENT_CONTEXT(ctx
);
806 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
808 if (MESA_VERBOSE
& VERBOSE_API
)
809 _mesa_debug(ctx
, "glLockArrays %d %d\n", first
, count
);
811 if (first
== 0 && count
> 0 &&
812 count
<= (GLint
) ctx
->Const
.MaxArrayLockSize
) {
813 ctx
->Array
.LockFirst
= first
;
814 ctx
->Array
.LockCount
= count
;
817 ctx
->Array
.LockFirst
= 0;
818 ctx
->Array
.LockCount
= 0;
821 ctx
->NewState
|= _NEW_ARRAY
;
822 ctx
->Array
.NewState
|= _NEW_ARRAY_ALL
;
824 if (ctx
->Driver
.LockArraysEXT
)
825 ctx
->Driver
.LockArraysEXT( ctx
, first
, count
);
830 _mesa_UnlockArraysEXT( void )
832 GET_CURRENT_CONTEXT(ctx
);
833 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
835 if (MESA_VERBOSE
& VERBOSE_API
)
836 _mesa_debug(ctx
, "glUnlockArrays\n");
838 ctx
->Array
.LockFirst
= 0;
839 ctx
->Array
.LockCount
= 0;
840 ctx
->NewState
|= _NEW_ARRAY
;
841 ctx
->Array
.NewState
|= _NEW_ARRAY_ALL
;
843 if (ctx
->Driver
.UnlockArraysEXT
)
844 ctx
->Driver
.UnlockArraysEXT( ctx
);
848 /* GL_EXT_multi_draw_arrays */
849 /* Somebody forgot to spec the first and count parameters as const! <sigh> */
851 _mesa_MultiDrawArraysEXT( GLenum mode
, GLint
*first
,
852 GLsizei
*count
, GLsizei primcount
)
854 GET_CURRENT_CONTEXT(ctx
);
857 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
859 for (i
= 0; i
< primcount
; i
++) {
861 CALL_DrawArrays(ctx
->Exec
, (mode
, first
[i
], count
[i
]));
867 /* GL_EXT_multi_draw_arrays */
869 _mesa_MultiDrawElementsEXT( GLenum mode
, const GLsizei
*count
, GLenum type
,
870 const GLvoid
**indices
, GLsizei primcount
)
872 GET_CURRENT_CONTEXT(ctx
);
875 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
877 for (i
= 0; i
< primcount
; i
++) {
879 CALL_DrawElements(ctx
->Exec
, (mode
, count
[i
], type
, indices
[i
]));
885 /* GL_IBM_multimode_draw_arrays */
887 _mesa_MultiModeDrawArraysIBM( const GLenum
* mode
, const GLint
* first
,
888 const GLsizei
* count
,
889 GLsizei primcount
, GLint modestride
)
891 GET_CURRENT_CONTEXT(ctx
);
894 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
896 for ( i
= 0 ; i
< primcount
; i
++ ) {
897 if ( count
[i
] > 0 ) {
898 GLenum m
= *((GLenum
*) ((GLubyte
*) mode
+ i
* modestride
));
899 CALL_DrawArrays(ctx
->Exec
, ( m
, first
[i
], count
[i
] ));
905 /* GL_IBM_multimode_draw_arrays */
907 _mesa_MultiModeDrawElementsIBM( const GLenum
* mode
, const GLsizei
* count
,
908 GLenum type
, const GLvoid
* const * indices
,
909 GLsizei primcount
, GLint modestride
)
911 GET_CURRENT_CONTEXT(ctx
);
914 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
916 /* XXX not sure about ARB_vertex_buffer_object handling here */
918 for ( i
= 0 ; i
< primcount
; i
++ ) {
919 if ( count
[i
] > 0 ) {
920 GLenum m
= *((GLenum
*) ((GLubyte
*) mode
+ i
* modestride
));
921 CALL_DrawElements(ctx
->Exec
, ( m
, count
[i
], type
, indices
[i
] ));
928 * Initialize vertex array state for given context.
931 _mesa_init_varray(GLcontext
*ctx
)
933 ctx
->Array
.DefaultArrayObj
= _mesa_new_array_object(ctx
, 0);
934 ctx
->Array
.ArrayObj
= ctx
->Array
.DefaultArrayObj
;
936 ctx
->Array
.ActiveTexture
= 0; /* GL_ARB_multitexture */