Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenmatrix.c
Go to the documentation of this file.
00001 /* 00002 * Mesa 3-D graphics library 00003 * Version: 6.5.3 00004 * 00005 * Copyright (C) 1999-2007 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 00037 #include "glheader.h" 00038 #include "imports.h" 00039 #include "context.h" 00040 #include "enums.h" 00041 #include "macros.h" 00042 #include "matrix.h" 00043 #include "mtypes.h" 00044 #include "math/m_matrix.h" 00045 #include "math/m_xform.h" 00046 00047 00064 void GLAPIENTRY 00065 _mesa_Frustum( GLdouble left, GLdouble right, 00066 GLdouble bottom, GLdouble top, 00067 GLdouble nearval, GLdouble farval ) 00068 { 00069 GET_CURRENT_CONTEXT(ctx); 00070 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); 00071 00072 if (nearval <= 0.0 || 00073 farval <= 0.0 || 00074 nearval == farval || 00075 left == right || 00076 top == bottom) 00077 { 00078 _mesa_error( ctx, GL_INVALID_VALUE, "glFrustum" ); 00079 return; 00080 } 00081 00082 _math_matrix_frustum( ctx->CurrentStack->Top, 00083 (GLfloat) left, (GLfloat) right, 00084 (GLfloat) bottom, (GLfloat) top, 00085 (GLfloat) nearval, (GLfloat) farval ); 00086 ctx->NewState |= ctx->CurrentStack->DirtyFlag; 00087 } 00088 00089 00106 void GLAPIENTRY 00107 _mesa_Ortho( GLdouble left, GLdouble right, 00108 GLdouble bottom, GLdouble top, 00109 GLdouble nearval, GLdouble farval ) 00110 { 00111 GET_CURRENT_CONTEXT(ctx); 00112 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); 00113 00114 if (MESA_VERBOSE & VERBOSE_API) 00115 _mesa_debug(ctx, "glOrtho(%f, %f, %f, %f, %f, %f)\n", 00116 left, right, bottom, top, nearval, farval); 00117 00118 if (left == right || 00119 bottom == top || 00120 nearval == farval) 00121 { 00122 _mesa_error( ctx, GL_INVALID_VALUE, "glOrtho" ); 00123 return; 00124 } 00125 00126 _math_matrix_ortho( ctx->CurrentStack->Top, 00127 (GLfloat) left, (GLfloat) right, 00128 (GLfloat) bottom, (GLfloat) top, 00129 (GLfloat) nearval, (GLfloat) farval ); 00130 ctx->NewState |= ctx->CurrentStack->DirtyFlag; 00131 } 00132 00133 00145 void GLAPIENTRY 00146 _mesa_MatrixMode( GLenum mode ) 00147 { 00148 GET_CURRENT_CONTEXT(ctx); 00149 ASSERT_OUTSIDE_BEGIN_END(ctx); 00150 00151 if (ctx->Transform.MatrixMode == mode && mode != GL_TEXTURE) 00152 return; 00153 FLUSH_VERTICES(ctx, _NEW_TRANSFORM); 00154 00155 switch (mode) { 00156 case GL_MODELVIEW: 00157 ctx->CurrentStack = &ctx->ModelviewMatrixStack; 00158 break; 00159 case GL_PROJECTION: 00160 ctx->CurrentStack = &ctx->ProjectionMatrixStack; 00161 break; 00162 case GL_TEXTURE: 00163 if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { 00164 _mesa_error(ctx, GL_INVALID_OPERATION, "glMatrixMode(texcoord unit)"); 00165 return; 00166 } 00167 ctx->CurrentStack = &ctx->TextureMatrixStack[ctx->Texture.CurrentUnit]; 00168 break; 00169 case GL_COLOR: 00170 ctx->CurrentStack = &ctx->ColorMatrixStack; 00171 break; 00172 case GL_MATRIX0_NV: 00173 case GL_MATRIX1_NV: 00174 case GL_MATRIX2_NV: 00175 case GL_MATRIX3_NV: 00176 case GL_MATRIX4_NV: 00177 case GL_MATRIX5_NV: 00178 case GL_MATRIX6_NV: 00179 case GL_MATRIX7_NV: 00180 if (ctx->Extensions.NV_vertex_program) { 00181 ctx->CurrentStack = &ctx->ProgramMatrixStack[mode - GL_MATRIX0_NV]; 00182 } 00183 else { 00184 _mesa_error( ctx, GL_INVALID_ENUM, "glMatrixMode(mode)" ); 00185 return; 00186 } 00187 break; 00188 case GL_MATRIX0_ARB: 00189 case GL_MATRIX1_ARB: 00190 case GL_MATRIX2_ARB: 00191 case GL_MATRIX3_ARB: 00192 case GL_MATRIX4_ARB: 00193 case GL_MATRIX5_ARB: 00194 case GL_MATRIX6_ARB: 00195 case GL_MATRIX7_ARB: 00196 if (ctx->Extensions.ARB_vertex_program || 00197 ctx->Extensions.ARB_fragment_program) { 00198 const GLuint m = mode - GL_MATRIX0_ARB; 00199 if (m > ctx->Const.MaxProgramMatrices) { 00200 _mesa_error(ctx, GL_INVALID_ENUM, 00201 "glMatrixMode(GL_MATRIX%d_ARB)", m); 00202 return; 00203 } 00204 ctx->CurrentStack = &ctx->ProgramMatrixStack[m]; 00205 } 00206 else { 00207 _mesa_error( ctx, GL_INVALID_ENUM, "glMatrixMode(mode)" ); 00208 return; 00209 } 00210 break; 00211 default: 00212 _mesa_error( ctx, GL_INVALID_ENUM, "glMatrixMode(mode)" ); 00213 return; 00214 } 00215 00216 ctx->Transform.MatrixMode = mode; 00217 } 00218 00219 00229 void GLAPIENTRY 00230 _mesa_PushMatrix( void ) 00231 { 00232 GET_CURRENT_CONTEXT(ctx); 00233 struct gl_matrix_stack *stack = ctx->CurrentStack; 00234 ASSERT_OUTSIDE_BEGIN_END(ctx); 00235 00236 if (MESA_VERBOSE&VERBOSE_API) 00237 _mesa_debug(ctx, "glPushMatrix %s\n", 00238 _mesa_lookup_enum_by_nr(ctx->Transform.MatrixMode)); 00239 00240 if (stack->Depth + 1 >= stack->MaxDepth) { 00241 if (ctx->Transform.MatrixMode == GL_TEXTURE) { 00242 _mesa_error(ctx, GL_STACK_OVERFLOW, 00243 "glPushMatrix(mode=GL_TEXTURE, unit=%d)", 00244 ctx->Texture.CurrentUnit); 00245 } 00246 else { 00247 _mesa_error(ctx, GL_STACK_OVERFLOW, "glPushMatrix(mode=%s)", 00248 _mesa_lookup_enum_by_nr(ctx->Transform.MatrixMode)); 00249 } 00250 return; 00251 } 00252 _math_matrix_copy( &stack->Stack[stack->Depth + 1], 00253 &stack->Stack[stack->Depth] ); 00254 stack->Depth++; 00255 stack->Top = &(stack->Stack[stack->Depth]); 00256 ctx->NewState |= stack->DirtyFlag; 00257 } 00258 00259 00269 void GLAPIENTRY 00270 _mesa_PopMatrix( void ) 00271 { 00272 GET_CURRENT_CONTEXT(ctx); 00273 struct gl_matrix_stack *stack = ctx->CurrentStack; 00274 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); 00275 00276 if (MESA_VERBOSE&VERBOSE_API) 00277 _mesa_debug(ctx, "glPopMatrix %s\n", 00278 _mesa_lookup_enum_by_nr(ctx->Transform.MatrixMode)); 00279 00280 if (stack->Depth == 0) { 00281 if (ctx->Transform.MatrixMode == GL_TEXTURE) { 00282 _mesa_error(ctx, GL_STACK_UNDERFLOW, 00283 "glPopMatrix(mode=GL_TEXTURE, unit=%d)", 00284 ctx->Texture.CurrentUnit); 00285 } 00286 else { 00287 _mesa_error(ctx, GL_STACK_UNDERFLOW, "glPopMatrix(mode=%s)", 00288 _mesa_lookup_enum_by_nr(ctx->Transform.MatrixMode)); 00289 } 00290 return; 00291 } 00292 stack->Depth--; 00293 stack->Top = &(stack->Stack[stack->Depth]); 00294 ctx->NewState |= stack->DirtyFlag; 00295 } 00296 00297 00307 void GLAPIENTRY 00308 _mesa_LoadIdentity( void ) 00309 { 00310 GET_CURRENT_CONTEXT(ctx); 00311 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); 00312 00313 if (MESA_VERBOSE & VERBOSE_API) 00314 _mesa_debug(ctx, "glLoadIdentity()"); 00315 00316 _math_matrix_set_identity( ctx->CurrentStack->Top ); 00317 ctx->NewState |= ctx->CurrentStack->DirtyFlag; 00318 } 00319 00320 00332 void GLAPIENTRY 00333 _mesa_LoadMatrixf( const GLfloat *m ) 00334 { 00335 GET_CURRENT_CONTEXT(ctx); 00336 if (!m) return; 00337 if (MESA_VERBOSE & VERBOSE_API) 00338 _mesa_debug(ctx, 00339 "glLoadMatrix(%f %f %f %f, %f %f %f %f, %f %f %f %f, %f %f %f %f\n", 00340 m[0], m[4], m[8], m[12], 00341 m[1], m[5], m[9], m[13], 00342 m[2], m[6], m[10], m[14], 00343 m[3], m[7], m[11], m[15]); 00344 00345 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); 00346 _math_matrix_loadf( ctx->CurrentStack->Top, m ); 00347 ctx->NewState |= ctx->CurrentStack->DirtyFlag; 00348 } 00349 00350 00362 void GLAPIENTRY 00363 _mesa_MultMatrixf( const GLfloat *m ) 00364 { 00365 GET_CURRENT_CONTEXT(ctx); 00366 if (!m) return; 00367 if (MESA_VERBOSE & VERBOSE_API) 00368 _mesa_debug(ctx, 00369 "glMultMatrix(%f %f %f %f, %f %f %f %f, %f %f %f %f, %f %f %f %f\n", 00370 m[0], m[4], m[8], m[12], 00371 m[1], m[5], m[9], m[13], 00372 m[2], m[6], m[10], m[14], 00373 m[3], m[7], m[11], m[15]); 00374 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); 00375 _math_matrix_mul_floats( ctx->CurrentStack->Top, m ); 00376 ctx->NewState |= ctx->CurrentStack->DirtyFlag; 00377 } 00378 00379 00394 void GLAPIENTRY 00395 _mesa_Rotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z ) 00396 { 00397 GET_CURRENT_CONTEXT(ctx); 00398 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); 00399 if (angle != 0.0F) { 00400 _math_matrix_rotate( ctx->CurrentStack->Top, angle, x, y, z); 00401 ctx->NewState |= ctx->CurrentStack->DirtyFlag; 00402 } 00403 } 00404 00405 00419 void GLAPIENTRY 00420 _mesa_Scalef( GLfloat x, GLfloat y, GLfloat z ) 00421 { 00422 GET_CURRENT_CONTEXT(ctx); 00423 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); 00424 _math_matrix_scale( ctx->CurrentStack->Top, x, y, z); 00425 ctx->NewState |= ctx->CurrentStack->DirtyFlag; 00426 } 00427 00428 00442 void GLAPIENTRY 00443 _mesa_Translatef( GLfloat x, GLfloat y, GLfloat z ) 00444 { 00445 GET_CURRENT_CONTEXT(ctx); 00446 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); 00447 _math_matrix_translate( ctx->CurrentStack->Top, x, y, z); 00448 ctx->NewState |= ctx->CurrentStack->DirtyFlag; 00449 } 00450 00451 00452 #if _HAVE_FULL_GL 00453 void GLAPIENTRY 00454 _mesa_LoadMatrixd( const GLdouble *m ) 00455 { 00456 GLint i; 00457 GLfloat f[16]; 00458 if (!m) return; 00459 for (i = 0; i < 16; i++) 00460 f[i] = (GLfloat) m[i]; 00461 _mesa_LoadMatrixf(f); 00462 } 00463 00464 void GLAPIENTRY 00465 _mesa_MultMatrixd( const GLdouble *m ) 00466 { 00467 GLint i; 00468 GLfloat f[16]; 00469 if (!m) return; 00470 for (i = 0; i < 16; i++) 00471 f[i] = (GLfloat) m[i]; 00472 _mesa_MultMatrixf( f ); 00473 } 00474 00475 00476 void GLAPIENTRY 00477 _mesa_Rotated( GLdouble angle, GLdouble x, GLdouble y, GLdouble z ) 00478 { 00479 _mesa_Rotatef((GLfloat) angle, (GLfloat) x, (GLfloat) y, (GLfloat) z); 00480 } 00481 00482 00483 void GLAPIENTRY 00484 _mesa_Scaled( GLdouble x, GLdouble y, GLdouble z ) 00485 { 00486 _mesa_Scalef((GLfloat) x, (GLfloat) y, (GLfloat) z); 00487 } 00488 00489 00490 void GLAPIENTRY 00491 _mesa_Translated( GLdouble x, GLdouble y, GLdouble z ) 00492 { 00493 _mesa_Translatef((GLfloat) x, (GLfloat) y, (GLfloat) z); 00494 } 00495 #endif 00496 00497 00498 #if _HAVE_FULL_GL 00499 void GLAPIENTRY 00500 _mesa_LoadTransposeMatrixfARB( const GLfloat *m ) 00501 { 00502 GLfloat tm[16]; 00503 if (!m) return; 00504 _math_transposef(tm, m); 00505 _mesa_LoadMatrixf(tm); 00506 } 00507 00508 00509 void GLAPIENTRY 00510 _mesa_LoadTransposeMatrixdARB( const GLdouble *m ) 00511 { 00512 GLfloat tm[16]; 00513 if (!m) return; 00514 _math_transposefd(tm, m); 00515 _mesa_LoadMatrixf(tm); 00516 } 00517 00518 00519 void GLAPIENTRY 00520 _mesa_MultTransposeMatrixfARB( const GLfloat *m ) 00521 { 00522 GLfloat tm[16]; 00523 if (!m) return; 00524 _math_transposef(tm, m); 00525 _mesa_MultMatrixf(tm); 00526 } 00527 00528 00529 void GLAPIENTRY 00530 _mesa_MultTransposeMatrixdARB( const GLdouble *m ) 00531 { 00532 GLfloat tm[16]; 00533 if (!m) return; 00534 _math_transposefd(tm, m); 00535 _mesa_MultMatrixf(tm); 00536 } 00537 #endif 00538 00551 void GLAPIENTRY 00552 _mesa_Viewport( GLint x, GLint y, GLsizei width, GLsizei height ) 00553 { 00554 GET_CURRENT_CONTEXT(ctx); 00555 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); 00556 _mesa_set_viewport(ctx, x, y, width, height); 00557 } 00558 00559 00569 void 00570 _mesa_set_viewport( GLcontext *ctx, GLint x, GLint y, 00571 GLsizei width, GLsizei height ) 00572 { 00573 if (MESA_VERBOSE & VERBOSE_API) 00574 _mesa_debug(ctx, "glViewport %d %d %d %d\n", x, y, width, height); 00575 00576 if (width < 0 || height < 0) { 00577 _mesa_error( ctx, GL_INVALID_VALUE, 00578 "glViewport(%d, %d, %d, %d)", x, y, width, height ); 00579 return; 00580 } 00581 00582 /* clamp width and height to the implementation dependent range */ 00583 width = CLAMP(width, 1, (GLsizei) ctx->Const.MaxViewportWidth); 00584 height = CLAMP(height, 1, (GLsizei) ctx->Const.MaxViewportHeight); 00585 00586 ctx->Viewport.X = x; 00587 ctx->Viewport.Width = width; 00588 ctx->Viewport.Y = y; 00589 ctx->Viewport.Height = height; 00590 ctx->NewState |= _NEW_VIEWPORT; 00591 00592 #if 1 00593 /* XXX remove this someday. Currently the DRI drivers rely on 00594 * the WindowMap matrix being up to date in the driver's Viewport 00595 * and DepthRange functions. 00596 */ 00597 _math_matrix_viewport(&ctx->Viewport._WindowMap, 00598 ctx->Viewport.X, ctx->Viewport.Y, 00599 ctx->Viewport.Width, ctx->Viewport.Height, 00600 ctx->Viewport.Near, ctx->Viewport.Far, 00601 ctx->DrawBuffer->_DepthMaxF); 00602 #endif 00603 00604 if (ctx->Driver.Viewport) { 00605 /* Many drivers will use this call to check for window size changes 00606 * and reallocate the z/stencil/accum/etc buffers if needed. 00607 */ 00608 (*ctx->Driver.Viewport)( ctx, x, y, width, height ); 00609 } 00610 } 00611 00612 00613 #if _HAVE_FULL_GL 00614 00622 void GLAPIENTRY 00623 _mesa_DepthRange( GLclampd nearval, GLclampd farval ) 00624 { 00625 GET_CURRENT_CONTEXT(ctx); 00626 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); 00627 00628 if (MESA_VERBOSE&VERBOSE_API) 00629 _mesa_debug(ctx, "glDepthRange %f %f\n", nearval, farval); 00630 00631 ctx->Viewport.Near = (GLfloat) CLAMP( nearval, 0.0, 1.0 ); 00632 ctx->Viewport.Far = (GLfloat) CLAMP( farval, 0.0, 1.0 ); 00633 ctx->NewState |= _NEW_VIEWPORT; 00634 00635 #if 1 00636 /* XXX remove this someday. Currently the DRI drivers rely on 00637 * the WindowMap matrix being up to date in the driver's Viewport 00638 * and DepthRange functions. 00639 */ 00640 _math_matrix_viewport(&ctx->Viewport._WindowMap, 00641 ctx->Viewport.X, ctx->Viewport.Y, 00642 ctx->Viewport.Width, ctx->Viewport.Height, 00643 ctx->Viewport.Near, ctx->Viewport.Far, 00644 ctx->DrawBuffer->_DepthMaxF); 00645 #endif 00646 00647 if (ctx->Driver.DepthRange) { 00648 (*ctx->Driver.DepthRange)( ctx, nearval, farval ); 00649 } 00650 } 00651 #endif 00652 00653 00654 00655 /**********************************************************************/ 00658 00659 00673 static void 00674 update_projection( GLcontext *ctx ) 00675 { 00676 _math_matrix_analyse( ctx->ProjectionMatrixStack.Top ); 00677 00678 #if FEATURE_userclip 00679 /* Recompute clip plane positions in clipspace. This is also done 00680 * in _mesa_ClipPlane(). 00681 */ 00682 if (ctx->Transform.ClipPlanesEnabled) { 00683 GLuint p; 00684 for (p = 0; p < ctx->Const.MaxClipPlanes; p++) { 00685 if (ctx->Transform.ClipPlanesEnabled & (1 << p)) { 00686 _mesa_transform_vector( ctx->Transform._ClipUserPlane[p], 00687 ctx->Transform.EyeUserPlane[p], 00688 ctx->ProjectionMatrixStack.Top->inv ); 00689 } 00690 } 00691 } 00692 #endif 00693 } 00694 00695 00705 static void 00706 calculate_model_project_matrix( GLcontext *ctx ) 00707 { 00708 _math_matrix_mul_matrix( &ctx->_ModelProjectMatrix, 00709 ctx->ProjectionMatrixStack.Top, 00710 ctx->ModelviewMatrixStack.Top ); 00711 00712 _math_matrix_analyse( &ctx->_ModelProjectMatrix ); 00713 } 00714 00715 00727 void _mesa_update_modelview_project( GLcontext *ctx, GLuint new_state ) 00728 { 00729 if (new_state & _NEW_MODELVIEW) { 00730 _math_matrix_analyse( ctx->ModelviewMatrixStack.Top ); 00731 00732 /* Bring cull position uptodate. 00733 */ 00734 TRANSFORM_POINT3( ctx->Transform.CullObjPos, 00735 ctx->ModelviewMatrixStack.Top->inv, 00736 ctx->Transform.CullEyePos ); 00737 } 00738 00739 00740 if (new_state & _NEW_PROJECTION) 00741 update_projection( ctx ); 00742 00743 /* Keep ModelviewProject uptodate always to allow tnl 00744 * implementations that go model->clip even when eye is required. 00745 */ 00746 calculate_model_project_matrix(ctx); 00747 } 00748 00752 /**********************************************************************/ 00755 00756 00768 static void 00769 init_matrix_stack( struct gl_matrix_stack *stack, 00770 GLuint maxDepth, GLuint dirtyFlag ) 00771 { 00772 GLuint i; 00773 00774 stack->Depth = 0; 00775 stack->MaxDepth = maxDepth; 00776 stack->DirtyFlag = dirtyFlag; 00777 /* The stack */ 00778 stack->Stack = (GLmatrix *) CALLOC(maxDepth * sizeof(GLmatrix)); 00779 for (i = 0; i < maxDepth; i++) { 00780 _math_matrix_ctr(&stack->Stack[i]); 00781 _math_matrix_alloc_inv(&stack->Stack[i]); 00782 } 00783 stack->Top = stack->Stack; 00784 } 00785 00794 static void 00795 free_matrix_stack( struct gl_matrix_stack *stack ) 00796 { 00797 GLuint i; 00798 for (i = 0; i < stack->MaxDepth; i++) { 00799 _math_matrix_dtr(&stack->Stack[i]); 00800 } 00801 FREE(stack->Stack); 00802 stack->Stack = stack->Top = NULL; 00803 } 00804 00808 /**********************************************************************/ 00811 00812 00821 void _mesa_init_matrix( GLcontext * ctx ) 00822 { 00823 GLint i; 00824 00825 /* Initialize matrix stacks */ 00826 init_matrix_stack(&ctx->ModelviewMatrixStack, MAX_MODELVIEW_STACK_DEPTH, 00827 _NEW_MODELVIEW); 00828 init_matrix_stack(&ctx->ProjectionMatrixStack, MAX_PROJECTION_STACK_DEPTH, 00829 _NEW_PROJECTION); 00830 init_matrix_stack(&ctx->ColorMatrixStack, MAX_COLOR_STACK_DEPTH, 00831 _NEW_COLOR_MATRIX); 00832 for (i = 0; i < MAX_TEXTURE_UNITS; i++) 00833 init_matrix_stack(&ctx->TextureMatrixStack[i], MAX_TEXTURE_STACK_DEPTH, 00834 _NEW_TEXTURE_MATRIX); 00835 for (i = 0; i < MAX_PROGRAM_MATRICES; i++) 00836 init_matrix_stack(&ctx->ProgramMatrixStack[i], 00837 MAX_PROGRAM_MATRIX_STACK_DEPTH, _NEW_TRACK_MATRIX); 00838 ctx->CurrentStack = &ctx->ModelviewMatrixStack; 00839 00840 /* Init combined Modelview*Projection matrix */ 00841 _math_matrix_ctr( &ctx->_ModelProjectMatrix ); 00842 } 00843 00844 00853 void _mesa_free_matrix_data( GLcontext *ctx ) 00854 { 00855 GLint i; 00856 00857 free_matrix_stack(&ctx->ModelviewMatrixStack); 00858 free_matrix_stack(&ctx->ProjectionMatrixStack); 00859 free_matrix_stack(&ctx->ColorMatrixStack); 00860 for (i = 0; i < MAX_TEXTURE_UNITS; i++) 00861 free_matrix_stack(&ctx->TextureMatrixStack[i]); 00862 for (i = 0; i < MAX_PROGRAM_MATRICES; i++) 00863 free_matrix_stack(&ctx->ProgramMatrixStack[i]); 00864 /* combined Modelview*Projection matrix */ 00865 _math_matrix_dtr( &ctx->_ModelProjectMatrix ); 00866 00867 } 00868 00869 00877 void _mesa_init_transform( GLcontext *ctx ) 00878 { 00879 GLint i; 00880 00881 /* Transformation group */ 00882 ctx->Transform.MatrixMode = GL_MODELVIEW; 00883 ctx->Transform.Normalize = GL_FALSE; 00884 ctx->Transform.RescaleNormals = GL_FALSE; 00885 ctx->Transform.RasterPositionUnclipped = GL_FALSE; 00886 for (i=0;i<MAX_CLIP_PLANES;i++) { 00887 ASSIGN_4V( ctx->Transform.EyeUserPlane[i], 0.0, 0.0, 0.0, 0.0 ); 00888 } 00889 ctx->Transform.ClipPlanesEnabled = 0; 00890 00891 ASSIGN_4V( ctx->Transform.CullObjPos, 0.0, 0.0, 1.0, 0.0 ); 00892 ASSIGN_4V( ctx->Transform.CullEyePos, 0.0, 0.0, 1.0, 0.0 ); 00893 } 00894 00895 00903 void _mesa_init_viewport( GLcontext *ctx ) 00904 { 00905 GLfloat depthMax = 65535.0F; /* sorf of arbitrary */ 00906 00907 /* Viewport group */ 00908 ctx->Viewport.X = 0; 00909 ctx->Viewport.Y = 0; 00910 ctx->Viewport.Width = 0; 00911 ctx->Viewport.Height = 0; 00912 ctx->Viewport.Near = 0.0; 00913 ctx->Viewport.Far = 1.0; 00914 _math_matrix_ctr(&ctx->Viewport._WindowMap); 00915 00916 _math_matrix_viewport(&ctx->Viewport._WindowMap, 0, 0, 0, 0, 00917 0.0F, 1.0F, depthMax); 00918 } 00919 00920 00928 void _mesa_free_viewport_data( GLcontext *ctx ) 00929 { 00930 _math_matrix_dtr(&ctx->Viewport._WindowMap); 00931 } 00932 Generated on Sun May 27 2012 04:19:00 for ReactOS by
1.7.6.1
|