CmRenderWindow.h 6.6 KB

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