BsWin32GLSupport.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #pragma once
  2. #include "BsWin32Prerequisites.h"
  3. #include "BsGLSupport.h"
  4. #include "BsGLRenderAPI.h"
  5. namespace BansheeEngine
  6. {
  7. /**
  8. * @brief Handles OpenGL initialization, window creation and extensions
  9. * on Windows.
  10. */
  11. class BS_RSGL_EXPORT Win32GLSupport : public GLSupport
  12. {
  13. public:
  14. Win32GLSupport();
  15. /**
  16. * @copydoc GLSupport::newWindow
  17. */
  18. virtual RenderWindowPtr newWindow(RENDER_WINDOW_DESC& desc, UINT32 windowId, RenderWindowPtr parentWindow) override;
  19. /**
  20. * @copydoc GLSupport::newWindowCore
  21. */
  22. virtual SPtr<RenderWindowCore> newWindowCore(RENDER_WINDOW_DESC& desc, UINT32 windowId) override;
  23. /**
  24. * @copydoc GLSupport::start
  25. */
  26. void start() override;
  27. /**
  28. * @copydoc GLSupport::stop
  29. */
  30. void stop() override;
  31. /**
  32. * @copydoc GLSupport::getProcAddress
  33. */
  34. void* getProcAddress(const String& procname) override;
  35. /**
  36. * @copydoc GLSupport::initializeExtensions
  37. */
  38. virtual void initializeExtensions() override;
  39. /**
  40. * @brief Creates a new OpenGL context.
  41. *
  42. * @param hdc Handle to device context to create the context from.
  43. * @param externalGlrc (Optional) Handle to external OpenGL context. If not provided
  44. * new context will be created.
  45. *
  46. * @returns Newly created GLContext class referencing the created or external context handle.
  47. */
  48. SPtr<Win32Context> createContext(HDC hdc, HGLRC externalGlrc = 0);
  49. /**
  50. * @brief Selects and sets an appropriate pixel format based on the provided parameters.
  51. *
  52. * @param hdc Handle to device context to create the context from.
  53. * @param colorDepth Wanted color depth of the pixel format, in bits.
  54. * @param multisample Amount of multisampling wanted, if any.
  55. * @param hwGamma Should the format support automatic gamma conversion on write/read.
  56. * @param depth Should the pixel format contain the depth/stencil buffer.
  57. *
  58. * @returns True if a pixel format was successfully set.
  59. */
  60. bool selectPixelFormat(HDC hdc, int colorDepth, int multisample, bool hwGamma, bool depthStencil);
  61. /**
  62. * @copydoc GLSupport::getVideoModeInfo
  63. */
  64. VideoModeInfoPtr getVideoModeInfo() const override;
  65. private:
  66. /**
  67. * @brief Initializes windows specific OpenGL extensions needed for advanced context creation.
  68. */
  69. void initialiseWGL();
  70. /**
  71. * @brief Dummy window procedure used when creating the initial dummy OpenGL context.
  72. */
  73. static LRESULT CALLBACK dummyWndProc(HWND hwnd, UINT umsg, WPARAM wp, LPARAM lp);
  74. Vector<DEVMODE> mDevModes;
  75. Win32RenderWindowCore *mInitialWindow;
  76. Vector<int> mMultisampleLevels;
  77. bool mHasPixelFormatARB;
  78. bool mHasMultisample;
  79. bool mHasHardwareGamma;
  80. bool mHasAdvancedContext;
  81. };
  82. }