Changeset 3079 for trunk/src/opengl/mesa/api1.c
- Timestamp:
- Mar 11, 2000, 10:05:07 AM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/opengl/mesa/api1.c
r2938 r3079 1 /* $Id: api1.c,v 1. 1 2000-02-29 00:49:57 sandervlExp $ */1 /* $Id: api1.c,v 1.2 2000-03-11 09:05:06 jeroen Exp $ */ 2 2 3 3 /* … … 54 54 #endif 55 55 56 #include <misc.h> 57 56 58 /* 57 59 * Part 1 of API functions … … 85 87 * function pointer. 86 88 */ 87 #define ARRAY_ELT( IM, i ) 88 { 89 GLuint count = IM->Count; 90 IM->Elt[count] = i; 91 IM->Flag[count] = ((IM->Flag[count] & IM->ArrayAndFlags) | 92 VERT_ELT);\93 IM->FlushElt |= IM->ArrayEltFlush; 94 IM->Count = count += IM->ArrayIncr; 95 if (count == VB_MAX) 96 IM->maybe_transform_vb( IM ); 89 #define ARRAY_ELT( IM, i ) \ 90 { \ 91 GLuint count = IM->Count; \ 92 IM->Elt[count] = i; \ 93 IM->Flag[count] = ((IM->Flag[count] & IM->ArrayAndFlags) | \ 94 VERT_ELT); \ 95 IM->FlushElt |= IM->ArrayEltFlush; \ 96 IM->Count = count += IM->ArrayIncr; \ 97 if (count == VB_MAX) \ 98 IM->maybe_transform_vb( IM ); \ 97 99 } 98 100 … … 125 127 if (mode < GL_POINTS || mode > GL_POLYGON) { 126 128 gl_compile_error( CC, GL_INVALID_ENUM, "glBegin" ); 127 return; 129 return; 128 130 } 129 131 … … 251 253 * color-material and vertex arrays. 252 254 */ 253 #define COLOR( IM, r,g,b,a ) 254 { 255 GLuint count = IM->Count; 256 IM->Flag[count] |= VERT_RGBA; 257 IM->Color[count][0] = r; 258 IM->Color[count][1] = g; 259 IM->Color[count][2] = b; 260 IM->Color[count][3] = a; 255 #define COLOR( IM, r,g,b,a ) \ 256 { \ 257 GLuint count = IM->Count; \ 258 IM->Flag[count] |= VERT_RGBA; \ 259 IM->Color[count][0] = r; \ 260 IM->Color[count][1] = g; \ 261 IM->Color[count][2] = b; \ 262 IM->Color[count][3] = a; \ 261 263 } 262 264 263 265 #if 0 264 #define COLOR4F( IM, r,g,b,a ) 265 { 266 GLuint count = IM->Count; 267 IM->Flag[count] |= VERT_RGBA | VERT_FLOAT_RGBA; 268 IM->FloatColor[count][0] = r; 269 IM->FloatColor[count][1] = g; 270 IM->FloatColor[count][2] = b; 271 IM->FloatColor[count][3] = a; 266 #define COLOR4F( IM, r,g,b,a ) \ 267 { \ 268 GLuint count = IM->Count; \ 269 IM->Flag[count] |= VERT_RGBA | VERT_FLOAT_RGBA; \ 270 IM->FloatColor[count][0] = r; \ 271 IM->FloatColor[count][1] = g; \ 272 IM->FloatColor[count][2] = b; \ 273 IM->FloatColor[count][3] = a; \ 272 274 } 273 275 #else 274 #define COLOR4F(IM, r, g, b, a) 275 { 276 GLubyte col[4]; 277 FLOAT_COLOR_TO_UBYTE_COLOR(col[0], r); 278 FLOAT_COLOR_TO_UBYTE_COLOR(col[1], g); 279 FLOAT_COLOR_TO_UBYTE_COLOR(col[2], b); 280 FLOAT_COLOR_TO_UBYTE_COLOR(col[3], a); 281 COLORV( IM, col ); 276 #define COLOR4F(IM, r, g, b, a) \ 277 { \ 278 GLubyte col[4]; \ 279 FLOAT_COLOR_TO_UBYTE_COLOR(col[0], r); \ 280 FLOAT_COLOR_TO_UBYTE_COLOR(col[1], g); \ 281 FLOAT_COLOR_TO_UBYTE_COLOR(col[2], b); \ 282 FLOAT_COLOR_TO_UBYTE_COLOR(col[3], a); \ 283 COLORV( IM, col ); \ 282 284 } 283 285 #endif … … 285 287 286 288 287 #define COLORV( IM, v ) 288 { 289 GLuint count = IM->Count; 290 IM->Flag[count] |= VERT_RGBA; 291 COPY_4UBV(IM->Color[count], v); 289 #define COLORV( IM, v ) \ 290 { \ 291 GLuint count = IM->Count; \ 292 IM->Flag[count] |= VERT_RGBA; \ 293 COPY_4UBV(IM->Color[count], v); \ 292 294 } 293 295 … … 297 299 GET_IMMEDIATE; 298 300 COLOR( IM, 299 300 301 302 301 BYTE_TO_UBYTE(red), 302 BYTE_TO_UBYTE(green), 303 BYTE_TO_UBYTE(blue), 304 255 ); 303 305 } 304 306 … … 339 341 GET_IMMEDIATE; 340 342 COLOR( IM, INT_TO_UBYTE(red), 341 342 343 343 INT_TO_UBYTE(green), 344 INT_TO_UBYTE(blue), 345 255); 344 346 } 345 347 … … 349 351 GET_IMMEDIATE; 350 352 COLOR( IM, SHORT_TO_UBYTE(red), 351 352 353 353 SHORT_TO_UBYTE(green), 354 SHORT_TO_UBYTE(blue), 355 255); 354 356 } 355 357 … … 366 368 GET_IMMEDIATE; 367 369 COLOR( IM, UINT_TO_UBYTE(red), 368 369 370 370 UINT_TO_UBYTE(green), 371 UINT_TO_UBYTE(blue), 372 255 ); 371 373 } 372 374 … … 376 378 GET_IMMEDIATE; 377 379 COLOR( IM, USHORT_TO_UBYTE(red), USHORT_TO_UBYTE(green), 378 379 380 USHORT_TO_UBYTE(blue), 381 255 ); 380 382 } 381 383 … … 385 387 GET_IMMEDIATE; 386 388 COLOR( IM, BYTE_TO_UBYTE(red), BYTE_TO_UBYTE(green), 387 389 BYTE_TO_UBYTE(blue), BYTE_TO_UBYTE(alpha) ); 388 390 } 389 391 390 392 391 393 void GLAPIENTRY glColor4d(CTX_ARG GLdouble red, GLdouble green, GLdouble blue, 392 394 GLdouble alpha ) 393 395 { 394 396 GLubyte col[4]; … … 426 428 GET_IMMEDIATE; 427 429 COLOR( IM, INT_TO_UBYTE(red), INT_TO_UBYTE(green), 428 430 INT_TO_UBYTE(blue), INT_TO_UBYTE(alpha) ); 429 431 } 430 432 … … 435 437 GET_IMMEDIATE; 436 438 COLOR( IM, SHORT_TO_UBYTE(red), SHORT_TO_UBYTE(green), 437 439 SHORT_TO_UBYTE(blue), SHORT_TO_UBYTE(alpha) ); 438 440 } 439 441 … … 450 452 GET_IMMEDIATE; 451 453 COLOR( IM, UINT_TO_UBYTE(red), UINT_TO_UBYTE(green), 452 454 UINT_TO_UBYTE(blue), UINT_TO_UBYTE(alpha) ); 453 455 } 454 456 … … 458 460 GET_IMMEDIATE; 459 461 COLOR( IM, USHORT_TO_UBYTE(red), USHORT_TO_UBYTE(green), 460 462 USHORT_TO_UBYTE(blue), USHORT_TO_UBYTE(alpha) ); 461 463 } 462 464 … … 466 468 GET_IMMEDIATE; 467 469 COLOR( IM, BYTE_TO_UBYTE(v[0]), BYTE_TO_UBYTE(v[1]), 468 470 BYTE_TO_UBYTE(v[2]), 255 ); 469 471 } 470 472 … … 505 507 GET_IMMEDIATE; 506 508 COLOR( IM, INT_TO_UBYTE(v[0]), INT_TO_UBYTE(v[1]), 507 509 INT_TO_UBYTE(v[2]), 255 ); 508 510 } 509 511 … … 513 515 GET_IMMEDIATE; 514 516 COLOR( IM, SHORT_TO_UBYTE(v[0]), SHORT_TO_UBYTE(v[1]), 515 517 SHORT_TO_UBYTE(v[2]), 255 ); 516 518 } 517 519 … … 528 530 GET_IMMEDIATE; 529 531 COLOR( IM, UINT_TO_UBYTE(v[0]), UINT_TO_UBYTE(v[1]), 530 532 UINT_TO_UBYTE(v[2]), 255 ); 531 533 } 532 534 … … 536 538 GET_IMMEDIATE; 537 539 COLOR( IM, USHORT_TO_UBYTE(v[0]), USHORT_TO_UBYTE(v[1]), 538 540 USHORT_TO_UBYTE(v[2]), 255 ); 539 541 540 542 } … … 545 547 GET_IMMEDIATE; 546 548 COLOR( IM, BYTE_TO_UBYTE(v[0]), BYTE_TO_UBYTE(v[1]), 547 549 BYTE_TO_UBYTE(v[2]), BYTE_TO_UBYTE(v[3]) ); 548 550 } 549 551 … … 585 587 GET_IMMEDIATE; 586 588 COLOR( IM, INT_TO_UBYTE(v[0]), INT_TO_UBYTE(v[1]), 587 589 INT_TO_UBYTE(v[2]), INT_TO_UBYTE(v[3]) ); 588 590 } 589 591 … … 593 595 GET_IMMEDIATE; 594 596 COLOR( IM, SHORT_TO_UBYTE(v[0]), SHORT_TO_UBYTE(v[1]), 595 597 SHORT_TO_UBYTE(v[2]), SHORT_TO_UBYTE(v[3]) ); 596 598 } 597 599 … … 608 610 GET_IMMEDIATE; 609 611 COLOR( IM, UINT_TO_UBYTE(v[0]), UINT_TO_UBYTE(v[1]), 610 612 UINT_TO_UBYTE(v[2]), UINT_TO_UBYTE(v[3]) ); 611 613 } 612 614 … … 616 618 GET_IMMEDIATE; 617 619 COLOR( IM, USHORT_TO_UBYTE(v[0]), USHORT_TO_UBYTE(v[1]), 618 620 USHORT_TO_UBYTE(v[2]), USHORT_TO_UBYTE(v[3]) ); 619 621 } 620 622 … … 833 835 state = IM->BeginState; 834 836 inflags = (~state) & (VERT_BEGIN_0|VERT_BEGIN_1); 835 state |= inflags << 2; 837 state |= inflags << 2; /* errors */ 836 838 837 839 if (MESA_VERBOSE&VERBOSE_API) { 838 840 if (MESA_VERBOSE&VERBOSE_IMMEDIATE) 839 840 841 841 fprintf(stderr, "glEnd(IM %d), BeginState is %x, errors %x\n", 842 IM->id, state, 843 inflags<<2); 842 844 else 843 845 fprintf(stderr, ">"); 844 846 } 845 847 … … 857 859 858 860 if (IM->FlushElt) { 859 860 861 gl_exec_array_elements( IM->backref, IM, last, count ); 862 IM->FlushElt = 0; 861 863 } 862 864 } … … 881 883 if (MESA_VERBOSE&VERBOSE_API) { 882 884 if (MESA_VERBOSE&VERBOSE_IMMEDIATE) 883 884 885 885 fprintf(stderr, "gl_End(IM %d), BeginState is %x, errors %x\n", 886 IM->id, state, 887 inflags<<2); 886 888 else 887 889 fprintf(stderr, ">"); 888 890 } 889 891 890 state |= inflags << 2; 892 state |= inflags << 2; /* errors */ 891 893 892 894 if (inflags != (VERT_BEGIN_0|VERT_BEGIN_1)) … … 902 904 903 905 if (IM->FlushElt) { 904 905 906 gl_exec_array_elements( ctx, IM, last, count ); 907 IM->FlushElt = 0; 906 908 } 907 909 } … … 950 952 951 953 952 #define EVALCOORD1(IM, x) \ 953 { \ 954 GLuint count = IM->Count++; \ 955 IM->Flag[count] |= VERT_EVAL_C1; \ 956 ASSIGN_4V(IM->Obj[count], x, 0, 0, 1); \ 957 if (count == VB_MAX-1) \ 958 IM->maybe_transform_vb( IM ); \ 959 } 960 961 #define EVALCOORD2(IM, x, y) \ 962 { \ 963 GLuint count = IM->Count++; \ 964 IM->Flag[count] |= VERT_EVAL_C2; \ 965 ASSIGN_4V(IM->Obj[count], x, y, 0, 1); \ 966 if (count == VB_MAX-1) \ 967 IM->maybe_transform_vb( IM ); \ 968 } 969 970 #define EVALPOINT1(IM, x) \ 971 { \ 972 GLuint count = IM->Count++; \ 973 IM->Flag[count] |= VERT_EVAL_P1; \ 974 ASSIGN_4V(IM->Obj[count], x, 0, 0, 1); \ 975 if (count == VB_MAX-1) \ 976 IM->maybe_transform_vb( IM ); \ 977 } 978 979 #define EVALPOINT2(IM, x, y) \ 980 { \ 981 GLuint count = IM->Count++; \ 982 IM->Flag[count] |= VERT_EVAL_P2; \ 983 ASSIGN_4V(IM->Obj[count], x, y, 0, 1); \ 984 if (count == VB_MAX-1) \ 985 IM->maybe_transform_vb( IM ); \ 954 #define EVALCOORD1(IM, x) \ 955 { \ 956 GLuint count = IM->Count++; \ 957 IM->Flag[count] |= VERT_EVAL_C1; \ 958 ASSIGN_4V(IM->Obj[count], x, 0, 0, 1); \ 959 if (count == VB_MAX-1) \ 960 IM->maybe_transform_vb( IM ); \ 961 } 962 963 #define EVALCOORD2(IM, x, y) \ 964 { \ 965 GLuint count = IM->Count++; \ 966 IM->Flag[count] |= VERT_EVAL_C2; \ 967 ASSIGN_4V(IM->Obj[count], x, y, 0, 1); \ 968 WriteLog("OPENGL32: EVALCOORD2 (%f,%f) IM: %08X - cnt %d\n",x,y,IM,count); \ 969 if (count == VB_MAX-1) \ 970 {WriteLog("OPENGL32: EVALCOORD2 is calling maybe_transform\n"); \ 971 IM->maybe_transform_vb( IM ); }\ 972 } 973 974 #define EVALPOINT1(IM, x) \ 975 { \ 976 GLuint count = IM->Count++; \ 977 IM->Flag[count] |= VERT_EVAL_P1; \ 978 ASSIGN_4V(IM->Obj[count], x, 0, 0, 1); \ 979 if (count == VB_MAX-1) \ 980 IM->maybe_transform_vb( IM ); \ 981 } 982 983 #define EVALPOINT2(IM, x, y) \ 984 { \ 985 GLuint count = IM->Count++; \ 986 IM->Flag[count] |= VERT_EVAL_P2; \ 987 ASSIGN_4V(IM->Obj[count], x, y, 0, 1); \ 988 if (count == VB_MAX-1) \ 989 IM->maybe_transform_vb( IM ); \ 986 990 } 987 991 … … 1173 1177 case GL_FOG_END: 1174 1178 case GL_FOG_INDEX: 1175 1176 1179 p[0] = (GLfloat) *params; 1180 break; 1177 1181 case GL_FOG_COLOR: 1178 1179 1180 1181 1182 1182 p[0] = INT_TO_FLOAT( params[0] ); 1183 p[1] = INT_TO_FLOAT( params[1] ); 1184 p[2] = INT_TO_FLOAT( params[2] ); 1185 p[3] = INT_TO_FLOAT( params[3] ); 1186 break; 1183 1187 default: 1184 1188 /* Error will be caught later in gl_Fogfv */ … … 1477 1481 1478 1482 1479 #define INDEX( c ) 1480 { 1481 GLuint count; 1482 GET_IMMEDIATE; 1483 count = IM->Count; 1484 IM->Index[count] = c; 1485 IM->Flag[count] |= VERT_INDEX; 1483 #define INDEX( c ) \ 1484 { \ 1485 GLuint count; \ 1486 GET_IMMEDIATE; \ 1487 count = IM->Count; \ 1488 IM->Index[count] = c; \ 1489 IM->Flag[count] |= VERT_INDEX; \ 1486 1490 } 1487 1491 … … 1740 1744 1741 1745 for (i=0;i<16;i++) { 1742 1746 fm[i] = (GLfloat) m[i]; 1743 1747 } 1744 1748 … … 1946 1950 1947 1951 for (i=0;i<16;i++) { 1948 1952 fm[i] = (GLfloat) m[i]; 1949 1953 } 1950 1954 … … 1974 1978 * (ie shared) normals. 1975 1979 */ 1976 #define NORMAL( x,y,z ) 1977 { 1978 GLuint count; 1979 GLfloat *normal; 1980 GET_IMMEDIATE; 1981 count = IM->Count; 1982 IM->Flag[count] |= VERT_NORM; 1983 normal = IM->Normal[count]; 1984 ASSIGN_3V(normal, x,y,z); 1980 #define NORMAL( x,y,z ) \ 1981 { \ 1982 GLuint count; \ 1983 GLfloat *normal; \ 1984 GET_IMMEDIATE; \ 1985 count = IM->Count; \ 1986 IM->Flag[count] |= VERT_NORM; \ 1987 normal = IM->Normal[count]; \ 1988 ASSIGN_3V(normal, x,y,z); \ 1985 1989 } 1986 1990 … … 1989 1993 { 1990 1994 NORMAL( BYTE_TO_FLOAT(nx), 1991 1992 1995 BYTE_TO_FLOAT(ny), 1996 BYTE_TO_FLOAT(nz) ); 1993 1997 } 1994 1998 … … 2009 2013 { 2010 2014 NORMAL( INT_TO_FLOAT(nx), 2011 2012 2015 INT_TO_FLOAT(ny), 2016 INT_TO_FLOAT(nz) ); 2013 2017 } 2014 2018 … … 2017 2021 { 2018 2022 NORMAL( SHORT_TO_FLOAT(nx), 2019 2020 2023 SHORT_TO_FLOAT(ny), 2024 SHORT_TO_FLOAT(nz) ); 2021 2025 } 2022 2026 … … 2025 2029 { 2026 2030 NORMAL( BYTE_TO_FLOAT(v[0]), 2027 2028 2031 BYTE_TO_FLOAT(v[1]), 2032 BYTE_TO_FLOAT(v[2]) ); 2029 2033 } 2030 2034 … … 2045 2049 { 2046 2050 NORMAL( INT_TO_FLOAT(v[0]), 2047 2048 2051 INT_TO_FLOAT(v[1]), 2052 INT_TO_FLOAT(v[2]) ); 2049 2053 } 2050 2054 … … 2053 2057 { 2054 2058 NORMAL( SHORT_TO_FLOAT(v[0]), 2055 2056 2057 } 2058 2059 SHORT_TO_FLOAT(v[1]), 2060 SHORT_TO_FLOAT(v[2]) ); 2061 } 2062
Note:
See TracChangeset
for help on using the changeset viewer.