r.SetRes
r.SetRes
#Overview
name: r.SetRes
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Set the display resolution for the current game view. Has no effect in the editor.\ne.g. 1280x720w for windowed\n 1920x1080f for fullscreen\n 1920x1080wf for windowed fullscreen\n
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.SetRes is to set the display resolution for the current game view. It is a console variable used to control the screen or window resolution in Unreal Engine 5.
This setting variable is primarily used by the rendering system and the application’s window management. Based on the callsites, it is utilized by the Engine module and the ApplicationCore module.
The value of this variable is set through the console or configuration files. It accepts a string in the format “WidthxHeightw” for windowed mode, “WidthxHeightf” for fullscreen, or “WidthxHeightwf” for windowed fullscreen.
The r.SetRes variable interacts with other resolution-related variables and functions in the engine. For example, it’s used in conjunction with the ParseResolution function to extract the width and height values.
Developers should be aware that:
- This variable has no effect in the editor, only in the game view.
- The resolution string must be in the correct format to be properly parsed.
- Changes to this variable at runtime may require additional handling to update the game window or viewport.
Best practices when using this variable include:
- Use it for setting default resolutions in configuration files.
- Provide user-friendly options in the game settings to modify this value.
- Ensure that the game UI and rendering pipeline can handle resolution changes gracefully.
- Validate the input string to prevent parsing errors.
- Consider performance implications when allowing users to set very high resolutions.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UnrealEngine.cpp:408
Scope: file
Source code excerpt:
static FAutoConsoleVariable CVarSystemResolution(
TEXT("r.SetRes"),
TEXT("1280x720w"),
TEXT("Set the display resolution for the current game view. Has no effect in the editor.\n")
TEXT("e.g. 1280x720w for windowed\n")
TEXT(" 1920x1080f for fullscreen\n")
TEXT(" 1920x1080wf for windowed fullscreen\n")
);
#Loc: <Workspace>/Engine/Source/Runtime/ApplicationCore/Private/Null/NullApplication.cpp:101
Scope (from outer to inner):
file
function FNullApplication::FNullApplication
Source code excerpt:
// Default work area to the config res
static const IConsoleVariable* CVarSystemResolution = IConsoleManager::Get().FindConsoleVariable(TEXT("r.SetRes"));
FString ResolutionStr = CVarSystemResolution->GetString();
uint32 ResolutionX, ResolutionY = 0;
if(ParseResolution(*ResolutionStr, ResolutionX, ResolutionY))
{
WorkArea.Right = ResolutionX;
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/Misc/Parse.cpp:187
Scope (from outer to inner):
file
function bool ConsoleCommandLibrary_DumpLibraryHTML
Source code excerpt:
}
//{name: "r.SetRes", help:"To change the screen/window resolution."},
FString DataLine = FString::Printf(TEXT("{name: \"%s\", help:\"%s\", type:\"%s\"},\r\n"), *Name, *Help, ElementType);
AllData += DataLine;
}
else
{