2
0

CmRenderWindow.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. /*-------------------------------------------------------------------------
  2. This source file is a part of OGRE
  3. (Object-oriented Graphics Rendering Engine)
  4. For the latest info, see http://www.ogre3d.org/
  5. Copyright (c) 2000-2011 Torus Knot Software Ltd
  6. Permission is hereby granted, free of charge, to any person obtaining a copy
  7. of this software and associated documentation files (the "Software"), to deal
  8. in the Software without restriction, including without limitation the rights
  9. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. copies of the Software, and to permit persons to whom the Software is
  11. furnished to do so, subject to the following conditions:
  12. The above copyright notice and this permission notice shall be included in
  13. all copies or substantial portions of the Software.
  14. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. THE SOFTWARE
  21. -------------------------------------------------------------------------*/
  22. #ifndef __RenderWindow_H__
  23. #define __RenderWindow_H__
  24. #include "CmPrerequisites.h"
  25. #include "CmRenderTarget.h"
  26. #include "CmInt2.h"
  27. namespace CamelotFramework
  28. {
  29. enum class WindowBorder
  30. {
  31. Normal,
  32. None,
  33. Fixed
  34. };
  35. enum class WindowResizeDirection
  36. {
  37. Left, TopLeft, Top, TopRight,
  38. Right, BottomRight, Bottom, BottomLeft
  39. };
  40. struct CM_EXPORT RENDER_WINDOW_DESC
  41. {
  42. RENDER_WINDOW_DESC()
  43. :width(0), height(0), fullscreen(false)
  44. , vsync(false), vsyncInterval(1), hidden(false)
  45. , displayFrequency(60), colorDepth(32), depthBuffer(true)
  46. , FSAA(0), FSAAHint(""), gamma(false), left(-1), top(-1)
  47. , title(""), border(WindowBorder::Normal), outerDimensions(false), enableDoubleClick(false)
  48. , monitorIndex(-1), toolWindow(false)
  49. { }
  50. UINT32 width;
  51. UINT32 height;
  52. bool fullscreen;
  53. bool vsync;
  54. UINT32 vsyncInterval;
  55. bool hidden;
  56. UINT32 displayFrequency;
  57. UINT32 colorDepth;
  58. bool depthBuffer;
  59. UINT32 FSAA;
  60. String FSAAHint;
  61. bool gamma;
  62. INT32 left; // -1 == screen center
  63. INT32 top; // -1 == screen center
  64. String title;
  65. WindowBorder border;
  66. bool outerDimensions;
  67. bool enableDoubleClick;
  68. bool toolWindow;
  69. UINT32 monitorIndex; // -1 == select based on coordinates
  70. NameValuePairList platformSpecific;
  71. };
  72. /** \addtogroup Core
  73. * @{
  74. */
  75. /** \addtogroup RenderSystem
  76. * @{
  77. */
  78. /** Manages the target rendering window.
  79. @remarks
  80. This class handles a window into which the contents
  81. of a scene are rendered. There is a many-to-1 relationship
  82. between instances of this class an instance of RenderSystem
  83. which controls the rendering of the scene. There may be
  84. more than one window in the case of level editor tools etc.
  85. This class is abstract since there may be
  86. different implementations for different windowing systems.
  87. @remarks
  88. Instances are created and communicated with by the render system
  89. although client programs can get a reference to it from
  90. the render system if required for resizing or moving.
  91. Note that you can have multiple viewpoints
  92. in the window for effects like rear-view mirrors and
  93. picture-in-picture views (see Viewport and Camera).
  94. @author
  95. Steven Streeting
  96. @version
  97. 1.0
  98. */
  99. class CM_EXPORT RenderWindow : public RenderTarget
  100. {
  101. public:
  102. virtual ~RenderWindow();
  103. /**
  104. @brief Core method. Alter fullscreen mode options.
  105. */
  106. virtual void setFullscreen(bool fullScreen, UINT32 width, UINT32 height)
  107. { (void)fullScreen; (void)width; (void)height; }
  108. /**
  109. * @brief Core method. Set the visibility state.
  110. */
  111. virtual void setVisible(bool visible);
  112. /**
  113. * @brief Core method. Alter the size of the window.
  114. */
  115. virtual void resize(UINT32 width, UINT32 height) = 0;
  116. /**
  117. * @brief Core method. Reposition the window.
  118. */
  119. virtual void reposition(INT32 left, INT32 top) = 0;
  120. /**
  121. * @copydoc RenderTarget::isWindow.
  122. */
  123. bool isWindow() const { return true; }
  124. /**
  125. * @brief Indicates whether the window is visible (not minimized or obscured).
  126. */
  127. virtual bool isVisible(void) const { return true; }
  128. /**
  129. * @copydoc RenderTarget::isActive
  130. */
  131. virtual bool isActive() const { return mActive && isVisible(); }
  132. /**
  133. * @brief Indicates whether the window has been closed by the user.
  134. */
  135. virtual bool isClosed() const = 0;
  136. /**
  137. * @brief Returns true if window is running in fullscreen mode.
  138. */
  139. virtual bool isFullScreen() const;
  140. INT32 getLeft() const { return mLeft; }
  141. INT32 getTop() const { return mTop; }
  142. /**
  143. * @brief Indicates whether the window currently has keyboard focus.
  144. */
  145. bool hasFocus() const { return mHasFocus; }
  146. /**
  147. * @brief Overloaded version of getMetrics from RenderTarget, including extra details
  148. * specific to windowing systems.
  149. */
  150. virtual void getMetrics(UINT32& width, UINT32& height, UINT32& colourDepth,
  151. INT32& left, INT32& top);
  152. /**
  153. * @brief Internal method. Core method. Called when window is moved or resized.
  154. */
  155. virtual void _windowMovedOrResized();
  156. /**
  157. * @brief Internal method. Core method. Called when window has received focus.
  158. */
  159. virtual void _windowFocusReceived();
  160. /**
  161. * @brief Internal method. Core method. Called when window has lost focus.
  162. */
  163. virtual void _windowFocusLost();
  164. virtual Int2 screenToWindowPos(const Int2& screenPos) const = 0;
  165. virtual Int2 windowToScreenPos(const Int2& windowPos) const = 0;
  166. virtual void startResize(WindowResizeDirection direction) = 0;
  167. virtual void endResize() = 0;
  168. virtual void startMove() = 0;
  169. virtual void endMove() = 0;
  170. virtual void destroy();
  171. static RenderWindowPtr create(RENDER_WINDOW_DESC& desc, RenderWindowPtr parentWindow = nullptr);
  172. protected:
  173. friend class RenderWindowManager;
  174. /** Default constructor.
  175. */
  176. RenderWindow(const RENDER_WINDOW_DESC& desc);
  177. protected:
  178. bool mIsFullScreen;
  179. INT32 mLeft;
  180. INT32 mTop;
  181. bool mHasFocus;
  182. RENDER_WINDOW_DESC mDesc;
  183. };
  184. /** @} */
  185. /** @} */
  186. } // Namespace
  187. #endif