Skip to main content
title
Link
Jelle
  • 331
  • 1
  • 14

resolution problems (with scale) scaling problem with some resolutions

New example
Source Link
Jelle
  • 331
  • 1
  • 14

example: enter image description here

summary: Everything looks/works fine with scaleSize 2, but doesn't with 1.

(NOTE -> edit: Also, the collisionscaling doesn't work when the scaleSize is 1, although scaleSize has nothing to do with the collision process (only the size of the collision boxes, but they are drawn so I see that there's nothing wrong with them), that's another question so I will post this as a separate onewell.)

summary: Everything looks/works fine with scaleSize 2, but doesn't with 1.

(NOTE: Also, the collision doesn't work when the scaleSize is 1, although scaleSize has nothing to do with the collision process (only the size of the collision boxes, but they are drawn so I see that there's nothing wrong with them), that's another question so I will post this as a separate one.)

example: enter image description here

summary: Everything looks/works fine with scaleSize 2, but doesn't with 1. -> edit: scaling doesn't work well.

Code
Source Link
Jelle
  • 331
  • 1
  • 14
int currentWidth;
int currentHeight;
int preferredWidth;
int preferredHeight;
float scaleWidth;
float scaleHeight;

public Matrix scale;
GameWindow Window;
ContentManager Content;
GraphicsDeviceManager Graphics;
GraphicsDevice GraphicsDevice;

public ScreenSize(GraphicsDevice graphicsDevice, GraphicsDeviceManager graphics, ContentManager content, GameWindow window)
{
    Window = window;
    Content = content;
    Graphics = graphics;
    GraphicsDevice = graphicsDevice;
    LoadContent();
}

public void LoadContent()
{
    Graphics.PreferredBackBufferWidth = 1920;
    Graphics.PreferredBackBufferHeight = 1080;

    currentWidth = GraphicsDevice.Viewport.Width;
    currentHeight = GraphicsDevice.Viewport.Height;

    preferredWidth = 800;
    preferredHeight = 450;

    scaleWidth = currentWidth / preferredWidth;
    scaleHeight = currentHeight / preferredHeight;

    scale = Matrix.CreateScale(scaleWidth, scaleHeight, 1.0f);

    this.Graphics.IsFullScreen = false;

    Graphics.ApplyChanges();
}
public void LoadContent()
{
    Graphics.PreferredBackBufferWidth = 1920;
    Graphics.PreferredBackBufferHeight = 1080;

    currentWidth = GraphicsDevice.Viewport.Width;
    currentHeight = GraphicsDevice.Viewport.Height;

    preferredWidth = 800;
    preferredHeight = 450;

    scaleWidth = currentWidth / preferredWidth;
    scaleHeight = currentHeight / preferredHeight;

    scale = Matrix.CreateScale(scaleWidth, scaleHeight, 1.0f);

    this.Graphics.IsFullScreen = false;

    Graphics.ApplyChanges();
}
int currentWidth;
int currentHeight;
int preferredWidth;
int preferredHeight;
float scaleWidth;
float scaleHeight;

public Matrix scale;
GameWindow Window;
ContentManager Content;
GraphicsDeviceManager Graphics;
GraphicsDevice GraphicsDevice;

public ScreenSize(GraphicsDevice graphicsDevice, GraphicsDeviceManager graphics, ContentManager content, GameWindow window)
{
    Window = window;
    Content = content;
    Graphics = graphics;
    GraphicsDevice = graphicsDevice;
    LoadContent();
}

public void LoadContent()
{
    Graphics.PreferredBackBufferWidth = 1920;
    Graphics.PreferredBackBufferHeight = 1080;

    currentWidth = GraphicsDevice.Viewport.Width;
    currentHeight = GraphicsDevice.Viewport.Height;

    preferredWidth = 800;
    preferredHeight = 450;

    scaleWidth = currentWidth / preferredWidth;
    scaleHeight = currentHeight / preferredHeight;

    scale = Matrix.CreateScale(scaleWidth, scaleHeight, 1.0f);

    this.Graphics.IsFullScreen = false;

    Graphics.ApplyChanges();
}
added 140 characters in body
Source Link
Jelle
  • 331
  • 1
  • 14
Loading
edited title
Link
Jelle
  • 331
  • 1
  • 14
Loading
Source Link
Jelle
  • 331
  • 1
  • 14
Loading