none
XNA -> Spritebatch+drawuserindexedprimitives RRS feed

  • Question

  • I'm trying to put a cursor on my program (where my actual cursor is), but that messes up my stuff in the background:

    Hmmm... can't post images, i'll try to describe:

    without spritbatch (i mean comment out) the terrain has its appropriate texture placed right with proper lighting.

    with spritbatch the terrain is on a single color (without the texture) or the texture is really messed up (the corners do have something there?), proper lighting , and the cursor appears alright.

    Here's my main draw code:

    protected override void Draw(GameTime gameTime)
            {
                GraphicsDevice.Clear(Color.White);
    
                Ground.Draw(GraphicsDevice,camera);
    
                spriteBatch.Begin();
                spriteBatch.Draw(cursor, cursorpos, Color.White);
                spriteBatch.End();
    
                base.Draw(gameTime);
            }

    "Ground" is my terrain, heres it's draw:

    public void Draw(GraphicsDevice device, ClsCamera view)
            {
                effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, device.Viewport.AspectRatio, 1.0f, 300.0f);
                effect.TextureEnabled = true;
                effect.Texture = texture;
                effect.VertexColorEnabled = false;
    
                effect.World = worldMatrix;
                effect.View = view.view;
    
                effect.CurrentTechnique.Passes[0].Apply();
                device.DrawUserIndexedPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList, vertices, 0, vertices.Length, indices, 0, indices.Length / 3);
            }

    "effect" is initialized before any draw.

    Any guesses on what went wrong? Thanks in advance.

    P.S. I'm using Monogame for Visual Studios.

    Wednesday, October 25, 2017 2:59 PM

All replies

  • Hi Gatinha123,

    Thank you for posting here.

    According to your question is more related to Monogame for Visual Studios, you could post a new thread in GitHub.

    https://github.com/MonoGame/MonoGame/issues

    This forum discusses and ask the C# programming language, IDE, libraries, samples and tools. If you have some grammar or code errors, please feel free to contact us. We will try our best to give you a solution.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, October 27, 2017 5:36 AM
  • Thank you, I will try that and close this issue once i get an answer on either sites.
    Tuesday, October 31, 2017 3:35 PM