private void ClipSprite <TSurface, TSource>(string spriteName, string spritesheet, Rectangle spriteBounds, IGraphicsContext <TSurface, TSource> graphicsContext, ISpriteManager <TSource> spriteManager)
        {
            TSurface target = graphicsContext.CreateTarget(spriteBounds.Width, spriteBounds.Height);

            graphicsContext.Draw(spriteManager[spritesheet], target, new Rectangle(0, 0, spriteBounds.Width, spriteBounds.Height), spriteBounds);
            spriteManager[spriteName] = graphicsContext.TargetToSource(target);
        }
Exemple #2
0
 public void Draw(TSurface subject, Rectangle destination) => GraphicsContext.Draw(subject, Surface, destination);
 public virtual void Draw(TSurface subject, Rectangle destination, Rectangle?source = null, DrawInfo info = default(DrawInfo)) => GraphicsContext.Draw(subject, Surface, destination, source, info);
Exemple #4
0
        public void Draw( World2 transform, IGraphicsContext graphicsContext = null )
        {
            if ( graphicsContext == null )
                graphicsContext = Core.GraphicsDevice.ImmediateContext;

            Matrix4x4 matrix;
            Effect.Use ( graphicsContext );
            //Effect.SetTextures ( textureArgument );
            graphicsContext.SetSampler ( 0, textureArgument );
            projectionMatrix.OffCenterSize = graphicsContext.CurrentRenderBuffer.Size ();
            projectionMatrix.GetMatrix ( out matrix );
            Effect.SetUniform<Matrix4x4> ( "projectionMatrix", ref matrix );
            transform.GetMatrix ( out matrix );
            Effect.SetUniform<Matrix4x4> ( "worldMatrix", ref matrix );
            graphicsContext.InputAssembler = new InputAssembler ( vertexBuffer, vertexDeclaration, PrimitiveType.TriangleStrip );
            graphicsContext.Draw ( 0, 2 );
        }