00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef SB_GL_CONTEXT_HELPER_H
00026 #define SB_GL_CONTEXT_HELPER_H
00027
00028 #include <Inventor/SbBase.h>
00029 #include <vector>
00030
00031 #ifndef HIDDEN_FROM_DOC
00032
00033 #if defined(OIV_HEADLESS)
00034 typedef void *EGLDisplay;
00035 typedef void *EGLConfig;
00036 typedef void *EGLSurface;
00037 typedef void *EGLContext;
00038 #elif defined(_WIN32)
00039 #elif defined(__APPLE__)
00040 typedef struct _CGLContextObject *CGLContextObj;
00041 typedef struct _CGLPixelFormatObject *CGLPixelFormatObj;
00042 typedef unsigned int CGDirectDisplayID;
00043 #else
00044 typedef struct _XDisplay Display;
00045 typedef unsigned long GLXDrawable;
00046 typedef unsigned long GLXPixmap;
00047 typedef struct __GLXcontextRec *GLXContext;
00048 typedef unsigned long GLXFBConfigID;
00049 typedef unsigned long GLXWindow;
00050 typedef unsigned long GLXPbuffer;
00051 typedef unsigned long Colormap;
00052 typedef unsigned long Pixmap;
00053 typedef unsigned long Window;
00054 #if !defined(BUILDING_SB_GL_CONTEXT_HELPER)
00055 typedef struct __GLXFBConfigRec *GLXFBConfig;
00056 #endif
00057 #endif
00058
00059 #endif //HIDDEN_FROM_DOC
00060
00061 class SoGLContext;
00062
00069 class SbGLShareContext
00070 {
00071 public:
00073 SoGLContext *shareContext;
00078 int shareContextID;
00079
00080 private:
00081
00082
00083 SbGLShareContext();
00084
00085
00086 SbGLShareContext(SoGLContext *shareContext, int shareContextID);
00087
00088
00089 SoGLContext * getContext();
00090
00091
00092 int getContextGroupId();
00093 };
00094
00095
00096 inline
00097 SbGLShareContext::SbGLShareContext()
00098 {
00099 shareContext = NULL;
00100 shareContextID = 0;
00101 }
00102
00103 inline
00104 SbGLShareContext::SbGLShareContext(SoGLContext* _shareContext, int _shareContextID)
00105 {
00106 shareContext = _shareContext;
00107 shareContextID = _shareContextID;
00108 }
00109
00110 inline SoGLContext *
00111 SbGLShareContext::getContext()
00112 {
00113 return shareContext;
00114 }
00115
00116 inline int
00117 SbGLShareContext::getContextGroupId()
00118 {
00119 return shareContextID;
00120 }
00121
00125 namespace SbGlContextHelper
00126 {
00127 #if defined(OIV_HEADLESS)
00128 typedef EGLDisplay Display;
00129 typedef EGLContext GLContext;
00130 typedef EGLConfig VisualInfo;
00131 typedef EGLSurface Drawable;
00132 #elif defined(_WIN32)
00133 typedef HDC Display;
00134 typedef HGLRC GLContext;
00135 typedef PIXELFORMATDESCRIPTOR* VisualInfo;
00136 typedef int Drawable;
00137 #elif defined(__APPLE__)
00138 #undef Display
00139 typedef int Display;
00140 typedef CGLContextObj GLContext;
00141 typedef CGLPixelFormatObj VisualInfo;
00142 typedef void* Drawable;
00143 #else
00144 typedef ::Display* Display;
00145 typedef GLXContext GLContext;
00146 typedef void* VisualInfo;
00147 typedef GLXDrawable Drawable;
00148 #endif
00149
00151 GLContext getCurrentContext();
00152
00154 Display getCurrentDisplay();
00155
00157 Drawable getCurrentDrawable();
00158
00160 bool isValidDisplay(Display dpy);
00161
00167 VisualInfo getWindowVisualInfo(Display dpy, Drawable drawable);
00168
00173 VisualInfo getWindowVisualInfo(Display dpy, Drawable drawable, GLContext ctx);
00174
00175
00177 void releaseVisualInfo(VisualInfo visualInfo);
00178
00186 GLContext createContext(Display dpy, VisualInfo vis, GLContext shareList,
00187 bool direct);
00188
00190 bool destroyContext(Display dpy, GLContext ctx);
00191
00198 bool makeCurrent(Display dpy, Drawable drawable, GLContext ctx);
00199
00208 SoINTERNAL GLContext createContextAttribs(Display dpy, VisualInfo vis, GLContext shareList,
00209 bool direct, const std::vector<int> &attribs);
00210 }
00211
00212 #endif
00213
00214
00215