Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenvarray.c
Go to the documentation of this file.
00001 /* 00002 * Mesa 3-D graphics library 00003 * Version: 7.2 00004 * 00005 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 00006 * 00007 * Permission is hereby granted, free of charge, to any person obtaining a 00008 * copy of this software and associated documentation files (the "Software"), 00009 * to deal in the Software without restriction, including without limitation 00010 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00011 * and/or sell copies of the Software, and to permit persons to whom the 00012 * Software is furnished to do so, subject to the following conditions: 00013 * 00014 * The above copyright notice and this permission notice shall be included 00015 * in all copies or substantial portions of the Software. 00016 * 00017 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00018 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00019 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00020 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 00021 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00022 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00023 */ 00024 00025 00026 #include "glheader.h" 00027 #include "imports.h" 00028 #include "bufferobj.h" 00029 #include "context.h" 00030 #include "enable.h" 00031 #include "enums.h" 00032 #include "mtypes.h" 00033 #include "varray.h" 00034 #include "arrayobj.h" 00035 #include "glapi/dispatch.h" 00036 00037 00052 static void 00053 update_array(GLcontext *ctx, struct gl_client_array *array, 00054 GLbitfield dirtyBit, GLsizei elementSize, 00055 GLint size, GLenum type, 00056 GLsizei stride, GLboolean normalized, const GLvoid *ptr) 00057 { 00058 array->Size = size; 00059 array->Type = type; 00060 array->Stride = stride; 00061 array->StrideB = stride ? stride : elementSize; 00062 array->Normalized = normalized; 00063 array->Ptr = (const GLubyte *) ptr; 00064 #if FEATURE_ARB_vertex_buffer_object 00065 _mesa_reference_buffer_object(ctx, &array->BufferObj, 00066 ctx->Array.ArrayBufferObj); 00067 00068 /* Compute the index of the last array element that's inside the buffer. 00069 * Later in glDrawArrays we'll check if start + count > _MaxElement to 00070 * be sure we won't go out of bounds. 00071 */ 00072 if (ctx->Array.ArrayBufferObj->Name) 00073 array->_MaxElement = ((GLsizeiptrARB) ctx->Array.ArrayBufferObj->Size 00074 - (GLsizeiptrARB) array->Ptr + array->StrideB 00075 - elementSize) / array->StrideB; 00076 else 00077 #endif 00078 array->_MaxElement = 2 * 1000 * 1000 * 1000; /* just a big number */ 00079 00080 ctx->NewState |= _NEW_ARRAY; 00081 ctx->Array.NewState |= dirtyBit; 00082 } 00083 00084 00085 void GLAPIENTRY 00086 _mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) 00087 { 00088 GLsizei elementSize; 00089 GET_CURRENT_CONTEXT(ctx); 00090 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); 00091 00092 if (size < 2 || size > 4) { 00093 _mesa_error( ctx, GL_INVALID_VALUE, "glVertexPointer(size)" ); 00094 return; 00095 } 00096 if (stride < 0) { 00097 _mesa_error( ctx, GL_INVALID_VALUE, "glVertexPointer(stride)" ); 00098 return; 00099 } 00100 00101 if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API)) 00102 _mesa_debug(ctx, "glVertexPointer( sz %d type %s stride %d )\n", size, 00103 _mesa_lookup_enum_by_nr( type ), stride); 00104 00105 /* always need to check that <type> is legal */ 00106 switch (type) { 00107 case GL_SHORT: 00108 elementSize = size * sizeof(GLshort); 00109 break; 00110 case GL_INT: 00111 elementSize = size * sizeof(GLint); 00112 break; 00113 case GL_FLOAT: 00114 elementSize = size * sizeof(GLfloat); 00115 break; 00116 case GL_DOUBLE: 00117 elementSize = size * sizeof(GLdouble); 00118 break; 00119 #if FEATURE_fixedpt 00120 case GL_FIXED: 00121 elementSize = size * sizeof(GLfixed); 00122 break; 00123 #endif 00124 #if FEATURE_vertex_array_byte 00125 case GL_BYTE: 00126 elementSize = size * sizeof(GLbyte); 00127 break; 00128 #endif 00129 default: 00130 _mesa_error( ctx, GL_INVALID_ENUM, "glVertexPointer(type)" ); 00131 return; 00132 } 00133 00134 update_array(ctx, &ctx->Array.ArrayObj->Vertex, _NEW_ARRAY_VERTEX, 00135 elementSize, size, type, stride, GL_FALSE, ptr); 00136 00137 if (ctx->Driver.VertexPointer) 00138 ctx->Driver.VertexPointer( ctx, size, type, stride, ptr ); 00139 } 00140 00141 00142 void GLAPIENTRY 00143 _mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr ) 00144 { 00145 GLsizei elementSize; 00146 GET_CURRENT_CONTEXT(ctx); 00147 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); 00148 00149 if (stride < 0) { 00150 _mesa_error( ctx, GL_INVALID_VALUE, "glNormalPointer(stride)" ); 00151 return; 00152 } 00153 00154 if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API)) 00155 _mesa_debug(ctx, "glNormalPointer( type %s stride %d )\n", 00156 _mesa_lookup_enum_by_nr( type ), stride); 00157 00158 switch (type) { 00159 case GL_BYTE: 00160 elementSize = 3 * sizeof(GLbyte); 00161 break; 00162 case GL_SHORT: 00163 elementSize = 3 * sizeof(GLshort); 00164 break; 00165 case GL_INT: 00166 elementSize = 3 * sizeof(GLint); 00167 break; 00168 case GL_FLOAT: 00169 elementSize = 3 * sizeof(GLfloat); 00170 break; 00171 case GL_DOUBLE: 00172 elementSize = 3 * sizeof(GLdouble); 00173 break; 00174 #if FEATURE_fixedpt 00175 case GL_FIXED: 00176 elementSize = 3 * sizeof(GLfixed); 00177 break; 00178 #endif 00179 default: 00180 _mesa_error( ctx, GL_INVALID_ENUM, "glNormalPointer(type)" ); 00181 return; 00182 } 00183 00184 update_array(ctx, &ctx->Array.ArrayObj->Normal, _NEW_ARRAY_NORMAL, 00185 elementSize, 3, type, stride, GL_TRUE, ptr); 00186 00187 if (ctx->Driver.NormalPointer) 00188 ctx->Driver.NormalPointer( ctx, type, stride, ptr ); 00189 } 00190 00191 00192 void GLAPIENTRY 00193 _mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) 00194 { 00195 GLsizei elementSize; 00196 GET_CURRENT_CONTEXT(ctx); 00197 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); 00198 00199 if (size < 3 || size > 4) { 00200 _mesa_error( ctx, GL_INVALID_VALUE, "glColorPointer(size)" ); 00201 return; 00202 } 00203 if (stride < 0) { 00204 _mesa_error( ctx, GL_INVALID_VALUE, "glColorPointer(stride)" ); 00205 return; 00206 } 00207 00208 if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API)) 00209 _mesa_debug(ctx, "glColorPointer( sz %d type %s stride %d )\n", size, 00210 _mesa_lookup_enum_by_nr( type ), stride); 00211 00212 switch (type) { 00213 case GL_BYTE: 00214 elementSize = size * sizeof(GLbyte); 00215 break; 00216 case GL_UNSIGNED_BYTE: 00217 elementSize = size * sizeof(GLubyte); 00218 break; 00219 case GL_SHORT: 00220 elementSize = size * sizeof(GLshort); 00221 break; 00222 case GL_UNSIGNED_SHORT: 00223 elementSize = size * sizeof(GLushort); 00224 break; 00225 case GL_INT: 00226 elementSize = size * sizeof(GLint); 00227 break; 00228 case GL_UNSIGNED_INT: 00229 elementSize = size * sizeof(GLuint); 00230 break; 00231 case GL_FLOAT: 00232 elementSize = size * sizeof(GLfloat); 00233 break; 00234 case GL_DOUBLE: 00235 elementSize = size * sizeof(GLdouble); 00236 break; 00237 #if FEATURE_fixedpt 00238 case GL_FIXED: 00239 elementSize = size * sizeof(GLfixed); 00240 break; 00241 #endif 00242 default: 00243 _mesa_error( ctx, GL_INVALID_ENUM, "glColorPointer(type)" ); 00244 return; 00245 } 00246 00247 update_array(ctx, &ctx->Array.ArrayObj->Color, _NEW_ARRAY_COLOR0, 00248 elementSize, size, type, stride, GL_TRUE, ptr); 00249 00250 if (ctx->Driver.ColorPointer) 00251 ctx->Driver.ColorPointer( ctx, size, type, stride, ptr ); 00252 } 00253 00254 00255 void GLAPIENTRY 00256 _mesa_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr) 00257 { 00258 GLint elementSize; 00259 GET_CURRENT_CONTEXT(ctx); 00260 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); 00261 00262 if (stride < 0) { 00263 _mesa_error( ctx, GL_INVALID_VALUE, "glFogCoordPointer(stride)" ); 00264 return; 00265 } 00266 00267 switch (type) { 00268 case GL_FLOAT: 00269 elementSize = sizeof(GLfloat); 00270 break; 00271 case GL_DOUBLE: 00272 elementSize = sizeof(GLdouble); 00273 break; 00274 default: 00275 _mesa_error( ctx, GL_INVALID_ENUM, "glFogCoordPointer(type)" ); 00276 return; 00277 } 00278 00279 update_array(ctx, &ctx->Array.ArrayObj->FogCoord, _NEW_ARRAY_FOGCOORD, 00280 elementSize, 1, type, stride, GL_FALSE, ptr); 00281 00282 if (ctx->Driver.FogCoordPointer) 00283 ctx->Driver.FogCoordPointer( ctx, type, stride, ptr ); 00284 } 00285 00286 00287 void GLAPIENTRY 00288 _mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr) 00289 { 00290 GLsizei elementSize; 00291 GET_CURRENT_CONTEXT(ctx); 00292 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); 00293 00294 if (stride < 0) { 00295 _mesa_error( ctx, GL_INVALID_VALUE, "glIndexPointer(stride)" ); 00296 return; 00297 } 00298 00299 switch (type) { 00300 case GL_UNSIGNED_BYTE: 00301 elementSize = sizeof(GLubyte); 00302 break; 00303 case GL_SHORT: 00304 elementSize = sizeof(GLshort); 00305 break; 00306 case GL_INT: 00307 elementSize = sizeof(GLint); 00308 break; 00309 case GL_FLOAT: 00310 elementSize = sizeof(GLfloat); 00311 break; 00312 case GL_DOUBLE: 00313 elementSize = sizeof(GLdouble); 00314 break; 00315 default: 00316 _mesa_error( ctx, GL_INVALID_ENUM, "glIndexPointer(type)" ); 00317 return; 00318 } 00319 00320 update_array(ctx, &ctx->Array.ArrayObj->Index, _NEW_ARRAY_INDEX, 00321 elementSize, 1, type, stride, GL_FALSE, ptr); 00322 00323 if (ctx->Driver.IndexPointer) 00324 ctx->Driver.IndexPointer( ctx, type, stride, ptr ); 00325 } 00326 00327 00328 void GLAPIENTRY 00329 _mesa_SecondaryColorPointerEXT(GLint size, GLenum type, 00330 GLsizei stride, const GLvoid *ptr) 00331 { 00332 GLsizei elementSize; 00333 GET_CURRENT_CONTEXT(ctx); 00334 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); 00335 00336 if (size != 3 && size != 4) { 00337 _mesa_error( ctx, GL_INVALID_VALUE, "glSecondaryColorPointer(size)" ); 00338 return; 00339 } 00340 if (stride < 0) { 00341 _mesa_error( ctx, GL_INVALID_VALUE, "glSecondaryColorPointer(stride)" ); 00342 return; 00343 } 00344 00345 if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API)) 00346 _mesa_debug(ctx, "glSecondaryColorPointer( sz %d type %s stride %d )\n", 00347 size, _mesa_lookup_enum_by_nr( type ), stride); 00348 00349 switch (type) { 00350 case GL_BYTE: 00351 elementSize = size * sizeof(GLbyte); 00352 break; 00353 case GL_UNSIGNED_BYTE: 00354 elementSize = size * sizeof(GLubyte); 00355 break; 00356 case GL_SHORT: 00357 elementSize = size * sizeof(GLshort); 00358 break; 00359 case GL_UNSIGNED_SHORT: 00360 elementSize = size * sizeof(GLushort); 00361 break; 00362 case GL_INT: 00363 elementSize = size * sizeof(GLint); 00364 break; 00365 case GL_UNSIGNED_INT: 00366 elementSize = size * sizeof(GLuint); 00367 break; 00368 case GL_FLOAT: 00369 elementSize = size * sizeof(GLfloat); 00370 break; 00371 case GL_DOUBLE: 00372 elementSize = size * sizeof(GLdouble); 00373 break; 00374 default: 00375 _mesa_error( ctx, GL_INVALID_ENUM, "glSecondaryColorPointer(type)" ); 00376 return; 00377 } 00378 00379 update_array(ctx, &ctx->Array.ArrayObj->SecondaryColor, _NEW_ARRAY_COLOR1, 00380 elementSize, size, type, stride, GL_TRUE, ptr); 00381 00382 if (ctx->Driver.SecondaryColorPointer) 00383 ctx->Driver.SecondaryColorPointer( ctx, size, type, stride, ptr ); 00384 } 00385 00386 00387 void GLAPIENTRY 00388 _mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride, 00389 const GLvoid *ptr) 00390 { 00391 GLint elementSize; 00392 GET_CURRENT_CONTEXT(ctx); 00393 const GLuint unit = ctx->Array.ActiveTexture; 00394 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); 00395 00396 if (size < 1 || size > 4) { 00397 _mesa_error( ctx, GL_INVALID_VALUE, "glTexCoordPointer(size)" ); 00398 return; 00399 } 00400 if (stride < 0) { 00401 _mesa_error( ctx, GL_INVALID_VALUE, "glTexCoordPointer(stride)" ); 00402 return; 00403 } 00404 00405 if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API)) 00406 _mesa_debug(ctx, "glTexCoordPointer(unit %u sz %d type %s stride %d)\n", 00407 unit, size, _mesa_lookup_enum_by_nr( type ), stride); 00408 00409 /* always need to check that <type> is legal */ 00410 switch (type) { 00411 case GL_SHORT: 00412 elementSize = size * sizeof(GLshort); 00413 break; 00414 case GL_INT: 00415 elementSize = size * sizeof(GLint); 00416 break; 00417 case GL_FLOAT: 00418 elementSize = size * sizeof(GLfloat); 00419 break; 00420 case GL_DOUBLE: 00421 elementSize = size * sizeof(GLdouble); 00422 break; 00423 #if FEATURE_fixedpt 00424 case GL_FIXED: 00425 elementSize = size * sizeof(GLfixed); 00426 break; 00427 #endif 00428 #if FEATURE_vertex_array_byte 00429 case GL_BYTE: 00430 elementSize = size * sizeof(GLbyte); 00431 break; 00432 #endif 00433 default: 00434 _mesa_error( ctx, GL_INVALID_ENUM, "glTexCoordPointer(type)" ); 00435 return; 00436 } 00437 00438 update_array(ctx, &ctx->Array.ArrayObj->TexCoord[unit], 00439 _NEW_ARRAY_TEXCOORD(unit), 00440 elementSize, size, type, stride, GL_FALSE, ptr); 00441 00442 if (ctx->Driver.TexCoordPointer) 00443 ctx->Driver.TexCoordPointer( ctx, size, type, stride, ptr ); 00444 } 00445 00446 00447 void GLAPIENTRY 00448 _mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *ptr) 00449 { 00450 GET_CURRENT_CONTEXT(ctx); 00451 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); 00452 00453 if (stride < 0) { 00454 _mesa_error( ctx, GL_INVALID_VALUE, "glEdgeFlagPointer(stride)" ); 00455 return; 00456 } 00457 00458 update_array(ctx, &ctx->Array.ArrayObj->EdgeFlag, _NEW_ARRAY_EDGEFLAG, 00459 sizeof(GLboolean), 1, GL_UNSIGNED_BYTE, stride, GL_FALSE, ptr); 00460 00461 if (ctx->Driver.EdgeFlagPointer) 00462 ctx->Driver.EdgeFlagPointer( ctx, stride, ptr ); 00463 } 00464 00465 00466 void GLAPIENTRY 00467 _mesa_PointSizePointer(GLenum type, GLsizei stride, const GLvoid *ptr) 00468 { 00469 GLsizei elementSize; 00470 GET_CURRENT_CONTEXT(ctx); 00471 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); 00472 00473 if (stride < 0) { 00474 _mesa_error( ctx, GL_INVALID_VALUE, "glPointSizePointer(stride)" ); 00475 return; 00476 } 00477 00478 switch (type) { 00479 case GL_FLOAT: 00480 elementSize = sizeof(GLfloat); 00481 break; 00482 #if FEATURE_fixedpt 00483 case GL_FIXED: 00484 elementSize = sizeof(GLfixed); 00485 break; 00486 #endif 00487 default: 00488 _mesa_error( ctx, GL_INVALID_ENUM, "glPointSizePointer(type)" ); 00489 return; 00490 } 00491 00492 update_array(ctx, &ctx->Array.ArrayObj->PointSize, _NEW_ARRAY_POINT_SIZE, 00493 elementSize, 1, type, stride, GL_FALSE, ptr); 00494 } 00495 00496 00497 #if FEATURE_NV_vertex_program 00498 void GLAPIENTRY 00499 _mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type, 00500 GLsizei stride, const GLvoid *ptr) 00501 { 00502 GLboolean normalized = GL_FALSE; 00503 GLsizei elementSize; 00504 GET_CURRENT_CONTEXT(ctx); 00505 ASSERT_OUTSIDE_BEGIN_END(ctx); 00506 00507 if (index >= MAX_VERTEX_PROGRAM_ATTRIBS) { 00508 _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(index)"); 00509 return; 00510 } 00511 00512 if (size < 1 || size > 4) { 00513 _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(size)"); 00514 return; 00515 } 00516 00517 if (stride < 0) { 00518 _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(stride)"); 00519 return; 00520 } 00521 00522 if (type == GL_UNSIGNED_BYTE && size != 4) { 00523 _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(size!=4)"); 00524 return; 00525 } 00526 00527 /* check for valid 'type' and compute StrideB right away */ 00528 switch (type) { 00529 case GL_UNSIGNED_BYTE: 00530 normalized = GL_TRUE; 00531 elementSize = size * sizeof(GLubyte); 00532 break; 00533 case GL_SHORT: 00534 elementSize = size * sizeof(GLshort); 00535 break; 00536 case GL_FLOAT: 00537 elementSize = size * sizeof(GLfloat); 00538 break; 00539 case GL_DOUBLE: 00540 elementSize = size * sizeof(GLdouble); 00541 break; 00542 default: 00543 _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttribPointerNV(type)" ); 00544 return; 00545 } 00546 00547 update_array(ctx, &ctx->Array.ArrayObj->VertexAttrib[index], 00548 _NEW_ARRAY_ATTRIB(index), 00549 elementSize, size, type, stride, normalized, ptr); 00550 00551 if (ctx->Driver.VertexAttribPointer) 00552 ctx->Driver.VertexAttribPointer( ctx, index, size, type, stride, ptr ); 00553 } 00554 #endif 00555 00556 00557 #if FEATURE_ARB_vertex_program 00558 void GLAPIENTRY 00559 _mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type, 00560 GLboolean normalized, 00561 GLsizei stride, const GLvoid *ptr) 00562 { 00563 GLsizei elementSize; 00564 GET_CURRENT_CONTEXT(ctx); 00565 ASSERT_OUTSIDE_BEGIN_END(ctx); 00566 00567 if (index >= ctx->Const.VertexProgram.MaxAttribs) { 00568 _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(index)"); 00569 return; 00570 } 00571 00572 if (size < 1 || size > 4) { 00573 _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(size)"); 00574 return; 00575 } 00576 00577 if (stride < 0) { 00578 _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(stride)"); 00579 return; 00580 } 00581 00582 /* check for valid 'type' and compute StrideB right away */ 00583 /* NOTE: more types are supported here than in the NV extension */ 00584 switch (type) { 00585 case GL_BYTE: 00586 elementSize = size * sizeof(GLbyte); 00587 break; 00588 case GL_UNSIGNED_BYTE: 00589 elementSize = size * sizeof(GLubyte); 00590 break; 00591 case GL_SHORT: 00592 elementSize = size * sizeof(GLshort); 00593 break; 00594 case GL_UNSIGNED_SHORT: 00595 elementSize = size * sizeof(GLushort); 00596 break; 00597 case GL_INT: 00598 elementSize = size * sizeof(GLint); 00599 break; 00600 case GL_UNSIGNED_INT: 00601 elementSize = size * sizeof(GLuint); 00602 break; 00603 case GL_FLOAT: 00604 elementSize = size * sizeof(GLfloat); 00605 break; 00606 case GL_DOUBLE: 00607 elementSize = size * sizeof(GLdouble); 00608 break; 00609 #if FEATURE_fixedpt 00610 case GL_FIXED: 00611 elementSize = size * sizeof(GLfixed); 00612 break; 00613 #endif 00614 default: 00615 _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttribPointerARB(type)" ); 00616 return; 00617 } 00618 00619 update_array(ctx, &ctx->Array.ArrayObj->VertexAttrib[index], 00620 _NEW_ARRAY_ATTRIB(index), 00621 elementSize, size, type, stride, normalized, ptr); 00622 00623 if (ctx->Driver.VertexAttribPointer) 00624 ctx->Driver.VertexAttribPointer(ctx, index, size, type, stride, ptr); 00625 } 00626 #endif 00627 00628 00629 void GLAPIENTRY 00630 _mesa_VertexPointerEXT(GLint size, GLenum type, GLsizei stride, 00631 GLsizei count, const GLvoid *ptr) 00632 { 00633 (void) count; 00634 _mesa_VertexPointer(size, type, stride, ptr); 00635 } 00636 00637 00638 void GLAPIENTRY 00639 _mesa_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count, 00640 const GLvoid *ptr) 00641 { 00642 (void) count; 00643 _mesa_NormalPointer(type, stride, ptr); 00644 } 00645 00646 00647 void GLAPIENTRY 00648 _mesa_ColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, 00649 const GLvoid *ptr) 00650 { 00651 (void) count; 00652 _mesa_ColorPointer(size, type, stride, ptr); 00653 } 00654 00655 00656 void GLAPIENTRY 00657 _mesa_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count, 00658 const GLvoid *ptr) 00659 { 00660 (void) count; 00661 _mesa_IndexPointer(type, stride, ptr); 00662 } 00663 00664 00665 void GLAPIENTRY 00666 _mesa_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride, 00667 GLsizei count, const GLvoid *ptr) 00668 { 00669 (void) count; 00670 _mesa_TexCoordPointer(size, type, stride, ptr); 00671 } 00672 00673 00674 void GLAPIENTRY 00675 _mesa_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr) 00676 { 00677 (void) count; 00678 _mesa_EdgeFlagPointer(stride, ptr); 00679 } 00680 00681 00682 void GLAPIENTRY 00683 _mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer) 00684 { 00685 GET_CURRENT_CONTEXT(ctx); 00686 GLboolean tflag, cflag, nflag; /* enable/disable flags */ 00687 GLint tcomps, ccomps, vcomps; /* components per texcoord, color, vertex */ 00688 GLenum ctype = 0; /* color type */ 00689 GLint coffset = 0, noffset = 0, voffset;/* color, normal, vertex offsets */ 00690 const GLint toffset = 0; /* always zero */ 00691 GLint defstride; /* default stride */ 00692 GLint c, f; 00693 00694 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); 00695 00696 f = sizeof(GLfloat); 00697 c = f * ((4 * sizeof(GLubyte) + (f - 1)) / f); 00698 00699 if (stride < 0) { 00700 _mesa_error( ctx, GL_INVALID_VALUE, "glInterleavedArrays(stride)" ); 00701 return; 00702 } 00703 00704 switch (format) { 00705 case GL_V2F: 00706 tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_FALSE; 00707 tcomps = 0; ccomps = 0; vcomps = 2; 00708 voffset = 0; 00709 defstride = 2*f; 00710 break; 00711 case GL_V3F: 00712 tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_FALSE; 00713 tcomps = 0; ccomps = 0; vcomps = 3; 00714 voffset = 0; 00715 defstride = 3*f; 00716 break; 00717 case GL_C4UB_V2F: 00718 tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE; 00719 tcomps = 0; ccomps = 4; vcomps = 2; 00720 ctype = GL_UNSIGNED_BYTE; 00721 coffset = 0; 00722 voffset = c; 00723 defstride = c + 2*f; 00724 break; 00725 case GL_C4UB_V3F: 00726 tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE; 00727 tcomps = 0; ccomps = 4; vcomps = 3; 00728 ctype = GL_UNSIGNED_BYTE; 00729 coffset = 0; 00730 voffset = c; 00731 defstride = c + 3*f; 00732 break; 00733 case GL_C3F_V3F: 00734 tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE; 00735 tcomps = 0; ccomps = 3; vcomps = 3; 00736 ctype = GL_FLOAT; 00737 coffset = 0; 00738 voffset = 3*f; 00739 defstride = 6*f; 00740 break; 00741 case GL_N3F_V3F: 00742 tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_TRUE; 00743 tcomps = 0; ccomps = 0; vcomps = 3; 00744 noffset = 0; 00745 voffset = 3*f; 00746 defstride = 6*f; 00747 break; 00748 case GL_C4F_N3F_V3F: 00749 tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_TRUE; 00750 tcomps = 0; ccomps = 4; vcomps = 3; 00751 ctype = GL_FLOAT; 00752 coffset = 0; 00753 noffset = 4*f; 00754 voffset = 7*f; 00755 defstride = 10*f; 00756 break; 00757 case GL_T2F_V3F: 00758 tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_FALSE; 00759 tcomps = 2; ccomps = 0; vcomps = 3; 00760 voffset = 2*f; 00761 defstride = 5*f; 00762 break; 00763 case GL_T4F_V4F: 00764 tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_FALSE; 00765 tcomps = 4; ccomps = 0; vcomps = 4; 00766 voffset = 4*f; 00767 defstride = 8*f; 00768 break; 00769 case GL_T2F_C4UB_V3F: 00770 tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_FALSE; 00771 tcomps = 2; ccomps = 4; vcomps = 3; 00772 ctype = GL_UNSIGNED_BYTE; 00773 coffset = 2*f; 00774 voffset = c+2*f; 00775 defstride = c+5*f; 00776 break; 00777 case GL_T2F_C3F_V3F: 00778 tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_FALSE; 00779 tcomps = 2; ccomps = 3; vcomps = 3; 00780 ctype = GL_FLOAT; 00781 coffset = 2*f; 00782 voffset = 5*f; 00783 defstride = 8*f; 00784 break; 00785 case GL_T2F_N3F_V3F: 00786 tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_TRUE; 00787 tcomps = 2; ccomps = 0; vcomps = 3; 00788 noffset = 2*f; 00789 voffset = 5*f; 00790 defstride = 8*f; 00791 break; 00792 case GL_T2F_C4F_N3F_V3F: 00793 tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_TRUE; 00794 tcomps = 2; ccomps = 4; vcomps = 3; 00795 ctype = GL_FLOAT; 00796 coffset = 2*f; 00797 noffset = 6*f; 00798 voffset = 9*f; 00799 defstride = 12*f; 00800 break; 00801 case GL_T4F_C4F_N3F_V4F: 00802 tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_TRUE; 00803 tcomps = 4; ccomps = 4; vcomps = 4; 00804 ctype = GL_FLOAT; 00805 coffset = 4*f; 00806 noffset = 8*f; 00807 voffset = 11*f; 00808 defstride = 15*f; 00809 break; 00810 default: 00811 _mesa_error( ctx, GL_INVALID_ENUM, "glInterleavedArrays(format)" ); 00812 return; 00813 } 00814 00815 if (stride==0) { 00816 stride = defstride; 00817 } 00818 00819 _mesa_DisableClientState( GL_EDGE_FLAG_ARRAY ); 00820 _mesa_DisableClientState( GL_INDEX_ARRAY ); 00821 /* XXX also disable secondary color and generic arrays? */ 00822 00823 /* Texcoords */ 00824 if (tflag) { 00825 _mesa_EnableClientState( GL_TEXTURE_COORD_ARRAY ); 00826 _mesa_TexCoordPointer( tcomps, GL_FLOAT, stride, 00827 (GLubyte *) pointer + toffset ); 00828 } 00829 else { 00830 _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY ); 00831 } 00832 00833 /* Color */ 00834 if (cflag) { 00835 _mesa_EnableClientState( GL_COLOR_ARRAY ); 00836 _mesa_ColorPointer( ccomps, ctype, stride, 00837 (GLubyte *) pointer + coffset ); 00838 } 00839 else { 00840 _mesa_DisableClientState( GL_COLOR_ARRAY ); 00841 } 00842 00843 00844 /* Normals */ 00845 if (nflag) { 00846 _mesa_EnableClientState( GL_NORMAL_ARRAY ); 00847 _mesa_NormalPointer( GL_FLOAT, stride, (GLubyte *) pointer + noffset ); 00848 } 00849 else { 00850 _mesa_DisableClientState( GL_NORMAL_ARRAY ); 00851 } 00852 00853 /* Vertices */ 00854 _mesa_EnableClientState( GL_VERTEX_ARRAY ); 00855 _mesa_VertexPointer( vcomps, GL_FLOAT, stride, 00856 (GLubyte *) pointer + voffset ); 00857 } 00858 00859 00860 void GLAPIENTRY 00861 _mesa_LockArraysEXT(GLint first, GLsizei count) 00862 { 00863 GET_CURRENT_CONTEXT(ctx); 00864 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); 00865 00866 if (MESA_VERBOSE & VERBOSE_API) 00867 _mesa_debug(ctx, "glLockArrays %d %d\n", first, count); 00868 00869 if (first < 0) { 00870 _mesa_error( ctx, GL_INVALID_VALUE, "glLockArraysEXT(first)" ); 00871 return; 00872 } 00873 if (count <= 0) { 00874 _mesa_error( ctx, GL_INVALID_VALUE, "glLockArraysEXT(count)" ); 00875 return; 00876 } 00877 if (ctx->Array.LockCount != 0) { 00878 _mesa_error( ctx, GL_INVALID_OPERATION, "glLockArraysEXT(reentry)" ); 00879 return; 00880 } 00881 00882 ctx->Array.LockFirst = first; 00883 ctx->Array.LockCount = count; 00884 00885 ctx->NewState |= _NEW_ARRAY; 00886 ctx->Array.NewState |= _NEW_ARRAY_ALL; 00887 00888 if (ctx->Driver.LockArraysEXT) 00889 ctx->Driver.LockArraysEXT( ctx, first, count ); 00890 } 00891 00892 00893 void GLAPIENTRY 00894 _mesa_UnlockArraysEXT( void ) 00895 { 00896 GET_CURRENT_CONTEXT(ctx); 00897 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); 00898 00899 if (MESA_VERBOSE & VERBOSE_API) 00900 _mesa_debug(ctx, "glUnlockArrays\n"); 00901 00902 if (ctx->Array.LockCount == 0) { 00903 _mesa_error( ctx, GL_INVALID_OPERATION, "glUnlockArraysEXT(reexit)" ); 00904 return; 00905 } 00906 00907 ctx->Array.LockFirst = 0; 00908 ctx->Array.LockCount = 0; 00909 ctx->NewState |= _NEW_ARRAY; 00910 ctx->Array.NewState |= _NEW_ARRAY_ALL; 00911 00912 if (ctx->Driver.UnlockArraysEXT) 00913 ctx->Driver.UnlockArraysEXT( ctx ); 00914 } 00915 00916 00917 /* GL_EXT_multi_draw_arrays */ 00918 /* Somebody forgot to spec the first and count parameters as const! <sigh> */ 00919 void GLAPIENTRY 00920 _mesa_MultiDrawArraysEXT( GLenum mode, GLint *first, 00921 GLsizei *count, GLsizei primcount ) 00922 { 00923 GET_CURRENT_CONTEXT(ctx); 00924 GLint i; 00925 00926 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); 00927 00928 for (i = 0; i < primcount; i++) { 00929 if (count[i] > 0) { 00930 CALL_DrawArrays(ctx->Exec, (mode, first[i], count[i])); 00931 } 00932 } 00933 } 00934 00935 00936 /* GL_EXT_multi_draw_arrays */ 00937 void GLAPIENTRY 00938 _mesa_MultiDrawElementsEXT( GLenum mode, const GLsizei *count, GLenum type, 00939 const GLvoid **indices, GLsizei primcount ) 00940 { 00941 GET_CURRENT_CONTEXT(ctx); 00942 GLint i; 00943 00944 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); 00945 00946 for (i = 0; i < primcount; i++) { 00947 if (count[i] > 0) { 00948 CALL_DrawElements(ctx->Exec, (mode, count[i], type, indices[i])); 00949 } 00950 } 00951 } 00952 00953 00954 /* GL_IBM_multimode_draw_arrays */ 00955 void GLAPIENTRY 00956 _mesa_MultiModeDrawArraysIBM( const GLenum * mode, const GLint * first, 00957 const GLsizei * count, 00958 GLsizei primcount, GLint modestride ) 00959 { 00960 GET_CURRENT_CONTEXT(ctx); 00961 GLint i; 00962 00963 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); 00964 00965 for ( i = 0 ; i < primcount ; i++ ) { 00966 if ( count[i] > 0 ) { 00967 GLenum m = *((GLenum *) ((GLubyte *) mode + i * modestride)); 00968 CALL_DrawArrays(ctx->Exec, ( m, first[i], count[i] )); 00969 } 00970 } 00971 } 00972 00973 00974 /* GL_IBM_multimode_draw_arrays */ 00975 void GLAPIENTRY 00976 _mesa_MultiModeDrawElementsIBM( const GLenum * mode, const GLsizei * count, 00977 GLenum type, const GLvoid * const * indices, 00978 GLsizei primcount, GLint modestride ) 00979 { 00980 GET_CURRENT_CONTEXT(ctx); 00981 GLint i; 00982 00983 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); 00984 00985 /* XXX not sure about ARB_vertex_buffer_object handling here */ 00986 00987 for ( i = 0 ; i < primcount ; i++ ) { 00988 if ( count[i] > 0 ) { 00989 GLenum m = *((GLenum *) ((GLubyte *) mode + i * modestride)); 00990 CALL_DrawElements(ctx->Exec, ( m, count[i], type, indices[i] )); 00991 } 00992 } 00993 } 00994 00995 00999 void 01000 _mesa_init_varray(GLcontext *ctx) 01001 { 01002 ctx->Array.DefaultArrayObj = _mesa_new_array_object(ctx, 0); 01003 ctx->Array.ArrayObj = ctx->Array.DefaultArrayObj; 01004 01005 ctx->Array.ActiveTexture = 0; /* GL_ARB_multitexture */ 01006 } Generated on Sun May 27 2012 04:20:31 for ReactOS by
1.7.6.1
|