CmRenderWindow.h 7.3 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. /** \addtogroup Core
  29. * @{
  30. */
  31. /** \addtogroup RenderSystem
  32. * @{
  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 CM_EXPORT RenderWindow : public RenderTarget
  56. {
  57. public:
  58. /** Default constructor.
  59. */
  60. RenderWindow();
  61. /** Creates & displays the new window.
  62. @param
  63. width The width of the window in pixels.
  64. @param
  65. height The height of the window in pixels.
  66. @param
  67. colourDepth The colour depth in bits. Ignored if
  68. fullScreen is false since the desktop depth is used.
  69. @param
  70. fullScreen If true, the window fills the screen,
  71. with no title bar or border.
  72. @param
  73. left The x-position of the window. Ignored if
  74. fullScreen = true.
  75. @param
  76. top The y-position of the window. Ignored if
  77. fullScreen = true.
  78. @param
  79. depthBuffer Specify true to include a depth-buffer.
  80. @param
  81. miscParam A variable number of pointers to platform-specific arguments. The
  82. actual requirements must be defined by the implementing subclasses.
  83. */
  84. virtual void create(const String& name, unsigned int width, unsigned int height,
  85. bool fullScreen, const NameValuePairList *miscParams) = 0;
  86. /** Alter fullscreen mode options.
  87. @note Nothing will happen unless the settings here are different from the
  88. current settings.
  89. @param fullScreen Whether to use fullscreen mode or not.
  90. @param width The new width to use
  91. @param height The new height to use
  92. */
  93. virtual void setFullscreen(bool fullScreen, unsigned int width, unsigned int height)
  94. { (void)fullScreen; (void)width; (void)height; }
  95. /** Destroys the window.
  96. */
  97. virtual void destroy(void) = 0;
  98. /** Alter the size of the window.
  99. */
  100. virtual void resize(unsigned int width, unsigned int height) = 0;
  101. /** Notify that the window has been resized
  102. @remarks
  103. You don't need to call this unless you created the window externally.
  104. */
  105. virtual void windowMovedOrResized() {}
  106. /** Reposition the window.
  107. */
  108. virtual void reposition(int left, int top) = 0;
  109. /** Indicates whether the window is visible (not minimized or obscured)
  110. */
  111. virtual bool isVisible(void) const { return true; }
  112. /** Set the visibility state
  113. */
  114. virtual void setVisible(bool visible)
  115. { (void)visible; }
  116. /** Overridden from RenderTarget, flags invisible windows as inactive
  117. */
  118. virtual bool isActive(void) const { return mActive && isVisible(); }
  119. /** Indicates whether the window has been closed by the user.
  120. */
  121. virtual bool isClosed(void) const = 0;
  122. /** Indicates whether the window is the primary window. The
  123. primary window is special in that it is destroyed when
  124. ogre is shut down, and cannot be destroyed directly.
  125. This is the case because it holds the context for vertex,
  126. index buffers and textures.
  127. */
  128. virtual bool isPrimary(void) const;
  129. /** Returns true if window is running in fullscreen mode.
  130. */
  131. virtual bool isFullScreen(void) const;
  132. /** Overloaded version of getMetrics from RenderTarget, including extra details
  133. specific to windowing systems.
  134. */
  135. virtual void getMetrics(unsigned int& width, unsigned int& height, unsigned int& colourDepth,
  136. int& left, int& top);
  137. /// Override since windows don't usually have alpha
  138. PixelFormat suggestPixelFormat() const { return PF_BYTE_RGB; }
  139. /** Returns true if the window will automatically de-activate itself when it loses focus.
  140. */
  141. bool isDeactivatedOnFocusChange() const;
  142. /** Indicates whether the window will automatically deactivate itself when it loses focus.
  143. * \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.
  144. * \note 'true' is the default behavior.
  145. */
  146. void setDeactivateOnFocusChange(bool deactivate);
  147. protected:
  148. bool mIsFullScreen;
  149. bool mIsPrimary;
  150. bool mAutoDeactivatedOnFocusChange;
  151. int mLeft;
  152. int mTop;
  153. /** Indicates that this is the primary window.
  154. */
  155. void _setPrimary() { mIsPrimary = true; }
  156. friend class Root;
  157. };
  158. /** @} */
  159. /** @} */
  160. } // Namespace
  161. #endif