[692] | 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-2005 The OGRE Team
|
---|
| 8 | Also see acknowledgements in Readme.html
|
---|
| 9 |
|
---|
| 10 | This library is free software; you can redistribute it and/or modify it
|
---|
| 11 | under the terms of the GNU Lesser General Public License (LGPL) as
|
---|
| 12 | published by the Free Software Foundation; either version 2.1 of the
|
---|
| 13 | License, or (at your option) any later version.
|
---|
| 14 |
|
---|
| 15 | This library is distributed in the hope that it will be useful, but
|
---|
| 16 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
---|
| 17 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
---|
| 18 | License for more details.
|
---|
| 19 |
|
---|
| 20 | You should have received a copy of the GNU Lesser General Public License
|
---|
| 21 | along with this library; if not, write to the Free Software Foundation,
|
---|
| 22 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or go to
|
---|
| 23 | http://www.gnu.org/copyleft/lesser.txt
|
---|
| 24 | -------------------------------------------------------------------------*/
|
---|
| 25 | #ifndef __RenderWindow_H__
|
---|
| 26 | #define __RenderWindow_H__
|
---|
| 27 |
|
---|
| 28 | #include "OgrePrerequisites.h"
|
---|
| 29 |
|
---|
| 30 | #include "OgreRenderTarget.h"
|
---|
| 31 |
|
---|
| 32 | namespace Ogre
|
---|
| 33 | {
|
---|
| 34 | /** Manages the target rendering window.
|
---|
| 35 | @remarks
|
---|
| 36 | This class handles a window into which the contents
|
---|
| 37 | of a scene are rendered. There is a many-to-1 relationship
|
---|
| 38 | between instances of this class an instance of RenderSystem
|
---|
| 39 | which controls the rendering of the scene. There may be
|
---|
| 40 | more than one window in the case of level editor tools etc.
|
---|
| 41 | This class is abstract since there may be
|
---|
| 42 | different implementations for different windowing systems.
|
---|
| 43 | @remarks
|
---|
| 44 | Instances are created and communicated with by the render system
|
---|
| 45 | although client programs can get a reference to it from
|
---|
| 46 | the render system if required for resizing or moving.
|
---|
| 47 | Note that you can have multiple viewpoints
|
---|
| 48 | in the window for effects like rear-view mirrors and
|
---|
| 49 | picture-in-picture views (see Viewport and Camera).
|
---|
| 50 | @author
|
---|
| 51 | Steven Streeting
|
---|
| 52 | @version
|
---|
| 53 | 1.0
|
---|
| 54 | */
|
---|
| 55 | class _OgreExport RenderWindow : public RenderTarget
|
---|
| 56 | {
|
---|
| 57 |
|
---|
| 58 | public:
|
---|
| 59 | /** Default constructor.
|
---|
| 60 | */
|
---|
| 61 | RenderWindow();
|
---|
| 62 |
|
---|
| 63 | /** Creates & displays the new window.
|
---|
| 64 | @param
|
---|
| 65 | width The width of the window in pixels.
|
---|
| 66 | @param
|
---|
| 67 | height The height of the window in pixels.
|
---|
| 68 | @param
|
---|
| 69 | colourDepth The colour depth in bits. Ignored if
|
---|
| 70 | fullScreen is false since the desktop depth is used.
|
---|
| 71 | @param
|
---|
| 72 | fullScreen If true, the window fills the screen,
|
---|
| 73 | with no title bar or border.
|
---|
| 74 | @param
|
---|
| 75 | left The x-position of the window. Ignored if
|
---|
| 76 | fullScreen = true.
|
---|
| 77 | @param
|
---|
| 78 | top The y-position of the window. Ignored if
|
---|
| 79 | fullScreen = true.
|
---|
| 80 | @param
|
---|
| 81 | depthBuffer Specify true to include a depth-buffer.
|
---|
| 82 | @param
|
---|
| 83 | miscParam A variable number of pointers to platform-specific arguments. The
|
---|
| 84 | actual requirements must be defined by the implementing subclasses.
|
---|
| 85 | */
|
---|
| 86 | virtual void create(const String& name, unsigned int width, unsigned int height,
|
---|
| 87 | bool fullScreen, const NameValuePairList *miscParams) = 0;
|
---|
| 88 |
|
---|
| 89 | /** Destroys the window.
|
---|
| 90 | */
|
---|
| 91 | virtual void destroy(void) = 0;
|
---|
| 92 |
|
---|
| 93 | /** Alter the size of the window.
|
---|
| 94 | */
|
---|
| 95 | virtual void resize(unsigned int width, unsigned int height) = 0;
|
---|
| 96 |
|
---|
| 97 | /** Notify that the window has been resized externally.
|
---|
| 98 | @remarks
|
---|
| 99 | You don't need to call this unless you created the window externally.
|
---|
| 100 | */
|
---|
| 101 | virtual void windowMovedOrResized() {}
|
---|
| 102 |
|
---|
| 103 | /** Reposition the window.
|
---|
| 104 | */
|
---|
| 105 | virtual void reposition(int left, int top) = 0;
|
---|
| 106 |
|
---|
| 107 | /** Indicates whether the window is visible (not minimized or obscured)
|
---|
| 108 | */
|
---|
| 109 | virtual bool isVisible(void) const { return true; }
|
---|
| 110 |
|
---|
| 111 | /** Overridden from RenderTarget, flags invisible windows as inactive
|
---|
| 112 | */
|
---|
| 113 | virtual bool isActive(void) const { return mActive && isVisible(); }
|
---|
| 114 |
|
---|
| 115 | /** Indicates whether the window has been closed by the user.
|
---|
| 116 | */
|
---|
| 117 | virtual bool isClosed(void) const = 0;
|
---|
| 118 |
|
---|
| 119 | /** Indicates wether the window is the primary window. The
|
---|
| 120 | primary window is special in that it is destroyed when
|
---|
| 121 | ogre is shut down, and cannot be destroyed directly.
|
---|
| 122 | This is the case because it holds the context for vertex,
|
---|
| 123 | index buffers and textures.
|
---|
| 124 | */
|
---|
| 125 | virtual bool isPrimary(void) const;
|
---|
| 126 |
|
---|
| 127 | /** Swaps the frame buffers to display the next frame.
|
---|
| 128 | @remarks
|
---|
| 129 | All render windows are double-buffered so that no
|
---|
| 130 | 'in-progress' versions of the scene are displayed
|
---|
| 131 | during rendering. Once rendering has completed (to
|
---|
| 132 | an off-screen version of the window) the buffers
|
---|
| 133 | are swapped to display the new frame.
|
---|
| 134 |
|
---|
| 135 | @param
|
---|
| 136 | waitForVSync If true, the system waits for the
|
---|
| 137 | next vertical blank period (when the CRT beam turns off
|
---|
| 138 | as it travels from bottom-right to top-left at the
|
---|
| 139 | end of the pass) before flipping. If false, flipping
|
---|
| 140 | occurs no matter what the beam position. Waiting for
|
---|
| 141 | a vertical blank can be slower (and limits the
|
---|
| 142 | framerate to the monitor refresh rate) but results
|
---|
| 143 | in a steadier image with no 'tearing' (a flicker
|
---|
| 144 | resulting from flipping buffers when the beam is
|
---|
| 145 | in the progress of drawing the last frame).
|
---|
| 146 | */
|
---|
| 147 | virtual void swapBuffers(bool waitForVSync = true) = 0;
|
---|
| 148 |
|
---|
| 149 | /// @copydoc RenderTarget::update
|
---|
| 150 | virtual void update(void);
|
---|
| 151 | /** Updates the window contents.
|
---|
| 152 | @remarks
|
---|
| 153 | The window is updated by telling each camera which is supposed
|
---|
| 154 | to render into this window to render it's view, and then
|
---|
| 155 | the window buffers are swapped via swapBuffers() if requested
|
---|
| 156 | @param swapBuffers If set to true, the window will immediately
|
---|
| 157 | swap it's buffers after update. Otherwise, the buffers are
|
---|
| 158 | not swapped, and you have to call swapBuffers yourself sometime
|
---|
| 159 | later. You might want to do this on some rendersystems which
|
---|
| 160 | pause for queued rendering commands to complete before accepting
|
---|
| 161 | swap buffers calls - so you could do other CPU tasks whilst the
|
---|
| 162 | queued commands complete. Or, you might do this if you want custom
|
---|
| 163 | control over your windows, such as for externally created windows.
|
---|
| 164 | */
|
---|
| 165 | virtual void update(bool swapBuffers);
|
---|
| 166 |
|
---|
| 167 | /** Returns true if window is running in fullscreen mode.
|
---|
| 168 | */
|
---|
| 169 | virtual bool isFullScreen(void) const;
|
---|
| 170 |
|
---|
| 171 | /** Overloaded version of getMetrics from RenderTarget, including extra details
|
---|
| 172 | specific to windowing systems.
|
---|
| 173 | */
|
---|
| 174 | virtual void getMetrics(unsigned int& width, unsigned int& height, unsigned int& colourDepth,
|
---|
| 175 | int& left, int& top);
|
---|
| 176 |
|
---|
| 177 | protected:
|
---|
| 178 | bool mIsFullScreen;
|
---|
| 179 | bool mIsPrimary;
|
---|
| 180 | int mLeft;
|
---|
| 181 | int mTop;
|
---|
| 182 |
|
---|
| 183 | /** Indicates that this is the primary window. Only to be called by
|
---|
| 184 | Ogre::Root
|
---|
| 185 | */
|
---|
| 186 | void _setPrimary() { mIsPrimary = true; }
|
---|
| 187 |
|
---|
| 188 | friend class Root;
|
---|
| 189 | };
|
---|
| 190 |
|
---|
| 191 | /** Defines the interface a DLL implemeting a platform-specific version must implement.
|
---|
| 192 | @remarks
|
---|
| 193 | Any library (.dll, .so) wishing to implement a platform-specific version of this
|
---|
| 194 | dialog must export the symbol 'createRenderWindow' with the signature
|
---|
| 195 | void createPlatformRenderWindow(RenderWindow** ppDlg)
|
---|
| 196 | */
|
---|
| 197 | typedef void (*DLL_CREATERENDERWINDOW)(RenderWindow** ppWindow);
|
---|
| 198 |
|
---|
| 199 | } // Namespace
|
---|
| 200 | #endif
|
---|