BsWin32Window.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. //__________________________ Banshee Project - A modern game development toolkit _________________________________//
  2. //_____________________________________ www.banshee-project.com __________________________________________________//
  3. //________________________ Copyright (c) 2014 Marko Pintera. All rights reserved. ________________________________//
  4. #pragma once
  5. #include "BsWin32Prerequisites.h"
  6. #include "BsRenderWindow.h"
  7. namespace BansheeEngine
  8. {
  9. /**
  10. * @brief Render window implementation for Windows.
  11. */
  12. class BS_RSGL_EXPORT Win32Window : public RenderWindow
  13. {
  14. public:
  15. ~Win32Window();
  16. /**
  17. * @copydoc RenderWindow::setFullscreen(UINT32, UINT32, float, UINT32)
  18. */
  19. void setFullscreen(UINT32 width, UINT32 height, float refreshRate = 60.0f, UINT32 monitorIdx = 0);
  20. /**
  21. * @copydoc RenderWindow::setFullscreen(const VideoMode&)
  22. */
  23. void setFullscreen(const VideoMode& mode);
  24. /**
  25. * @copydoc RenderWindow::setWindowed
  26. */
  27. void setWindowed(UINT32 width, UINT32 height);
  28. /**
  29. * @copydoc RenderWindow::setHidden
  30. */
  31. void setHidden(bool hidden);
  32. /**
  33. * @copydoc RenderWindow::isActive
  34. */
  35. bool isActive() const;
  36. /**
  37. * @copydoc RenderWindow::isVisible
  38. */
  39. bool isVisible() const;
  40. /**
  41. * @copydoc RenderWindow::isClosed
  42. */
  43. bool isClosed() const;
  44. /**
  45. * @copydoc RenderWindow::move
  46. */
  47. void move(INT32 left, INT32 top);
  48. /**
  49. * @copydoc RenderWindow::resize
  50. */
  51. void resize(UINT32 width, UINT32 height);
  52. /**
  53. * @copydoc RenderWindow::copyContentsToMemory
  54. */
  55. void copyToMemory(PixelData &dst, FrameBuffer buffer);
  56. /**
  57. * @copydoc RenderWindow::swapBuffers
  58. */
  59. void swapBuffers();
  60. /**
  61. * @copydoc RenderWindow::requiresTextureFlipping
  62. */
  63. bool requiresTextureFlipping() const { return false; }
  64. /**
  65. * @copydoc RenderWindow::screenToWindowPos
  66. */
  67. Vector2I screenToWindowPos(const Vector2I& screenPos) const;
  68. /**
  69. * @copydoc RenderWindow::windowToScreenPos
  70. */
  71. Vector2I windowToScreenPos(const Vector2I& windowPos) const;
  72. /**
  73. * @copydoc RenderWindow::getCustomAttribute
  74. */
  75. void getCustomAttribute(const String& name, void* pData) const;
  76. /**
  77. * @copydoc RenderWindow::setActive
  78. */
  79. virtual void setActive(bool state);
  80. /**
  81. * @copydoc RenderWindow::_windowMovedOrResized
  82. */
  83. void _windowMovedOrResized();
  84. /**
  85. * @brief Returns handle to device context associated with the window.
  86. */
  87. HDC _getHDC() const { return mHDC; }
  88. protected:
  89. friend class GLRenderWindowManager;
  90. friend class Win32GLSupport;
  91. Win32Window(const RENDER_WINDOW_DESC& desc, Win32GLSupport &glsupport);
  92. /**
  93. * @copydoc RenderWindow::initialize_internal().
  94. */
  95. void initialize_internal();
  96. /**
  97. * @copydoc RenderWindow::destroy_internal().
  98. */
  99. void destroy_internal();
  100. /**
  101. * @brief Calculates window size based on provided client area size and currently set window style.
  102. */
  103. void getAdjustedWindowSize(UINT32 clientWidth, UINT32 clientHeight, UINT32* winWidth, UINT32* winHeight);
  104. protected:
  105. Win32GLSupport &mGLSupport;
  106. HWND mHWnd;
  107. HDC mHDC;
  108. DWORD mWindowedStyle;
  109. DWORD mWindowedStyleEx;
  110. bool mIsExternal;
  111. bool mIsChild;
  112. char* mDeviceName;
  113. bool mIsExternalGLControl;
  114. bool mSizing;
  115. bool mClosed;
  116. int mDisplayFrequency;
  117. Win32Context *mContext;
  118. };
  119. }