public void Setup(RenderState state, Matrix modelViewMatrix, float alpha, uint blendMode) { Alpha = alpha * state.Alpha; BlendMode = blendMode == Sparrow.Display.BlendMode.AUTO ? state.BlendMode : blendMode; ModelViewMatrix.CopyFromMatrix(state.ModelViewMatrix); ModelViewMatrix.PrependMatrix(modelViewMatrix); }
/// <summary> /// Restores the previous render state. /// </summary> public void PopState() { if (_stateStack.Count == 0) { throw new InvalidOperationException("The state stack must not be empty"); } _stateStackTop = _stateStack[--_stateStackIndex]; }
/// <summary> /// Adds a new render state to the stack. The passed matrix is prepended to the modelview matrix; /// the alpha value is multiplied with the current alpha; the blend mode replaces the existing /// mode (except 'BlendMode.Auto', which will cause the current mode to prevail). /// </summary> public void PushState(Matrix matrix, float alpha, uint blendMode) { RenderState previousState = _stateStackTop; if (_stateStackSize == _stateStackIndex + 1) { _stateStack.Add(new RenderState()); _stateStackSize++; } _stateStackTop = _stateStack[++_stateStackIndex]; _stateStackTop.Setup(previousState, matrix, alpha, blendMode); }
/// <summary> /// Resets the render state stack to the default. /// </summary> public void NextFrame() { _clipRectStackSize = 0; _stateStackIndex = 0; _quadBatchIndex = 0; _numDrawCalls = 0; _quadBatchTop = _quadBatches[0]; _stateStackTop = _stateStack[0]; }
public RenderSupport() { _projectionMatrix = Matrix.Create(); _mvpMatrix = Matrix.Create(); _stateStack = new List<RenderState> { new RenderState() }; _stateStackIndex = 0; _stateStackSize = 1; _stateStackTop = _stateStack[0]; _quadBatches = new List<QuadBatch> { new QuadBatch() }; _quadBatchIndex = 0; _quadBatchSize = 1; _quadBatchTop = _quadBatches[0]; _clipRectStack = new List<Rectangle>(); _clipRectStackSize = 0; SetupOrthographicProjection(0, 320, 0, 480); }