openscenegraph
GraphicsHandleWin32
Go to the documentation of this file.
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
14#ifndef OSGVIEWER_GRAPHICSHANDLEWIN32
15#define OSGVIEWER_GRAPHICSHANDLEWIN32 1
16
17#include <osgViewer/Export>
18
19// Fallback if not correctly detected in CMake macro
20#ifndef _WIN32_WINNT
21//#define _WIN32_WINNT 0x0A00 // Windows 10
22//#define _WIN32_WINNT 0x0603 // Windows 8.1
23//#define _WIN32_WINNT 0x0602 // Windows 8
24//#define _WIN32_WINNT 0x0601 // Windows 7
25//#define _WIN32_WINNT 0x0600 // Windows Server 2008
26//#define _WIN32_WINNT 0x0600 // Windows Vista
27//#define _WIN32_WINNT 0x0502 // Windows Server 2003 with SP1, Windows XP with SP2
28//#define _WIN32_WINNT 0x0501 // Windows Server 2003, Windows XP
29#define _WIN32_WINNT 0x0500 // Windows NT
30#endif
31#include <windows.h>
32
33namespace osgViewer
34{
35
36/** Class to encapsulate platform-specific OpenGL context handle variables.
37 * Derived osg::GraphicsContext classes can inherit from this class to
38 * share OpenGL resources.*/
39
40class OSGVIEWER_EXPORT GraphicsHandleWin32
41{
42 public:
43
44 GraphicsHandleWin32():
45 _hwnd(0),
46 _hdc(0),
47 _hglrc(0) {}
48
49 /** Set native window.*/
50 inline void setHWND(HWND hwnd) { _hwnd = hwnd; }
51
52 /** Get native window.*/
53 inline HWND getHWND() const { return _hwnd; }
54
55 /** Set device context.*/
56 inline void setHDC(HDC hdc) { _hdc = hdc; }
57
58 /** Get device context.*/
59 inline HDC getHDC() const { return _hdc; }
60
61 /** Set native OpenGL graphics context.*/
62 inline void setWGLContext(HGLRC hglrc) { _hglrc = hglrc; }
63
64 /** Get native OpenGL graphics context.*/
65 inline HGLRC getWGLContext() const { return _hglrc; }
66
67 protected:
68
69 HWND _hwnd;
70 HDC _hdc;
71 HGLRC _hglrc;
72
73};
74
75}
76
77
78// Definitions required to create an OpenGL pixel format, from the WGL_ARB_pixel_format specification document.
79// See http://www.opengl.org/registry/specs/ARB/wgl_pixel_format.txt
80
81#ifndef WGL_ARB_pixel_format
82#define WGL_ARB_pixel_format 1
83#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
84#define WGL_DRAW_TO_WINDOW_ARB 0x2001
85#define WGL_DRAW_TO_BITMAP_ARB 0x2002
86#define WGL_ACCELERATION_ARB 0x2003
87#define WGL_NEED_PALETTE_ARB 0x2004
88#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005
89#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006
90#define WGL_SWAP_METHOD_ARB 0x2007
91#define WGL_NUMBER_OVERLAYS_ARB 0x2008
92#define WGL_NUMBER_UNDERLAYS_ARB 0x2009
93#define WGL_TRANSPARENT_ARB 0x200A
94#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037
95#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038
96#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039
97#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A
98#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B
99#define WGL_SHARE_DEPTH_ARB 0x200C
100#define WGL_SHARE_STENCIL_ARB 0x200D
101#define WGL_SHARE_ACCUM_ARB 0x200E
102#define WGL_SUPPORT_GDI_ARB 0x200F
103#define WGL_SUPPORT_OPENGL_ARB 0x2010
104#define WGL_DOUBLE_BUFFER_ARB 0x2011
105#define WGL_STEREO_ARB 0x2012
106#define WGL_PIXEL_TYPE_ARB 0x2013
107#define WGL_COLOR_BITS_ARB 0x2014
108#define WGL_RED_BITS_ARB 0x2015
109#define WGL_RED_SHIFT_ARB 0x2016
110#define WGL_GREEN_BITS_ARB 0x2017
111#define WGL_GREEN_SHIFT_ARB 0x2018
112#define WGL_BLUE_BITS_ARB 0x2019
113#define WGL_BLUE_SHIFT_ARB 0x201A
114#define WGL_ALPHA_BITS_ARB 0x201B
115#define WGL_ALPHA_SHIFT_ARB 0x201C
116#define WGL_ACCUM_BITS_ARB 0x201D
117#define WGL_ACCUM_RED_BITS_ARB 0x201E
118#define WGL_ACCUM_GREEN_BITS_ARB 0x201F
119#define WGL_ACCUM_BLUE_BITS_ARB 0x2020
120#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021
121#define WGL_DEPTH_BITS_ARB 0x2022
122#define WGL_STENCIL_BITS_ARB 0x2023
123#define WGL_AUX_BUFFERS_ARB 0x2024
124#define WGL_NO_ACCELERATION_ARB 0x2025
125#define WGL_GENERIC_ACCELERATION_ARB 0x2026
126#define WGL_FULL_ACCELERATION_ARB 0x2027
127#define WGL_SWAP_EXCHANGE_ARB 0x2028
128#define WGL_SWAP_COPY_ARB 0x2029
129#define WGL_SWAP_UNDEFINED_ARB 0x202A
130#define WGL_TYPE_RGBA_ARB 0x202B
131#define WGL_TYPE_COLORINDEX_ARB 0x202C
132#define WGL_SAMPLE_BUFFERS_ARB 0x2041
133#define WGL_SAMPLES_ARB 0x2042
134#endif
135
136#endif