I’m trying to get the native resolution of my Monitor. I stumble upon Rama’s tutorial but I don’t seems to understand it well.
This is the function he provide
static FORCEINLINE void GetDisplayAdapterScreenResolutions(FScreenResolutionArray& Resolutions)
{
if (RHIGetAvailableResolutions(Resolutions, false))
{
for (const FScreenResolutionRHI& EachResolution : Resolutions)
{
UE_LOG(YourLog, Warning, TEXT("DefaultAdapter - %4d x %4d @ %d"),
EachResolution.Width, EachResolution.Height, EachResolution.RefreshRate);
}
}
else
{
UE_LOG(YourLog, Error, TEXT("Screen Resolutions could not be obtained"));
}
}
I’m trying to implement it on my game but I’m sort of loss
.H File
#pragma once
#include "RHI.h"
#include "Components/ActorComponent.h"
#include "PositionReport.generated.h"
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class BUILDINGESCAPE_API UPositionReport : public UActorComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UPositionReport();
// Called when the game starts
virtual void BeginPlay() override;
// Called every frame
virtual void TickComponent( float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction ) override;
//Grab Screen Resolution
void GetDisplayAdapterScreenResolutions(FScreenResolutionArray* Resolutions);
};
.CPP file
void GetDisplayAdapterScreenResolutions(FScreenResolutionArray& Resolutions)
{
if (RHIGetAvailableResolutions(Resolutions, false))
{
for (const FScreenResolutionRHI& EachResolution : Resolutions)
{
UE_LOG(LogTemp, Warning, TEXT("DefaultAdapter - %4d x %4d @ %d"),
EachResolution.Width, EachResolution.Height, EachResolution.RefreshRate);
}
}
else
{
UE_LOG(LogTemp, Error, TEXT("Screen Resolutions could not be obtained"));
}
}
If I were to call the GetDisplayAdapterScreenResolution function won’t I need to initialize Resolutions?