Changeset 3598 for trunk/src/opengl/mesa/matrix.c
- Timestamp:
- May 23, 2000, 10:41:28 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/opengl/mesa/matrix.c
r2962 r3598 1 /* $Id: matrix.c,v 1. 2 2000-03-01 18:49:31jeroen Exp $ */1 /* $Id: matrix.c,v 1.3 2000-05-23 20:40:40 jeroen Exp $ */ 2 2 3 3 /* 4 4 * Mesa 3-D graphics library 5 * Version: 3. 15 * Version: 3.3 6 6 * 7 7 * Copyright (C) 1999 Brian Paul All Rights Reserved. … … 44 44 #include "all.h" 45 45 #else 46 #ifndef XFree86Server 47 #include <math.h> 48 #include <stdio.h> 49 #include <stdlib.h> 50 #include <string.h> 51 #else 52 #include "GL/xf86glx.h" 53 #endif 46 #include "glheader.h" 54 47 #include "types.h" 55 48 #include "context.h" … … 58 51 #include "matrix.h" 59 52 #include "mmath.h" 53 #include "buffers.h" 54 #include "mem.h" 60 55 #endif 61 62 56 63 57 static const char *types[] = { … … 347 341 /* Do the translation part */ 348 342 MAT(out,0,3) = - (MAT(in,0,3) * MAT(out,0,0) + 349 350 343 MAT(in,1,3) * MAT(out,0,1) + 344 MAT(in,2,3) * MAT(out,0,2) ); 351 345 MAT(out,1,3) = - (MAT(in,0,3) * MAT(out,1,0) + 352 353 346 MAT(in,1,3) * MAT(out,1,1) + 347 MAT(in,2,3) * MAT(out,1,2) ); 354 348 MAT(out,2,3) = - (MAT(in,0,3) * MAT(out,2,0) + 355 356 349 MAT(in,1,3) * MAT(out,2,1) + 350 MAT(in,2,3) * MAT(out,2,2) ); 357 351 358 352 return GL_TRUE; … … 373 367 { 374 368 GLfloat scale = (MAT(in,0,0) * MAT(in,0,0) + 375 376 369 MAT(in,0,1) * MAT(in,0,1) + 370 MAT(in,0,2) * MAT(in,0,2)); 377 371 378 372 if (scale == 0.0) … … 418 412 /* Do the translation part */ 419 413 MAT(out,0,3) = - (MAT(in,0,3) * MAT(out,0,0) + 420 421 414 MAT(in,1,3) * MAT(out,0,1) + 415 MAT(in,2,3) * MAT(out,0,2) ); 422 416 MAT(out,1,3) = - (MAT(in,0,3) * MAT(out,1,0) + 423 424 417 MAT(in,1,3) * MAT(out,1,1) + 418 MAT(in,2,3) * MAT(out,1,2) ); 425 419 MAT(out,2,3) = - (MAT(in,0,3) * MAT(out,2,0) + 426 427 420 MAT(in,1,3) * MAT(out,2,1) + 421 MAT(in,2,3) * MAT(out,2,2) ); 428 422 } 429 423 else … … 523 517 invert_matrix_3d_no_rot, 524 518 invert_matrix_perspective, 525 invert_matrix_3d, 519 invert_matrix_3d, /* lazy! */ 526 520 invert_matrix_2d_no_rot, 527 521 invert_matrix_3d … … 544 538 return GL_FALSE; 545 539 } 540 } 541 542 543 544 void gl_matrix_transposef( GLfloat to[16], const GLfloat from[16] ) 545 { 546 to[0] = from[0]; 547 to[1] = from[4]; 548 to[2] = from[8]; 549 to[3] = from[12]; 550 to[4] = from[1]; 551 to[5] = from[5]; 552 to[6] = from[9]; 553 to[7] = from[13]; 554 to[8] = from[2]; 555 to[9] = from[6]; 556 to[10] = from[10]; 557 to[11] = from[14]; 558 to[12] = from[3]; 559 to[13] = from[7]; 560 to[14] = from[11]; 561 to[15] = from[15]; 562 } 563 564 565 566 void gl_matrix_transposed( GLdouble to[16], const GLdouble from[16] ) 567 { 568 to[0] = from[0]; 569 to[1] = from[4]; 570 to[2] = from[8]; 571 to[3] = from[12]; 572 to[4] = from[1]; 573 to[5] = from[5]; 574 to[6] = from[9]; 575 to[7] = from[13]; 576 to[8] = from[2]; 577 to[9] = from[6]; 578 to[10] = from[10]; 579 to[11] = from[14]; 580 to[12] = from[3]; 581 to[13] = from[7]; 582 to[14] = from[11]; 583 to[15] = from[15]; 546 584 } 547 585 … … 669 707 670 708 #define MASK_IDENTITY ( ONE(0) | ZERO(4) | ZERO(8) | ZERO(12) |\ 671 672 673 709 ZERO(1) | ONE(5) | ZERO(9) | ZERO(13) |\ 710 ZERO(2) | ZERO(6) | ONE(10) | ZERO(14) |\ 711 ZERO(3) | ZERO(7) | ZERO(11) | ONE(15) ) 674 712 675 713 #define MASK_2D_NO_ROT ( ZERO(4) | ZERO(8) | \ 676 677 678 714 ZERO(1) | ZERO(9) | \ 715 ZERO(2) | ZERO(6) | ONE(10) | ZERO(14) |\ 716 ZERO(3) | ZERO(7) | ZERO(11) | ONE(15) ) 679 717 680 718 #define MASK_2D ( ZERO(8) | \ 681 682 683 719 ZERO(9) | \ 720 ZERO(2) | ZERO(6) | ONE(10) | ZERO(14) |\ 721 ZERO(3) | ZERO(7) | ZERO(11) | ONE(15) ) 684 722 685 723 686 724 #define MASK_3D_NO_ROT ( ZERO(4) | ZERO(8) | \ 687 688 689 725 ZERO(1) | ZERO(9) | \ 726 ZERO(2) | ZERO(6) | \ 727 ZERO(3) | ZERO(7) | ZERO(11) | ONE(15) ) 690 728 691 729 #define MASK_3D ( \ 692 693 694 730 \ 731 \ 732 ZERO(3) | ZERO(7) | ZERO(11) | ONE(15) ) 695 733 696 734 697 735 #define MASK_PERSPECTIVE ( ZERO(4) | ZERO(12) |\ 698 699 700 736 ZERO(1) | ZERO(13) |\ 737 ZERO(2) | ZERO(6) | \ 738 ZERO(3) | ZERO(7) | ZERO(15) ) 701 739 702 740 #define SQ(x) ((x)*(x)) … … 738 776 739 777 if ((mask & MASK_NO_2D_SCALE) != MASK_NO_2D_SCALE) 740 778 mat->flags = MAT_FLAG_GENERAL_SCALE; 741 779 } 742 780 else if ((mask & MASK_2D) == MASK_2D) … … 750 788 /* Check for scale */ 751 789 if (SQ(mm-1) > SQ(1e-6) || 752 753 790 SQ(m4m4-1) > SQ(1e-6)) 791 mat->flags |= MAT_FLAG_GENERAL_SCALE; 754 792 755 793 /* Check for rotation */ 756 794 if (SQ(mm4) > SQ(1e-6)) 757 795 mat->flags |= MAT_FLAG_GENERAL_3D; 758 796 else 759 797 mat->flags |= MAT_FLAG_ROTATION; 760 798 761 799 } … … 766 804 /* Check for scale */ 767 805 if (SQ(m[0]-m[5]) < SQ(1e-6) && 768 769 770 806 SQ(m[0]-m[10]) < SQ(1e-6)) { 807 if (SQ(m[0]-1.0) > SQ(1e-6)) 808 mat->flags |= MAT_FLAG_UNIFORM_SCALE; 771 809 } else 772 810 mat->flags |= MAT_FLAG_GENERAL_SCALE; 773 811 } 774 812 else if ((mask & MASK_3D) == MASK_3D) … … 784 822 /* Check for scale */ 785 823 if (SQ(c1-c2) < SQ(1e-6) && SQ(c1-c3) < SQ(1e-6)) { 786 787 788 824 if (SQ(c1-1.0) > SQ(1e-6)) 825 mat->flags |= MAT_FLAG_UNIFORM_SCALE; 826 /* else no scale at all */ 789 827 } else 790 828 mat->flags |= MAT_FLAG_GENERAL_SCALE; 791 829 792 830 /* Check for rotation */ 793 831 if (SQ(d1) < SQ(1e-6)) { 794 795 796 797 798 799 832 CROSS3( cp, m, m+4 ); 833 SUB_3V( cp, cp, (m+8) ); 834 if (LEN_SQUARED_3FV(cp) < SQ(1e-6)) 835 mat->flags |= MAT_FLAG_ROTATION; 836 else 837 mat->flags |= MAT_FLAG_GENERAL_3D; 800 838 } 801 839 else 802 840 mat->flags |= MAT_FLAG_GENERAL_3D; /* shear, etc */ 803 841 } 804 842 else if ((mask & MASK_PERSPECTIVE) == MASK_PERSPECTIVE && m[11]==-1.0F) … … 825 863 } 826 864 else if (TEST_MAT_FLAGS(mat, (MAT_FLAG_TRANSLATION | 827 828 865 MAT_FLAG_UNIFORM_SCALE | 866 MAT_FLAG_GENERAL_SCALE))) 829 867 { 830 868 if ( m[10]==1.0F && m[14]==0.0F ) { 831 869 mat->type = MATRIX_2D_NO_ROT; 832 870 } 833 871 else { 834 872 mat->type = MATRIX_3D_NO_ROT; 835 873 } 836 874 } … … 840 878 && m[2]==0.0F && m[6]==0.0F && m[10]==1.0F && m[14]==0.0F) 841 879 { 842 880 mat->type = MATRIX_2D; 843 881 } 844 882 else 845 883 { 846 884 mat->type = MATRIX_3D; 847 885 } 848 886 } … … 865 903 if (mat->flags & MAT_DIRTY_TYPE) { 866 904 if (mat->flags & MAT_DIRTY_FLAGS) 867 905 analyze_from_scratch( mat ); 868 906 else 869 907 analyze_from_flags( mat ); 870 908 } 871 909 … … 875 913 876 914 mat->flags &= ~(MAT_DIRTY_FLAGS| 877 878 879 } 880 881 882 #define GET_ACTIVE_MATRIX(ctx, mat, flags, where) 883 do { 915 MAT_DIRTY_TYPE| 916 MAT_DIRTY_INVERSE); 917 } 918 919 920 #define GET_ACTIVE_MATRIX(ctx, mat, flags, where) \ 921 do { \ 884 922 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, where); \ 885 923 if (MESA_VERBOSE&VERBOSE_API) fprintf(stderr, "%s\n", where); \ 886 switch (ctx->Transform.MatrixMode) { 887 case GL_MODELVIEW: 888 mat = &ctx->ModelView;\889 flags |= NEW_MODELVIEW;\890 break;\891 case GL_PROJECTION: 892 mat = &ctx->ProjectionMatrix;\893 flags |= NEW_PROJECTION;\894 break;\895 case GL_TEXTURE: 896 mat = &ctx->TextureMatrix[ctx->Texture.CurrentTransformUnit];\897 flags |= NEW_TEXTURE_MATRIX;\898 break;\899 default: 900 gl_problem(ctx, where); 901 } 924 switch (ctx->Transform.MatrixMode) { \ 925 case GL_MODELVIEW: \ 926 mat = &ctx->ModelView; \ 927 flags |= NEW_MODELVIEW; \ 928 break; \ 929 case GL_PROJECTION: \ 930 mat = &ctx->ProjectionMatrix; \ 931 flags |= NEW_PROJECTION; \ 932 break; \ 933 case GL_TEXTURE: \ 934 mat = &ctx->TextureMatrix[ctx->Texture.CurrentTransformUnit]; \ 935 flags |= NEW_TEXTURE_MATRIX; \ 936 break; \ 937 default: \ 938 gl_problem(ctx, where); \ 939 } \ 902 940 } while (0) 903 941 904 942 905 void gl_Frustum( GLcontext *ctx, 906 GLdouble left, GLdouble right, 907 GLdouble bottom, GLdouble top, 908 GLdouble nearval, GLdouble farval ) 909 { 943 void 944 _mesa_Frustum( GLdouble left, GLdouble right, 945 GLdouble bottom, GLdouble top, 946 GLdouble nearval, GLdouble farval ) 947 { 948 GET_CURRENT_CONTEXT(ctx); 910 949 GLfloat x, y, a, b, c, d; 911 950 GLfloat m[16]; … … 947 986 948 987 if (ctx->Driver.NearFar) { 949 988 (*ctx->Driver.NearFar)( ctx, nearval, farval ); 950 989 } 951 990 } … … 953 992 954 993 955 void gl_Ortho( GLcontext *ctx, 956 GLdouble left, GLdouble right, 957 GLdouble bottom, GLdouble top, 958 GLdouble nearval, GLdouble farval ) 959 { 994 void 995 _mesa_Ortho( GLdouble left, GLdouble right, 996 GLdouble bottom, GLdouble top, 997 GLdouble nearval, GLdouble farval ) 998 { 999 GET_CURRENT_CONTEXT(ctx); 960 1000 GLfloat x, y, z; 961 1001 GLfloat tx, ty, tz; … … 992 1032 993 1033 994 void gl_MatrixMode( GLcontext *ctx, GLenum mode ) 995 { 1034 void 1035 _mesa_MatrixMode( GLenum mode ) 1036 { 1037 GET_CURRENT_CONTEXT(ctx); 996 1038 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glMatrixMode"); 997 1039 switch (mode) { … … 1008 1050 1009 1051 1010 void gl_PushMatrix( GLcontext *ctx ) 1011 { 1052 void 1053 _mesa_PushMatrix( void ) 1054 { 1055 GET_CURRENT_CONTEXT(ctx); 1012 1056 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPushMatrix"); 1013 1057 1014 1058 if (MESA_VERBOSE&VERBOSE_API) 1015 1059 fprintf(stderr, "glPushMatrix %s\n", 1016 1060 gl_lookup_enum_by_nr(ctx->Transform.MatrixMode)); 1017 1061 1018 1062 switch (ctx->Transform.MatrixMode) { 1019 1063 case GL_MODELVIEW: 1020 if (ctx->ModelViewStackDepth >=MAX_MODELVIEW_STACK_DEPTH-1) {1064 if (ctx->ModelViewStackDepth >= MAX_MODELVIEW_STACK_DEPTH - 1) { 1021 1065 gl_error( ctx, GL_STACK_OVERFLOW, "glPushMatrix"); 1022 1066 return; 1023 1067 } 1024 1068 gl_matrix_copy( &ctx->ModelViewStack[ctx->ModelViewStackDepth++], 1025 1069 &ctx->ModelView ); 1026 1070 break; 1027 1071 case GL_PROJECTION: 1028 if (ctx->ProjectionStackDepth >=MAX_PROJECTION_STACK_DEPTH) {1072 if (ctx->ProjectionStackDepth >= MAX_PROJECTION_STACK_DEPTH - 1) { 1029 1073 gl_error( ctx, GL_STACK_OVERFLOW, "glPushMatrix"); 1030 1074 return; 1031 1075 } 1032 1076 gl_matrix_copy( &ctx->ProjectionStack[ctx->ProjectionStackDepth++], 1033 1077 &ctx->ProjectionMatrix ); 1034 1078 1035 1079 /* Save near and far projection values */ … … 1042 1086 { 1043 1087 GLuint t = ctx->Texture.CurrentTransformUnit; 1044 if (ctx->TextureStackDepth[t] >= MAX_TEXTURE_STACK_DEPTH ) {1088 if (ctx->TextureStackDepth[t] >= MAX_TEXTURE_STACK_DEPTH - 1) { 1045 1089 gl_error( ctx, GL_STACK_OVERFLOW, "glPushMatrix"); 1046 1090 return; 1047 1091 } 1048 1049 1092 gl_matrix_copy( &ctx->TextureStack[t][ctx->TextureStackDepth[t]++], 1093 &ctx->TextureMatrix[t] ); 1050 1094 } 1051 1095 break; … … 1057 1101 1058 1102 1059 void gl_PopMatrix( GLcontext *ctx ) 1060 { 1103 void 1104 _mesa_PopMatrix( void ) 1105 { 1106 GET_CURRENT_CONTEXT(ctx); 1061 1107 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPopMatrix"); 1062 1108 1063 1109 if (MESA_VERBOSE&VERBOSE_API) 1064 1110 fprintf(stderr, "glPopMatrix %s\n", 1065 1111 gl_lookup_enum_by_nr(ctx->Transform.MatrixMode)); 1066 1112 1067 1113 switch (ctx->Transform.MatrixMode) { … … 1072 1118 } 1073 1119 gl_matrix_copy( &ctx->ModelView, 1074 1075 1120 &ctx->ModelViewStack[--ctx->ModelViewStackDepth] ); 1121 ctx->NewState |= NEW_MODELVIEW; 1076 1122 break; 1077 1123 case GL_PROJECTION: … … 1082 1128 1083 1129 gl_matrix_copy( &ctx->ProjectionMatrix, 1084 1085 1130 &ctx->ProjectionStack[--ctx->ProjectionStackDepth] ); 1131 ctx->NewState |= NEW_PROJECTION; 1086 1132 1087 1133 /* Device driver near/far values */ … … 1101 1147 return; 1102 1148 } 1103 1104 1149 gl_matrix_copy(&ctx->TextureMatrix[t], 1150 &ctx->TextureStack[t][--ctx->TextureStackDepth[t]]); 1105 1151 } 1106 1152 break; … … 1112 1158 1113 1159 1114 void gl_LoadIdentity( GLcontext *ctx ) 1115 { 1160 void 1161 _mesa_LoadIdentity( void ) 1162 { 1163 GET_CURRENT_CONTEXT(ctx); 1116 1164 GLmatrix *mat = 0; 1117 1165 GET_ACTIVE_MATRIX(ctx, mat, ctx->NewState, "glLoadIdentity"); … … 1128 1176 * shortcircuit anyway... 1129 1177 */ 1130 mat->flags = MAT_DIRTY_DEPENDENTS; 1131 } 1132 1133 1134 void gl_LoadMatrixf( GLcontext *ctx, const GLfloat *m ) 1135 { 1178 mat->flags = MAT_DIRTY_DEPENDENTS; 1179 } 1180 1181 1182 void 1183 _mesa_LoadMatrixf( const GLfloat *m ) 1184 { 1185 GET_CURRENT_CONTEXT(ctx); 1136 1186 GLmatrix *mat = 0; 1137 1187 GET_ACTIVE_MATRIX(ctx, mat, ctx->NewState, "glLoadMatrix"); … … 1157 1207 1158 1208 if (ctx->Driver.NearFar) { 1159 1209 (*ctx->Driver.NearFar)( ctx, n, f ); 1160 1210 } 1161 1211 } 1212 } 1213 1214 1215 void 1216 _mesa_LoadMatrixd( const GLdouble *m ) 1217 { 1218 GLfloat f[16]; 1219 GLint i; 1220 for (i = 0; i < 16; i++) 1221 f[i] = m[i]; 1222 _mesa_LoadMatrixf(f); 1162 1223 } 1163 1224 … … 1167 1228 * Multiply the active matrix by an arbitary matrix. 1168 1229 */ 1169 void gl_MultMatrixf( GLcontext *ctx, const GLfloat *m ) 1170 { 1230 void 1231 _mesa_MultMatrixf( const GLfloat *m ) 1232 { 1233 GET_CURRENT_CONTEXT(ctx); 1171 1234 GLmatrix *mat = 0; 1172 1235 GET_ACTIVE_MATRIX( ctx, mat, ctx->NewState, "glMultMatrix" ); … … 1179 1242 * Multiply the active matrix by an arbitary matrix. 1180 1243 */ 1181 void gl_MultMatrixd( GLcontext *ctx, const GLdouble *m ) 1182 { 1244 void 1245 _mesa_MultMatrixd( const GLdouble *m ) 1246 { 1247 GET_CURRENT_CONTEXT(ctx); 1183 1248 GLmatrix *mat = 0; 1184 1249 GET_ACTIVE_MATRIX( ctx, mat, ctx->NewState, "glMultMatrix" ); … … 1196 1261 { 1197 1262 mat->flags |= (flags | 1198 1199 1200 1263 MAT_DIRTY_TYPE | 1264 MAT_DIRTY_INVERSE | 1265 MAT_DIRTY_DEPENDENTS); 1201 1266 1202 1267 if (TEST_MAT_FLAGS(mat, MAT_FLAGS_3D)) … … 1213 1278 { 1214 1279 mat->flags |= (m->flags | 1215 1216 1217 1280 MAT_DIRTY_TYPE | 1281 MAT_DIRTY_INVERSE | 1282 MAT_DIRTY_DEPENDENTS); 1218 1283 1219 1284 if (TEST_MAT_FLAGS(mat, MAT_FLAGS_3D)) … … 1228 1293 * Execute a glRotate call 1229 1294 */ 1230 void gl_Rotatef( GLcontext *ctx, 1231 GLfloat angle, GLfloat x, GLfloat y, GLfloat z ) 1232 { 1295 void 1296 _mesa_Rotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z ) 1297 { 1298 GET_CURRENT_CONTEXT(ctx); 1233 1299 GLfloat m[16]; 1234 1300 if (angle != 0.0F) { … … 1241 1307 } 1242 1308 1309 void 1310 _mesa_Rotated( GLdouble angle, GLdouble x, GLdouble y, GLdouble z ) 1311 { 1312 _mesa_Rotatef(angle, x, y, z); 1313 } 1314 1315 1243 1316 /* 1244 1317 * Execute a glScale call 1245 1318 */ 1246 void gl_Scalef( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z ) 1247 { 1319 void 1320 _mesa_Scalef( GLfloat x, GLfloat y, GLfloat z ) 1321 { 1322 GET_CURRENT_CONTEXT(ctx); 1248 1323 GLmatrix *mat = 0; 1249 1324 GLfloat *m; … … 1262 1337 1263 1338 mat->flags |= (MAT_DIRTY_TYPE | 1264 MAT_DIRTY_INVERSE | 1265 MAT_DIRTY_DEPENDENTS); 1266 } 1339 MAT_DIRTY_INVERSE | 1340 MAT_DIRTY_DEPENDENTS); 1341 } 1342 1343 1344 void 1345 _mesa_Scaled( GLdouble x, GLdouble y, GLdouble z ) 1346 { 1347 _mesa_Scalef(x, y, z); 1348 } 1349 1267 1350 1268 1351 /* 1269 1352 * Execute a glTranslate call 1270 1353 */ 1271 void gl_Translatef( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z ) 1272 { 1354 void 1355 _mesa_Translatef( GLfloat x, GLfloat y, GLfloat z ) 1356 { 1357 GET_CURRENT_CONTEXT(ctx); 1273 1358 GLmatrix *mat = 0; 1274 1359 GLfloat *m; … … 1281 1366 1282 1367 mat->flags |= (MAT_FLAG_TRANSLATION | 1283 MAT_DIRTY_TYPE | 1284 MAT_DIRTY_INVERSE | 1285 MAT_DIRTY_DEPENDENTS); 1286 } 1368 MAT_DIRTY_TYPE | 1369 MAT_DIRTY_INVERSE | 1370 MAT_DIRTY_DEPENDENTS); 1371 } 1372 1373 1374 void 1375 _mesa_Translated( GLdouble x, GLdouble y, GLdouble z ) 1376 { 1377 _mesa_Translatef(x, y, z); 1378 } 1379 1380 1381 1382 void 1383 _mesa_LoadTransposeMatrixfARB( const GLfloat *m ) 1384 { 1385 GLfloat tm[16]; 1386 gl_matrix_transposef(tm, m); 1387 _mesa_LoadMatrixf(tm); 1388 } 1389 1390 1391 void 1392 _mesa_LoadTransposeMatrixdARB( const GLdouble *m ) 1393 { 1394 GLdouble tm[16]; 1395 gl_matrix_transposed(tm, m); 1396 _mesa_LoadMatrixd(tm); 1397 } 1398 1399 1400 void 1401 _mesa_MultTransposeMatrixfARB( const GLfloat *m ) 1402 { 1403 GLfloat tm[16]; 1404 gl_matrix_transposef(tm, m); 1405 _mesa_MultMatrixf(tm); 1406 } 1407 1408 1409 void 1410 _mesa_MultTransposeMatrixdARB( const GLdouble *m ) 1411 { 1412 GLdouble tm[16]; 1413 gl_matrix_transposed(tm, m); 1414 _mesa_MultMatrixd(tm); 1415 } 1416 1417 1418 /* 1419 * Called via glViewport or display list execution. 1420 */ 1421 void 1422 _mesa_Viewport( GLint x, GLint y, GLsizei width, GLsizei height ) 1423 { 1424 GET_CURRENT_CONTEXT(ctx); 1425 gl_Viewport(ctx, x, y, width, height); 1426 } 1427 1287 1428 1288 1429 … … 1290 1431 * Define a new viewport and reallocate auxillary buffers if the size of 1291 1432 * the window (color buffer) has changed. 1292 */ 1293 void gl_Viewport( GLcontext *ctx, 1294 GLint x, GLint y, GLsizei width, GLsizei height ) 1433 * 1434 * XXX This is directly called by device drivers, BUT this function 1435 * may be renamed _mesa_Viewport (without ctx arg) in the future so 1436 * use of _mesa_Viewport is encouraged. 1437 */ 1438 void 1439 gl_Viewport( GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height ) 1295 1440 { 1296 1441 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glViewport"); … … 1319 1464 ctx->Viewport.WindowMap.m[MAT_SY] = (GLfloat) height / 2.0F; 1320 1465 ctx->Viewport.WindowMap.m[MAT_TY] = ctx->Viewport.WindowMap.m[MAT_SY] + y; 1321 ctx->Viewport.WindowMap.m[MAT_SZ] = 0.5 * DEPTH_SCALE;1322 ctx->Viewport.WindowMap.m[MAT_TZ] = 0.5 * DEPTH_SCALE;1466 ctx->Viewport.WindowMap.m[MAT_SZ] = 0.5 * ctx->Visual->DepthMaxF; 1467 ctx->Viewport.WindowMap.m[MAT_TZ] = 0.5 * ctx->Visual->DepthMaxF; 1323 1468 1324 1469 ctx->Viewport.WindowMap.flags = MAT_FLAG_GENERAL_SCALE|MAT_FLAG_TRANSLATION; … … 1331 1476 * ancillary buffers. 1332 1477 */ 1333 gl_ResizeBuffersMESA(ctx);1478 _mesa_ResizeBuffersMESA(); 1334 1479 1335 1480 … … 1337 1482 1338 1483 if ( ctx->Viewport.X<0 1339 || ctx->Viewport.X + ctx->Viewport.Width > ctx-> Buffer->Width1484 || ctx->Viewport.X + ctx->Viewport.Width > ctx->DrawBuffer->Width 1340 1485 || ctx->Viewport.Y<0 1341 || ctx->Viewport.Y + ctx->Viewport.Height > ctx-> Buffer->Height) {1486 || ctx->Viewport.Y + ctx->Viewport.Height > ctx->DrawBuffer->Height) { 1342 1487 ctx->RasterMask |= WINCLIP_BIT; 1343 1488 } … … 1351 1496 1352 1497 1353 void gl_DepthRange( GLcontext *ctx, GLclampd nearval, GLclampd farval ) 1498 void 1499 _mesa_DepthRange( GLclampd nearval, GLclampd farval ) 1354 1500 { 1355 1501 /* … … 1365 1511 */ 1366 1512 GLfloat n, f; 1367 1513 GET_CURRENT_CONTEXT(ctx); 1368 1514 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glDepthRange"); 1369 1515 … … 1376 1522 ctx->Viewport.Near = n; 1377 1523 ctx->Viewport.Far = f; 1378 ctx->Viewport.WindowMap.m[MAT_SZ] = DEPTH_SCALE* ((f - n) / 2.0);1379 ctx->Viewport.WindowMap.m[MAT_TZ] = DEPTH_SCALE* ((f - n) / 2.0 + n);1524 ctx->Viewport.WindowMap.m[MAT_SZ] = ctx->Visual->DepthMaxF * ((f - n) / 2.0); 1525 ctx->Viewport.WindowMap.m[MAT_TZ] = ctx->Visual->DepthMaxF * ((f - n) / 2.0 + n); 1380 1526 1381 1527 ctx->ModelProjectWinMatrixUptodate = GL_FALSE; … … 1390 1536 { 1391 1537 gl_matrix_mul( &ctx->ModelProjectMatrix, 1392 1393 1538 &ctx->ProjectionMatrix, 1539 &ctx->ModelView ); 1394 1540 1395 1541 gl_matrix_analyze( &ctx->ModelProjectMatrix ); … … 1413 1559 } 1414 1560 1561 #if 0 1415 1562 void gl_matrix_set_identity( GLmatrix *m ) 1416 1563 { … … 1419 1566 m->flags = MAT_DIRTY_DEPENDENTS; 1420 1567 } 1421 1568 #endif 1422 1569 1423 1570 void gl_matrix_alloc_inv( GLmatrix *m ) … … 1437 1584 if (to->inv != 0) { 1438 1585 if (from->inv == 0) { 1439 1586 gl_matrix_invert( to ); 1440 1587 } else { 1441 1588 MEMCPY(to->inv, from->inv, sizeof(GLfloat)*16); 1442 1589 } 1443 1590 } … … 1447 1594 { 1448 1595 dest->flags = (a->flags | 1449 1450 1451 1452 1596 b->flags | 1597 MAT_DIRTY_TYPE | 1598 MAT_DIRTY_INVERSE | 1599 MAT_DIRTY_DEPENDENTS); 1453 1600 1454 1601 if (TEST_MAT_FLAGS(dest, MAT_FLAGS_3D))
Note:
See TracChangeset
for help on using the changeset viewer.