BsWin32GLSupport.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. /** @addtogroup GL
  10. * @{
  11. */
  12. /** Handles OpenGL initialization, window creation and extensions on Windows. */
  13. class BS_RSGL_EXPORT Win32GLSupport : public GLSupport
  14. {
  15. public:
  16. Win32GLSupport();
  17. /** @copydoc GLSupport::newWindow */
  18. SPtr<RenderWindow> newWindow(RENDER_WINDOW_DESC& desc, UINT32 windowId, SPtr<RenderWindow> parentWindow) override;
  19. /** @copydoc GLSupport::newWindowCore */
  20. SPtr<RenderWindowCore> newWindowCore(RENDER_WINDOW_DESC& desc, UINT32 windowId) override;
  21. /** @copydoc GLSupport::start */
  22. void start() override;
  23. /** @copydoc GLSupport::stop */
  24. void stop() override;
  25. /** @copydoc GLSupport::getProcAddress */
  26. void* getProcAddress(const String& procname) override;
  27. /** @copydoc GLSupport::initializeExtensions */
  28. void initializeExtensions() override;
  29. /**
  30. * Creates a new OpenGL context.
  31. *
  32. * @param[in] hdc Handle to device context to create the context from.
  33. * @param[in] externalGlrc (Optional) Handle to external OpenGL context. If not provided new context will be
  34. * created.
  35. * @return Newly created GLContext class referencing the created or external context handle.
  36. */
  37. SPtr<Win32Context> createContext(HDC hdc, HGLRC externalGlrc = 0);
  38. /**
  39. * Selects and sets an appropriate pixel format based on the provided parameters.
  40. *
  41. * @param[in] hdc Handle to device context to create the context from.
  42. * @param[in] colorDepth Wanted color depth of the pixel format, in bits.
  43. * @param[in] multisample Amount of multisampling wanted, if any.
  44. * @param[in] hwGamma Should the format support automatic gamma conversion on write/read.
  45. * @param[in] depth Should the pixel format contain the depth/stencil buffer.
  46. * @return True if a pixel format was successfully set.
  47. */
  48. bool selectPixelFormat(HDC hdc, int colorDepth, int multisample, bool hwGamma, bool depth);
  49. /** @copydoc GLSupport::getVideoModeInfo */
  50. SPtr<VideoModeInfo> getVideoModeInfo() const override;
  51. private:
  52. /** Initializes windows specific OpenGL extensions needed for advanced context creation. */
  53. void initialiseWGL();
  54. /** Dummy window procedure used when creating the initial dummy OpenGL context. */
  55. static LRESULT CALLBACK dummyWndProc(HWND hwnd, UINT umsg, WPARAM wp, LPARAM lp);
  56. Vector<DEVMODE> mDevModes;
  57. Win32RenderWindowCore *mInitialWindow;
  58. Vector<int> mMultisampleLevels;
  59. bool mHasPixelFormatARB;
  60. bool mHasMultisample;
  61. bool mHasHardwareGamma;
  62. bool mHasAdvancedContext;
  63. };
  64. /** @} */
  65. }