Jump to content
  • Advertisement
Sign in to follow this  
Thomas Wiborg

Mouse pointer out of applicationresolution when running fullscreen

This topic is 1147 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Im having some problems when running my application at fullscreen.

My game is currently running at 800x600 resolution. When im in windowed mode my mouse pos x and y is 0.0 upper left corner and 800.600 bottom right.
If im running my game in fullscreen its still 0.0 in upper left corner but at bottom right it changes to 1920x1080.
My mouse then follows the resolution of my screen and not the applications resolution.


Is there a way to fix this, maybe a workaround or something like that?

Here are my constructor for Game1.cs and Initialize

  public Game1()
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            Window.IsBorderless = true;

            graphics.PreferredBackBufferWidth = screenWidth;
            graphics.PreferredBackBufferHeight = screenHeight;

            graphics.IsFullScreen = true;

        protected override void Initialize()
            Mouse.SetPosition(0, 0);

            IsMouseVisible = true;

            currentGameState = GameState.MainMenu;

Share this post

Link to post
Share on other sites

If people wonder how i managed it.... I made this method.
Now my mousePos is scaling after the resolution. Works great.

public Vector2 ReturnNewMousePosScale(float defaultComputerResolutionWidth, float defaultComputerResolutionHeight, float gameScreenWidth, float gameScreenHeight, Vector2 defaultMousePos)
            Matrix ScaleMatrix = Matrix.CreateScale(defaultComputerResolutionWidth / gameScreenWidth, defaultComputerResolutionHeight / gameScreenHeight, 0.0F);

            Vector2 Scale = new Vector2(ScaleMatrix.M11, ScaleMatrix.M22);

            defaultMousePos = new Vector2(getMouseState.X, getMouseState.Y);

            return defaultMousePos = defaultMousePos / Scale;

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!