/// <summary> /// Sets the blending function to draw with. /// </summary> /// <param name="blendingInfo">The infor we should use to update the active state.</param> public static void SetBlend(BlendingInfo blendingInfo) { if (lastBlendingInfo.Equals(blendingInfo)) { return; } FlushCurrentBatch(); if (blendingInfo.IsDisabled) { if (!lastBlendingEnabledState.HasValue || lastBlendingEnabledState.Value) { GL.Disable(EnableCap.Blend); } lastBlendingEnabledState = false; } else { if (!lastBlendingEnabledState.HasValue || !lastBlendingEnabledState.Value) { GL.Enable(EnableCap.Blend); } lastBlendingEnabledState = true; GL.BlendEquationSeparate(blendingInfo.RGBEquation, blendingInfo.AlphaEquation); GL.BlendFuncSeparate(blendingInfo.Source, blendingInfo.Destination, blendingInfo.SourceAlpha, blendingInfo.DestinationAlpha); } lastBlendingInfo = blendingInfo; }
internal static void Reset(Vector2 size) { Trace.Assert(shader_stack.Count == 0); reset_scheduler.Update(); if (expensive_operations_queue.TryDequeue(out Action action)) { action.Invoke(); } lastBoundTexture = null; lastDepthTest = null; lastBlendingInfo = new BlendingInfo(); lastBlendingEnabledState = null; foreach (IVertexBatch b in this_frame_batches) { b.ResetCounters(); } this_frame_batches.Clear(); if (lastActiveBatch != null) { this_frame_batches.Add(lastActiveBatch); } lastFrameBuffer = 0; viewport_stack.Clear(); ortho_stack.Clear(); masking_stack.Clear(); scissor_rect_stack.Clear(); scissor_rect_stack.Push(new RectangleI(0, 0, (int)size.X, (int)size.Y)); Viewport = RectangleI.Empty; Ortho = RectangleF.Empty; PushViewport(new RectangleI(0, 0, (int)size.X, (int)size.Y)); PushMaskingInfo(new MaskingInfo { ScreenSpaceAABB = new RectangleI(0, 0, (int)size.X, (int)size.Y), MaskingRect = new RectangleF(0, 0, size.X, size.Y), ToMaskingSpace = Matrix3.Identity, BlendRange = 1, AlphaExponent = 1, }, true); }
internal static void Reset(Vector2 size) { Trace.Assert(shader_stack.Count == 0); reset_scheduler.Update(); if (expensive_operations_queue.TryDequeue(out Action action)) { action.Invoke(); } lastBoundTexture = null; lastActiveBatch = null; lastBlendingInfo = new BlendingInfo(); lastBlendingEnabledState = null; foreach (var b in batch_reset_list) { b.ResetCounters(); } batch_reset_list.Clear(); viewport_stack.Clear(); ortho_stack.Clear(); masking_stack.Clear(); scissor_rect_stack.Clear(); frame_buffer_stack.Clear(); depth_stack.Clear(); scissor_state_stack.Clear(); BindFrameBuffer(DefaultFrameBuffer); scissor_rect_stack.Push(new RectangleI(0, 0, (int)size.X, (int)size.Y)); Viewport = RectangleI.Empty; Ortho = RectangleF.Empty; PushScissorState(true); PushViewport(new RectangleI(0, 0, (int)size.X, (int)size.Y)); PushMaskingInfo(new MaskingInfo { ScreenSpaceAABB = new RectangleI(0, 0, (int)size.X, (int)size.Y), MaskingRect = new RectangleF(0, 0, size.X, size.Y), ToMaskingSpace = Matrix3.Identity, BlendRange = 1, AlphaExponent = 1, }, true); PushDepthInfo(DepthInfo.Default); Clear(ClearInfo.Default); }
internal static void Reset(Vector2 size) { Debug.Assert(shaderStack.Count == 0); resetScheduler.Update(); lastBoundTexture = null; lastDepthTest = null; lastBlendingInfo = new BlendingInfo(); lastBlendingEnabledState = null; foreach (IVertexBatch b in thisFrameBatches) { b.ResetCounters(); } thisFrameBatches.Clear(); if (lastActiveBatch != null) { thisFrameBatches.Add(lastActiveBatch); } lastFrameBuffer = 0; viewportStack.Clear(); orthoStack.Clear(); maskingStack.Clear(); scissorRectStack.Clear(); scissorRectStack.Push(new Rectangle(0, 0, (int)size.X, (int)size.Y)); Viewport = Rectangle.Empty; Ortho = Rectangle.Empty; PushViewport(new Rectangle(0, 0, (int)size.X, (int)size.Y)); PushMaskingInfo(new MaskingInfo { ScreenSpaceAABB = new Rectangle(0, 0, (int)size.X, (int)size.Y), MaskingRect = new RectangleF(0, 0, size.X, size.Y), ToMaskingSpace = Matrix3.Identity, BlendRange = 1, AlphaExponent = 1, }, true); }