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.
38 _mesa_VertexPointer(GLint size
, GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
40 GET_CURRENT_CONTEXT(ctx
);
41 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
43 if (size
< 2 || size
> 4) {
44 _mesa_error( ctx
, GL_INVALID_VALUE
, "glVertexPointer(size)" );
48 _mesa_error( ctx
, GL_INVALID_VALUE
, "glVertexPointer(stride)" );
52 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
53 _mesa_debug(ctx
, "glVertexPointer( sz %d type %s stride %d )\n", size
,
54 _mesa_lookup_enum_by_nr( type
), stride
);
56 /* always need to check that <type> is legal */
59 ctx
->Array
.Vertex
.StrideB
= size
* sizeof(GLshort
);
62 ctx
->Array
.Vertex
.StrideB
= size
* sizeof(GLint
);
65 ctx
->Array
.Vertex
.StrideB
= size
* sizeof(GLfloat
);
68 ctx
->Array
.Vertex
.StrideB
= size
* sizeof(GLdouble
);
71 _mesa_error( ctx
, GL_INVALID_ENUM
, "glVertexPointer(type)" );
76 ctx
->Array
.Vertex
.StrideB
= stride
;
78 ctx
->Array
.Vertex
.Size
= size
;
79 ctx
->Array
.Vertex
.Type
= type
;
80 ctx
->Array
.Vertex
.Stride
= stride
;
81 ctx
->Array
.Vertex
.Ptr
= (void *) ptr
;
82 #if FEATURE_ARB_vertex_buffer_object
83 ctx
->Array
.Vertex
.BufferObj
= ctx
->Array
.ArrayBufferObj
;
85 ctx
->NewState
|= _NEW_ARRAY
;
86 ctx
->Array
.NewState
|= _NEW_ARRAY_VERTEX
;
88 if (ctx
->Driver
.VertexPointer
)
89 ctx
->Driver
.VertexPointer( ctx
, size
, type
, stride
, ptr
);
94 _mesa_NormalPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
96 GET_CURRENT_CONTEXT(ctx
);
97 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
100 _mesa_error( ctx
, GL_INVALID_VALUE
, "glNormalPointer(stride)" );
104 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
105 _mesa_debug(ctx
, "glNormalPointer( type %s stride %d )\n",
106 _mesa_lookup_enum_by_nr( type
), stride
);
110 ctx
->Array
.Normal
.StrideB
= 3 * sizeof(GLbyte
);
113 ctx
->Array
.Normal
.StrideB
= 3 * sizeof(GLshort
);
116 ctx
->Array
.Normal
.StrideB
= 3 * sizeof(GLint
);
119 ctx
->Array
.Normal
.StrideB
= 3 * sizeof(GLfloat
);
122 ctx
->Array
.Normal
.StrideB
= 3 * sizeof(GLdouble
);
125 _mesa_error( ctx
, GL_INVALID_ENUM
, "glNormalPointer(type)" );
129 ctx
->Array
.Normal
.StrideB
= stride
;
131 ctx
->Array
.Normal
.Size
= 3;
132 ctx
->Array
.Normal
.Type
= type
;
133 ctx
->Array
.Normal
.Stride
= stride
;
134 ctx
->Array
.Normal
.Ptr
= (void *) ptr
;
135 #if FEATURE_ARB_vertex_buffer_object
136 ctx
->Array
.Normal
.BufferObj
= ctx
->Array
.ArrayBufferObj
;
138 ctx
->NewState
|= _NEW_ARRAY
;
139 ctx
->Array
.NewState
|= _NEW_ARRAY_NORMAL
;
141 if (ctx
->Driver
.NormalPointer
)
142 ctx
->Driver
.NormalPointer( ctx
, type
, stride
, ptr
);
147 _mesa_ColorPointer(GLint size
, GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
149 GET_CURRENT_CONTEXT(ctx
);
150 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
152 if (size
< 3 || size
> 4) {
153 _mesa_error( ctx
, GL_INVALID_VALUE
, "glColorPointer(size)" );
157 _mesa_error( ctx
, GL_INVALID_VALUE
, "glColorPointer(stride)" );
161 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
162 _mesa_debug(ctx
, "glColorPointer( sz %d type %s stride %d )\n", size
,
163 _mesa_lookup_enum_by_nr( type
), stride
);
167 ctx
->Array
.Color
.StrideB
= size
* sizeof(GLbyte
);
169 case GL_UNSIGNED_BYTE
:
170 ctx
->Array
.Color
.StrideB
= size
* sizeof(GLubyte
);
173 ctx
->Array
.Color
.StrideB
= size
* sizeof(GLshort
);
175 case GL_UNSIGNED_SHORT
:
176 ctx
->Array
.Color
.StrideB
= size
* sizeof(GLushort
);
179 ctx
->Array
.Color
.StrideB
= size
* sizeof(GLint
);
181 case GL_UNSIGNED_INT
:
182 ctx
->Array
.Color
.StrideB
= size
* sizeof(GLuint
);
185 ctx
->Array
.Color
.StrideB
= size
* sizeof(GLfloat
);
188 ctx
->Array
.Color
.StrideB
= size
* sizeof(GLdouble
);
191 _mesa_error( ctx
, GL_INVALID_ENUM
, "glColorPointer(type)" );
196 ctx
->Array
.Color
.StrideB
= stride
;
198 ctx
->Array
.Color
.Size
= size
;
199 ctx
->Array
.Color
.Type
= type
;
200 ctx
->Array
.Color
.Stride
= stride
;
201 ctx
->Array
.Color
.Ptr
= (void *) ptr
;
202 #if FEATURE_ARB_vertex_buffer_object
203 ctx
->Array
.Color
.BufferObj
= ctx
->Array
.ArrayBufferObj
;
205 ctx
->NewState
|= _NEW_ARRAY
;
206 ctx
->Array
.NewState
|= _NEW_ARRAY_COLOR0
;
208 if (ctx
->Driver
.ColorPointer
)
209 ctx
->Driver
.ColorPointer( ctx
, size
, type
, stride
, ptr
);
214 _mesa_FogCoordPointerEXT(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
216 GET_CURRENT_CONTEXT(ctx
);
217 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
220 _mesa_error( ctx
, GL_INVALID_VALUE
, "glFogCoordPointer(stride)" );
226 ctx
->Array
.FogCoord
.StrideB
= sizeof(GLfloat
);
229 ctx
->Array
.FogCoord
.StrideB
= sizeof(GLdouble
);
232 _mesa_error( ctx
, GL_INVALID_ENUM
, "glFogCoordPointer(type)" );
237 ctx
->Array
.FogCoord
.StrideB
= stride
;
239 ctx
->Array
.FogCoord
.Size
= 1;
240 ctx
->Array
.FogCoord
.Type
= type
;
241 ctx
->Array
.FogCoord
.Stride
= stride
;
242 ctx
->Array
.FogCoord
.Ptr
= (void *) ptr
;
243 #if FEATURE_ARB_vertex_buffer_object
244 ctx
->Array
.FogCoord
.BufferObj
= ctx
->Array
.ArrayBufferObj
;
246 ctx
->NewState
|= _NEW_ARRAY
;
247 ctx
->Array
.NewState
|= _NEW_ARRAY_FOGCOORD
;
249 if (ctx
->Driver
.FogCoordPointer
)
250 ctx
->Driver
.FogCoordPointer( ctx
, type
, stride
, ptr
);
255 _mesa_IndexPointer(GLenum type
, GLsizei stride
, const GLvoid
*ptr
)
257 GET_CURRENT_CONTEXT(ctx
);
258 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
261 _mesa_error( ctx
, GL_INVALID_VALUE
, "glIndexPointer(stride)" );
266 case GL_UNSIGNED_BYTE
:
267 ctx
->Array
.Index
.StrideB
= sizeof(GLubyte
);
270 ctx
->Array
.Index
.StrideB
= sizeof(GLshort
);
273 ctx
->Array
.Index
.StrideB
= sizeof(GLint
);
276 ctx
->Array
.Index
.StrideB
= sizeof(GLfloat
);
279 ctx
->Array
.Index
.StrideB
= sizeof(GLdouble
);
282 _mesa_error( ctx
, GL_INVALID_ENUM
, "glIndexPointer(type)" );
287 ctx
->Array
.Index
.StrideB
= stride
;
289 ctx
->Array
.Index
.Size
= 1;
290 ctx
->Array
.Index
.Type
= type
;
291 ctx
->Array
.Index
.Stride
= stride
;
292 ctx
->Array
.Index
.Ptr
= (void *) ptr
;
293 #if FEATURE_ARB_vertex_buffer_object
294 ctx
->Array
.Index
.BufferObj
= ctx
->Array
.ArrayBufferObj
;
296 ctx
->NewState
|= _NEW_ARRAY
;
297 ctx
->Array
.NewState
|= _NEW_ARRAY_INDEX
;
299 if (ctx
->Driver
.IndexPointer
)
300 ctx
->Driver
.IndexPointer( ctx
, type
, stride
, ptr
);
305 _mesa_SecondaryColorPointerEXT(GLint size
, GLenum type
,
306 GLsizei stride
, const GLvoid
*ptr
)
308 GET_CURRENT_CONTEXT(ctx
);
309 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
311 if (size
!= 3 && size
!= 4) {
312 _mesa_error( ctx
, GL_INVALID_VALUE
, "glSecondaryColorPointer(size)" );
316 _mesa_error( ctx
, GL_INVALID_VALUE
, "glSecondaryColorPointer(stride)" );
320 if (MESA_VERBOSE
&(VERBOSE_VARRAY
|VERBOSE_API
))
321 _mesa_debug(ctx
, "glSecondaryColorPointer( sz %d type %s stride %d )\n",
322 size
, _mesa_lookup_enum_by_nr( type
), stride
);
326 ctx
->Array
.SecondaryColor
.StrideB
= size
* sizeof(GLbyte
);
328 case GL_UNSIGNED_BYTE
:
329 ctx
->Array
.SecondaryColor
.StrideB
= size
* sizeof(GLubyte
);
332 ctx
->Array
.SecondaryColor
.StrideB
= size
* sizeof(GLshort
);
334 case GL_UNSIGNED_SHORT
:
335 ctx
->Array
.SecondaryColor
.StrideB
= size
* sizeof(GLushort
);
338 ctx
->Array
.SecondaryColor
.StrideB
= size
* sizeof(GLint
);
340 case GL_UNSIGNED_INT
:
341 ctx
->Array
.SecondaryColor
.StrideB
= size
* sizeof(GLuint
);
344 ctx
->Array
.SecondaryColor
.StrideB
= size
* sizeof(GLfloat
);
347 ctx
->Array
.SecondaryColor
.StrideB
= size
* sizeof(GLdouble
);
350 _mesa_error( ctx
, GL_INVALID_ENUM
, "glSecondaryColorPointer(type)" );
355 ctx
->Array
.SecondaryColor
.StrideB
= stride
;
357 ctx
->Array
.SecondaryColor
.Size
= 3; /* hardwire */
358 ctx
->Array
.SecondaryColor
.Type
= type
;
359 ctx
->Array
.SecondaryColor
.Stride
= stride
;
360 ctx
->Array
.SecondaryColor
.Ptr
= (void *) ptr
;
361 #if FEATURE_ARB_vertex_buffer_object
362 ctx
->Array
.SecondaryColor
.BufferObj
= ctx
->Array
.ArrayBufferObj
;
364 ctx
->NewState
|= _NEW_ARRAY
;
365 ctx
->Array
.NewState
|= _NEW_ARRAY_COLOR1
;
367 if (ctx
->Driver
.SecondaryColorPointer
)
368 ctx
->Driver
.SecondaryColorPointer( ctx
, size
, type
, stride
, ptr
);
373 _mesa_TexCoordPointer(GLint size
, GLenum type
, GLsizei stride
,
376 GET_CURRENT_CONTEXT(ctx
);
377 GLuint texUnit
= 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 texUnit
, size
, _mesa_lookup_enum_by_nr( type
), stride
);
393 /* always need to check that <type> is legal */
396 ctx
->Array
.TexCoord
[texUnit
].StrideB
= size
* sizeof(GLshort
);
399 ctx
->Array
.TexCoord
[texUnit
].StrideB
= size
* sizeof(GLint
);
402 ctx
->Array
.TexCoord
[texUnit
].StrideB
= size
* sizeof(GLfloat
);
405 ctx
->Array
.TexCoord
[texUnit
].StrideB
= size
* sizeof(GLdouble
);
408 _mesa_error( ctx
, GL_INVALID_ENUM
, "glTexCoordPointer(type)" );
413 ctx
->Array
.TexCoord
[texUnit
].StrideB
= stride
;
415 ctx
->Array
.TexCoord
[texUnit
].Size
= size
;
416 ctx
->Array
.TexCoord
[texUnit
].Type
= type
;
417 ctx
->Array
.TexCoord
[texUnit
].Stride
= stride
;
418 ctx
->Array
.TexCoord
[texUnit
].Ptr
= (void *) ptr
;
419 #if FEATURE_ARB_vertex_buffer_object
420 ctx
->Array
.TexCoord
[texUnit
].BufferObj
= ctx
->Array
.ArrayBufferObj
;
422 ctx
->NewState
|= _NEW_ARRAY
;
423 ctx
->Array
.NewState
|= _NEW_ARRAY_TEXCOORD(texUnit
);
425 if (ctx
->Driver
.TexCoordPointer
)
426 ctx
->Driver
.TexCoordPointer( ctx
, size
, type
, stride
, ptr
);
431 _mesa_EdgeFlagPointer(GLsizei stride
, const GLvoid
*vptr
)
433 GET_CURRENT_CONTEXT(ctx
);
434 const GLboolean
*ptr
= (GLboolean
*)vptr
;
435 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
438 _mesa_error( ctx
, GL_INVALID_VALUE
, "glEdgeFlagPointer(stride)" );
441 ctx
->Array
.EdgeFlag
.Stride
= stride
;
442 ctx
->Array
.EdgeFlag
.StrideB
= stride
? stride
: sizeof(GLboolean
);
443 ctx
->Array
.EdgeFlag
.Ptr
= (GLboolean
*) ptr
;
444 #if FEATURE_ARB_vertex_buffer_object
445 ctx
->Array
.EdgeFlag
.BufferObj
= ctx
->Array
.ArrayBufferObj
;
447 ctx
->NewState
|= _NEW_ARRAY
;
448 ctx
->Array
.NewState
|= _NEW_ARRAY_EDGEFLAG
;
450 if (ctx
->Driver
.EdgeFlagPointer
)
451 ctx
->Driver
.EdgeFlagPointer( ctx
, stride
, ptr
);
455 #if FEATURE_NV_vertex_program
457 _mesa_VertexAttribPointerNV(GLuint index
, GLint size
, GLenum type
,
458 GLsizei stride
, const GLvoid
*ptr
)
460 GET_CURRENT_CONTEXT(ctx
);
461 ASSERT_OUTSIDE_BEGIN_END(ctx
);
463 if (index
>= VERT_ATTRIB_MAX
) {
464 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(index)");
468 if (size
< 1 || size
> 4) {
469 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(size)");
474 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(stride)");
478 if (type
== GL_UNSIGNED_BYTE
&& size
!= 4) {
479 _mesa_error(ctx
, GL_INVALID_VALUE
, "glVertexAttribPointerNV(size!=4)");
483 /* check for valid 'type' and compute StrideB right away */
485 case GL_UNSIGNED_BYTE
:
486 ctx
->Array
.VertexAttrib
[index
].StrideB
= size
* sizeof(GLubyte
);
489 ctx
->Array
.VertexAttrib
[index
].StrideB
= size
* sizeof(GLshort
);
492 ctx
->Array
.VertexAttrib
[index
].StrideB
= size
* sizeof(GLfloat
);
495 ctx
->Array
.VertexAttrib
[index
].StrideB
= size
* sizeof(GLdouble
);
498 _mesa_error( ctx
, GL_INVALID_ENUM
, "glVertexAttribPointerNV(type)" );
503 ctx
->Array
.VertexAttrib
[index
].StrideB
= stride
;
505 ctx
->Array
.VertexAttrib
[index
].Stride
= stride
;
506 ctx
->Array
.VertexAttrib
[index
].Size
= size
;
507 ctx
->Array
.VertexAttrib
[index
].Type
= type
;
508 ctx
->Array
.VertexAttrib
[index
].Ptr
= (void *) ptr
;
509 #if FEATURE_ARB_vertex_buffer_object
510 ctx
->Array
.VertexAttrib
[index
].BufferObj
= ctx
->Array
.ArrayBufferObj
;
512 ctx
->NewState
|= _NEW_ARRAY
;
513 ctx
->Array
.NewState
|= _NEW_ARRAY_ATTRIB(index
);
515 if (ctx
->Driver
.VertexAttribPointer
)
516 ctx
->Driver
.VertexAttribPointer( ctx
, index
, size
, type
, stride
, ptr
);
521 #if FEATURE_ARB_vertex_program
523 _mesa_VertexAttribPointerARB(GLuint index
, GLint size
, GLenum type
,
524 GLboolean normalized
,
525 GLsizei stride
, const GLvoid
*ptr
)
527 GET_CURRENT_CONTEXT(ctx
);
528 ASSERT_OUTSIDE_BEGIN_END(ctx
);
530 if (index
>= ctx
->Const
.MaxVertexProgramAttribs
) {
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 ctx
->Array
.VertexAttrib
[index
].StrideB
= size
* sizeof(GLbyte
);
556 case GL_UNSIGNED_BYTE
:
557 ctx
->Array
.VertexAttrib
[index
].StrideB
= size
* sizeof(GLubyte
);
560 ctx
->Array
.VertexAttrib
[index
].StrideB
= size
* sizeof(GLshort
);
562 case GL_UNSIGNED_SHORT
:
563 ctx
->Array
.VertexAttrib
[index
].StrideB
= size
* sizeof(GLushort
);
566 ctx
->Array
.VertexAttrib
[index
].StrideB
= size
* sizeof(GLint
);
568 case GL_UNSIGNED_INT
:
569 ctx
->Array
.VertexAttrib
[index
].StrideB
= size
* sizeof(GLuint
);
572 ctx
->Array
.VertexAttrib
[index
].StrideB
= size
* sizeof(GLfloat
);
575 ctx
->Array
.VertexAttrib
[index
].StrideB
= size
* sizeof(GLdouble
);
578 _mesa_error( ctx
, GL_INVALID_ENUM
, "glVertexAttribPointerARB(type)" );
583 ctx
->Array
.VertexAttrib
[index
].StrideB
= stride
;
585 ctx
->Array
.VertexAttrib
[index
].Stride
= stride
;
586 ctx
->Array
.VertexAttrib
[index
].Size
= size
;
587 ctx
->Array
.VertexAttrib
[index
].Type
= type
;
588 ctx
->Array
.VertexAttrib
[index
].Normalized
= normalized
;
589 ctx
->Array
.VertexAttrib
[index
].Ptr
= (void *) ptr
;
590 #if FEATURE_ARB_vertex_buffer_object
591 ctx
->Array
.VertexAttrib
[index
].BufferObj
= ctx
->Array
.ArrayBufferObj
;
593 ctx
->NewState
|= _NEW_ARRAY
;
594 ctx
->Array
.NewState
|= _NEW_ARRAY_ATTRIB(index
);
597 if (ctx->Driver.VertexAttribPointer)
598 ctx->Driver.VertexAttribPointer( ctx, index, size, type, stride, ptr );
605 _mesa_VertexPointerEXT(GLint size
, GLenum type
, GLsizei stride
,
606 GLsizei count
, const GLvoid
*ptr
)
609 _mesa_VertexPointer(size
, type
, stride
, ptr
);
614 _mesa_NormalPointerEXT(GLenum type
, GLsizei stride
, GLsizei count
,
618 _mesa_NormalPointer(type
, stride
, ptr
);
623 _mesa_ColorPointerEXT(GLint size
, GLenum type
, GLsizei stride
, GLsizei count
,
627 _mesa_ColorPointer(size
, type
, stride
, ptr
);
632 _mesa_IndexPointerEXT(GLenum type
, GLsizei stride
, GLsizei count
,
636 _mesa_IndexPointer(type
, stride
, ptr
);
641 _mesa_TexCoordPointerEXT(GLint size
, GLenum type
, GLsizei stride
,
642 GLsizei count
, const GLvoid
*ptr
)
645 _mesa_TexCoordPointer(size
, type
, stride
, ptr
);
650 _mesa_EdgeFlagPointerEXT(GLsizei stride
, GLsizei count
, const GLboolean
*ptr
)
653 _mesa_EdgeFlagPointer(stride
, ptr
);
658 _mesa_InterleavedArrays(GLenum format
, GLsizei stride
, const GLvoid
*pointer
)
660 GET_CURRENT_CONTEXT(ctx
);
661 GLboolean tflag
, cflag
, nflag
; /* enable/disable flags */
662 GLint tcomps
, ccomps
, vcomps
; /* components per texcoord, color, vertex */
664 GLenum ctype
= 0; /* color type */
665 GLint coffset
= 0, noffset
= 0, voffset
;/* color, normal, vertex offsets */
666 GLint defstride
; /* default stride */
670 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
673 c
= f
* ((4*sizeof(GLubyte
) + (f
-1)) / f
);
676 _mesa_error( ctx
, GL_INVALID_VALUE
, "glInterleavedArrays(stride)" );
682 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
683 tcomps
= 0; ccomps
= 0; vcomps
= 2;
688 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
689 tcomps
= 0; ccomps
= 0; vcomps
= 3;
694 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
695 tcomps
= 0; ccomps
= 4; vcomps
= 2;
696 ctype
= GL_UNSIGNED_BYTE
;
702 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
703 tcomps
= 0; ccomps
= 4; vcomps
= 3;
704 ctype
= GL_UNSIGNED_BYTE
;
710 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
711 tcomps
= 0; ccomps
= 3; vcomps
= 3;
718 tflag
= GL_FALSE
; cflag
= GL_FALSE
; nflag
= GL_TRUE
;
719 tcomps
= 0; ccomps
= 0; vcomps
= 3;
725 tflag
= GL_FALSE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
726 tcomps
= 0; ccomps
= 4; vcomps
= 3;
734 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
735 tcomps
= 2; ccomps
= 0; vcomps
= 3;
740 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_FALSE
;
741 tcomps
= 4; ccomps
= 0; vcomps
= 4;
745 case GL_T2F_C4UB_V3F
:
746 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
747 tcomps
= 2; ccomps
= 4; vcomps
= 3;
748 ctype
= GL_UNSIGNED_BYTE
;
754 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_FALSE
;
755 tcomps
= 2; ccomps
= 3; vcomps
= 3;
762 tflag
= GL_TRUE
; cflag
= GL_FALSE
; nflag
= GL_TRUE
;
763 tcomps
= 2; ccomps
= 0; vcomps
= 3;
768 case GL_T2F_C4F_N3F_V3F
:
769 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
770 tcomps
= 2; ccomps
= 4; vcomps
= 3;
777 case GL_T4F_C4F_N3F_V4F
:
778 tflag
= GL_TRUE
; cflag
= GL_TRUE
; nflag
= GL_TRUE
;
779 tcomps
= 4; ccomps
= 4; vcomps
= 4;
787 _mesa_error( ctx
, GL_INVALID_ENUM
, "glInterleavedArrays(format)" );
795 _mesa_DisableClientState( GL_EDGE_FLAG_ARRAY
);
796 _mesa_DisableClientState( GL_INDEX_ARRAY
);
799 coordUnitSave
= ctx
->Array
.ActiveTexture
;
802 GLint factor
= ctx
->Array
.TexCoordInterleaveFactor
;
803 for (i
= 0; i
< factor
; i
++) {
804 _mesa_ClientActiveTextureARB( (GLenum
) (GL_TEXTURE0_ARB
+ i
) );
805 _mesa_EnableClientState( GL_TEXTURE_COORD_ARRAY
);
806 _mesa_TexCoordPointer( tcomps
, GL_FLOAT
, stride
,
807 (GLubyte
*) pointer
+ i
* coffset
);
809 for (i
= factor
; i
< (GLint
) ctx
->Const
.MaxTextureCoordUnits
; i
++) {
810 _mesa_ClientActiveTextureARB( (GLenum
) (GL_TEXTURE0_ARB
+ i
) );
811 _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY
);
816 for (i
= 0; i
< (GLint
) ctx
->Const
.MaxTextureCoordUnits
; i
++) {
817 _mesa_ClientActiveTextureARB( (GLenum
) (GL_TEXTURE0_ARB
+ i
) );
818 _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY
);
821 /* Restore texture coordinate unit index */
822 _mesa_ClientActiveTextureARB( (GLenum
) (GL_TEXTURE0_ARB
+ coordUnitSave
) );
827 _mesa_EnableClientState( GL_COLOR_ARRAY
);
828 _mesa_ColorPointer( ccomps
, ctype
, stride
,
829 (GLubyte
*) pointer
+ coffset
);
832 _mesa_DisableClientState( GL_COLOR_ARRAY
);
838 _mesa_EnableClientState( GL_NORMAL_ARRAY
);
839 _mesa_NormalPointer( GL_FLOAT
, stride
,
840 (GLubyte
*) pointer
+ noffset
);
843 _mesa_DisableClientState( GL_NORMAL_ARRAY
);
846 _mesa_EnableClientState( GL_VERTEX_ARRAY
);
847 _mesa_VertexPointer( vcomps
, GL_FLOAT
, stride
,
848 (GLubyte
*) pointer
+ voffset
);
853 _mesa_LockArraysEXT(GLint first
, GLsizei count
)
855 GET_CURRENT_CONTEXT(ctx
);
856 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
858 if (MESA_VERBOSE
& VERBOSE_API
)
859 _mesa_debug(ctx
, "glLockArrays %d %d\n", first
, count
);
861 if (first
== 0 && count
> 0 &&
862 count
<= (GLint
) ctx
->Const
.MaxArrayLockSize
) {
863 ctx
->Array
.LockFirst
= first
;
864 ctx
->Array
.LockCount
= count
;
867 ctx
->Array
.LockFirst
= 0;
868 ctx
->Array
.LockCount
= 0;
871 ctx
->NewState
|= _NEW_ARRAY
;
872 ctx
->Array
.NewState
|= _NEW_ARRAY_ALL
;
874 if (ctx
->Driver
.LockArraysEXT
)
875 ctx
->Driver
.LockArraysEXT( ctx
, first
, count
);
880 _mesa_UnlockArraysEXT( void )
882 GET_CURRENT_CONTEXT(ctx
);
883 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
885 if (MESA_VERBOSE
& VERBOSE_API
)
886 _mesa_debug(ctx
, "glUnlockArrays\n");
888 ctx
->Array
.LockFirst
= 0;
889 ctx
->Array
.LockCount
= 0;
890 ctx
->NewState
|= _NEW_ARRAY
;
891 ctx
->Array
.NewState
|= _NEW_ARRAY_ALL
;
893 if (ctx
->Driver
.UnlockArraysEXT
)
894 ctx
->Driver
.UnlockArraysEXT( ctx
);
898 /* GL_EXT_multi_draw_arrays */
899 /* Somebody forgot to spec the first and count parameters as const! <sigh> */
901 _mesa_MultiDrawArraysEXT( GLenum mode
, GLint
*first
,
902 GLsizei
*count
, GLsizei primcount
)
904 GET_CURRENT_CONTEXT(ctx
);
907 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
909 for (i
= 0; i
< primcount
; i
++) {
911 (ctx
->Exec
->DrawArrays
)(mode
, first
[i
], count
[i
]);
917 /* GL_EXT_multi_draw_arrays */
919 _mesa_MultiDrawElementsEXT( GLenum mode
, const GLsizei
*count
, GLenum type
,
920 const GLvoid
**indices
, GLsizei primcount
)
922 GET_CURRENT_CONTEXT(ctx
);
925 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
927 if (ctx
->Array
.ElementArrayBufferObj
->Name
) {
928 /* use indices in the buffer object */
929 ASSERT(ctx
->Array
.ElementArrayBufferObj
->Data
);
930 indices
= (const GLvoid
**) ctx
->Array
.ElementArrayBufferObj
->Data
;
933 for (i
= 0; i
< primcount
; i
++) {
935 (ctx
->Exec
->DrawElements
)(mode
, count
[i
], type
, indices
[i
]);
941 /* GL_IBM_multimode_draw_arrays */
943 _mesa_MultiModeDrawArraysIBM( const GLenum
* mode
, const GLint
* first
,
944 const GLsizei
* count
,
945 GLsizei primcount
, GLint modestride
)
947 GET_CURRENT_CONTEXT(ctx
);
950 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
952 for ( i
= 0 ; i
< primcount
; i
++ ) {
953 if ( count
[i
] > 0 ) {
954 (ctx
->Exec
->DrawArrays
)( *(GLenum
*) ((char *) mode
+ (i
* modestride
)),
955 first
[i
], count
[i
] );
961 /* GL_IBM_multimode_draw_arrays */
963 _mesa_MultiModeDrawElementsIBM( const GLenum
* mode
, const GLsizei
* count
,
964 GLenum type
, const GLvoid
* const * indices
,
965 GLsizei primcount
, GLint modestride
)
967 GET_CURRENT_CONTEXT(ctx
);
970 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
);
972 /* XXX not sure about ARB_vertex_buffer_object handling here */
974 for ( i
= 0 ; i
< primcount
; i
++ ) {
975 if ( count
[i
] > 0 ) {
976 (ctx
->Exec
->DrawElements
)( *(GLenum
*) ((char *) mode
+ (i
* modestride
)),
977 count
[i
], type
, indices
[i
] );
983 /**********************************************************************/
984 /***** Initialization *****/
985 /**********************************************************************/
988 _mesa_init_varray( GLcontext
* ctx
)
993 ctx
->Array
.Vertex
.Size
= 4;
994 ctx
->Array
.Vertex
.Type
= GL_FLOAT
;
995 ctx
->Array
.Vertex
.Stride
= 0;
996 ctx
->Array
.Vertex
.StrideB
= 0;
997 ctx
->Array
.Vertex
.Ptr
= NULL
;
998 ctx
->Array
.Vertex
.Enabled
= GL_FALSE
;
999 ctx
->Array
.Vertex
.Flags
= CA_CLIENT_DATA
;
1000 ctx
->Array
.Normal
.Type
= GL_FLOAT
;
1001 ctx
->Array
.Normal
.Stride
= 0;
1002 ctx
->Array
.Normal
.StrideB
= 0;
1003 ctx
->Array
.Normal
.Ptr
= NULL
;
1004 ctx
->Array
.Normal
.Enabled
= GL_FALSE
;
1005 ctx
->Array
.Normal
.Flags
= CA_CLIENT_DATA
;
1006 ctx
->Array
.Color
.Size
= 4;
1007 ctx
->Array
.Color
.Type
= GL_FLOAT
;
1008 ctx
->Array
.Color
.Stride
= 0;
1009 ctx
->Array
.Color
.StrideB
= 0;
1010 ctx
->Array
.Color
.Ptr
= NULL
;
1011 ctx
->Array
.Color
.Enabled
= GL_FALSE
;
1012 ctx
->Array
.Color
.Flags
= CA_CLIENT_DATA
;
1013 ctx
->Array
.SecondaryColor
.Size
= 4;
1014 ctx
->Array
.SecondaryColor
.Type
= GL_FLOAT
;
1015 ctx
->Array
.SecondaryColor
.Stride
= 0;
1016 ctx
->Array
.SecondaryColor
.StrideB
= 0;
1017 ctx
->Array
.SecondaryColor
.Ptr
= NULL
;
1018 ctx
->Array
.SecondaryColor
.Enabled
= GL_FALSE
;
1019 ctx
->Array
.SecondaryColor
.Flags
= CA_CLIENT_DATA
;
1020 ctx
->Array
.FogCoord
.Size
= 1;
1021 ctx
->Array
.FogCoord
.Type
= GL_FLOAT
;
1022 ctx
->Array
.FogCoord
.Stride
= 0;
1023 ctx
->Array
.FogCoord
.StrideB
= 0;
1024 ctx
->Array
.FogCoord
.Ptr
= NULL
;
1025 ctx
->Array
.FogCoord
.Enabled
= GL_FALSE
;
1026 ctx
->Array
.FogCoord
.Flags
= CA_CLIENT_DATA
;
1027 ctx
->Array
.Index
.Type
= GL_FLOAT
;
1028 ctx
->Array
.Index
.Stride
= 0;
1029 ctx
->Array
.Index
.StrideB
= 0;
1030 ctx
->Array
.Index
.Ptr
= NULL
;
1031 ctx
->Array
.Index
.Enabled
= GL_FALSE
;
1032 ctx
->Array
.Index
.Flags
= CA_CLIENT_DATA
;
1033 for (i
= 0; i
< MAX_TEXTURE_UNITS
; i
++) {
1034 ctx
->Array
.TexCoord
[i
].Size
= 4;
1035 ctx
->Array
.TexCoord
[i
].Type
= GL_FLOAT
;
1036 ctx
->Array
.TexCoord
[i
].Stride
= 0;
1037 ctx
->Array
.TexCoord
[i
].StrideB
= 0;
1038 ctx
->Array
.TexCoord
[i
].Ptr
= NULL
;
1039 ctx
->Array
.TexCoord
[i
].Enabled
= GL_FALSE
;
1040 ctx
->Array
.TexCoord
[i
].Flags
= CA_CLIENT_DATA
;
1042 ctx
->Array
.TexCoordInterleaveFactor
= 1;
1043 ctx
->Array
.EdgeFlag
.Stride
= 0;
1044 ctx
->Array
.EdgeFlag
.StrideB
= 0;
1045 ctx
->Array
.EdgeFlag
.Ptr
= NULL
;
1046 ctx
->Array
.EdgeFlag
.Enabled
= GL_FALSE
;
1047 ctx
->Array
.EdgeFlag
.Flags
= CA_CLIENT_DATA
;
1048 ctx
->Array
.ActiveTexture
= 0; /* GL_ARB_multitexture */
1049 for (i
= 0; i
< VERT_ATTRIB_MAX
; i
++) {
1050 ctx
->Array
.TexCoord
[i
].Size
= 4;
1051 ctx
->Array
.TexCoord
[i
].Type
= GL_FLOAT
;
1052 ctx
->Array
.TexCoord
[i
].Stride
= 0;
1053 ctx
->Array
.TexCoord
[i
].StrideB
= 0;
1054 ctx
->Array
.TexCoord
[i
].Ptr
= NULL
;
1055 ctx
->Array
.TexCoord
[i
].Enabled
= GL_FALSE
;
1056 ctx
->Array
.TexCoord
[i
].Flags
= CA_CLIENT_DATA
;