BsWin32GLSupport.h 3.0 KB

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