Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6471183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:11:42+00:00 2026-05-25T06:11:42+00:00

I am using XNA with SpriteBatch and custom drawn verticies in parallel. The goal

  • 0

I am using XNA with SpriteBatch and custom drawn verticies in parallel. The goal is to have the same coordinate system for both techniques.
That means I need a projection matrix that maps to screen coordinates: (0, 0) is in the top left screen corner, while width and height are determined by the screen resolution.

Matrix.CreateOrthographicOffCenter(0, width, 0, height, -1, 1);

Works well but has the center in the bottom-left corner.

Matrix.CreateOrthographicOffCenter(0, width, height, 0, -1, 1);

Does not display anything at all.

Trying to combine the first projection matrix with a translation and scaling y by -1 does not display anything at all either. Scaling by positive values works well, translation too. But as soon as I scale by a negative value I do not get any output at all.

Any ideas?

PS: For testing purpose I am drawing vertices far beyond the screen coordinates, so I would at least see something if there is some error in translation.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:11:42+00:00Added an answer on May 25, 2026 at 6:11 am

    I use this code to initialize my 2D camera for drawing lines, and use a basic custom effect to draw.

        Vector2 center;
        center.X = Game.GraphicsDevice.Viewport.Width * 0.5f;
        center.Y = Game.GraphicsDevice.Viewport.Height * 0.5f;
    
        Matrix View = Matrix.CreateLookAt( new Vector3( center, 0 ), new Vector3( center, 1 ), new Vector3( 0, -1, 0 ) );
        Matrix Projection = Matrix.CreateOrthographic( center.X * 2, center.Y * 2, -0.5f, 1 );
    

    Effect

    uniform float4x4 xWorld;
    uniform float4x4 xViewProjection;
    
    void VS_Basico(in float4 inPos : POSITION,  in float4 inColor: COLOR0,  out float4      outPos: POSITION,    out float4 outColor:COLOR0 )
    {
        float4 tmp = mul (inPos, xWorld);
        outPos = mul (tmp, xViewProjection);
        outColor = inColor; 
    }
    
    technique Lines
    {
        pass Pass0
        {   
            VertexShader = compile vs_2_0 VS_Basico();
            FILLMODE = SOLID;
            CULLMODE = NONE;        
        }  
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to draw a rectangle shape in XNA using spritebatch. I have
Using online interfaces to a version control system is a nice way to have
using System; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; namespace proj { public class game
We've been working on a digital drawing system using XNA for display and using
I've been practicing certain techniques in XNA and lately came across an issue that's
I've begun writing a game using XNA Framework and have hit some simple problem
I have sucessfully used Farseer to develop one of my game using XNA .
Using XNA, I'm trying to make an adventure game engine that lets you make
I'm using XNA and creating a bunch of forms that roll their own 'game
Using XNA 4.0, I am currently playing songs from the user's PC/XBox360 using the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.