CmRenderWindow.h 6.9 KB

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