BsWin32GLSupport.h 2.7 KB

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