PURE API 0.5
PR00F's Ultimate Rendering Engine full documentation
Loading...
Searching...
No Matches
PureScreenImpl Class Reference

Detailed Description

Definition at line 25 of file PureScreen.cpp.

+ Inheritance diagram for PureScreenImpl:

Public Member Functions

virtual ~PureScreenImpl ()
 
CConsole & getConsole () const
 Returns access to console preset with logger module name as this class.
 
TPureBool applyDisplaySettings (HDC dc, TPURE_SCREEN_PF pixelFormat=PURE_SCREEN_PF_SIMPLE)
 Applies the set settings and the appropriate pixel format for the given HDC.
 
void ResetDisplaySettings ()
 Resets the original display settings.
 
TPureBool isInitialized () const
 Gets whether display settings are applied.
 
TPureUInt getResWidth () const
 Gets the horizontal display resolution.
 
TPureUInt getResHeight () const
 Gets the vertical display resolution.
 
void SetResolution (TPureUInt w, TPureUInt h)
 Stores the given display resolution.
 
TPureBool isFullScreened () const
 Gets whether we wanted fullscreen or not.
 
void SetFullScreened (TPureBool fs)
 Stores whether we want fullscreen mode or not.
 
TPureUInt getFreq () const
 Gets the stored display refresh rate.
 
void SetFreq (TPureUInt f)
 Stores the needed display refresh rate.
 
TPureInt getColorBits () const
 Gets the stored display color depth.
 
void SetColorBits (TPureInt c)
 Stores the needed display color depth.
 
TPureInt getDepthBits () const
 Gets the needed Z-buffer depth.
 
void SetDepthBits (TPureInt d)
 Stores the needed Z-Buffer depth.
 
TPureInt getStencilBits () const
 Gets the stored Stencil Buffer depth.
 
void SetStencilBits (TPureInt s)
 Stores the needed Stencil Buffer depth.
 
TPureBool isScreensaverEnabled () const
 Gets whether the screensaver is allowed or not while the engine is running.
 
void SetScreensaverEnabled (TPureBool state)
 Sets whether the screensaver is allowed or not while the engine is running.
 
TPureBool isMonitorPowersaveEnabled () const
 Gets whether monitor power saving is allowed or not while the engine is running.
 
void SetMonitorPowersaveEnabled (TPureBool state)
 Sets whether monitor power saving is allowed or not while the engine is running.
 
TPureBool isStandbyEnabled () const
 Gets whether computer standy is allowed or not while the engine is running.
 
void SetStandbyEnabled (TPureBool state)
 Sets whether computer standy is allowed or not while the engine is running.
 
TPureBool isFSAAready () const
 Gets whether the engine is ready to use FSAA.
 
TPureInt getFSAAlevel () const
 Gets the actual FSAA-level.
 
void SetFSAAlevel (TPureInt level)
 Sets the needed FSAA-level.
 
TPureBool isVSyncEnabled () const
 Gets whether VSync is enabled or not.
 
TPureBool setVSyncEnabled (TPureBool state)
 Sets the state of VSync.
 
- Public Member Functions inherited from PureScreen

Static Public Member Functions

static const char * getLoggerModuleName ()
 Returns the logger module name of this class.
 
- Static Public Member Functions inherited from PureScreen
static PureScreencreateAndGet ()
 Creates and gets the singleton instance.
 
static const char * getLoggerModuleName ()
 Returns the logger module name of this class.
 

Private Member Functions

 PureScreenImpl ()
 Fills up members with default values.
 
 PureScreenImpl (const PureScreenImpl &)
 
PureScreenImploperator= (const PureScreenImpl &)
 
void FindSimplePixelFormat (HDC dc)
 Finds a pixel format for the given HDC based on the previously set values like color bits.
 
void FindAdvancedPixelFormat (HDC dc)
 Finds a pixel format for the given HDC based on the previously set values like color bits.
 
void ReadAdvancedPixelFormatInfo (HDC dc, int iAppliedPixelFormat)
 Reads advanced pixel format about the given pixel format using wglGetPixelFormatAttrib...().
 
TPureBool applyPixelFormat (HDC dc, int iPixelFormat, PIXELFORMATDESCRIPTOR *pfd)
 Sets the given pixel format for the given HDC.
 
void ReadCurrentDisplaySettings (TPureUInt &nWidth, TPureUInt &nHeight, TPureInt &nCDepth, TPureUInt &nRefRate)
 Reads and stores current display resolution width, height, color depth and refresh rate.
 
TPureUInt findMaximumRefreshRate (TPureUInt nWidth, TPureUInt nHeight, TPureInt nCDepth)
 Finds the maximum available refresh rate for the given display resolution width, height and color depth.
 
bool switchToFullscreenMode (TPureUInt nWidth, TPureUInt nHeight, TPureInt nCDepth, TPureUInt nRefRate)
 Switches display mode to fullscreen at the given resolution width, height, color depth with the given refresh rate.
 

Private Attributes

PureSharedSettingssharedSettings
 Pointer to shared settings.
 
PIXELFORMATDESCRIPTOR m_pfd
 Pixelformat descriptor.
 
TPureBool bDisplaySettingsApplied
 Are the set display settings applied?
 
TPureBool bFullScreen
 Are we in fullscreen mode?
 
int iSimplePixelFormat
 Best pixel format found by Win32.
 
int m_iAdvancedPixelFormat
 Best pixel format found by OpenGL.
 
int m_iAppliedPixelFormat
 Currently applied pixel format, iSimple or iAdvanced.
 
TPureUInt nResX
 Horizontal screen resolution.
 
TPureUInt nResY
 Vertical screen resolution.
 
TPureUInt nRefreshRate
 Screen refresh rate.
 
TPureInt nBitsColor
 Screen color depth.
 
TPureInt nBitsDepth
 ZBuffer depth (32/24/16).
 
TPureInt nBitsStencil
 Stencil buffer depth (8/0).
 
TPureBool bFSAA_ready
 Is FSAA initialized?
 
GLint iFSAA_state
 Current FSAA-level (0x/1x/2x/3x/...).
 
GLint iFSAA_req
 Requested FSAA-level.
 
TPureBool bVSyncState
 Is VSync enabled?
 

Friends

class PureScreen
 

Additional Inherited Members

- Static Public Attributes inherited from PureScreen
static constexpr char * CVAR_GFX_VSYNC = "gfx_vsync"
 

Constructor & Destructor Documentation

◆ ~PureScreenImpl()

PureScreenImpl::~PureScreenImpl ( )
virtual

Definition at line 132 of file PureScreen.cpp.

◆ PureScreenImpl() [1/2]

PureScreenImpl::PureScreenImpl ( )
private

Fills up members with default values.

Definition at line 469 of file PureScreen.cpp.

◆ PureScreenImpl() [2/2]

PureScreenImpl::PureScreenImpl ( const PureScreenImpl & )
private

Definition at line 491 of file PureScreen.cpp.

Member Function Documentation

◆ applyDisplaySettings()

TPureBool PureScreenImpl::applyDisplaySettings ( HDC dc,
TPURE_SCREEN_PF pixelFormat = PURE_SCREEN_PF_SIMPLE )
virtual

Applies the set settings and the appropriate pixel format for the given HDC.

The following functions must be called before this:

  • SetResolution()
  • SetColorBits()
  • SetDepthBits() The result of not calling any of the mentioned functions is the function has no effect. Changes screen resolution, color depth and refresh rate ONLY IF fullscreen mode is requested. If fullscreen mode is requested without calling SetFreq() with an available value, like 60, the greatest available refresh rate will be applied.

Requesting an FSAA mode is complex a little bit: first call this method with pixelFormat = simple, then after initializing OpenGL, call this method again so an advanced pixel format will be selected. Then shutdown OpenGL, and close the previously created window, create a new window and call this method with pixelFormat = advanced. This time an FSAA-ready pixel format will be set so you can reinitialize OpenGL and enable FSAA in it.

Returns
True if succeeds, false on error.

Implements PureScreen.

Definition at line 163 of file PureScreen.cpp.

◆ applyPixelFormat()

TPureBool PureScreenImpl::applyPixelFormat ( HDC dc,
int iPixelFormat,
PIXELFORMATDESCRIPTOR * pfd )
private

Sets the given pixel format for the given HDC.

Updates m_iAppliedPixelFormat.

Returns
True on success, false otherwise.

Definition at line 669 of file PureScreen.cpp.

◆ FindAdvancedPixelFormat()

void PureScreenImpl::FindAdvancedPixelFormat ( HDC dc)
private

Finds a pixel format for the given HDC based on the previously set values like color bits.

Advanced means the pfd will be selected by OpenGL so this method requires OpenGL to be initialized. This method can be used if an FSAA-ready pfd is needed. Updates m_iAdvancedPixelFormat.

Definition at line 553 of file PureScreen.cpp.

◆ findMaximumRefreshRate()

TPureUInt PureScreenImpl::findMaximumRefreshRate ( TPureUInt nWidth,
TPureUInt nHeight,
TPureInt nCDepth )
private

Finds the maximum available refresh rate for the given display resolution width, height and color depth.

Definition at line 715 of file PureScreen.cpp.

◆ FindSimplePixelFormat()

void PureScreenImpl::FindSimplePixelFormat ( HDC dc)
private

Finds a pixel format for the given HDC based on the previously set values like color bits.

This is the legacy way of selecting a pfd and this does not support setting up FSAA. Tries to lower Z-depth bits to 24 or 16 to ensure success. Updates iSimplePixelFormat.

Definition at line 508 of file PureScreen.cpp.

◆ getColorBits()

TPureInt PureScreenImpl::getColorBits ( ) const
virtual

Gets the stored display color depth.

Returns
0 before a call to applyDisplaySettings() or SetColorBits(). The stored value after SetColorBits() and before applyDisplaySettings(). The finally selected value after a successful applyDisplaySettings().

Implements PureScreen.

Definition at line 332 of file PureScreen.cpp.

◆ getConsole()

CConsole & PureScreenImpl::getConsole ( ) const

Returns access to console preset with logger module name as this class.

Intentionally not virtual, so the getConsole() in derived class should hide this instead of overriding.

Returns
Console instance used by this class.

Definition at line 144 of file PureScreen.cpp.

◆ getDepthBits()

TPureInt PureScreenImpl::getDepthBits ( ) const
virtual

Gets the needed Z-buffer depth.

Returns
0 before a call to applyDisplaySettings() or SetDepthBits(). The stored value after SetColorBits() and before applyDisplaySettings(). The finally selected value after a successful applyDisplaySettings(). This value maybe lower than the needed value because the engine automatically tries to apply a lower value if the needed value is not supported by the driver.

Implements PureScreen.

Definition at line 346 of file PureScreen.cpp.

◆ getFreq()

TPureUInt PureScreenImpl::getFreq ( ) const
virtual

Gets the stored display refresh rate.

Returns
0 or the stored value, if called before a successful applyDisplaySettings(), otherwise the finally selected refreshrate after a successful applyDisplaySettings().

Implements PureScreen.

Definition at line 318 of file PureScreen.cpp.

◆ getFSAAlevel()

TPureInt PureScreenImpl::getFSAAlevel ( ) const
virtual

Gets the actual FSAA-level.

Default value is 0.

Returns
The actual FSAA-value, 0 means no FSAA.

Implements PureScreen.

Definition at line 412 of file PureScreen.cpp.

◆ getLoggerModuleName()

const char * PureScreenImpl::getLoggerModuleName ( )
static

Returns the logger module name of this class.

Intentionally not virtual, so derived class should hide this instead of overriding. Not even private, so user can also access this from outside, for any reason like controlling log filtering per logger module name.

Returns
The logger module name of this class.

Definition at line 157 of file PureScreen.cpp.

◆ getResHeight()

TPureUInt PureScreenImpl::getResHeight ( ) const
virtual

Gets the vertical display resolution.

Should be used only after a successful applyDisplaySettings().

Returns
The vertical display resolution in pixels.

Implements PureScreen.

Definition at line 270 of file PureScreen.cpp.

◆ getResWidth()

TPureUInt PureScreenImpl::getResWidth ( ) const
virtual

Gets the horizontal display resolution.

Should be used only after a successful applyDisplaySettings().

Returns
The horizontal display resolution in pixels.

Implements PureScreen.

Definition at line 265 of file PureScreen.cpp.

◆ getStencilBits()

TPureInt PureScreenImpl::getStencilBits ( ) const
virtual

Gets the stored Stencil Buffer depth.

Returns
0 before a call to applyDisplaySettings() or SetStencilBits(). The stored value after SetStencilBits() and before applyDisplaySettings(). The finally selected value after a successful applyDisplaySettings().

Implements PureScreen.

Definition at line 360 of file PureScreen.cpp.

◆ isFSAAready()

TPureBool PureScreenImpl::isFSAAready ( ) const
virtual

Gets whether the engine is ready to use FSAA.

Returns
True if FSAA can be used, false otherwise.

Implements PureScreen.

Definition at line 407 of file PureScreen.cpp.

◆ isFullScreened()

TPureBool PureScreenImpl::isFullScreened ( ) const
virtual

Gets whether we wanted fullscreen or not.

Returns
True, if we wanted fullscreen mode, otherwise false.

Implements PureScreen.

Definition at line 305 of file PureScreen.cpp.

◆ isInitialized()

TPureBool PureScreenImpl::isInitialized ( ) const
virtual

Gets whether display settings are applied.

Implements PureScreen.

Definition at line 259 of file PureScreen.cpp.

◆ isMonitorPowersaveEnabled()

TPureBool PureScreenImpl::isMonitorPowersaveEnabled ( ) const
virtual

Gets whether monitor power saving is allowed or not while the engine is running.

Enabled by default.

Returns
True if monitor power saving is allowed, false otherwise.

Implements PureScreen.

Definition at line 385 of file PureScreen.cpp.

◆ isScreensaverEnabled()

TPureBool PureScreenImpl::isScreensaverEnabled ( ) const
virtual

Gets whether the screensaver is allowed or not while the engine is running.

Disabled by default.

Returns
True if screensaver is allowed, false otherwise.

Implements PureScreen.

Definition at line 374 of file PureScreen.cpp.

◆ isStandbyEnabled()

TPureBool PureScreenImpl::isStandbyEnabled ( ) const
virtual

Gets whether computer standy is allowed or not while the engine is running.

Disabled by default.

Returns
True if computer standy is allowed, false otherwise.

Implements PureScreen.

Definition at line 396 of file PureScreen.cpp.

◆ isVSyncEnabled()

TPureBool PureScreenImpl::isVSyncEnabled ( ) const
virtual

Gets whether VSync is enabled or not.

Disabled by default.

Returns
True if VSync is currently enabled, otherwise false.

Implements PureScreen.

Definition at line 426 of file PureScreen.cpp.

◆ operator=()

PureScreenImpl & PureScreenImpl::operator= ( const PureScreenImpl & )
private

Definition at line 496 of file PureScreen.cpp.

◆ ReadAdvancedPixelFormatInfo()

void PureScreenImpl::ReadAdvancedPixelFormatInfo ( HDC dc,
int iAppliedPixelFormat )
private

Reads advanced pixel format about the given pixel format using wglGetPixelFormatAttrib...().

Definition at line 600 of file PureScreen.cpp.

◆ ReadCurrentDisplaySettings()

void PureScreenImpl::ReadCurrentDisplaySettings ( TPureUInt & nWidth,
TPureUInt & nHeight,
TPureInt & nCDepth,
TPureUInt & nRefRate )
private

Reads and stores current display resolution width, height, color depth and refresh rate.

Definition at line 695 of file PureScreen.cpp.

◆ ResetDisplaySettings()

void PureScreenImpl::ResetDisplaySettings ( )
virtual

Resets the original display settings.

If no settings have been applied yet or not in fullscreen mode, the function has no effect.

Implements PureScreen.

Definition at line 231 of file PureScreen.cpp.

◆ SetColorBits()

void PureScreenImpl::SetColorBits ( TPureInt c)
virtual

Stores the needed display color depth.

Can be used only before applyDisplaySettings(), no effect otherwise. A call to applyDisplaySettings() is needed to apply the setting.

Implements PureScreen.

Definition at line 337 of file PureScreen.cpp.

◆ SetDepthBits()

void PureScreenImpl::SetDepthBits ( TPureInt d)
virtual

Stores the needed Z-Buffer depth.

Can be used only before applyDisplaySettings(), no effect otherwise. A call to applyDisplaySettings() is needed to apply the setting.

Implements PureScreen.

Definition at line 351 of file PureScreen.cpp.

◆ SetFreq()

void PureScreenImpl::SetFreq ( TPureUInt f)
virtual

Stores the needed display refresh rate.

Can be used only before applyDisplaySettings(), no effect otherwise. The stored display refresh rate will be applied only in fullscreen mode by a successful applyDisplaySettings().

Implements PureScreen.

Definition at line 323 of file PureScreen.cpp.

◆ SetFSAAlevel()

void PureScreenImpl::SetFSAAlevel ( TPureInt level)
virtual

Sets the needed FSAA-level.

Default value is 0. Can be used only before applyDisplaySettings(), no effect otherwise. A call to applyDisplaySettings() is needed to apply the setting.

Implements PureScreen.

Definition at line 417 of file PureScreen.cpp.

◆ SetFullScreened()

void PureScreenImpl::SetFullScreened ( TPureBool fs)
virtual

Stores whether we want fullscreen mode or not.

Can be used only before applyDisplaySettings(), no effect otherwise. A call to applyDisplaySettings() is needed to apply the setting.

Implements PureScreen.

Definition at line 310 of file PureScreen.cpp.

◆ SetMonitorPowersaveEnabled()

void PureScreenImpl::SetMonitorPowersaveEnabled ( TPureBool state)
virtual

Sets whether monitor power saving is allowed or not while the engine is running.

Enabled by default.

Implements PureScreen.

Definition at line 390 of file PureScreen.cpp.

◆ SetResolution()

void PureScreenImpl::SetResolution ( TPureUInt w,
TPureUInt h )
virtual

Stores the given display resolution.

Can be used only before applyDisplaySettings(), no effect otherwise. If w or h is 0, the target width and height will be the current screen resolution. If the current screen resolution can't be queried, the target will be 800x600. A call to applyDisplaySettings() is needed to apply the stored display resolution.

Implements PureScreen.

Definition at line 276 of file PureScreen.cpp.

◆ SetScreensaverEnabled()

void PureScreenImpl::SetScreensaverEnabled ( TPureBool state)
virtual

Sets whether the screensaver is allowed or not while the engine is running.

Disabled by default.

Implements PureScreen.

Definition at line 379 of file PureScreen.cpp.

◆ SetStandbyEnabled()

void PureScreenImpl::SetStandbyEnabled ( TPureBool state)
virtual

Sets whether computer standy is allowed or not while the engine is running.

Disabled by default.

Implements PureScreen.

Definition at line 401 of file PureScreen.cpp.

◆ SetStencilBits()

void PureScreenImpl::SetStencilBits ( TPureInt s)
virtual

Stores the needed Stencil Buffer depth.

Can be used only before applyDisplaySettings(), no effect otherwise. A call to applyDisplaySettings() is needed to apply the setting.

Implements PureScreen.

Definition at line 365 of file PureScreen.cpp.

◆ setVSyncEnabled()

TPureBool PureScreenImpl::setVSyncEnabled ( TPureBool state)
virtual

Sets the state of VSync.

Default state is false. No effect if VSync is not supported.

Returns
The new state. This implies that if requested enabled but a failure happened, false is returned.

Implements PureScreen.

Definition at line 431 of file PureScreen.cpp.

◆ switchToFullscreenMode()

bool PureScreenImpl::switchToFullscreenMode ( TPureUInt nWidth,
TPureUInt nHeight,
TPureInt nCDepth,
TPureUInt nRefRate )
private

Switches display mode to fullscreen at the given resolution width, height, color depth with the given refresh rate.

Returns
True on success, false otherwise.

Definition at line 738 of file PureScreen.cpp.

Friends And Related Symbol Documentation

◆ PureScreen

friend class PureScreen
friend

Definition at line 123 of file PureScreen.cpp.

Member Data Documentation

◆ bDisplaySettingsApplied

TPureBool PureScreenImpl::bDisplaySettingsApplied
private

Are the set display settings applied?

Definition at line 86 of file PureScreen.cpp.

◆ bFSAA_ready

TPureBool PureScreenImpl::bFSAA_ready
private

Is FSAA initialized?

Definition at line 97 of file PureScreen.cpp.

◆ bFullScreen

TPureBool PureScreenImpl::bFullScreen
private

Are we in fullscreen mode?

Definition at line 87 of file PureScreen.cpp.

◆ bVSyncState

TPureBool PureScreenImpl::bVSyncState
private

Is VSync enabled?

Definition at line 100 of file PureScreen.cpp.

◆ iFSAA_req

GLint PureScreenImpl::iFSAA_req
private

Requested FSAA-level.

Definition at line 99 of file PureScreen.cpp.

◆ iFSAA_state

GLint PureScreenImpl::iFSAA_state
private

Current FSAA-level (0x/1x/2x/3x/...).

Definition at line 98 of file PureScreen.cpp.

◆ iSimplePixelFormat

int PureScreenImpl::iSimplePixelFormat
private

Best pixel format found by Win32.

Definition at line 88 of file PureScreen.cpp.

◆ m_iAdvancedPixelFormat

int PureScreenImpl::m_iAdvancedPixelFormat
private

Best pixel format found by OpenGL.

Definition at line 89 of file PureScreen.cpp.

◆ m_iAppliedPixelFormat

int PureScreenImpl::m_iAppliedPixelFormat
private

Currently applied pixel format, iSimple or iAdvanced.

Definition at line 90 of file PureScreen.cpp.

◆ m_pfd

PIXELFORMATDESCRIPTOR PureScreenImpl::m_pfd
private

Pixelformat descriptor.

Definition at line 85 of file PureScreen.cpp.

◆ nBitsColor

TPureInt PureScreenImpl::nBitsColor
private

Screen color depth.

Definition at line 94 of file PureScreen.cpp.

◆ nBitsDepth

TPureInt PureScreenImpl::nBitsDepth
private

ZBuffer depth (32/24/16).

Definition at line 95 of file PureScreen.cpp.

◆ nBitsStencil

TPureInt PureScreenImpl::nBitsStencil
private

Stencil buffer depth (8/0).

Definition at line 96 of file PureScreen.cpp.

◆ nRefreshRate

TPureUInt PureScreenImpl::nRefreshRate
private

Screen refresh rate.

Definition at line 93 of file PureScreen.cpp.

◆ nResX

TPureUInt PureScreenImpl::nResX
private

Horizontal screen resolution.

Definition at line 91 of file PureScreen.cpp.

◆ nResY

TPureUInt PureScreenImpl::nResY
private

Vertical screen resolution.

Definition at line 92 of file PureScreen.cpp.

◆ sharedSettings

PureSharedSettings& PureScreenImpl::sharedSettings
private

Pointer to shared settings.

Definition at line 83 of file PureScreen.cpp.


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