/** * Push the current matrix stack. * * \sa glPushMatrix(). * * Verifies the current matrix stack is not full, and duplicates the top-most * matrix in the stack. * Marks __struct gl_contextRec::NewState with the stack dirty flag. */ void GLAPIENTRY _mesa_PushMatrix( void ) { GET_CURRENT_CONTEXT(ctx); struct gl_matrix_stack *stack = ctx->CurrentStack; if (MESA_VERBOSE&VERBOSE_API) _mesa_debug(ctx, "glPushMatrix %s\n", _mesa_enum_to_string(ctx->Transform.MatrixMode)); if (stack->Depth + 1 >= stack->MaxDepth) { if (ctx->Transform.MatrixMode == GL_TEXTURE) { _mesa_error(ctx, GL_STACK_OVERFLOW, "glPushMatrix(mode=GL_TEXTURE, unit=%d)", ctx->Texture.CurrentUnit); } else { _mesa_error(ctx, GL_STACK_OVERFLOW, "glPushMatrix(mode=%s)", _mesa_enum_to_string(ctx->Transform.MatrixMode)); } return; } _math_matrix_copy( &stack->Stack[stack->Depth + 1], &stack->Stack[stack->Depth] ); stack->Depth++; stack->Top = &(stack->Stack[stack->Depth]); ctx->NewState |= stack->DirtyFlag; }
/** * Copy attribute groups from one context to another. * * \param src source context * \param dst destination context * \param mask bitwise OR of GL_*_BIT flags * * According to the bits specified in \p mask, copies the corresponding * attributes from \p src into \p dst. For many of the attributes a simple \c * memcpy is not enough due to the existence of internal pointers in their data * structures. */ void _mesa_copy_context( const GLcontext *src, GLcontext *dst, GLuint mask ) { if (mask & GL_ACCUM_BUFFER_BIT) { /* OK to memcpy */ dst->Accum = src->Accum; } if (mask & GL_COLOR_BUFFER_BIT) { /* OK to memcpy */ dst->Color = src->Color; } if (mask & GL_CURRENT_BIT) { /* OK to memcpy */ dst->Current = src->Current; } if (mask & GL_DEPTH_BUFFER_BIT) { /* OK to memcpy */ dst->Depth = src->Depth; } if (mask & GL_ENABLE_BIT) { /* no op */ } if (mask & GL_EVAL_BIT) { /* OK to memcpy */ dst->Eval = src->Eval; } if (mask & GL_FOG_BIT) { /* OK to memcpy */ dst->Fog = src->Fog; } if (mask & GL_HINT_BIT) { /* OK to memcpy */ dst->Hint = src->Hint; } if (mask & GL_LIGHTING_BIT) { GLuint i; /* begin with memcpy */ dst->Light = src->Light; /* fixup linked lists to prevent pointer insanity */ make_empty_list( &(dst->Light.EnabledList) ); for (i = 0; i < MAX_LIGHTS; i++) { if (dst->Light.Light[i].Enabled) { insert_at_tail(&(dst->Light.EnabledList), &(dst->Light.Light[i])); } } } if (mask & GL_LINE_BIT) { /* OK to memcpy */ dst->Line = src->Line; } if (mask & GL_LIST_BIT) { /* OK to memcpy */ dst->List = src->List; } if (mask & GL_PIXEL_MODE_BIT) { /* OK to memcpy */ dst->Pixel = src->Pixel; } if (mask & GL_POINT_BIT) { /* OK to memcpy */ dst->Point = src->Point; } if (mask & GL_POLYGON_BIT) { /* OK to memcpy */ dst->Polygon = src->Polygon; } if (mask & GL_POLYGON_STIPPLE_BIT) { /* Use loop instead of MEMCPY due to problem with Portland Group's * C compiler. Reported by John Stone. */ GLuint i; for (i = 0; i < 32; i++) { dst->PolygonStipple[i] = src->PolygonStipple[i]; } } if (mask & GL_SCISSOR_BIT) { /* OK to memcpy */ dst->Scissor = src->Scissor; } if (mask & GL_STENCIL_BUFFER_BIT) { /* OK to memcpy */ dst->Stencil = src->Stencil; } if (mask & GL_TEXTURE_BIT) { /* Cannot memcpy because of pointers */ _mesa_copy_texture_state(src, dst); } if (mask & GL_TRANSFORM_BIT) { /* OK to memcpy */ dst->Transform = src->Transform; } if (mask & GL_VIEWPORT_BIT) { /* Cannot use memcpy, because of pointers in GLmatrix _WindowMap */ dst->Viewport.X = src->Viewport.X; dst->Viewport.Y = src->Viewport.Y; dst->Viewport.Width = src->Viewport.Width; dst->Viewport.Height = src->Viewport.Height; dst->Viewport.Near = src->Viewport.Near; dst->Viewport.Far = src->Viewport.Far; _math_matrix_copy(&dst->Viewport._WindowMap, &src->Viewport._WindowMap); } /* XXX FIXME: Call callbacks? */ dst->NewState = _NEW_ALL; }