/// <summary> /// Draws the geometry texture. /// </summary> /// <param name="buffer">The buffer.</param> /// <param name="position">The position.</param> /// <param name="texture">The texture.</param> /// <param name="opacity">The opacity.</param> /// <param name="depth">The depth.</param> public override void DrawGeometryTexture(GeometryBuffer buffer, PointF position, TextureBase texture, float opacity, float depth) { XenkoGeometryBuffer paradoxBuffer = buffer as XenkoGeometryBuffer; Texture2D nativeTexture = texture.GetNativeTexture() as Texture2D; paradoxBuffer.EffectInstance.Parameters.Set(SpriteEffectKeys.Color, Color.White * opacity); paradoxBuffer.EffectInstance.Parameters.Set(TexturingKeys.Texture0, nativeTexture); DrawGeometry(buffer, position, depth); }
/// <summary> /// Draws the color of the geometry. /// </summary> /// <param name="buffer">The buffer.</param> /// <param name="position">The position.</param> /// <param name="color">The color.</param> /// <param name="opacity">The opacity.</param> /// <param name="depth">The depth.</param> public override void DrawGeometryColor(GeometryBuffer buffer, PointF position, ColorW color, float opacity, float depth) { XenkoGeometryBuffer xenkoBuffer = buffer as XenkoGeometryBuffer; Color4 nativeColor = new Color4(color.PackedValue) * opacity; xenkoBuffer.EffectInstance.Parameters.Set(SpriteEffectKeys.Color, nativeColor); xenkoBuffer.EffectInstance.Parameters.Set(TexturingKeys.Texture0, GraphicsDevice.GetSharedWhiteTexture()); DrawGeometry(buffer, position, depth); }
private void DrawGeometry(GeometryBuffer buffer, PointF position, float depth) { if (isSpriteRenderInProgress) { spriteBatch.End(); } Matrix world = Matrix.Translation(position.X, position.Y, 0); Matrix worldView; Matrix.MultiplyTo(ref world, ref view, out worldView); Matrix worldViewProjection; UpdateProjection(graphicsContext.CommandList); Matrix.MultiplyTo(ref worldView, ref projection, out worldViewProjection); XenkoGeometryBuffer paradoxBuffer = buffer as XenkoGeometryBuffer; paradoxBuffer.EffectInstance.Parameters.Set(SpriteBaseKeys.MatrixTransform, worldViewProjection); if (isClipped) { geometryPipelineState.State.RasterizerState = scissorRasterizerStateDescription; } else { geometryPipelineState.State.RasterizerState = geometryRasterizerStateDescription; } switch (buffer.PrimitiveType) { case GeometryPrimitiveType.TriangleList: geometryPipelineState.State.PrimitiveType = PrimitiveType.TriangleList; break; case GeometryPrimitiveType.TriangleStrip: geometryPipelineState.State.PrimitiveType = PrimitiveType.TriangleStrip; break; case GeometryPrimitiveType.LineList: geometryPipelineState.State.PrimitiveType = PrimitiveType.LineList; break; case GeometryPrimitiveType.LineStrip: geometryPipelineState.State.PrimitiveType = PrimitiveType.LineStrip; break; default: break; } geometryPipelineState.State.RootSignature = paradoxBuffer.EffectInstance.RootSignature; geometryPipelineState.State.EffectBytecode = paradoxBuffer.EffectInstance.Effect.Bytecode; geometryPipelineState.State.InputElements = paradoxBuffer.InputElementDescriptions; geometryPipelineState.State.Output.CaptureState(graphicsContext.CommandList); geometryPipelineState.Update(); graphicsContext.CommandList.SetPipelineState(geometryPipelineState.CurrentState); paradoxBuffer.EffectInstance.Apply(graphicsContext); graphicsContext.CommandList.SetVertexBuffer(0, paradoxBuffer.VertexBufferBinding.Buffer, 0, paradoxBuffer.VertexBufferBinding.Stride); graphicsContext.CommandList.Draw(paradoxBuffer.PrimitiveCount); if (isSpriteRenderInProgress) { if (isClipped) { spriteBatch.Begin(graphicsContext, SpriteSortMode.Deferred, depthStencilState: DepthStencilStates.None, rasterizerState: scissorRasterizerStateDescription, effect: currentActiveEffect); } else { spriteBatch.Begin(graphicsContext, SpriteSortMode.Deferred, depthStencilState: DepthStencilStates.None, effect: currentActiveEffect); } } }