[148] | 1 | /*------------------------------------------------------------------------- |
---|
| 2 | This source file is a part of OGRE |
---|
| 3 | (Object-oriented Graphics Rendering Engine) |
---|
| 4 | |
---|
| 5 | For the latest info, see http://www.ogre3d.org/ |
---|
| 6 | |
---|
| 7 | Copyright (c) 2000-2013 Torus Knot Software Ltd |
---|
| 8 | Permission is hereby granted, free of charge, to any person obtaining a copy |
---|
| 9 | of this software and associated documentation files (the "Software"), to deal |
---|
| 10 | in the Software without restriction, including without limitation the rights |
---|
| 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
---|
| 12 | copies of the Software, and to permit persons to whom the Software is |
---|
| 13 | furnished to do so, subject to the following conditions: |
---|
| 14 | |
---|
| 15 | The above copyright notice and this permission notice shall be included in |
---|
| 16 | all copies or substantial portions of the Software. |
---|
| 17 | |
---|
| 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
---|
| 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
---|
| 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
---|
| 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
---|
| 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
---|
| 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
---|
| 24 | THE SOFTWARE |
---|
| 25 | -------------------------------------------------------------------------*/ |
---|
| 26 | #ifndef __RenderWindow_H__ |
---|
| 27 | #define __RenderWindow_H__ |
---|
| 28 | |
---|
| 29 | #include "OgrePrerequisites.h" |
---|
| 30 | |
---|
| 31 | #include "OgreRenderTarget.h" |
---|
| 32 | |
---|
| 33 | namespace Ogre |
---|
| 34 | { |
---|
| 35 | /** \addtogroup Core |
---|
| 36 | * @{ |
---|
| 37 | */ |
---|
| 38 | /** \addtogroup RenderSystem |
---|
| 39 | * @{ |
---|
| 40 | */ |
---|
| 41 | /** Manages the target rendering window. |
---|
| 42 | @remarks |
---|
| 43 | This class handles a window into which the contents |
---|
| 44 | of a scene are rendered. There is a many-to-1 relationship |
---|
| 45 | between instances of this class an instance of RenderSystem |
---|
| 46 | which controls the rendering of the scene. There may be |
---|
| 47 | more than one window in the case of level editor tools etc. |
---|
| 48 | This class is abstract since there may be |
---|
| 49 | different implementations for different windowing systems. |
---|
| 50 | @remarks |
---|
| 51 | Instances are created and communicated with by the render system |
---|
| 52 | although client programs can get a reference to it from |
---|
| 53 | the render system if required for resizing or moving. |
---|
| 54 | Note that you can have multiple viewpoints |
---|
| 55 | in the window for effects like rear-view mirrors and |
---|
| 56 | picture-in-picture views (see Viewport and Camera). |
---|
| 57 | @author |
---|
| 58 | Steven Streeting |
---|
| 59 | @version |
---|
| 60 | 1.0 |
---|
| 61 | */ |
---|
| 62 | class _OgreExport RenderWindow : public RenderTarget |
---|
| 63 | { |
---|
| 64 | |
---|
| 65 | public: |
---|
| 66 | /** Default constructor. |
---|
| 67 | */ |
---|
| 68 | RenderWindow(); |
---|
| 69 | |
---|
| 70 | /** Creates & displays the new window. |
---|
| 71 | @param |
---|
| 72 | width The width of the window in pixels. |
---|
| 73 | @param |
---|
| 74 | height The height of the window in pixels. |
---|
| 75 | @param |
---|
| 76 | fullScreen If true, the window fills the screen, |
---|
| 77 | with no title bar or border. |
---|
| 78 | @param |
---|
| 79 | miscParams A variable number of pointers to platform-specific arguments. The |
---|
| 80 | actual requirements must be defined by the implementing subclasses. |
---|
| 81 | */ |
---|
| 82 | virtual void create(const String& name, unsigned int width, unsigned int height, |
---|
| 83 | bool fullScreen, const NameValuePairList *miscParams) = 0; |
---|
| 84 | |
---|
| 85 | /** Alter fullscreen mode options. |
---|
| 86 | @note Nothing will happen unless the settings here are different from the |
---|
| 87 | current settings. |
---|
| 88 | @param fullScreen Whether to use fullscreen mode or not. |
---|
| 89 | @param width The new width to use |
---|
| 90 | @param height The new height to use |
---|
| 91 | */ |
---|
| 92 | virtual void setFullscreen(bool fullScreen, unsigned int width, unsigned int height) |
---|
| 93 | { (void)fullScreen; (void)width; (void)height; } |
---|
| 94 | |
---|
| 95 | /** Destroys the window. |
---|
| 96 | */ |
---|
| 97 | virtual void destroy(void) = 0; |
---|
| 98 | |
---|
| 99 | /** Alter the size of the window. |
---|
| 100 | */ |
---|
| 101 | virtual void resize(unsigned int width, unsigned int height) = 0; |
---|
| 102 | |
---|
| 103 | /** Notify that the window has been resized |
---|
| 104 | @remarks |
---|
| 105 | You don't need to call this unless you created the window externally. |
---|
| 106 | */ |
---|
| 107 | virtual void windowMovedOrResized() {} |
---|
| 108 | |
---|
| 109 | /** Reposition the window. |
---|
| 110 | */ |
---|
| 111 | virtual void reposition(int left, int top) = 0; |
---|
| 112 | |
---|
| 113 | /** Indicates whether the window is visible (not minimized or obscured) |
---|
| 114 | */ |
---|
| 115 | virtual bool isVisible(void) const { return true; } |
---|
| 116 | |
---|
| 117 | /** Set the visibility state |
---|
| 118 | */ |
---|
| 119 | virtual void setVisible(bool visible) |
---|
| 120 | { (void)visible; } |
---|
| 121 | |
---|
| 122 | /** Indicates whether the window was set to hidden (not displayed) |
---|
| 123 | */ |
---|
| 124 | virtual bool isHidden(void) const { return false; } |
---|
| 125 | |
---|
| 126 | /** Hide (or show) the window. If called with hidden=true, this |
---|
| 127 | will make the window completely invisible to the user. |
---|
| 128 | @remarks |
---|
| 129 | Setting a window to hidden is useful to create a dummy primary |
---|
| 130 | RenderWindow hidden from the user so that you can create and |
---|
| 131 | recreate your actual RenderWindows without having to recreate |
---|
| 132 | all your resources. |
---|
| 133 | */ |
---|
| 134 | virtual void setHidden(bool hidden) |
---|
| 135 | { (void)hidden; } |
---|
| 136 | |
---|
| 137 | /** Enable or disable vertical sync for the RenderWindow. |
---|
| 138 | */ |
---|
| 139 | virtual void setVSyncEnabled(bool vsync) |
---|
| 140 | { (void)vsync; } |
---|
| 141 | |
---|
| 142 | /** Indicates whether vertical sync is activated for the window. |
---|
| 143 | */ |
---|
| 144 | virtual bool isVSyncEnabled() const { return false; } |
---|
| 145 | |
---|
| 146 | /** Set the vertical sync interval. This indicates the number of vertical retraces to wait for |
---|
| 147 | before swapping buffers. A value of 1 is the default. |
---|
| 148 | */ |
---|
| 149 | virtual void setVSyncInterval(unsigned int interval) |
---|
| 150 | { (void)interval; } |
---|
| 151 | |
---|
| 152 | /** Returns the vertical sync interval. |
---|
| 153 | */ |
---|
| 154 | virtual unsigned int getVSyncInterval() const { return 1; } |
---|
| 155 | |
---|
| 156 | |
---|
| 157 | /** Overridden from RenderTarget, flags invisible windows as inactive |
---|
| 158 | */ |
---|
| 159 | virtual bool isActive(void) const { return mActive && isVisible(); } |
---|
| 160 | |
---|
| 161 | /** Indicates whether the window has been closed by the user. |
---|
| 162 | */ |
---|
| 163 | virtual bool isClosed(void) const = 0; |
---|
| 164 | |
---|
| 165 | /** Indicates whether the window is the primary window. The |
---|
| 166 | primary window is special in that it is destroyed when |
---|
| 167 | ogre is shut down, and cannot be destroyed directly. |
---|
| 168 | This is the case because it holds the context for vertex, |
---|
| 169 | index buffers and textures. |
---|
| 170 | */ |
---|
| 171 | virtual bool isPrimary(void) const; |
---|
| 172 | |
---|
| 173 | /** Returns true if window is running in fullscreen mode. |
---|
| 174 | */ |
---|
| 175 | virtual bool isFullScreen(void) const; |
---|
| 176 | |
---|
| 177 | /** Overloaded version of getMetrics from RenderTarget, including extra details |
---|
| 178 | specific to windowing systems. |
---|
| 179 | */ |
---|
| 180 | virtual void getMetrics(unsigned int& width, unsigned int& height, unsigned int& colourDepth, |
---|
| 181 | int& left, int& top); |
---|
| 182 | |
---|
| 183 | /// Override since windows don't usually have alpha |
---|
| 184 | PixelFormat suggestPixelFormat() const { return PF_BYTE_RGB; } |
---|
| 185 | |
---|
| 186 | /** Returns true if the window will automatically de-activate itself when it loses focus. |
---|
| 187 | */ |
---|
| 188 | bool isDeactivatedOnFocusChange() const; |
---|
| 189 | |
---|
| 190 | /** Indicates whether the window will automatically deactivate itself when it loses focus. |
---|
| 191 | * @param deactivate a value of 'true' will cause the window to deactivate itself when it loses focus. 'false' will allow it to continue to render even when window focus is lost. |
---|
| 192 | * @note 'true' is the default behavior. |
---|
| 193 | */ |
---|
| 194 | void setDeactivateOnFocusChange(bool deactivate); |
---|
| 195 | |
---|
| 196 | protected: |
---|
| 197 | bool mIsFullScreen; |
---|
| 198 | bool mIsPrimary; |
---|
| 199 | bool mAutoDeactivatedOnFocusChange; |
---|
| 200 | int mLeft; |
---|
| 201 | int mTop; |
---|
| 202 | |
---|
| 203 | /** Indicates that this is the primary window. Only to be called by |
---|
| 204 | Ogre::Root |
---|
| 205 | */ |
---|
| 206 | void _setPrimary() { mIsPrimary = true; } |
---|
| 207 | |
---|
| 208 | friend class Root; |
---|
| 209 | }; |
---|
| 210 | /** @} */ |
---|
| 211 | /** @} */ |
---|
| 212 | |
---|
| 213 | } // Namespace |
---|
| 214 | #endif |
---|