52f8c8cef95b23a902dca4e2223db36c090c09e4
2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2003 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 #define GL_BOOLEAN 0x9999
44 * Update the fields of a vertex array structure.
45 * We need to do a few special things for arrays that live in
46 * vertex buffer objects.
49 update_array(GLcontext
*ctx
, struct gl_client_array
*array
,
50 GLuint dirtyFlag
, GLsizei elementSize
,
51 GLint size
, GLenum type
,
52 GLsizei stride
, GLboolean normalized
, const GLvoid
*ptr
)
56 array
->Stride
= stride
;
57 array
->StrideB
= stride
? stride
: elementSize
;
58 array
->Normalized
= normalized
;
59 array
->Ptr
= (const GLubyte
*) ptr
;
60 #if FEATURE_ARB_vertex_buffer_object
61 array
->BufferObj
->RefCount
--;
62 if (array
->BufferObj
->RefCount
<= 0) {
63 _mesa_remove_buffer_object( ctx
, array
->BufferObj
);
64 (*ctx
->Driver
.DeleteBuffer
)( ctx
, array
->BufferObj
);
66 array
->BufferObj
= ctx
->Array
.ArrayBufferObj
;
67 array
->BufferObj
->RefCount
++;
68 /* Compute the index of the last array element that's inside the buffer.
69 * Later in glDrawArrays we'll check if start + count > _MaxElement to
70 * be sure we won't go out of bounds.
72 if (ctx
->Array
.ArrayBufferObj
->Name
)
73 array
->_MaxElement
= ((GLsizeiptrARB
) ctx
->Array
.ArrayBufferObj
->Size
74 - (GLsizeiptrARB
) array
->Ptr
) / array
->StrideB
;
77 array
->_MaxElement
= 2 * 1000 * 1000 * 1000; /* just a big number */
79 ctx
->NewState
|= _NEW_ARRAY
;
80 ctx
->Array
.NewState
|= dirtyFlag
;
85 _mesa_VertexPointer(GLint size
, GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
88 GET_CURRENT_CONTEXT(ctx
);
89 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
91 if (size
< 2 || size
> 4) {
92 _mesa_error( ctx
, GL_INVALID_VALUE
, "glVertexPointer(size)" );
96 _mesa_error( ctx
, GL_INVALID_VALUE
, "glVertexPointer(stride)" );
100 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
101 _mesa_debug(ctx
, "glVertexPointer( sz %d type %s stride %d )\n", size
,
102 _mesa_lookup_enum_by_nr( type
), stride
);
104 /* always need to check that <type> is legal */
107 elementSize
= size
* sizeof(GLshort
);
110 elementSize
= size
* sizeof(GLint
);
113 elementSize
= size
* sizeof(GLfloat
);
116 elementSize
= size
* sizeof(GLdouble
);
119 _mesa_error( ctx
, GL_INVALID_ENUM
, "glVertexPointer(type)" );
123 update_array(ctx
, &ctx
->Array
.Vertex
, _NEW_ARRAY_VERTEX
,
124 elementSize
, size
, type
, stride
, GL_FALSE
, ptr
);
126 if (ctx
->Driver
.VertexPointer
)
127 ctx
->Driver
.VertexPointer( ctx
, size
, type
, stride
, ptr
);
132 _mesa_NormalPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
135 GET_CURRENT_CONTEXT(ctx
);
136 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
139 _mesa_error( ctx
, GL_INVALID_VALUE
, "glNormalPointer(stride)" );
143 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
144 _mesa_debug(ctx
, "glNormalPointer( type %s stride %d )\n",
145 _mesa_lookup_enum_by_nr( type
), stride
);
149 elementSize
= 3 * sizeof(GLbyte
);
152 elementSize
= 3 * sizeof(GLshort
);
155 elementSize
= 3 * sizeof(GLint
);
158 elementSize
= 3 * sizeof(GLfloat
);
161 elementSize
= 3 * sizeof(GLdouble
);
164 _mesa_error( ctx
, GL_INVALID_ENUM
, "glNormalPointer(type)" );
168 update_array(ctx
, &ctx
->Array
.Normal
, _NEW_ARRAY_NORMAL
,
169 elementSize
, 3, type
, stride
, GL_FALSE
, ptr
);
171 if (ctx
->Driver
.NormalPointer
)
172 ctx
->Driver
.NormalPointer( ctx
, type
, stride
, ptr
);
177 _mesa_ColorPointer(GLint size
, GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
180 GET_CURRENT_CONTEXT(ctx
);
181 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
183 if (size
< 3 || size
> 4) {
184 _mesa_error( ctx
, GL_INVALID_VALUE
, "glColorPointer(size)" );
188 _mesa_error( ctx
, GL_INVALID_VALUE
, "glColorPointer(stride)" );
192 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
193 _mesa_debug(ctx
, "glColorPointer( sz %d type %s stride %d )\n", size
,
194 _mesa_lookup_enum_by_nr( type
), stride
);
198 elementSize
= size
* sizeof(GLbyte
);
200 case GL_UNSIGNED_BYTE
:
201 elementSize
= size
* sizeof(GLubyte
);
204 elementSize
= size
* sizeof(GLshort
);
206 case GL_UNSIGNED_SHORT
:
207 elementSize
= size
* sizeof(GLushort
);
210 elementSize
= size
* sizeof(GLint
);
212 case GL_UNSIGNED_INT
:
213 elementSize
= size
* sizeof(GLuint
);
216 elementSize
= size
* sizeof(GLfloat
);
219 elementSize
= size
* sizeof(GLdouble
);
222 _mesa_error( ctx
, GL_INVALID_ENUM
, "glColorPointer(type)" );
226 update_array(ctx
, &ctx
->Array
.Color
, _NEW_ARRAY_COLOR0
,
227 elementSize
, size
, type
, stride
, GL_FALSE
, ptr
);
229 if (ctx
->Driver
.ColorPointer
)
230 ctx
->Driver
.ColorPointer( ctx
, size
, type
, stride
, ptr
);
235 _mesa_FogCoordPointerEXT(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
238 GET_CURRENT_CONTEXT(ctx
);
239 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
242 _mesa_error( ctx
, GL_INVALID_VALUE
, "glFogCoordPointer(stride)" );
248 elementSize
= sizeof(GLfloat
);
251 elementSize
= sizeof(GLdouble
);
254 _mesa_error( ctx
, GL_INVALID_ENUM
, "glFogCoordPointer(type)" );
258 update_array(ctx
, &ctx
->Array
.FogCoord
, _NEW_ARRAY_FOGCOORD
,
259 elementSize
, 1, type
, stride
, GL_FALSE
, ptr
);
261 if (ctx
->Driver
.FogCoordPointer
)
262 ctx
->Driver
.FogCoordPointer( ctx
, type
, stride
, ptr
);
267 _mesa_IndexPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
270 GET_CURRENT_CONTEXT(ctx
);
271 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
274 _mesa_error( ctx
, GL_INVALID_VALUE
, "glIndexPointer(stride)" );
279 case GL_UNSIGNED_BYTE
:
280 elementSize
= sizeof(GLubyte
);
283 elementSize
= sizeof(GLshort
);
286 elementSize
= sizeof(GLint
);
289 elementSize
= sizeof(GLfloat
);
292 elementSize
= sizeof(GLdouble
);
295 _mesa_error( ctx
, GL_INVALID_ENUM
, "glIndexPointer(type)" );
299 update_array(ctx
, &ctx
->Array
.Index
, _NEW_ARRAY_INDEX
,
300 elementSize
, 1, type
, stride
, GL_FALSE
, ptr
);
302 if (ctx
->Driver
.IndexPointer
)
303 ctx
->Driver
.IndexPointer( ctx
, type
, stride
, ptr
);
308 _mesa_SecondaryColorPointerEXT(GLint size
, GLenum type
,
309 GLsizei stride
, const GLvoid
*ptr
)
312 GET_CURRENT_CONTEXT(ctx
);
313 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
315 if (size
!= 3 && size
!= 4) {
316 _mesa_error( ctx
, GL_INVALID_VALUE
, "glSecondaryColorPointer(size)" );
320 _mesa_error( ctx
, GL_INVALID_VALUE
, "glSecondaryColorPointer(stride)" );
324 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
325 _mesa_debug(ctx
, "glSecondaryColorPointer( sz %d type %s stride %d )\n",
326 size
, _mesa_lookup_enum_by_nr( type
), stride
);
330 elementSize
= size
* sizeof(GLbyte
);
332 case GL_UNSIGNED_BYTE
:
333 elementSize
= size
* sizeof(GLubyte
);
336 elementSize
= size
* sizeof(GLshort
);
338 case GL_UNSIGNED_SHORT
:
339 elementSize
= size
* sizeof(GLushort
);
342 elementSize
= size
* sizeof(GLint
);
344 case GL_UNSIGNED_INT
:
345 elementSize
= size
* sizeof(GLuint
);
348 elementSize
= size
* sizeof(GLfloat
);
351 elementSize
= size
* sizeof(GLdouble
);
354 _mesa_error( ctx
, GL_INVALID_ENUM
, "glSecondaryColorPointer(type)" );
358 update_array(ctx
, &ctx
->Array
.SecondaryColor
, _NEW_ARRAY_COLOR1
,
359 elementSize
, size
, type
, stride
, GL_FALSE
, ptr
);
361 if (ctx
->Driver
.SecondaryColorPointer
)
362 ctx
->Driver
.SecondaryColorPointer( ctx
, size
, type
, stride
, ptr
);
367 _mesa_TexCoordPointer(GLint size
, GLenum type
, GLsizei stride
,
371 GET_CURRENT_CONTEXT(ctx
);
372 const GLuint unit
= ctx
->Array
.ActiveTexture
;
373 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
375 if (size
< 1 || size
> 4) {
376 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexCoordPointer(size)" );
380 _mesa_error( ctx
, GL_INVALID_VALUE
, "glTexCoordPointer(stride)" );
384 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
385 _mesa_debug(ctx
, "glTexCoordPointer(unit %u sz %d type %s stride %d)\n",
386 unit
, size
, _mesa_lookup_enum_by_nr( type
), stride
);
388 /* always need to check that <type> is legal */
391 elementSize
= size
* sizeof(GLshort
);
394 elementSize
= size
* sizeof(GLint
);
397 elementSize
= size
* sizeof(GLfloat
);
400 elementSize
= size
* sizeof(GLdouble
);
403 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexCoordPointer(type)" );
407 update_array(ctx
, &ctx
->Array
.TexCoord
[unit
], _NEW_ARRAY_TEXCOORD(unit
),
408 elementSize
, size
, type
, stride
, GL_FALSE
, ptr
);
410 if (ctx
->Driver
.TexCoordPointer
)
411 ctx
->Driver
.TexCoordPointer( ctx
, size
, type
, stride
, ptr
);
416 _mesa_EdgeFlagPointer(GLsizei stride
, const GLvoid
*ptr
)
418 GET_CURRENT_CONTEXT(ctx
);
419 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
422 _mesa_error( ctx
, GL_INVALID_VALUE
, "glEdgeFlagPointer(stride)" );
426 update_array(ctx
, &ctx
->Array
.EdgeFlag
, _NEW_ARRAY_EDGEFLAG
,
427 sizeof(GLboolean
), 1, GL_BOOLEAN
, stride
, GL_FALSE
, ptr
);
429 if (ctx
->Driver
.EdgeFlagPointer
)
430 ctx
->Driver
.EdgeFlagPointer( ctx
, stride
, ptr
);
434 #if FEATURE_NV_vertex_program
436 _mesa_VertexAttribPointerNV(GLuint index
, GLint size
, GLenum type
,
437 GLsizei stride
, const GLvoid
*ptr
)
440 GET_CURRENT_CONTEXT(ctx
);
441 ASSERT_OUTSIDE_BEGIN_END(ctx
);
443 if (index
>= VERT_ATTRIB_MAX
) {
444 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(index)");
448 if (size
< 1 || size
> 4) {
449 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(size)");
454 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(stride)");
458 if (type
== GL_UNSIGNED_BYTE
&& size
!= 4) {
459 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(size!=4)");
463 /* check for valid 'type' and compute StrideB right away */
465 case GL_UNSIGNED_BYTE
:
466 elementSize
= size
* sizeof(GLubyte
);
469 elementSize
= size
* sizeof(GLshort
);
472 elementSize
= size
* sizeof(GLfloat
);
475 elementSize
= size
* sizeof(GLdouble
);
478 _mesa_error( ctx
, GL_INVALID_ENUM
, "glVertexAttribPointerNV(type)" );
482 update_array(ctx
, &ctx
->Array
.VertexAttrib
[index
], _NEW_ARRAY_ATTRIB(index
),
483 elementSize
, size
, type
, stride
, GL_FALSE
, ptr
);
485 if (ctx
->Driver
.VertexAttribPointer
)
486 ctx
->Driver
.VertexAttribPointer( ctx
, index
, size
, type
, stride
, ptr
);
491 #if FEATURE_ARB_vertex_program
493 _mesa_VertexAttribPointerARB(GLuint index
, GLint size
, GLenum type
,
494 GLboolean normalized
,
495 GLsizei stride
, const GLvoid
*ptr
)
498 GET_CURRENT_CONTEXT(ctx
);
499 ASSERT_OUTSIDE_BEGIN_END(ctx
);
501 if (index
>= ctx
->Const
.MaxVertexProgramAttribs
) {
502 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(index)");
506 if (size
< 1 || size
> 4) {
507 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(size)");
512 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(stride)");
516 if (type
== GL_UNSIGNED_BYTE
&& size
!= 4) {
517 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerARB(size!=4)");
521 /* check for valid 'type' and compute StrideB right away */
522 /* NOTE: more types are supported here than in the NV extension */
525 elementSize
= size
* sizeof(GLbyte
);
527 case GL_UNSIGNED_BYTE
:
528 elementSize
= size
* sizeof(GLubyte
);
531 elementSize
= size
* sizeof(GLshort
);
533 case GL_UNSIGNED_SHORT
:
534 elementSize
= size
* sizeof(GLushort
);
537 elementSize
= size
* sizeof(GLint
);
539 case GL_UNSIGNED_INT
:
540 elementSize
= size
* sizeof(GLuint
);
543 elementSize
= size
* sizeof(GLfloat
);
546 elementSize
= size
* sizeof(GLdouble
);
549 _mesa_error( ctx
, GL_INVALID_ENUM
, "glVertexAttribPointerARB(type)" );
553 update_array(ctx
, &ctx
->Array
.VertexAttrib
[index
], _NEW_ARRAY_ATTRIB(index
),
554 elementSize
, size
, type
, stride
, normalized
, ptr
);
557 if (ctx->Driver.VertexAttribPointer)
558 ctx->Driver.VertexAttribPointer( ctx, index, size, type, stride, ptr );
565 _mesa_VertexPointerEXT(GLint size
, GLenum type
, GLsizei stride
,
566 GLsizei count
, const GLvoid
*ptr
)
569 _mesa_VertexPointer(size
, type
, stride
, ptr
);
574 _mesa_NormalPointerEXT(GLenum type
, GLsizei stride
, GLsizei count
,
578 _mesa_NormalPointer(type
, stride
, ptr
);
583 _mesa_ColorPointerEXT(GLint size
, GLenum type
, GLsizei stride
, GLsizei count
,
587 _mesa_ColorPointer(size
, type
, stride
, ptr
);
592 _mesa_IndexPointerEXT(GLenum type
, GLsizei stride
, GLsizei count
,
596 _mesa_IndexPointer(type
, stride
, ptr
);
601 _mesa_TexCoordPointerEXT(GLint size
, GLenum type
, GLsizei stride
,
602 GLsizei count
, const GLvoid
*ptr
)
605 _mesa_TexCoordPointer(size
, type
, stride
, ptr
);
610 _mesa_EdgeFlagPointerEXT(GLsizei stride
, GLsizei count
, const GLboolean
*ptr
)
613 _mesa_EdgeFlagPointer(stride
, ptr
);
618 _mesa_InterleavedArrays(GLenum format
, GLsizei stride
, const GLvoid
*pointer
)
620 GET_CURRENT_CONTEXT(ctx
);
621 GLboolean tflag
, cflag
, nflag
; /* enable/disable flags */
622 GLint tcomps
, ccomps
, vcomps
; /* components per texcoord, color, vertex */
623 GLenum ctype
= 0; /* color type */
624 GLint coffset
= 0, noffset
= 0, voffset
;/* color, normal, vertex offsets */
625 const GLint toffset
= 0; /* always zero */
626 GLint defstride
; /* default stride */
630 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
633 c
= f
* ((4 * sizeof(GLubyte
) + (f
- 1)) / f
);
636 _mesa_error( ctx
, GL_INVALID_VALUE
, "glInterleavedArrays(stride)" );
642 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
643 tcomps
= 0; ccomps
= 0; vcomps
= 2;
648 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
649 tcomps
= 0; ccomps
= 0; vcomps
= 3;
654 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
655 tcomps
= 0; ccomps
= 4; vcomps
= 2;
656 ctype
= GL_UNSIGNED_BYTE
;
662 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
663 tcomps
= 0; ccomps
= 4; vcomps
= 3;
664 ctype
= GL_UNSIGNED_BYTE
;
670 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
671 tcomps
= 0; ccomps
= 3; vcomps
= 3;
678 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_TRUE
;
679 tcomps
= 0; ccomps
= 0; vcomps
= 3;
685 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
686 tcomps
= 0; ccomps
= 4; vcomps
= 3;
694 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
695 tcomps
= 2; ccomps
= 0; vcomps
= 3;
700 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
701 tcomps
= 4; ccomps
= 0; vcomps
= 4;
705 case GL_T2F_C4UB_V3F
:
706 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
707 tcomps
= 2; ccomps
= 4; vcomps
= 3;
708 ctype
= GL_UNSIGNED_BYTE
;
714 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
715 tcomps
= 2; ccomps
= 3; vcomps
= 3;
722 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_TRUE
;
723 tcomps
= 2; ccomps
= 0; vcomps
= 3;
728 case GL_T2F_C4F_N3F_V3F
:
729 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
730 tcomps
= 2; ccomps
= 4; vcomps
= 3;
737 case GL_T4F_C4F_N3F_V4F
:
738 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
739 tcomps
= 4; ccomps
= 4; vcomps
= 4;
747 _mesa_error( ctx
, GL_INVALID_ENUM
, "glInterleavedArrays(format)" );
755 _mesa_DisableClientState( GL_EDGE_FLAG_ARRAY
);
756 _mesa_DisableClientState( GL_INDEX_ARRAY
);
759 coordUnitSave
= ctx
->Array
.ActiveTexture
;
762 /* enable unit 0 texcoord array */
763 _mesa_ClientActiveTextureARB( GL_TEXTURE0_ARB
);
764 _mesa_EnableClientState( GL_TEXTURE_COORD_ARRAY
);
765 _mesa_TexCoordPointer( tcomps
, GL_FLOAT
, stride
,
766 (GLubyte
*) pointer
+ i
* toffset
);
767 /* disable all other texcoord arrays */
768 for (i
= 1; i
< ctx
->Const
.MaxTextureCoordUnits
; i
++) {
769 _mesa_ClientActiveTextureARB( (GLenum
) (GL_TEXTURE0_ARB
+ i
) );
770 _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY
);
774 /* disable all texcoord arrays */
776 for (i
= 0; i
< ctx
->Const
.MaxTextureCoordUnits
; i
++) {
777 _mesa_ClientActiveTextureARB( (GLenum
) (GL_TEXTURE0_ARB
+ i
) );
778 _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY
);
781 /* Restore texture coordinate unit index */
782 _mesa_ClientActiveTextureARB( (GLenum
) (GL_TEXTURE0_ARB
+ coordUnitSave
) );
787 _mesa_EnableClientState( GL_COLOR_ARRAY
);
788 _mesa_ColorPointer( ccomps
, ctype
, stride
,
789 (GLubyte
*) pointer
+ coffset
);
792 _mesa_DisableClientState( GL_COLOR_ARRAY
);
798 _mesa_EnableClientState( GL_NORMAL_ARRAY
);
799 _mesa_NormalPointer( GL_FLOAT
, stride
, (GLubyte
*) pointer
+ noffset
);
802 _mesa_DisableClientState( GL_NORMAL_ARRAY
);
806 _mesa_EnableClientState( GL_VERTEX_ARRAY
);
807 _mesa_VertexPointer( vcomps
, GL_FLOAT
, stride
,
808 (GLubyte
*) pointer
+ voffset
);
813 _mesa_LockArraysEXT(GLint first
, GLsizei count
)
815 GET_CURRENT_CONTEXT(ctx
);
816 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
818 if (MESA_VERBOSE
& VERBOSE_API
)
819 _mesa_debug(ctx
, "glLockArrays %d %d\n", first
, count
);
821 if (first
== 0 && count
> 0 &&
822 count
<= (GLint
) ctx
->Const
.MaxArrayLockSize
) {
823 ctx
->Array
.LockFirst
= first
;
824 ctx
->Array
.LockCount
= count
;
827 ctx
->Array
.LockFirst
= 0;
828 ctx
->Array
.LockCount
= 0;
831 ctx
->NewState
|= _NEW_ARRAY
;
832 ctx
->Array
.NewState
|= _NEW_ARRAY_ALL
;
834 if (ctx
->Driver
.LockArraysEXT
)
835 ctx
->Driver
.LockArraysEXT( ctx
, first
, count
);
840 _mesa_UnlockArraysEXT( void )
842 GET_CURRENT_CONTEXT(ctx
);
843 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
845 if (MESA_VERBOSE
& VERBOSE_API
)
846 _mesa_debug(ctx
, "glUnlockArrays\n");
848 ctx
->Array
.LockFirst
= 0;
849 ctx
->Array
.LockCount
= 0;
850 ctx
->NewState
|= _NEW_ARRAY
;
851 ctx
->Array
.NewState
|= _NEW_ARRAY_ALL
;
853 if (ctx
->Driver
.UnlockArraysEXT
)
854 ctx
->Driver
.UnlockArraysEXT( ctx
);
858 /* GL_EXT_multi_draw_arrays */
859 /* Somebody forgot to spec the first and count parameters as const! <sigh> */
861 _mesa_MultiDrawArraysEXT( GLenum mode
, GLint
*first
,
862 GLsizei
*count
, GLsizei primcount
)
864 GET_CURRENT_CONTEXT(ctx
);
867 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
869 for (i
= 0; i
< primcount
; i
++) {
871 (ctx
->Exec
->DrawArrays
)(mode
, first
[i
], count
[i
]);
877 /* GL_EXT_multi_draw_arrays */
879 _mesa_MultiDrawElementsEXT( GLenum mode
, const GLsizei
*count
, GLenum type
,
880 const GLvoid
**indices
, GLsizei primcount
)
882 GET_CURRENT_CONTEXT(ctx
);
885 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
887 for (i
= 0; i
< primcount
; i
++) {
889 (ctx
->Exec
->DrawElements
)(mode
, count
[i
], type
, indices
[i
]);
895 /* GL_IBM_multimode_draw_arrays */
897 _mesa_MultiModeDrawArraysIBM( const GLenum
* mode
, const GLint
* first
,
898 const GLsizei
* count
,
899 GLsizei primcount
, GLint modestride
)
901 GET_CURRENT_CONTEXT(ctx
);
904 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
906 for ( i
= 0 ; i
< primcount
; i
++ ) {
907 if ( count
[i
] > 0 ) {
908 GLenum m
= *((GLenum
*) ((GLubyte
*) mode
+ i
* modestride
));
909 (ctx
->Exec
->DrawArrays
)( m
, first
[i
], count
[i
] );
915 /* GL_IBM_multimode_draw_arrays */
917 _mesa_MultiModeDrawElementsIBM( const GLenum
* mode
, const GLsizei
* count
,
918 GLenum type
, const GLvoid
* const * indices
,
919 GLsizei primcount
, GLint modestride
)
921 GET_CURRENT_CONTEXT(ctx
);
924 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
926 /* XXX not sure about ARB_vertex_buffer_object handling here */
928 for ( i
= 0 ; i
< primcount
; i
++ ) {
929 if ( count
[i
] > 0 ) {
930 GLenum m
= *((GLenum
*) ((GLubyte
*) mode
+ i
* modestride
));
931 (ctx
->Exec
->DrawElements
)( m
, count
[i
], type
, indices
[i
] );
937 /**********************************************************************/
938 /***** Initialization *****/
939 /**********************************************************************/
942 _mesa_init_varray( GLcontext
* ctx
)
947 ctx
->Array
.Vertex
.Size
= 4;
948 ctx
->Array
.Vertex
.Type
= GL_FLOAT
;
949 ctx
->Array
.Vertex
.Stride
= 0;
950 ctx
->Array
.Vertex
.StrideB
= 0;
951 ctx
->Array
.Vertex
.Ptr
= NULL
;
952 ctx
->Array
.Vertex
.Enabled
= GL_FALSE
;
953 ctx
->Array
.Vertex
.Flags
= CA_CLIENT_DATA
;
954 ctx
->Array
.Normal
.Type
= GL_FLOAT
;
955 ctx
->Array
.Normal
.Stride
= 0;
956 ctx
->Array
.Normal
.StrideB
= 0;
957 ctx
->Array
.Normal
.Ptr
= NULL
;
958 ctx
->Array
.Normal
.Enabled
= GL_FALSE
;
959 ctx
->Array
.Normal
.Flags
= CA_CLIENT_DATA
;
960 ctx
->Array
.Color
.Size
= 4;
961 ctx
->Array
.Color
.Type
= GL_FLOAT
;
962 ctx
->Array
.Color
.Stride
= 0;
963 ctx
->Array
.Color
.StrideB
= 0;
964 ctx
->Array
.Color
.Ptr
= NULL
;
965 ctx
->Array
.Color
.Enabled
= GL_FALSE
;
966 ctx
->Array
.Color
.Flags
= CA_CLIENT_DATA
;
967 ctx
->Array
.SecondaryColor
.Size
= 4;
968 ctx
->Array
.SecondaryColor
.Type
= GL_FLOAT
;
969 ctx
->Array
.SecondaryColor
.Stride
= 0;
970 ctx
->Array
.SecondaryColor
.StrideB
= 0;
971 ctx
->Array
.SecondaryColor
.Ptr
= NULL
;
972 ctx
->Array
.SecondaryColor
.Enabled
= GL_FALSE
;
973 ctx
->Array
.SecondaryColor
.Flags
= CA_CLIENT_DATA
;
974 ctx
->Array
.FogCoord
.Size
= 1;
975 ctx
->Array
.FogCoord
.Type
= GL_FLOAT
;
976 ctx
->Array
.FogCoord
.Stride
= 0;
977 ctx
->Array
.FogCoord
.StrideB
= 0;
978 ctx
->Array
.FogCoord
.Ptr
= NULL
;
979 ctx
->Array
.FogCoord
.Enabled
= GL_FALSE
;
980 ctx
->Array
.FogCoord
.Flags
= CA_CLIENT_DATA
;
981 ctx
->Array
.Index
.Type
= GL_FLOAT
;
982 ctx
->Array
.Index
.Stride
= 0;
983 ctx
->Array
.Index
.StrideB
= 0;
984 ctx
->Array
.Index
.Ptr
= NULL
;
985 ctx
->Array
.Index
.Enabled
= GL_FALSE
;
986 ctx
->Array
.Index
.Flags
= CA_CLIENT_DATA
;
987 for (i
= 0; i
< MAX_TEXTURE_UNITS
; i
++) {
988 ctx
->Array
.TexCoord
[i
].Size
= 4;
989 ctx
->Array
.TexCoord
[i
].Type
= GL_FLOAT
;
990 ctx
->Array
.TexCoord
[i
].Stride
= 0;
991 ctx
->Array
.TexCoord
[i
].StrideB
= 0;
992 ctx
->Array
.TexCoord
[i
].Ptr
= NULL
;
993 ctx
->Array
.TexCoord
[i
].Enabled
= GL_FALSE
;
994 ctx
->Array
.TexCoord
[i
].Flags
= CA_CLIENT_DATA
;
996 ctx
->Array
.EdgeFlag
.Stride
= 0;
997 ctx
->Array
.EdgeFlag
.StrideB
= 0;
998 ctx
->Array
.EdgeFlag
.Ptr
= NULL
;
999 ctx
->Array
.EdgeFlag
.Enabled
= GL_FALSE
;
1000 ctx
->Array
.EdgeFlag
.Flags
= CA_CLIENT_DATA
;
1001 ctx
->Array
.ActiveTexture
= 0; /* GL_ARB_multitexture */
1002 for (i
= 0; i
< VERT_ATTRIB_MAX
; i
++) {
1003 ctx
->Array
.VertexAttrib
[i
].Size
= 4;
1004 ctx
->Array
.VertexAttrib
[i
].Type
= GL_FLOAT
;
1005 ctx
->Array
.VertexAttrib
[i
].Stride
= 0;
1006 ctx
->Array
.VertexAttrib
[i
].StrideB
= 0;
1007 ctx
->Array
.VertexAttrib
[i
].Ptr
= NULL
;
1008 ctx
->Array
.VertexAttrib
[i
].Enabled
= GL_FALSE
;
1009 ctx
->Array
.VertexAttrib
[i
].Flags
= CA_CLIENT_DATA
;