OGRE-Next  3.0.0
Object-Oriented Graphics Rendering Engine
Ogre::Window Class Referenceabstract

#include <OgreWindow.h>

+ Inheritance diagram for Ogre::Window:

Public Member Functions

 Window (const String &title, uint32 widthPt, uint32 heightPt, bool fullscreenMode)
 
virtual ~Window ()
 
virtual void _initialize (TextureGpuManager *textureGpuManager)=0
 
void _setPrimary ()
 Indicates that this is the primary window. More...
 
virtual void _setVisible (bool visible)=0
 Internal method to notify the window it has been obscured or minimized. More...
 
virtual bool canDownloadData () const
 Returns true if you can download to CPU (i.e. More...
 
virtual void destroy ()=0
 
bool getBorderless () const
 
virtual void getCustomAttribute (IdString name, void *pData)
 
TextureGpugetDepthBuffer () const
 
uint32 getFrequencyDenominator () const
 
uint32 getFrequencyNumerator () const
 
uint32 getHeight () const
 
virtual void getMetrics (uint32 &width, uint32 &height, int32 &left, int32 &top) const
 Overloaded version of getMetrics from RenderTarget, including extra details specific to windowing systems. More...
 
PixelFormatGpu getPixelFormat () const
 
uint32 getRequestedHeightPt () const
 
uint32 getRequestedWidthPt () const
 
SampleDescription getSampleDescription () const
 
TextureGpugetStencilBuffer () const
 
TextureGpugetTexture () const
 WARNING: Attempting to change the TextureGpu (e.g. More...
 
const StringgetTitle () const
 
virtual float getViewPointToPixelScale () const
 Many windowing systems that support HiDPI displays use special points to specify size of the windows and controls, so that windows and controls with hardcoded sizes does not become too small on HiDPI displays. More...
 
bool getVSync () const
 
uint32 getVSyncInterval () const
 
uint32 getWidth () const
 
virtual bool isClosed () const =0
 Indicates whether the window has been closed by the user. More...
 
bool isFocused () const
 
bool isFullscreen () const
 Returns true if we are currently in fullscreen mode. More...
 
virtual bool isHidden () const =0
 Indicates whether the window was set to hidden (not displayed) More...
 
virtual bool isManualSwapRelease () const
 Returns the value set by setManualSwapRelease when supported. More...
 
bool isMultisample () const
 
bool isPrimary () const
 
virtual bool isVisible () const =0
 
virtual void performManualRelease ()
 See Window::setManualSwapRelease. More...
 
virtual void reposition (int32 leftPt, int32 topPt)=0
 
virtual void requestFullscreenSwitch (bool goFullscreen, bool borderless, uint32 monitorIdx, uint32 widthPt, uint32 heightPt, uint32 frequencyNumerator, uint32 frequencyDenominator)
 Requests to toggle between fullscreen and windowed mode. More...
 
virtual void requestResolution (uint32 widthPt, uint32 heightPt)
 Requests a change in resolution. More...
 
virtual void setBorderless (bool borderless)
 
virtual void setFocused (bool focused)
 
virtual void setFsaa (const String &fsaa)
 Set the FSAA mode to be used if hardware support it. More...
 
virtual void setHidden (bool hidden)=0
 Hide (or show) the window. More...
 
virtual void setManualSwapRelease (bool bManualRelease)
 Metal doesn't want us to hold on to a drawable after presenting. More...
 
virtual void setTitle (const String &title)
 
virtual void setVSync (bool vSync, uint32 vSyncInterval)
 Turns VSync on/off. More...
 
virtual void setWantsToDownload (bool bWantsToDownload)
 On Metal you must call this function and set it to true in order to take pictures. More...
 
virtual void swapBuffers ()=0
 
bool wantsToGoFullscreen () const
 Returns true if we are in windowed mode right now, but want to go fullscreen. More...
 
bool wantsToGoWindowed () const
 Returns true if we are in fullscreen mode right now, but want to go windowed mode. More...
 
virtual void windowMovedOrResized ()
 Notify that the window has been resized. More...
 

Constructor & Destructor Documentation

◆ Window()

Ogre::Window::Window ( const String title,
uint32  widthPt,
uint32  heightPt,
bool  fullscreenMode 
)

◆ ~Window()

virtual Ogre::Window::~Window ( )
virtual

Member Function Documentation

◆ _initialize()

◆ _setPrimary()

void Ogre::Window::_setPrimary ( )

Indicates that this is the primary window.

Only to be called by Ogre::Root

◆ _setVisible()

virtual void Ogre::Window::_setVisible ( bool  visible)
pure virtual

◆ canDownloadData()

virtual bool Ogre::Window::canDownloadData ( ) const
virtual

Returns true if you can download to CPU (i.e.

transfer it via AsyncTextureTicket) If it returns false, attempting to do so could result in a crash

See Window::setWantsToDownload See Window::setManualSwapRelease

Reimplemented in Ogre::VulkanWindowSwapChainBased, and Ogre::MetalWindow.

◆ destroy()

◆ getBorderless()

bool Ogre::Window::getBorderless ( ) const

◆ getCustomAttribute()

◆ getDepthBuffer()

TextureGpu* Ogre::Window::getDepthBuffer ( ) const

◆ getFrequencyDenominator()

uint32 Ogre::Window::getFrequencyDenominator ( ) const

◆ getFrequencyNumerator()

uint32 Ogre::Window::getFrequencyNumerator ( ) const

◆ getHeight()

uint32 Ogre::Window::getHeight ( ) const

◆ getMetrics()

virtual void Ogre::Window::getMetrics ( uint32 width,
uint32 height,
int32 left,
int32 top 
) const
virtual

Overloaded version of getMetrics from RenderTarget, including extra details specific to windowing systems.

Result is in pixels.

◆ getPixelFormat()

PixelFormatGpu Ogre::Window::getPixelFormat ( ) const

◆ getRequestedHeightPt()

uint32 Ogre::Window::getRequestedHeightPt ( ) const

◆ getRequestedWidthPt()

uint32 Ogre::Window::getRequestedWidthPt ( ) const

◆ getSampleDescription()

SampleDescription Ogre::Window::getSampleDescription ( ) const

◆ getStencilBuffer()

TextureGpu* Ogre::Window::getStencilBuffer ( ) const

◆ getTexture()

TextureGpu* Ogre::Window::getTexture ( ) const

WARNING: Attempting to change the TextureGpu (e.g.

setResolution, setPixelFormat) is undefined behavior

◆ getTitle()

const String& Ogre::Window::getTitle ( ) const

◆ getViewPointToPixelScale()

virtual float Ogre::Window::getViewPointToPixelScale ( ) const
inlinevirtual

Many windowing systems that support HiDPI displays use special points to specify size of the windows and controls, so that windows and controls with hardcoded sizes does not become too small on HiDPI displays.

Such points have constant density ~ 100 points per inch (probably 96 on Windows and 72 on Mac), that is independent of pixel density of real display, and are used through the all windowing system.

Sometimes, such view points are choosen bigger for output devices that are viewed from larger distances, like 30" TV comparing to 30" monitor, therefore maintaining constant points angular density rather than constant linear density.

In any case, all such windowing system provides the way to convert such view points to pixels, be it DisplayProperties::LogicalDpi on WinRT or backingScaleFactor on MacOSX. We use pixels consistently through the Ogre, but window/view management functions takes view points for convenience, as does the rest of windowing system. Such parameters are named using xxxxPt pattern, and should not be mixed with pixels without being converted using getViewPointToPixelScale() function.

Sometimes such scale factor can change on-the-fly, for example if window is dragged to monitor with different DPI. In such situation, window size in view points is usually preserved by windowing system, and Ogre should adjust pixel size of RenderWindow.

Reimplemented in Ogre::MetalWindow, and Ogre::CocoaWindow.

◆ getVSync()

bool Ogre::Window::getVSync ( ) const

◆ getVSyncInterval()

uint32 Ogre::Window::getVSyncInterval ( ) const

◆ getWidth()

uint32 Ogre::Window::getWidth ( ) const

◆ isClosed()

virtual bool Ogre::Window::isClosed ( ) const
pure virtual

◆ isFocused()

bool Ogre::Window::isFocused ( ) const

◆ isFullscreen()

bool Ogre::Window::isFullscreen ( ) const

Returns true if we are currently in fullscreen mode.

◆ isHidden()

virtual bool Ogre::Window::isHidden ( ) const
pure virtual

◆ isManualSwapRelease()

virtual bool Ogre::Window::isManualSwapRelease ( ) const
inlinevirtual

Returns the value set by setManualSwapRelease when supported.

Reimplemented in Ogre::MetalWindow.

◆ isMultisample()

bool Ogre::Window::isMultisample ( ) const

◆ isPrimary()

bool Ogre::Window::isPrimary ( ) const

◆ isVisible()

◆ performManualRelease()

virtual void Ogre::Window::performManualRelease ( )
virtual

◆ reposition()

◆ requestFullscreenSwitch()

virtual void Ogre::Window::requestFullscreenSwitch ( bool  goFullscreen,
bool  borderless,
uint32  monitorIdx,
uint32  widthPt,
uint32  heightPt,
uint32  frequencyNumerator,
uint32  frequencyDenominator 
)
virtual

Requests to toggle between fullscreen and windowed mode.

Remarks
Use wantsToGoFullscreen & wantsToGoWindowed to know what you've requested. Same remarks as requestResolution apply: If we request to go fullscreen, wantsToGoFullscreen will return true. But if get word from OS saying we stay in windowed mode, wantsToGoFullscreen will start returning false.
Parameters
goFullscreenTrue to go fullscreen, false to go windowed mode.
borderlessWhether to be borderless. Only useful if goFullscreen == false;
monitorIdx
widthPtNew width. Leave 0 if you don't care.
heightPtNew height. Leave 0 if you don't care.
frequencyNumeratorNew frequency (fullscreen only). Leave 0 if you don't care.
frequencyDenominatorNew frequency (fullscreen only). Leave 0 if you don't care.

Reimplemented in Ogre::VulkanXcbWindow, Ogre::VulkanWin32Window, Ogre::NULLWindow, Ogre::GLXWindow, Ogre::Win32Window, Ogre::EglPBufferWindow, and Ogre::EGLWindow.

◆ requestResolution()

virtual void Ogre::Window::requestResolution ( uint32  widthPt,
uint32  heightPt 
)
virtual

Requests a change in resolution.

Change is not immediate. Use getRequestedWidthPt & getRequestedHeightPt if you need to know what you've requested, but beware you may not get that resolution, and once we get word from the OS, getRequested{Width/Height}Pt will change again so that getWidth == getRequestedWidthPt * getViewPointToPixelScale.

Reimplemented in Ogre::VulkanXcbWindow, Ogre::VulkanWin32Window, Ogre::VulkanAndroidWindow, Ogre::NULLWindow, Ogre::MetalWindow, Ogre::GLXWindow, Ogre::Win32Window, Ogre::EglPBufferWindow, and Ogre::EGLWindow.

◆ setBorderless()

virtual void Ogre::Window::setBorderless ( bool  borderless)
virtual

◆ setFocused()

virtual void Ogre::Window::setFocused ( bool  focused)
virtual

◆ setFsaa()

virtual void Ogre::Window::setFsaa ( const String fsaa)
inlinevirtual

Set the FSAA mode to be used if hardware support it.

This option will be ignored if the hardware does not support it or setting can not be changed on the fly on per-target level.

Parameters
fsaaRequesed FSAA mode (
See also
Root::createRenderWindow)

Reimplemented in Ogre::D3D11WindowSwapChainBased.

◆ setHidden()

virtual void Ogre::Window::setHidden ( bool  hidden)
pure virtual

Hide (or show) the window.

If called with hidden=true, this will make the window completely invisible to the user.

Remarks
Setting a window to hidden is useful to create a dummy primary RenderWindow hidden from the user so that you can create and recreate your actual RenderWindows without having to recreate all your resources.

Implemented in Ogre::VulkanXcbWindow, Ogre::VulkanWin32Window, Ogre::VulkanAndroidWindow, Ogre::VulkanWindowNull, Ogre::NULLWindow, Ogre::MetalWindow, Ogre::CocoaWindow, Ogre::GLXWindow, Ogre::D3D11Window, Ogre::Win32Window, Ogre::EglPBufferWindow, and Ogre::EGLWindow.

◆ setManualSwapRelease()

virtual void Ogre::Window::setManualSwapRelease ( bool  bManualRelease)
virtual

Metal doesn't want us to hold on to a drawable after presenting.

If you want to take a screenshot capture of the window this is a problem because we no longer have a pointer of the backbuffer to download from.

You can either take your screenshot before swapBuffers() gets called, or, if you intend to take a screenshot, do the following:

window->setWantsToDownload( true );
window->setManualSwapRelease( true );
mRoot->renderOneFrame();
if( window->canDownloadData() )
{
Ogre::TextureGpu *texture = window->getTexture();
img.convertFromTexture( texture, 0u, texture->getNumMipmaps() - 1u );
}
window->performManualRelease();
window->setManualSwapRelease( false );
Class representing an image file.
Definition: OgreImage2.h:57
void convertFromTexture(TextureGpu *texture, uint8 minMip, uint8 maxMip, bool automaticResolve=true)
Synchronously downloads the selected mips from a TextureGpu into this Image.
Definition: OgreTextureGpu.h:291
uint8 getNumMipmaps() const

Technically you can do setManualSwapRelease( true ) and leave it like that, but then you MUST call performManualRelease and that's bug prone.

Remarks
Incorrect usage of this functionality may result in crashes or leaks

Alternatively you can avoid setManualSwapRelease by taking pictures before calling Window::swapBuffers.

To do that use FrameListener::frameRenderingQueued listener, but* you still have to call setWantsToDownload( true ) and check canDownloadData returns true.

Reimplemented in Ogre::MetalWindow.

◆ setTitle()

virtual void Ogre::Window::setTitle ( const String title)
virtual

◆ setVSync()

virtual void Ogre::Window::setVSync ( bool  vSync,
uint32  vSyncInterval 
)
virtual

Turns VSync on/off.

Parameters
vSync
vSyncIntervalWhen true, specifies how often the screen should be updated. e.g. at 60hz: vSyncInterval = 1 then update at 60hz vSyncInterval = 2 then update at 30hz vSyncInterval = 3 then update at 15hz vSyncInterval = 4 then update at 7.5hz

If the 31st bit is set, i.e. 0x80000000, then lowest latency mode, aka mailbox, will be used (which doesn't limit the framerate)

Reimplemented in Ogre::VulkanWindowSwapChainBased, Ogre::GLXWindow, Ogre::Win32Window, Ogre::EglPBufferWindow, and Ogre::EGLWindow.

◆ setWantsToDownload()

virtual void Ogre::Window::setWantsToDownload ( bool  bWantsToDownload)
virtual

On Metal you must call this function and set it to true in order to take pictures.

If you no longer need that functionality, set it to false to improve performance

Reimplemented in Ogre::VulkanWindowSwapChainBased, and Ogre::MetalWindow.

◆ swapBuffers()

◆ wantsToGoFullscreen()

bool Ogre::Window::wantsToGoFullscreen ( ) const

Returns true if we are in windowed mode right now, but want to go fullscreen.

◆ wantsToGoWindowed()

bool Ogre::Window::wantsToGoWindowed ( ) const

Returns true if we are in fullscreen mode right now, but want to go windowed mode.

◆ windowMovedOrResized()

virtual void Ogre::Window::windowMovedOrResized ( )
inlinevirtual

Notify that the window has been resized.

Remarks
You don't need to call this unless you created the window externally.

Reimplemented in Ogre::VulkanXcbWindow, Ogre::VulkanWin32Window, Ogre::VulkanAndroidWindow, Ogre::MetalWindow, Ogre::CocoaWindow, Ogre::GLXWindow, Ogre::Win32Window, and Ogre::EGLWindow.


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