BsWin32GLSupport.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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);
  19. /**
  20. * @copydoc GLSupport::newWindowCore
  21. */
  22. virtual SPtr<RenderWindowCore> newWindowCore(RENDER_WINDOW_DESC& desc, UINT32 windowId);
  23. /**
  24. * @copydoc GLSupport::start
  25. */
  26. void start();
  27. /**
  28. * @copydoc GLSupport::stop
  29. */
  30. void stop();
  31. /**
  32. * @copydoc GLSupport::getProcAddress
  33. */
  34. void* getProcAddress(const String& procname);
  35. /**
  36. * @copydoc GLSupport::initializeExtensions
  37. */
  38. virtual void initializeExtensions();
  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. *
  57. * @returns True if a pixel format was successfully set.
  58. */
  59. bool selectPixelFormat(HDC hdc, int colorDepth, int multisample, bool hwGamma);
  60. /**
  61. * @copydoc GLSupport::getVideoModeInfo
  62. */
  63. VideoModeInfoPtr getVideoModeInfo() const;
  64. private:
  65. /**
  66. * @brief Initializes windows specific OpenGL extensions needed for advanced context creation.
  67. */
  68. void initialiseWGL();
  69. /**
  70. * @brief Dummy window procedure used when creating the initial dummy OpenGL context.
  71. */
  72. static LRESULT CALLBACK dummyWndProc(HWND hwnd, UINT umsg, WPARAM wp, LPARAM lp);
  73. Vector<DEVMODE> mDevModes;
  74. Win32WindowCore *mInitialWindow;
  75. Vector<int> mMultisampleLevels;
  76. bool mHasPixelFormatARB;
  77. bool mHasMultisample;
  78. bool mHasHardwareGamma;
  79. bool mHasAdvancedContext;
  80. };
  81. }