GraphicsHandleWin32 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2009 Robert Osfield
  2. *
  3. * This library is open source and may be redistributed and/or modified under
  4. * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
  5. * (at your option) any later version. The full license is in LICENSE file
  6. * included with this distribution, and on the openscenegraph.org website.
  7. *
  8. * This library is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * OpenSceneGraph Public License for more details.
  12. */
  13. #ifndef OSGVIEWER_GRAPHICSHANDLEWIN32
  14. #define OSGVIEWER_GRAPHICSHANDLEWIN32 1
  15. #include <osgViewer/Export>
  16. // Fallback if not correctly detected in CMake macro
  17. #ifndef _WIN32_WINNT
  18. //#define _WIN32_WINNT 0x0A00 // Windows 10
  19. //#define _WIN32_WINNT 0x0603 // Windows 8.1
  20. //#define _WIN32_WINNT 0x0602 // Windows 8
  21. //#define _WIN32_WINNT 0x0601 // Windows 7
  22. //#define _WIN32_WINNT 0x0600 // Windows Server 2008
  23. //#define _WIN32_WINNT 0x0600 // Windows Vista
  24. //#define _WIN32_WINNT 0x0502 // Windows Server 2003 with SP1, Windows XP with SP2
  25. //#define _WIN32_WINNT 0x0501 // Windows Server 2003, Windows XP
  26. #define _WIN32_WINNT 0x0500 // Windows NT
  27. #endif
  28. #include <windows.h>
  29. namespace osgViewer
  30. {
  31. /** Class to encapsulate platform-specific OpenGL context handle variables.
  32. * Derived osg::GraphicsContext classes can inherit from this class to
  33. * share OpenGL resources.*/
  34. class OSGVIEWER_EXPORT GraphicsHandleWin32
  35. {
  36. public:
  37. GraphicsHandleWin32():
  38. _hwnd(0),
  39. _hdc(0),
  40. _hglrc(0) {}
  41. /** Set native window.*/
  42. inline void setHWND(HWND hwnd) { _hwnd = hwnd; }
  43. /** Get native window.*/
  44. inline HWND getHWND() const { return _hwnd; }
  45. /** Set device context.*/
  46. inline void setHDC(HDC hdc) { _hdc = hdc; }
  47. /** Get device context.*/
  48. inline HDC getHDC() const { return _hdc; }
  49. /** Set native OpenGL graphics context.*/
  50. inline void setWGLContext(HGLRC hglrc) { _hglrc = hglrc; }
  51. /** Get native OpenGL graphics context.*/
  52. inline HGLRC getWGLContext() const { return _hglrc; }
  53. protected:
  54. HWND _hwnd;
  55. HDC _hdc;
  56. HGLRC _hglrc;
  57. };
  58. }
  59. // Definitions required to create an OpenGL pixel format, from the WGL_ARB_pixel_format specification document.
  60. // See http://www.opengl.org/registry/specs/ARB/wgl_pixel_format.txt
  61. #ifndef WGL_ARB_pixel_format
  62. #define WGL_ARB_pixel_format 1
  63. #define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
  64. #define WGL_DRAW_TO_WINDOW_ARB 0x2001
  65. #define WGL_DRAW_TO_BITMAP_ARB 0x2002
  66. #define WGL_ACCELERATION_ARB 0x2003
  67. #define WGL_NEED_PALETTE_ARB 0x2004
  68. #define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005
  69. #define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006
  70. #define WGL_SWAP_METHOD_ARB 0x2007
  71. #define WGL_NUMBER_OVERLAYS_ARB 0x2008
  72. #define WGL_NUMBER_UNDERLAYS_ARB 0x2009
  73. #define WGL_TRANSPARENT_ARB 0x200A
  74. #define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037
  75. #define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038
  76. #define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039
  77. #define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A
  78. #define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B
  79. #define WGL_SHARE_DEPTH_ARB 0x200C
  80. #define WGL_SHARE_STENCIL_ARB 0x200D
  81. #define WGL_SHARE_ACCUM_ARB 0x200E
  82. #define WGL_SUPPORT_GDI_ARB 0x200F
  83. #define WGL_SUPPORT_OPENGL_ARB 0x2010
  84. #define WGL_DOUBLE_BUFFER_ARB 0x2011
  85. #define WGL_STEREO_ARB 0x2012
  86. #define WGL_PIXEL_TYPE_ARB 0x2013
  87. #define WGL_COLOR_BITS_ARB 0x2014
  88. #define WGL_RED_BITS_ARB 0x2015
  89. #define WGL_RED_SHIFT_ARB 0x2016
  90. #define WGL_GREEN_BITS_ARB 0x2017
  91. #define WGL_GREEN_SHIFT_ARB 0x2018
  92. #define WGL_BLUE_BITS_ARB 0x2019
  93. #define WGL_BLUE_SHIFT_ARB 0x201A
  94. #define WGL_ALPHA_BITS_ARB 0x201B
  95. #define WGL_ALPHA_SHIFT_ARB 0x201C
  96. #define WGL_ACCUM_BITS_ARB 0x201D
  97. #define WGL_ACCUM_RED_BITS_ARB 0x201E
  98. #define WGL_ACCUM_GREEN_BITS_ARB 0x201F
  99. #define WGL_ACCUM_BLUE_BITS_ARB 0x2020
  100. #define WGL_ACCUM_ALPHA_BITS_ARB 0x2021
  101. #define WGL_DEPTH_BITS_ARB 0x2022
  102. #define WGL_STENCIL_BITS_ARB 0x2023
  103. #define WGL_AUX_BUFFERS_ARB 0x2024
  104. #define WGL_NO_ACCELERATION_ARB 0x2025
  105. #define WGL_GENERIC_ACCELERATION_ARB 0x2026
  106. #define WGL_FULL_ACCELERATION_ARB 0x2027
  107. #define WGL_SWAP_EXCHANGE_ARB 0x2028
  108. #define WGL_SWAP_COPY_ARB 0x2029
  109. #define WGL_SWAP_UNDEFINED_ARB 0x202A
  110. #define WGL_TYPE_RGBA_ARB 0x202B
  111. #define WGL_TYPE_COLORINDEX_ARB 0x202C
  112. #define WGL_SAMPLE_BUFFERS_ARB 0x2041
  113. #define WGL_SAMPLES_ARB 0x2042
  114. #endif
  115. #endif