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
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 const 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 elementSize
= size
* sizeof(GLubyte
);
477 elementSize
= size
* sizeof(GLshort
);
480 elementSize
= size
* sizeof(GLfloat
);
483 elementSize
= size
* sizeof(GLdouble
);
486 _mesa_error( ctx
, GL_INVALID_ENUM
, "glVertexAttribPointerNV(type)" );
490 update_array(ctx
, &ctx
->Array
.ArrayObj
->VertexAttrib
[index
],
491 _NEW_ARRAY_ATTRIB(index
),
492 elementSize
, size
, type
, stride
, normalized
, ptr
);
494 if (ctx
->Driver
.VertexAttribPointer
)
495 ctx
->Driver
.VertexAttribPointer( ctx
, index
, size
, type
, stride
, ptr
);
500 #if FEATURE_ARB_vertex_program
502 _mesa_VertexAttribPointerARB(GLuint index
, GLint size
, GLenum type
,
503 GLboolean normalized
,
504 GLsizei stride
, const GLvoid
*ptr
)
507 GET_CURRENT_CONTEXT(ctx
);
508 ASSERT_OUTSIDE_BEGIN_END(ctx
);
510 if (index
>= ctx
->Const
.VertexProgram
.MaxAttribs
) {
511 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(index)");
515 if (size
< 1 || size
> 4) {
516 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(size)");
521 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(stride)");
525 if (type
== GL_UNSIGNED_BYTE
&& size
!= 4) {
526 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(size!=4)");
530 /* check for valid 'type' and compute StrideB right away */
531 /* NOTE: more types are supported here than in the NV extension */
534 elementSize
= size
* sizeof(GLbyte
);
536 case GL_UNSIGNED_BYTE
:
537 elementSize
= size
* sizeof(GLubyte
);
540 elementSize
= size
* sizeof(GLshort
);
542 case GL_UNSIGNED_SHORT
:
543 elementSize
= size
* sizeof(GLushort
);
546 elementSize
= size
* sizeof(GLint
);
548 case GL_UNSIGNED_INT
:
549 elementSize
= size
* sizeof(GLuint
);
552 elementSize
= size
* sizeof(GLfloat
);
555 elementSize
= size
* sizeof(GLdouble
);
558 _mesa_error( ctx
, GL_INVALID_ENUM
, "glVertexAttribPointerARB(type)" );
562 update_array(ctx
, &ctx
->Array
.ArrayObj
->VertexAttrib
[index
],
563 _NEW_ARRAY_ATTRIB(index
),
564 elementSize
, size
, type
, stride
, normalized
, ptr
);
566 if (ctx
->Driver
.VertexAttribPointer
)
567 ctx
->Driver
.VertexAttribPointer(ctx
, index
, size
, type
, stride
, ptr
);
573 _mesa_VertexPointerEXT(GLint size
, GLenum type
, GLsizei stride
,
574 GLsizei count
, const GLvoid
*ptr
)
577 _mesa_VertexPointer(size
, type
, stride
, ptr
);
582 _mesa_NormalPointerEXT(GLenum type
, GLsizei stride
, GLsizei count
,
586 _mesa_NormalPointer(type
, stride
, ptr
);
591 _mesa_ColorPointerEXT(GLint size
, GLenum type
, GLsizei stride
, GLsizei count
,
595 _mesa_ColorPointer(size
, type
, stride
, ptr
);
600 _mesa_IndexPointerEXT(GLenum type
, GLsizei stride
, GLsizei count
,
604 _mesa_IndexPointer(type
, stride
, ptr
);
609 _mesa_TexCoordPointerEXT(GLint size
, GLenum type
, GLsizei stride
,
610 GLsizei count
, const GLvoid
*ptr
)
613 _mesa_TexCoordPointer(size
, type
, stride
, ptr
);
618 _mesa_EdgeFlagPointerEXT(GLsizei stride
, GLsizei count
, const GLboolean
*ptr
)
621 _mesa_EdgeFlagPointer(stride
, ptr
);
626 _mesa_InterleavedArrays(GLenum format
, GLsizei stride
, const GLvoid
*pointer
)
628 GET_CURRENT_CONTEXT(ctx
);
629 GLboolean tflag
, cflag
, nflag
; /* enable/disable flags */
630 GLint tcomps
, ccomps
, vcomps
; /* components per texcoord, color, vertex */
631 GLenum ctype
= 0; /* color type */
632 GLint coffset
= 0, noffset
= 0, voffset
;/* color, normal, vertex offsets */
633 const GLint toffset
= 0; /* always zero */
634 GLint defstride
; /* default stride */
637 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
640 c
= f
* ((4 * sizeof(GLubyte
) + (f
- 1)) / f
);
643 _mesa_error( ctx
, GL_INVALID_VALUE
, "glInterleavedArrays(stride)" );
649 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
650 tcomps
= 0; ccomps
= 0; vcomps
= 2;
655 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
656 tcomps
= 0; ccomps
= 0; vcomps
= 3;
661 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
662 tcomps
= 0; ccomps
= 4; vcomps
= 2;
663 ctype
= GL_UNSIGNED_BYTE
;
669 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
670 tcomps
= 0; ccomps
= 4; vcomps
= 3;
671 ctype
= GL_UNSIGNED_BYTE
;
677 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
678 tcomps
= 0; ccomps
= 3; vcomps
= 3;
685 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_TRUE
;
686 tcomps
= 0; ccomps
= 0; vcomps
= 3;
692 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
693 tcomps
= 0; ccomps
= 4; vcomps
= 3;
701 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
702 tcomps
= 2; ccomps
= 0; vcomps
= 3;
707 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
708 tcomps
= 4; ccomps
= 0; vcomps
= 4;
712 case GL_T2F_C4UB_V3F
:
713 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
714 tcomps
= 2; ccomps
= 4; vcomps
= 3;
715 ctype
= GL_UNSIGNED_BYTE
;
721 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
722 tcomps
= 2; ccomps
= 3; vcomps
= 3;
729 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_TRUE
;
730 tcomps
= 2; ccomps
= 0; vcomps
= 3;
735 case GL_T2F_C4F_N3F_V3F
:
736 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
737 tcomps
= 2; ccomps
= 4; vcomps
= 3;
744 case GL_T4F_C4F_N3F_V4F
:
745 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
746 tcomps
= 4; ccomps
= 4; vcomps
= 4;
754 _mesa_error( ctx
, GL_INVALID_ENUM
, "glInterleavedArrays(format)" );
762 _mesa_DisableClientState( GL_EDGE_FLAG_ARRAY
);
763 _mesa_DisableClientState( GL_INDEX_ARRAY
);
764 /* XXX also disable secondary color and generic arrays? */
768 _mesa_EnableClientState( GL_TEXTURE_COORD_ARRAY
);
769 _mesa_TexCoordPointer( tcomps
, GL_FLOAT
, stride
,
770 (GLubyte
*) pointer
+ toffset
);
773 _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY
);
778 _mesa_EnableClientState( GL_COLOR_ARRAY
);
779 _mesa_ColorPointer( ccomps
, ctype
, stride
,
780 (GLubyte
*) pointer
+ coffset
);
783 _mesa_DisableClientState( GL_COLOR_ARRAY
);
789 _mesa_EnableClientState( GL_NORMAL_ARRAY
);
790 _mesa_NormalPointer( GL_FLOAT
, stride
, (GLubyte
*) pointer
+ noffset
);
793 _mesa_DisableClientState( GL_NORMAL_ARRAY
);
797 _mesa_EnableClientState( GL_VERTEX_ARRAY
);
798 _mesa_VertexPointer( vcomps
, GL_FLOAT
, stride
,
799 (GLubyte
*) pointer
+ voffset
);
804 _mesa_LockArraysEXT(GLint first
, GLsizei count
)
806 GET_CURRENT_CONTEXT(ctx
);
807 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
809 if (MESA_VERBOSE
& VERBOSE_API
)
810 _mesa_debug(ctx
, "glLockArrays %d %d\n", first
, count
);
812 if (first
== 0 && count
> 0 &&
813 count
<= (GLint
) ctx
->Const
.MaxArrayLockSize
) {
814 ctx
->Array
.LockFirst
= first
;
815 ctx
->Array
.LockCount
= count
;
818 ctx
->Array
.LockFirst
= 0;
819 ctx
->Array
.LockCount
= 0;
822 ctx
->NewState
|= _NEW_ARRAY
;
823 ctx
->Array
.NewState
|= _NEW_ARRAY_ALL
;
825 if (ctx
->Driver
.LockArraysEXT
)
826 ctx
->Driver
.LockArraysEXT( ctx
, first
, count
);
831 _mesa_UnlockArraysEXT( void )
833 GET_CURRENT_CONTEXT(ctx
);
834 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
836 if (MESA_VERBOSE
& VERBOSE_API
)
837 _mesa_debug(ctx
, "glUnlockArrays\n");
839 ctx
->Array
.LockFirst
= 0;
840 ctx
->Array
.LockCount
= 0;
841 ctx
->NewState
|= _NEW_ARRAY
;
842 ctx
->Array
.NewState
|= _NEW_ARRAY_ALL
;
844 if (ctx
->Driver
.UnlockArraysEXT
)
845 ctx
->Driver
.UnlockArraysEXT( ctx
);
849 /* GL_EXT_multi_draw_arrays */
850 /* Somebody forgot to spec the first and count parameters as const! <sigh> */
852 _mesa_MultiDrawArraysEXT( GLenum mode
, GLint
*first
,
853 GLsizei
*count
, GLsizei primcount
)
855 GET_CURRENT_CONTEXT(ctx
);
858 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
860 for (i
= 0; i
< primcount
; i
++) {
862 CALL_DrawArrays(ctx
->Exec
, (mode
, first
[i
], count
[i
]));
868 /* GL_EXT_multi_draw_arrays */
870 _mesa_MultiDrawElementsEXT( GLenum mode
, const GLsizei
*count
, GLenum type
,
871 const GLvoid
**indices
, GLsizei primcount
)
873 GET_CURRENT_CONTEXT(ctx
);
876 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
878 for (i
= 0; i
< primcount
; i
++) {
880 CALL_DrawElements(ctx
->Exec
, (mode
, count
[i
], type
, indices
[i
]));
886 /* GL_IBM_multimode_draw_arrays */
888 _mesa_MultiModeDrawArraysIBM( const GLenum
* mode
, const GLint
* first
,
889 const GLsizei
* count
,
890 GLsizei primcount
, GLint modestride
)
892 GET_CURRENT_CONTEXT(ctx
);
895 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
897 for ( i
= 0 ; i
< primcount
; i
++ ) {
898 if ( count
[i
] > 0 ) {
899 GLenum m
= *((GLenum
*) ((GLubyte
*) mode
+ i
* modestride
));
900 CALL_DrawArrays(ctx
->Exec
, ( m
, first
[i
], count
[i
] ));
906 /* GL_IBM_multimode_draw_arrays */
908 _mesa_MultiModeDrawElementsIBM( const GLenum
* mode
, const GLsizei
* count
,
909 GLenum type
, const GLvoid
* const * indices
,
910 GLsizei primcount
, GLint modestride
)
912 GET_CURRENT_CONTEXT(ctx
);
915 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
917 /* XXX not sure about ARB_vertex_buffer_object handling here */
919 for ( i
= 0 ; i
< primcount
; i
++ ) {
920 if ( count
[i
] > 0 ) {
921 GLenum m
= *((GLenum
*) ((GLubyte
*) mode
+ i
* modestride
));
922 CALL_DrawElements(ctx
->Exec
, ( m
, count
[i
], type
, indices
[i
] ));
929 * Initialize vertex array state for given context.
932 _mesa_init_varray(GLcontext
*ctx
)
934 ctx
->Array
.DefaultArrayObj
= _mesa_new_array_object(ctx
, 0);
935 ctx
->Array
.ArrayObj
= ctx
->Array
.DefaultArrayObj
;
937 ctx
->Array
.ActiveTexture
= 0; /* GL_ARB_multitexture */