The Camera Settings in Glue allows you to set your Camera and resolution project-wide.
To access the settings click the camera icon.
Clicking the Settings-> Camera Settings menu item brings up the same menu as well.
This will bring up the camera window.
Camera and Resolution Variables
The “Is2D” property will control whether the camera is in 2D mode or 3D mode. In 2D mode, your screen will use pixel coordinates. In other words, if your screen resolution is 800 wide, then an object with 800 width will take up the entire screen.
If Is2D is false, then the Camera will be in 3D mode, and the size of objects depends on the Z of the camera.
Controls the width of the game window. Increasing this value will make the game window wider and (by default) will display more of the game world.
Controls the height of the game window. Increasing this value will make the game window taller and (by default) will display more of the game world.
Fixed Aspect Ratio
If checked, the game will maintain a fixed aspect ratio as specified by the horizontal and vertical ratio values.
If the game window is does not match the desired aspect ratio, the game will be letterboxed or pillarboxed.
For example, consider these variables:
- Width = 400
- Height = 400
- Fixed Aspect Ratio = true
- Aspect Ratio = 16 : 9
Whether the game runs in full screen. If unchecked the game runs in windowed mode. Note that fullscreen is “borderless fullscreen” which means it does not change the display adaptor’s actual resolution. This means that alt-tabbing will be much faster and textures will not get unloaded when the game loses focus.
Allow Window Resizing
Whether the window can be resized by dragging the edges. If false, the window cannot be resized by the user by grabbing the edges.
A percentage value used to make the window larger or smaller. A larger value will make the window larger, stretching the contents of the game window. For example, a 200×200 game window at 300 scale will draw at 600×600, with each object in the game being three times as wide and three times as tall.
Controls the behavior of the contents of the game window when the game window is resized.
If set to Preserve (Stretch) Visible Area, stretching the game window will not allow the user to see more of the game world – instead objects will become larger as the window is stretched.
If set to Increase Visible Area, stretching the game window will allow the user to see more of the game world – objects will remain the same size.
Changing Resolution and Camera Values in Initialize Code
Glue’s camera window provides an easy way to set the default behavior of your game, and it can be used to change camera settings during development. Many games allow the user to customize the window (such as by setting if the game runs in full screen), and the resolution information is then saved in a configuration file.
The generated code for camera settings allows changing the Glue-assigned values prior to the window being created.
To modify the settings in initialize:
- Open your project in Visual Studio
- Open Game1.cs
- Find the following line of code in the Game1’s
- Add code to assign values to CameraSetup.Data before the call to SetupCamera
For example, the following code could be used to set the values, assuming configurationData is a valid object:
protected override void Initialize()
var bounds = UIKit.UIScreen.MainScreen.Bounds;
var nativeScale = UIKit.UIScreen.MainScreen.Scale;
var screenWidth = (int)(bounds.Width * nativeScale);
var screenHeight = (int)(bounds.Height * nativeScale);
graphics.PreferredBackBufferWidth = screenWidth;
graphics.PreferredBackBufferHeight = screenHeight;
// assuming there is configuration data to load
var configurationData = LoadConfigurationData();
// assign the values before SetupCamera is called:
CameraSetup.Data.ResolutionWidth = configurationData.ResolutionWidth;
CameraSetup.Data.ResolutionHeight = configurationData.ResolutionHeight;
CameraSetup.Data.IsFullScreen = configurationData.IsFullScreen;
Changing Resolution and Camera Values After Initialize
Camera and resolution values can be changed after initialize. Some games provide control over the resolution in a settings window. The generated CameraSetup object can be modified at any point in the game’s execution.
For example, the following code could be used to adjust the resolution and camera settings when the user presses the space bar:
// In any screen:
void CustomActivity(bool firstTimeCalled)
var keyboard = InputManager.Keyboard;
CameraSetup.Data.ResolutionWidth = 500;
CameraSetup.Data.ResolutionHeight = 300;
CameraSetup.Data.AspectRatio = 3;
CameraSetup.Data.AllowWidowResizing = false;
CameraSetup.Data.Scale = 300;
CameraSetup.Data.IsFullScreen = true;
Notice that the above code calls both ResetWindow and ResetCamera . Typically modifications to the CameraSetup.Data require both to be called. The two functions are separated because Glue generated code calls ResetCamera inbetween each screen.