BsWin32GLSupport.h 2.3 KB

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