Quantcast
Channel: Community | MonoGame - Latest topics
Viewing all articles
Browse latest Browse all 6821

DrawUserIndexedPrimitives has 1px offset

$
0
0

@EnemyArea wrote:

Hey guys,

I have some stange issue with my xna port. In XNA I used a litte lib to draw lines into my editor. In Monogame this lines have a strange offset of one pixel. Here a some screenshots:

Monogame: https://www.dropbox.com/s/ixv9qviiwu85niy/monogamewrong.png?dl=0
XNA: https://www.dropbox.com/s/ixv9qviiwu85niy/monogamewrong.png?dl=0

Platform is windows 10 with DX and current monogame nuget build

The code is very short:

this.effect = new BasicEffect(this.GraphicsDevice);
this.effect.VertexColorEnabled = true;
this.effect.View = Matrix.Identity;// Matrix.CreateLookAt(new Vector3(0f, 0f, 1f), Vector3.Zero, Vector3.Up);
this.effect.Projection = Matrix.CreateOrthographicOffCenter (0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, 0, 0, 1);

protected override void Draw(GameTime gameTime)
{
    this.GraphicsDevice.Clear(Color.CornflowerBlue);
                
    short[] indexData = { 0, 1 };
    VertexPositionColor[] vertexData =
    {
    new VertexPositionColor(new Vector3(10, 10, 0), Color.Red),
    new VertexPositionColor(new Vector3(100, 10, 0), Color.Red)
    };

    // TODO: Add your drawing code here
    this.effect.CurrentTechnique.Passes[0].Apply();
    this.GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.LineList, vertexData, 0, 2, indexData, 0, 1);

    base.Draw(gameTime);
}

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 6821

Trending Articles