[PROPSYS]
[reactos.git] / reactos / dll / opengl / mesa / main / matrix.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 7.5
4 *
5 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
6 * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 */
25
26
27 /**
28 * \file matrix.c
29 * Matrix operations.
30 *
31 * \note
32 * -# 4x4 transformation matrices are stored in memory in column major order.
33 * -# Points/vertices are to be thought of as column vectors.
34 * -# Transformation of a point p by a matrix M is: p' = M * p
35 */
36
37 #include <precomp.h>
38
39 /**
40 * Apply a perspective projection matrix.
41 *
42 * \param left left clipping plane coordinate.
43 * \param right right clipping plane coordinate.
44 * \param bottom bottom clipping plane coordinate.
45 * \param top top clipping plane coordinate.
46 * \param nearval distance to the near clipping plane.
47 * \param farval distance to the far clipping plane.
48 *
49 * \sa glFrustum().
50 *
51 * Flushes vertices and validates parameters. Calls _math_matrix_frustum() with
52 * the top matrix of the current matrix stack and sets
53 * __struct gl_contextRec::NewState.
54 */
55 void GLAPIENTRY
56 _mesa_Frustum( GLdouble left, GLdouble right,
57 GLdouble bottom, GLdouble top,
58 GLdouble nearval, GLdouble farval )
59 {
60 GET_CURRENT_CONTEXT(ctx);
61 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
62
63 if (nearval <= 0.0 ||
64 farval <= 0.0 ||
65 nearval == farval ||
66 left == right ||
67 top == bottom)
68 {
69 _mesa_error( ctx, GL_INVALID_VALUE, "glFrustum" );
70 return;
71 }
72
73 _math_matrix_frustum( ctx->CurrentStack->Top,
74 (GLfloat) left, (GLfloat) right,
75 (GLfloat) bottom, (GLfloat) top,
76 (GLfloat) nearval, (GLfloat) farval );
77 ctx->NewState |= ctx->CurrentStack->DirtyFlag;
78 }
79
80
81 /**
82 * Apply an orthographic projection matrix.
83 *
84 * \param left left clipping plane coordinate.
85 * \param right right clipping plane coordinate.
86 * \param bottom bottom clipping plane coordinate.
87 * \param top top clipping plane coordinate.
88 * \param nearval distance to the near clipping plane.
89 * \param farval distance to the far clipping plane.
90 *
91 * \sa glOrtho().
92 *
93 * Flushes vertices and validates parameters. Calls _math_matrix_ortho() with
94 * the top matrix of the current matrix stack and sets
95 * __struct gl_contextRec::NewState.
96 */
97 void GLAPIENTRY
98 _mesa_Ortho( GLdouble left, GLdouble right,
99 GLdouble bottom, GLdouble top,
100 GLdouble nearval, GLdouble farval )
101 {
102 GET_CURRENT_CONTEXT(ctx);
103 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
104
105 if (MESA_VERBOSE & VERBOSE_API)
106 _mesa_debug(ctx, "glOrtho(%f, %f, %f, %f, %f, %f)\n",
107 left, right, bottom, top, nearval, farval);
108
109 if (left == right ||
110 bottom == top ||
111 nearval == farval)
112 {
113 _mesa_error( ctx, GL_INVALID_VALUE, "glOrtho" );
114 return;
115 }
116
117 _math_matrix_ortho( ctx->CurrentStack->Top,
118 (GLfloat) left, (GLfloat) right,
119 (GLfloat) bottom, (GLfloat) top,
120 (GLfloat) nearval, (GLfloat) farval );
121 ctx->NewState |= ctx->CurrentStack->DirtyFlag;
122 }
123
124
125 /**
126 * Set the current matrix stack.
127 *
128 * \param mode matrix stack.
129 *
130 * \sa glMatrixMode().
131 *
132 * Flushes the vertices, validates the parameter and updates
133 * __struct gl_contextRec::CurrentStack and gl_transform_attrib::MatrixMode
134 * with the specified matrix stack.
135 */
136 void GLAPIENTRY
137 _mesa_MatrixMode( GLenum mode )
138 {
139 GET_CURRENT_CONTEXT(ctx);
140 ASSERT_OUTSIDE_BEGIN_END(ctx);
141
142 if (ctx->Transform.MatrixMode == mode && mode != GL_TEXTURE)
143 return;
144 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
145
146 switch (mode) {
147 case GL_MODELVIEW:
148 ctx->CurrentStack = &ctx->ModelviewMatrixStack;
149 break;
150 case GL_PROJECTION:
151 ctx->CurrentStack = &ctx->ProjectionMatrixStack;
152 break;
153 case GL_TEXTURE:
154 ctx->CurrentStack = &ctx->TextureMatrixStack;
155 break;
156 default:
157 _mesa_error( ctx, GL_INVALID_ENUM, "glMatrixMode(mode)" );
158 return;
159 }
160
161 ctx->Transform.MatrixMode = mode;
162 }
163
164
165 /**
166 * Push the current matrix stack.
167 *
168 * \sa glPushMatrix().
169 *
170 * Verifies the current matrix stack is not full, and duplicates the top-most
171 * matrix in the stack.
172 * Marks __struct gl_contextRec::NewState with the stack dirty flag.
173 */
174 void GLAPIENTRY
175 _mesa_PushMatrix( void )
176 {
177 GET_CURRENT_CONTEXT(ctx);
178 struct gl_matrix_stack *stack = ctx->CurrentStack;
179 ASSERT_OUTSIDE_BEGIN_END(ctx);
180
181 if (MESA_VERBOSE&VERBOSE_API)
182 _mesa_debug(ctx, "glPushMatrix %s\n",
183 _mesa_lookup_enum_by_nr(ctx->Transform.MatrixMode));
184
185 if (stack->Depth + 1 >= stack->MaxDepth) {
186 if (ctx->Transform.MatrixMode == GL_TEXTURE) {
187 _mesa_error(ctx, GL_STACK_OVERFLOW,
188 "glPushMatrix(mode=GL_TEXTURE)");
189 }
190 else {
191 _mesa_error(ctx, GL_STACK_OVERFLOW, "glPushMatrix(mode=%s)",
192 _mesa_lookup_enum_by_nr(ctx->Transform.MatrixMode));
193 }
194 return;
195 }
196 _math_matrix_copy( &stack->Stack[stack->Depth + 1],
197 &stack->Stack[stack->Depth] );
198 stack->Depth++;
199 stack->Top = &(stack->Stack[stack->Depth]);
200 ctx->NewState |= stack->DirtyFlag;
201 }
202
203
204 /**
205 * Pop the current matrix stack.
206 *
207 * \sa glPopMatrix().
208 *
209 * Flushes the vertices, verifies the current matrix stack is not empty, and
210 * moves the stack head down.
211 * Marks __struct gl_contextRec::NewState with the dirty stack flag.
212 */
213 void GLAPIENTRY
214 _mesa_PopMatrix( void )
215 {
216 GET_CURRENT_CONTEXT(ctx);
217 struct gl_matrix_stack *stack = ctx->CurrentStack;
218 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
219
220 if (MESA_VERBOSE&VERBOSE_API)
221 _mesa_debug(ctx, "glPopMatrix %s\n",
222 _mesa_lookup_enum_by_nr(ctx->Transform.MatrixMode));
223
224 if (stack->Depth == 0) {
225 if (ctx->Transform.MatrixMode == GL_TEXTURE) {
226 _mesa_error(ctx, GL_STACK_UNDERFLOW,
227 "glPopMatrix(mode=GL_TEXTURE)");
228 }
229 else {
230 _mesa_error(ctx, GL_STACK_UNDERFLOW, "glPopMatrix(mode=%s)",
231 _mesa_lookup_enum_by_nr(ctx->Transform.MatrixMode));
232 }
233 return;
234 }
235 stack->Depth--;
236 stack->Top = &(stack->Stack[stack->Depth]);
237 ctx->NewState |= stack->DirtyFlag;
238 }
239
240
241 /**
242 * Replace the current matrix with the identity matrix.
243 *
244 * \sa glLoadIdentity().
245 *
246 * Flushes the vertices and calls _math_matrix_set_identity() with the
247 * top-most matrix in the current stack.
248 * Marks __struct gl_contextRec::NewState with the stack dirty flag.
249 */
250 void GLAPIENTRY
251 _mesa_LoadIdentity( void )
252 {
253 GET_CURRENT_CONTEXT(ctx);
254 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
255
256 if (MESA_VERBOSE & VERBOSE_API)
257 _mesa_debug(ctx, "glLoadIdentity()\n");
258
259 _math_matrix_set_identity( ctx->CurrentStack->Top );
260 ctx->NewState |= ctx->CurrentStack->DirtyFlag;
261 }
262
263
264 /**
265 * Replace the current matrix with a given matrix.
266 *
267 * \param m matrix.
268 *
269 * \sa glLoadMatrixf().
270 *
271 * Flushes the vertices and calls _math_matrix_loadf() with the top-most
272 * matrix in the current stack and the given matrix.
273 * Marks __struct gl_contextRec::NewState with the dirty stack flag.
274 */
275 void GLAPIENTRY
276 _mesa_LoadMatrixf( const GLfloat *m )
277 {
278 GET_CURRENT_CONTEXT(ctx);
279 if (!m) return;
280 if (MESA_VERBOSE & VERBOSE_API)
281 _mesa_debug(ctx,
282 "glLoadMatrix(%f %f %f %f, %f %f %f %f, %f %f %f %f, %f %f %f %f\n",
283 m[0], m[4], m[8], m[12],
284 m[1], m[5], m[9], m[13],
285 m[2], m[6], m[10], m[14],
286 m[3], m[7], m[11], m[15]);
287
288 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
289 _math_matrix_loadf( ctx->CurrentStack->Top, m );
290 ctx->NewState |= ctx->CurrentStack->DirtyFlag;
291 }
292
293
294 /**
295 * Multiply the current matrix with a given matrix.
296 *
297 * \param m matrix.
298 *
299 * \sa glMultMatrixf().
300 *
301 * Flushes the vertices and calls _math_matrix_mul_floats() with the top-most
302 * matrix in the current stack and the given matrix. Marks
303 * __struct gl_contextRec::NewState with the dirty stack flag.
304 */
305 void GLAPIENTRY
306 _mesa_MultMatrixf( const GLfloat *m )
307 {
308 GET_CURRENT_CONTEXT(ctx);
309 if (!m) return;
310 if (MESA_VERBOSE & VERBOSE_API)
311 _mesa_debug(ctx,
312 "glMultMatrix(%f %f %f %f, %f %f %f %f, %f %f %f %f, %f %f %f %f\n",
313 m[0], m[4], m[8], m[12],
314 m[1], m[5], m[9], m[13],
315 m[2], m[6], m[10], m[14],
316 m[3], m[7], m[11], m[15]);
317 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
318 _math_matrix_mul_floats( ctx->CurrentStack->Top, m );
319 ctx->NewState |= ctx->CurrentStack->DirtyFlag;
320 }
321
322
323 /**
324 * Multiply the current matrix with a rotation matrix.
325 *
326 * \param angle angle of rotation, in degrees.
327 * \param x rotation vector x coordinate.
328 * \param y rotation vector y coordinate.
329 * \param z rotation vector z coordinate.
330 *
331 * \sa glRotatef().
332 *
333 * Flushes the vertices and calls _math_matrix_rotate() with the top-most
334 * matrix in the current stack and the given parameters. Marks
335 * __struct gl_contextRec::NewState with the dirty stack flag.
336 */
337 void GLAPIENTRY
338 _mesa_Rotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z )
339 {
340 GET_CURRENT_CONTEXT(ctx);
341 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
342 if (angle != 0.0F) {
343 _math_matrix_rotate( ctx->CurrentStack->Top, angle, x, y, z);
344 ctx->NewState |= ctx->CurrentStack->DirtyFlag;
345 }
346 }
347
348
349 /**
350 * Multiply the current matrix with a general scaling matrix.
351 *
352 * \param x x axis scale factor.
353 * \param y y axis scale factor.
354 * \param z z axis scale factor.
355 *
356 * \sa glScalef().
357 *
358 * Flushes the vertices and calls _math_matrix_scale() with the top-most
359 * matrix in the current stack and the given parameters. Marks
360 * __struct gl_contextRec::NewState with the dirty stack flag.
361 */
362 void GLAPIENTRY
363 _mesa_Scalef( GLfloat x, GLfloat y, GLfloat z )
364 {
365 GET_CURRENT_CONTEXT(ctx);
366 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
367 _math_matrix_scale( ctx->CurrentStack->Top, x, y, z);
368 ctx->NewState |= ctx->CurrentStack->DirtyFlag;
369 }
370
371
372 /**
373 * Multiply the current matrix with a translation matrix.
374 *
375 * \param x translation vector x coordinate.
376 * \param y translation vector y coordinate.
377 * \param z translation vector z coordinate.
378 *
379 * \sa glTranslatef().
380 *
381 * Flushes the vertices and calls _math_matrix_translate() with the top-most
382 * matrix in the current stack and the given parameters. Marks
383 * __struct gl_contextRec::NewState with the dirty stack flag.
384 */
385 void GLAPIENTRY
386 _mesa_Translatef( GLfloat x, GLfloat y, GLfloat z )
387 {
388 GET_CURRENT_CONTEXT(ctx);
389 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
390 _math_matrix_translate( ctx->CurrentStack->Top, x, y, z);
391 ctx->NewState |= ctx->CurrentStack->DirtyFlag;
392 }
393
394
395 #if _HAVE_FULL_GL
396 void GLAPIENTRY
397 _mesa_LoadMatrixd( const GLdouble *m )
398 {
399 GLint i;
400 GLfloat f[16];
401 if (!m) return;
402 for (i = 0; i < 16; i++)
403 f[i] = (GLfloat) m[i];
404 _mesa_LoadMatrixf(f);
405 }
406
407 void GLAPIENTRY
408 _mesa_MultMatrixd( const GLdouble *m )
409 {
410 GLint i;
411 GLfloat f[16];
412 if (!m) return;
413 for (i = 0; i < 16; i++)
414 f[i] = (GLfloat) m[i];
415 _mesa_MultMatrixf( f );
416 }
417
418
419 void GLAPIENTRY
420 _mesa_Rotated( GLdouble angle, GLdouble x, GLdouble y, GLdouble z )
421 {
422 _mesa_Rotatef((GLfloat) angle, (GLfloat) x, (GLfloat) y, (GLfloat) z);
423 }
424
425
426 void GLAPIENTRY
427 _mesa_Scaled( GLdouble x, GLdouble y, GLdouble z )
428 {
429 _mesa_Scalef((GLfloat) x, (GLfloat) y, (GLfloat) z);
430 }
431
432
433 void GLAPIENTRY
434 _mesa_Translated( GLdouble x, GLdouble y, GLdouble z )
435 {
436 _mesa_Translatef((GLfloat) x, (GLfloat) y, (GLfloat) z);
437 }
438 #endif
439
440
441 #if _HAVE_FULL_GL
442 void GLAPIENTRY
443 _mesa_LoadTransposeMatrixfARB( const GLfloat *m )
444 {
445 GLfloat tm[16];
446 if (!m) return;
447 _math_transposef(tm, m);
448 _mesa_LoadMatrixf(tm);
449 }
450
451
452 void GLAPIENTRY
453 _mesa_LoadTransposeMatrixdARB( const GLdouble *m )
454 {
455 GLfloat tm[16];
456 if (!m) return;
457 _math_transposefd(tm, m);
458 _mesa_LoadMatrixf(tm);
459 }
460
461
462 void GLAPIENTRY
463 _mesa_MultTransposeMatrixfARB( const GLfloat *m )
464 {
465 GLfloat tm[16];
466 if (!m) return;
467 _math_transposef(tm, m);
468 _mesa_MultMatrixf(tm);
469 }
470
471
472 void GLAPIENTRY
473 _mesa_MultTransposeMatrixdARB( const GLdouble *m )
474 {
475 GLfloat tm[16];
476 if (!m) return;
477 _math_transposefd(tm, m);
478 _mesa_MultMatrixf(tm);
479 }
480 #endif
481
482
483
484 /**********************************************************************/
485 /** \name State management */
486 /*@{*/
487
488
489 /**
490 * Update the projection matrix stack.
491 *
492 * \param ctx GL context.
493 *
494 * Calls _math_matrix_analyse() with the top-matrix of the projection matrix
495 * stack, and recomputes user clip positions if necessary.
496 *
497 * \note This routine references __struct gl_contextRec::Tranform attribute
498 * values to compute userclip positions in clip space, but is only called on
499 * _NEW_PROJECTION. The _mesa_ClipPlane() function keeps these values up to
500 * date across changes to the __struct gl_contextRec::Transform attributes.
501 */
502 static void
503 update_projection( struct gl_context *ctx )
504 {
505 _math_matrix_analyse( ctx->ProjectionMatrixStack.Top );
506
507 #if FEATURE_userclip
508 /* Recompute clip plane positions in clipspace. This is also done
509 * in _mesa_ClipPlane().
510 */
511 if (ctx->Transform.ClipPlanesEnabled) {
512 GLuint p;
513 for (p = 0; p < ctx->Const.MaxClipPlanes; p++) {
514 if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
515 _mesa_transform_vector( ctx->Transform._ClipUserPlane[p],
516 ctx->Transform.EyeUserPlane[p],
517 ctx->ProjectionMatrixStack.Top->inv );
518 }
519 }
520 }
521 #endif
522 }
523
524
525 /**
526 * Calculate the combined modelview-projection matrix.
527 *
528 * \param ctx GL context.
529 *
530 * Multiplies the top matrices of the projection and model view stacks into
531 * __struct gl_contextRec::_ModelProjectMatrix via _math_matrix_mul_matrix()
532 * and analyzes the resulting matrix via _math_matrix_analyse().
533 */
534 static void
535 calculate_model_project_matrix( struct gl_context *ctx )
536 {
537 _math_matrix_mul_matrix( &ctx->_ModelProjectMatrix,
538 ctx->ProjectionMatrixStack.Top,
539 ctx->ModelviewMatrixStack.Top );
540
541 _math_matrix_analyse( &ctx->_ModelProjectMatrix );
542 }
543
544
545 /**
546 * Updates the combined modelview-projection matrix.
547 *
548 * \param ctx GL context.
549 * \param new_state new state bit mask.
550 *
551 * If there is a new model view matrix then analyzes it. If there is a new
552 * projection matrix, updates it. Finally calls
553 * calculate_model_project_matrix() to recalculate the modelview-projection
554 * matrix.
555 */
556 void _mesa_update_modelview_project( struct gl_context *ctx, GLuint new_state )
557 {
558 if (new_state & _NEW_MODELVIEW) {
559 _math_matrix_analyse( ctx->ModelviewMatrixStack.Top );
560
561 /* Bring cull position up to date.
562 */
563 TRANSFORM_POINT3( ctx->Transform.CullObjPos,
564 ctx->ModelviewMatrixStack.Top->inv,
565 ctx->Transform.CullEyePos );
566 }
567
568
569 if (new_state & _NEW_PROJECTION)
570 update_projection( ctx );
571
572 /* Keep ModelviewProject up to date always to allow tnl
573 * implementations that go model->clip even when eye is required.
574 */
575 calculate_model_project_matrix(ctx);
576 }
577
578 /*@}*/
579
580
581 /**********************************************************************/
582 /** Matrix stack initialization */
583 /*@{*/
584
585
586 /**
587 * Initialize a matrix stack.
588 *
589 * \param stack matrix stack.
590 * \param maxDepth maximum stack depth.
591 * \param dirtyFlag dirty flag.
592 *
593 * Allocates an array of \p maxDepth elements for the matrix stack and calls
594 * _math_matrix_ctr() and _math_matrix_alloc_inv() for each element to
595 * initialize it.
596 */
597 static void
598 init_matrix_stack( struct gl_matrix_stack *stack,
599 GLuint maxDepth, GLuint dirtyFlag )
600 {
601 GLuint i;
602
603 stack->Depth = 0;
604 stack->MaxDepth = maxDepth;
605 stack->DirtyFlag = dirtyFlag;
606 /* The stack */
607 stack->Stack = (GLmatrix *) CALLOC(maxDepth * sizeof(GLmatrix));
608 for (i = 0; i < maxDepth; i++) {
609 _math_matrix_ctr(&stack->Stack[i]);
610 _math_matrix_alloc_inv(&stack->Stack[i]);
611 }
612 stack->Top = stack->Stack;
613 }
614
615 /**
616 * Free matrix stack.
617 *
618 * \param stack matrix stack.
619 *
620 * Calls _math_matrix_dtr() for each element of the matrix stack and
621 * frees the array.
622 */
623 static void
624 free_matrix_stack( struct gl_matrix_stack *stack )
625 {
626 GLuint i;
627 for (i = 0; i < stack->MaxDepth; i++) {
628 _math_matrix_dtr(&stack->Stack[i]);
629 }
630 FREE(stack->Stack);
631 stack->Stack = stack->Top = NULL;
632 }
633
634 /*@}*/
635
636
637 /**********************************************************************/
638 /** \name Initialization */
639 /*@{*/
640
641
642 /**
643 * Initialize the context matrix data.
644 *
645 * \param ctx GL context.
646 *
647 * Initializes each of the matrix stacks and the combined modelview-projection
648 * matrix.
649 */
650 void _mesa_init_matrix( struct gl_context * ctx )
651 {
652 /* Initialize matrix stacks */
653 init_matrix_stack(&ctx->ModelviewMatrixStack, MAX_MODELVIEW_STACK_DEPTH,
654 _NEW_MODELVIEW);
655 init_matrix_stack(&ctx->ProjectionMatrixStack, MAX_PROJECTION_STACK_DEPTH,
656 _NEW_PROJECTION);
657 init_matrix_stack(&ctx->TextureMatrixStack, MAX_TEXTURE_STACK_DEPTH,
658 _NEW_TEXTURE_MATRIX);
659 ctx->CurrentStack = &ctx->ModelviewMatrixStack;
660
661 /* Init combined Modelview*Projection matrix */
662 _math_matrix_ctr( &ctx->_ModelProjectMatrix );
663 }
664
665
666 /**
667 * Free the context matrix data.
668 *
669 * \param ctx GL context.
670 *
671 * Frees each of the matrix stacks and the combined modelview-projection
672 * matrix.
673 */
674 void _mesa_free_matrix_data( struct gl_context *ctx )
675 {
676 free_matrix_stack(&ctx->ModelviewMatrixStack);
677 free_matrix_stack(&ctx->ProjectionMatrixStack);
678 free_matrix_stack(&ctx->TextureMatrixStack);
679 /* combined Modelview*Projection matrix */
680 _math_matrix_dtr( &ctx->_ModelProjectMatrix );
681
682 }
683
684
685 /**
686 * Initialize the context transform attribute group.
687 *
688 * \param ctx GL context.
689 *
690 * \todo Move this to a new file with other 'transform' routines.
691 */
692 void _mesa_init_transform( struct gl_context *ctx )
693 {
694 GLint i;
695
696 /* Transformation group */
697 ctx->Transform.MatrixMode = GL_MODELVIEW;
698 ctx->Transform.Normalize = GL_FALSE;
699 ctx->Transform.RescaleNormals = GL_FALSE;
700 ctx->Transform.RasterPositionUnclipped = GL_FALSE;
701 for (i=0;i<ctx->Const.MaxClipPlanes;i++) {
702 ASSIGN_4V( ctx->Transform.EyeUserPlane[i], 0.0, 0.0, 0.0, 0.0 );
703 }
704 ctx->Transform.ClipPlanesEnabled = 0;
705
706 ASSIGN_4V( ctx->Transform.CullObjPos, 0.0, 0.0, 1.0, 0.0 );
707 ASSIGN_4V( ctx->Transform.CullEyePos, 0.0, 0.0, 1.0, 0.0 );
708 }
709
710
711 /*@}*/