CmRenderWindow.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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. namespace CamelotFramework
  27. {
  28. enum class WindowBorder
  29. {
  30. Normal,
  31. None,
  32. Fixed
  33. };
  34. struct CM_EXPORT RENDER_WINDOW_DESC
  35. {
  36. RENDER_WINDOW_DESC()
  37. :width(0), height(0), fullscreen(false)
  38. , vsync(false), vsyncInterval(1), hidden(false)
  39. , displayFrequency(60), colorDepth(32), depthBuffer(true)
  40. , FSAA(0), FSAAHint(""), gamma(false), left(-1), top(-1)
  41. , title(""), border(WindowBorder::Normal), outerDimensions(false), enableDoubleClick(false)
  42. , monitorIndex(-1), toolWindow(false)
  43. { }
  44. UINT32 width;
  45. UINT32 height;
  46. bool fullscreen;
  47. bool vsync;
  48. UINT32 vsyncInterval;
  49. bool hidden;
  50. UINT32 displayFrequency;
  51. UINT32 colorDepth;
  52. bool depthBuffer;
  53. UINT32 FSAA;
  54. String FSAAHint;
  55. bool gamma;
  56. INT32 left; // -1 == screen center
  57. INT32 top; // -1 == screen center
  58. String title;
  59. WindowBorder border;
  60. bool outerDimensions;
  61. bool enableDoubleClick;
  62. bool toolWindow;
  63. UINT32 monitorIndex; // -1 == select based on coordinates
  64. NameValuePairList platformSpecific;
  65. };
  66. /** \addtogroup Core
  67. * @{
  68. */
  69. /** \addtogroup RenderSystem
  70. * @{
  71. */
  72. /** Manages the target rendering window.
  73. @remarks
  74. This class handles a window into which the contents
  75. of a scene are rendered. There is a many-to-1 relationship
  76. between instances of this class an instance of RenderSystem
  77. which controls the rendering of the scene. There may be
  78. more than one window in the case of level editor tools etc.
  79. This class is abstract since there may be
  80. different implementations for different windowing systems.
  81. @remarks
  82. Instances are created and communicated with by the render system
  83. although client programs can get a reference to it from
  84. the render system if required for resizing or moving.
  85. Note that you can have multiple viewpoints
  86. in the window for effects like rear-view mirrors and
  87. picture-in-picture views (see Viewport and Camera).
  88. @author
  89. Steven Streeting
  90. @version
  91. 1.0
  92. */
  93. class CM_EXPORT RenderWindow : public RenderTarget
  94. {
  95. public:
  96. virtual ~RenderWindow();
  97. /**
  98. * @copydoc RenderTarget::isWindow.
  99. */
  100. bool isWindow() const { return true; }
  101. /** Alter fullscreen mode options.
  102. @note Nothing will happen unless the settings here are different from the
  103. current settings.
  104. @param fullScreen Whether to use fullscreen mode or not.
  105. @param width The new width to use
  106. @param height The new height to use
  107. */
  108. virtual void setFullscreen(bool fullScreen, unsigned int width, unsigned int height)
  109. { (void)fullScreen; (void)width; (void)height; }
  110. /** Alter the size of the window.
  111. */
  112. virtual void resize(unsigned int width, unsigned int height) = 0;
  113. /** Notify that the window has been resized
  114. @remarks
  115. You don't need to call this unless you created the window externally.
  116. */
  117. virtual void windowMovedOrResized();
  118. /** Reposition the window.
  119. */
  120. virtual void reposition(int left, int top) = 0;
  121. /** Indicates whether the window is visible (not minimized or obscured)
  122. */
  123. virtual bool isVisible(void) const { return true; }
  124. /** Set the visibility state
  125. */
  126. virtual void setVisible(bool visible)
  127. { (void)visible; }
  128. /** Overridden from RenderTarget, flags invisible windows as inactive
  129. */
  130. virtual bool isActive(void) const { return mActive && isVisible(); }
  131. /** Indicates whether the window has been closed by the user.
  132. */
  133. virtual bool isClosed(void) const = 0;
  134. /** Returns true if window is running in fullscreen mode.
  135. */
  136. virtual bool isFullScreen(void) const;
  137. /** Overloaded version of getMetrics from RenderTarget, including extra details
  138. specific to windowing systems.
  139. */
  140. virtual void getMetrics(unsigned int& width, unsigned int& height, unsigned int& colourDepth,
  141. int& left, int& top);
  142. /// Override since windows don't usually have alpha
  143. PixelFormat suggestPixelFormat() const { return PF_BYTE_RGB; }
  144. /** Returns true if the window will automatically de-activate itself when it loses focus.
  145. */
  146. bool isDeactivatedOnFocusChange() const;
  147. /** Indicates whether the window will automatically deactivate itself when it loses focus.
  148. * \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.
  149. * \note 'true' is the default behavior.
  150. */
  151. void setDeactivateOnFocusChange(bool deactivate);
  152. void setHasFocus(bool focus);
  153. bool hasFocus() const { return mHasFocus; }
  154. mutable boost::signal<void(RenderWindow*)> onFocusChanged;
  155. virtual void destroy();
  156. static RenderWindowPtr create(RENDER_WINDOW_DESC& desc, RenderWindowPtr parentWindow = nullptr);
  157. protected:
  158. /** Default constructor.
  159. */
  160. RenderWindow(const RENDER_WINDOW_DESC& desc);
  161. protected:
  162. bool mIsFullScreen;
  163. bool mAutoDeactivatedOnFocusChange;
  164. int mLeft;
  165. int mTop;
  166. bool mHasFocus;
  167. RENDER_WINDOW_DESC mDesc;
  168. };
  169. /** @} */
  170. /** @} */
  171. } // Namespace
  172. #endif