Nameless Engine
Loading...
Searching...
No Matches
ne::RenderSettings Class Reference

#include <RenderSettings.h>

Inheritance diagram for ne::RenderSettings:
ne::Serializable

Public Member Functions

void setFpsLimit (unsigned int iNewFpsLimit)
 
void setShadowQuality (ShadowQuality quality)
 
void setAntialiasingQuality (AntialiasingQuality quality)
 
void setTextureFilteringQuality (TextureFilteringQuality quality)
 
void setTextureQuality (TextureQuality quality)
 
void setRenderResolution (std::pair< unsigned int, unsigned int > resolution)
 
void setVsyncEnabled (bool bEnableVsync)
 
void setRefreshRate (std::pair< unsigned int, unsigned int > refreshRate)
 
void setGpuToUse (const std::string &sGpuName)
 
void setPreferredRenderer (RendererType preferredRenderer)
 
unsigned int getFpsLimit () const
 
std::optional< AntialiasingQuality > getAntialiasingQuality () const
 
ShadowQuality getShadowQuality () const
 
std::variant< std::optional< AntialiasingQuality >, ErrorgetMaxSupportedAntialiasingQuality () const
 
TextureFilteringQuality getTextureFilteringQuality () const
 
TextureQuality getTextureQuality () const
 
std::pair< unsigned int, unsigned int > getRenderResolution () const
 
bool isVsyncEnabled () const
 
std::pair< unsigned int, unsigned int > getRefreshRate () const
 
std::string getGpuToUse () const
 
- Public Member Functions inherited from ne::Serializable
std::optional< Errorserialize (std::filesystem::path pathToFile, bool bEnableBackup, const std::unordered_map< std::string, std::string > &customAttributes={})
 
std::variant< std::string, Errorserialize (toml::value &tomlData, const std::string &sEntityId="", const std::unordered_map< std::string, std::string > &customAttributes={}, const std::optional< std::filesystem::path > &optionalPathToFile={}, bool bEnableBackup=false)
 
std::variant< std::string, Errorserialize (toml::value &tomlData, Serializable *pOriginalObject, std::string sEntityId="", const std::unordered_map< std::string, std::string > &customAttributes={}, const std::optional< std::filesystem::path > &optionalPathToFile={}, bool bEnableBackup=false)
 
std::optional< std::pair< std::string, std::string > > getPathDeserializedFromRelativeToRes () const
 

Static Public Member Functions

static std::filesystem::path getPathToConfigurationFile ()
 
- Static Public Member Functions inherited from ne::Serializable
static std::variant< std::pair< std::set< std::string >, toml::value >, ErrorgetIdsFromFile (std::filesystem::path pathToFile)
 
static std::optional< ErrorserializeMultiple (std::filesystem::path pathToFile, std::vector< SerializableObjectInformation > vObjects, bool bEnableBackup)
 
template<typename SmartPointer , typename InnerType = typename SmartPointer::element_type>
requires std::derived_from<InnerType, Serializable> && (std::same_as<SmartPointer, sgc::GcPtr<InnerType>> || std::same_as<SmartPointer, std::unique_ptr<InnerType>>)
static std::variant< SmartPointer, Errordeserialize (const std::filesystem::path &pathToFile)
 
template<typename SmartPointer , typename InnerType = typename SmartPointer::element_type>
requires std::derived_from<InnerType, Serializable> && (std::same_as<SmartPointer, sgc::GcPtr<InnerType>> || std::same_as<SmartPointer, std::unique_ptr<InnerType>>)
static std::variant< SmartPointer, Errordeserialize (const std::filesystem::path &pathToFile, std::unordered_map< std::string, std::string > &customAttributes)
 
template<typename SmartPointer , typename InnerType = typename SmartPointer::element_type>
requires std::derived_from<InnerType, Serializable> && (std::same_as<SmartPointer, sgc::GcPtr<InnerType>> || std::same_as<SmartPointer, std::unique_ptr<InnerType>>)
static std::variant< SmartPointer, Errordeserialize (std::filesystem::path pathToFile, std::unordered_map< std::string, std::string > &customAttributes, const std::string &sEntityId)
 
template<typename SmartPointer , typename InnerType = typename SmartPointer::element_type>
requires std::derived_from<InnerType, Serializable> && (std::same_as<SmartPointer, sgc::GcPtr<InnerType>> || std::same_as<SmartPointer, std::unique_ptr<InnerType>>)
static std::variant< SmartPointer, Errordeserialize (const std::filesystem::path &pathToFile, const std::string &sEntityId)
 
template<typename SmartPointer , typename InnerType = typename SmartPointer::element_type>
requires std::same_as<SmartPointer, sgc::GcPtr<Serializable>> || std::same_as<SmartPointer, std::unique_ptr<Serializable>>
static std::variant< std::vector< DeserializedObjectInformation< SmartPointer > >, ErrordeserializeMultiple (std::filesystem::path pathToFile)
 
template<typename SmartPointer , typename InnerType = typename SmartPointer::element_type>
requires std::derived_from<InnerType, Serializable> && (std::same_as<SmartPointer, sgc::GcPtr<InnerType>> || std::same_as<SmartPointer, std::unique_ptr<InnerType>>)
static std::variant< SmartPointer, Errordeserialize (const toml::value &tomlData, std::unordered_map< std::string, std::string > &customAttributes, std::string sEntityId="", const std::optional< std::filesystem::path > &optionalPathToFile={})
 

Protected Member Functions

virtual void onAfterDeserialized () override
 
virtual void onAfterDeserialized ()
 

Private Member Functions

void setRenderer (Renderer *pRenderer)
 
std::optional< ErroronRendererInitialized ()
 
std::optional< ErrorsaveConfigurationToDisk ()
 
void notifyRendererAboutChangedSettings (bool bShadowMapSizeChanged=false)
 

Static Private Member Functions

static std::string getConfigurationFileName (bool bIncludeFileExtension)
 

Private Attributes

unsigned int iRenderResolutionWidth = 0
 
unsigned int iRenderResolutionHeight = 0
 
unsigned int iRefreshRateNumerator = 0
 
unsigned int iRefreshRateDenominator = 0
 
unsigned int iFpsLimit = 0
 
std::string sGpuToUse
 
unsigned int iRendererType = 0
 
unsigned int iShadowMapSize = static_cast<unsigned int>(ShadowQuality::HIGH)
 
unsigned int iAntialiasingSampleCount = static_cast<unsigned int>(AntialiasingQuality::HIGH)
 
unsigned int iTextureFilteringQuality = static_cast<unsigned int>(TextureFilteringQuality::HIGH)
 
unsigned int iTextureQuality = static_cast<unsigned int>(TextureQuality::VERY_HIGH)
 
bool bIsVsyncEnabled = false
 
RendererpRenderer = nullptr
 
bool bAllowSavingConfigurationToDisk = false
 

Static Private Attributes

static const char * sRenderSettingsConfigurationFileName = "render"
 

Friends

class Renderer
 

Detailed Description

Controls renderer settings.

Member Function Documentation

◆ getAntialiasingQuality()

std::optional< AntialiasingQuality > ne::RenderSettings::getAntialiasingQuality ( ) const

Returns current anti-aliasing (AA) quality.

Returns
Returns empty if AA is not supported (see getMaxSupportedAntialiasingQuality), otherwise current AA quality.

◆ getConfigurationFileName()

std::string ne::RenderSettings::getConfigurationFileName ( bool  bIncludeFileExtension)
staticprivate

Returns name of the file that is used to store setting configuration.

Parameters
bIncludeFileExtensionWhether to include file extension in the returned string or not.
Returns
Name of the file.

◆ getFpsLimit()

unsigned int ne::RenderSettings::getFpsLimit ( ) const

Returns the maximum number of FPS that is allowed to be produced in a second.

Returns
Maximum allowed FPS, 0 means disabled.

◆ getGpuToUse()

std::string ne::RenderSettings::getGpuToUse ( ) const

Returns name of the GPU to use.

Remarks
This value is taken from the renderer's settings file (see setGpuToUse) which sometimes might not represent the actual GPU being used. Instead you might be interested in Renderer::getCurrentlyUsedGpuName.
Returns
Name of the GPU specified in the settings.

◆ getMaxSupportedAntialiasingQuality()

std::variant< std::optional< AntialiasingQuality >, Error > ne::RenderSettings::getMaxSupportedAntialiasingQuality ( ) const

Returns the maximum anti-aliasing quality that can be used on the picked GPU (see Renderer::getCurrentlyUsedGpuName).

Remarks
Note that the maximum supported AA quality can differ depending on the used GPU/renderer.
Returns
Error if something went wrong, otherwise empty if AA is not supported.

◆ getPathToConfigurationFile()

std::filesystem::path ne::RenderSettings::getPathToConfigurationFile ( )
static

Returns path to the file that is used to store setting configuration.

Returns
Path to file.

◆ getRefreshRate()

std::pair< unsigned int, unsigned int > ne::RenderSettings::getRefreshRate ( ) const

Returns currently used screen's refresh rate.

Returns
Numerator and denominator of the refresh rate.

◆ getRenderResolution()

std::pair< unsigned int, unsigned int > ne::RenderSettings::getRenderResolution ( ) const

Returns currently used render resolution (width and height).

Returns
Width and height in pixels.

◆ getShadowQuality()

ShadowQuality ne::RenderSettings::getShadowQuality ( ) const

Returns current shadow quality.

Returns
Shadow quality.

◆ getTextureFilteringQuality()

TextureFilteringQuality ne::RenderSettings::getTextureFilteringQuality ( ) const

Returns currently used texture filtering quality.

Returns
Texture filtering quality.

◆ getTextureQuality()

TextureQuality ne::RenderSettings::getTextureQuality ( ) const

Returns currently used texture quality.

Returns
Texture quality.

◆ isVsyncEnabled()

bool ne::RenderSettings::isVsyncEnabled ( ) const

Tells if vertical synchronization is currently enabled or not.

Returns
Whether vertical synchronization is currently enabled or not.

◆ notifyRendererAboutChangedSettings()

void ne::RenderSettings::notifyRendererAboutChangedSettings ( bool  bShadowMapSizeChanged = false)
private

Notifies the renderer to change its internal state to match the current settings.

Remarks
Does nothing if the renderer is not initialized yet. The renderer will take values from the settings upon initialization.
Parameters
bShadowMapSizeChangedtrue if shadow map size was changed, false otherwise.

◆ onAfterDeserialized()

void ne::RenderSettings::onAfterDeserialized ( )
overrideprotectedvirtual

Called after the object was successfully deserialized. Used to execute post-deserialization logic.

Warning
If overriding you must call the parent's version of this function first (before executing your login) to execute parent's logic.

Reimplemented from ne::Serializable.

◆ onRendererInitialized()

std::optional< Error > ne::RenderSettings::onRendererInitialized ( )
private

Called by the renderer when it has finished initializing its essential entities so that the settings can query maximum supported settings and clamp the current values (if needed) and do other post-initialization checks.

Returns
Error if something went wrong.

◆ saveConfigurationToDisk()

std::optional< Error > ne::RenderSettings::saveConfigurationToDisk ( )
private

Saves the current configuration to disk.

Remarks
Does nothing if bAllowSavingConfigurationToDisk is false.
Returns
Error if something went wrong.

◆ setAntialiasingQuality()

void ne::RenderSettings::setAntialiasingQuality ( AntialiasingQuality  quality)

Sets anti-aliasing (AA) quality.

Warning
Use getMaxSupportedAntialiasingQuality to query for maximum supported AA quality, if the specified quality is not supported an error will be logged.
Parameters
qualityAA quality.

◆ setFpsLimit()

void ne::RenderSettings::setFpsLimit ( unsigned int  iNewFpsLimit)

Sets the maximum number of FPS that is allowed to be produced in a second.

Parameters
iNewFpsLimitMaximum allowed FPS, specify 0 to disable.

◆ setGpuToUse()

void ne::RenderSettings::setGpuToUse ( const std::string &  sGpuName)

Sets GPU to be used next time the engine starts.

Remarks
Use Renderer to get available GPU names.
In order for this setting to be applied the engine needs to be restarted.
Parameters
sGpuNameName of the GPU to use.

◆ setPreferredRenderer()

void ne::RenderSettings::setPreferredRenderer ( RendererType  preferredRenderer)

Changes renderer's config file setting about preferred renderer.

Remarks
In order for this setting to be applied the engine needs to be restarted.
Note that this setting will be ignored if you use Window::setPreferredRenderer.
Parameters
preferredRendererRenderer to prefer (test the first one) next time the game is started.

◆ setRefreshRate()

void ne::RenderSettings::setRefreshRate ( std::pair< unsigned int, unsigned int >  refreshRate)

Sets screen's refresh rate to use.

Remarks
In order for this setting to be applied the engine needs to be restarted.
Parameters
refreshRateNumerator and denominator of the refresh rate to use.

◆ setRenderer()

void ne::RenderSettings::setRenderer ( Renderer pRenderer)
private

Sets renderer to be used.

Remarks
It is essential to call this function to initialize the object.
Parameters
pRendererGame's renderer.

◆ setRenderResolution()

void ne::RenderSettings::setRenderResolution ( std::pair< unsigned int, unsigned int >  resolution)

Sets the width and the height of the render resolution.

Remarks
Use Renderer::getSupportedRenderResolutions to query for available render resolutions.
Parameters
resolutionWidth and height in pixels.

◆ setShadowQuality()

void ne::RenderSettings::setShadowQuality ( ShadowQuality  quality)

Sets shadow quality.

Parameters
qualityQuality to use.

◆ setTextureFilteringQuality()

void ne::RenderSettings::setTextureFilteringQuality ( TextureFilteringQuality  quality)

Sets texture filtering quality to be used.

Parameters
qualityQuality to use.

◆ setTextureQuality()

void ne::RenderSettings::setTextureQuality ( TextureQuality  quality)

Sets texture quality to be used.

Remarks
In order for this setting to be applied the engine needs to be restarted.
Parameters
qualityQuality to use.

◆ setVsyncEnabled()

void ne::RenderSettings::setVsyncEnabled ( bool  bEnableVsync)

Sets whether to enable vertical synchronization or not.

Parameters
bEnableVsyncWhether to enable vertical synchronization or not.

Member Data Documentation

◆ bAllowSavingConfigurationToDisk

bool ne::RenderSettings::bAllowSavingConfigurationToDisk = false
private

Defines whether or not changes to render settings trigger saving on disk.

Remarks
Disabled by default as render settings can be modified by a renderer during its initialization (some settings getting clamped/fixed due to render/hardware capabilities) and because a renderer can fail to initialize (for example if the hardware does not support it) we don't want any of these modifications to be saved. Once a renderer was initialized the base Renderer class will enable saving on disk and will trigger a manual resave to apply possibly fixed/clamped settings.

◆ bIsVsyncEnabled

bool ne::RenderSettings::bIsVsyncEnabled = false
private

Whether VSync is enabled or not.

◆ iAntialiasingSampleCount

unsigned int ne::RenderSettings::iAntialiasingSampleCount = static_cast<unsigned int>(AntialiasingQuality::HIGH)
private

Sample count of AA.

◆ iFpsLimit

unsigned int ne::RenderSettings::iFpsLimit = 0
private

The maximum number of FPS that is allowed to be produced in a second.

Remarks
Disabled if zero.

◆ iRefreshRateDenominator

unsigned int ne::RenderSettings::iRefreshRateDenominator = 0
private

Denominator of screen's refresh rate.

◆ iRefreshRateNumerator

unsigned int ne::RenderSettings::iRefreshRateNumerator = 0
private

Numerator of screen's refresh rate.

◆ iRendererType

unsigned int ne::RenderSettings::iRendererType = 0
private

Stored used type of the renderer (DirectX/Vulkan/etc.).

Remarks
Can be changed from the config file to change preferred renderer.

◆ iRenderResolutionHeight

unsigned int ne::RenderSettings::iRenderResolutionHeight = 0
private

Height of the back buffer.

◆ iRenderResolutionWidth

unsigned int ne::RenderSettings::iRenderResolutionWidth = 0
private

Width of the back buffer.

◆ iShadowMapSize

unsigned int ne::RenderSettings::iShadowMapSize = static_cast<unsigned int>(ShadowQuality::HIGH)
private

Shadow map resolution in pixels.

◆ iTextureFilteringQuality

unsigned int ne::RenderSettings::iTextureFilteringQuality = static_cast<unsigned int>(TextureFilteringQuality::HIGH)
private

Texture filtering mode.

◆ iTextureQuality

unsigned int ne::RenderSettings::iTextureQuality = static_cast<unsigned int>(TextureQuality::VERY_HIGH)
private

Defines how much mipmaps we will skip when loading textures from disk.

◆ pRenderer

Renderer* ne::RenderSettings::pRenderer = nullptr
private

Do not delete (free) this pointer. Game's renderer.

◆ sGpuToUse

std::string ne::RenderSettings::sGpuToUse
private

Name of the GPU to use.

◆ sRenderSettingsConfigurationFileName

const char* ne::RenderSettings::sRenderSettingsConfigurationFileName = "render"
inlinestaticprivate

Name of the file we use to store render settings.


The documentation for this class was generated from the following files: