Open Inventor Release 2024.1.3
 
Loading...
Searching...
No Matches
SbGlContextHelper.h
1/*=======================================================================
2 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
3 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
4 *** ***
5 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
6 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
7 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
8 *** ***
9 *** RESTRICTED RIGHTS LEGEND ***
10 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
11 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
12 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
13 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
14 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
15 *** ***
16 *** COPYRIGHT (C) 1996-2024 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : Benjamin GRANGE (Dec 2008)
22**=======================================================================*/
23
24
25#ifndef SB_GL_CONTEXT_HELPER_H
26#define SB_GL_CONTEXT_HELPER_H
27
28#include <Inventor/SbBase.h>
29#include <vector>
30
31#ifndef HIDDEN_FROM_DOC
32
33#if defined(OIV_HEADLESS)
34typedef void *EGLDisplay;
35typedef void *EGLConfig;
36typedef void *EGLSurface;
37typedef void *EGLContext;
38#elif defined(_WIN32)
39#elif defined(__APPLE__)
40typedef struct _CGLContextObject *CGLContextObj;
41typedef struct _CGLPixelFormatObject *CGLPixelFormatObj;
42typedef unsigned int CGDirectDisplayID;
43#else
44typedef struct _XDisplay Display;
45typedef unsigned long GLXDrawable;
46typedef unsigned long GLXPixmap;
47typedef struct __GLXcontextRec *GLXContext;
48typedef unsigned long GLXFBConfigID;
49typedef unsigned long GLXWindow;
50typedef unsigned long GLXPbuffer;
51typedef unsigned long Colormap;
52typedef unsigned long Pixmap;
53typedef unsigned long Window;
54#if !defined(BUILDING_SB_GL_CONTEXT_HELPER)
55typedef struct __GLXFBConfigRec *GLXFBConfig;
56#endif
57#endif
58
59#endif //HIDDEN_FROM_DOC
60
61class SoGLContext;
62
72{
73public:
81
82private:
83
84
86
87
89
90
91 SoGLContext * getContext();
92
93
94 int getContextGroupId();
95};
96
97
98inline
99SbGLShareContext::SbGLShareContext()
100{
101 shareContext = NULL;
102 shareContextID = 0;
103}
104
105inline
106SbGLShareContext::SbGLShareContext(SoGLContext* _shareContext, int _shareContextID)
107{
108 shareContext = _shareContext;
109 shareContextID = _shareContextID;
110}
111
112inline SoGLContext *
113SbGLShareContext::getContext()
114{
115 return shareContext;
116}
117
118inline int
119SbGLShareContext::getContextGroupId()
120{
121 return shareContextID;
122}
123
128{
129#if defined(OIV_HEADLESS)
130 typedef EGLDisplay Display;
131 typedef EGLContext GLContext;
132 typedef EGLConfig VisualInfo;
133 typedef EGLSurface Drawable;
134#elif defined(_WIN32)
135 typedef HDC Display;
136 typedef HGLRC GLContext;
137 typedef PIXELFORMATDESCRIPTOR* VisualInfo;
138 typedef int Drawable;
139#elif defined(__APPLE__)
140 #undef Display
141 typedef int Display;
142 typedef CGLContextObj GLContext;
143 typedef CGLPixelFormatObj VisualInfo;
144 typedef void* Drawable;
145#else
147 typedef GLXContext GLContext;
148 typedef void* VisualInfo;
149 typedef GLXDrawable Drawable;
150#endif
151
154
157
160
163
170
176
177
180
189 bool direct);
190
193
200 bool makeCurrent(Display dpy, Drawable drawable, GLContext ctx);
201
211 bool direct, const std::vector<int> &attribs);
212}
213
214#endif
215
216
Class encapsulating information about an OpenGL context: a handle on an OpenGL context and its id.
int shareContextID
Corresponding shared context Id managed by upper layer viewer class.
SoGLContext * shareContext
Handle on OpenGL context.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> OpenGL context m...
Platform indepent functions for OpenGL context handling.
VisualInfo getWindowVisualInfo(Display dpy, Drawable drawable)
Returns the VisualInfo used for the specified drawable.
GLContext getCurrentContext()
Return the current active context.
bool isValidDisplay(Display dpy)
Return true if the specified display is valid.
bool makeCurrent(Display dpy, Drawable drawable, GLContext ctx)
Make given context current.
Drawable getCurrentDrawable()
Return the current active drawable.
SoINTERNAL GLContext createContextAttribs(Display dpy, VisualInfo vis, GLContext shareList, bool direct, const std::vector< int > &attribs)
Create a new context.
void releaseVisualInfo(VisualInfo visualInfo)
Release a VisualInfo returned by getWindowVisualInfo()
GLContext createContext(Display dpy, VisualInfo vis, GLContext shareList, bool direct)
Create a new context.
Display getCurrentDisplay()
Return the current active display.
bool destroyContext(Display dpy, GLContext ctx)
Destroy given context.