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 #if defined(OIV_HEADLESS)
00032 typedef void *EGLDisplay;
00033 typedef void *EGLConfig;
00034 typedef void *EGLSurface;
00035 typedef void *EGLContext;
00036 #elif defined(_WIN32)
00037 #elif defined(__APPLE__)
00038 typedef struct _CGLContextObject *CGLContextObj;
00039 typedef struct _CGLPixelFormatObject *CGLPixelFormatObj;
00040 typedef unsigned int CGDirectDisplayID;
00041 #else
00042 typedef struct _XDisplay Display;
00043 typedef unsigned long GLXDrawable;
00044 typedef unsigned long GLXPixmap;
00045 typedef struct __GLXcontextRec *GLXContext;
00046 typedef unsigned long GLXFBConfigID;
00047 typedef unsigned long GLXWindow;
00048 typedef unsigned long GLXPbuffer;
00049 typedef unsigned long Colormap;
00050 typedef unsigned long Pixmap;
00051 typedef unsigned long Window;
00052 #if !defined(BUILDING_SB_GL_CONTEXT_HELPER)
00053 typedef struct __GLXFBConfigRec *GLXFBConfig;
00054 #endif
00055 #endif
00056
00057 class SoGLContext;
00058
00065 class SbGLShareContext
00066 {
00067 public:
00069 SoGLContext *shareContext;
00074 int shareContextID;
00075
00076 private:
00077
00078
00079 SbGLShareContext();
00080
00081
00082 SbGLShareContext(SoGLContext *shareContext, int shareContextID);
00083
00084
00085 SoGLContext * getContext();
00086
00087
00088 int getContextGroupId();
00089 };
00090
00091
00092 inline
00093 SbGLShareContext::SbGLShareContext()
00094 {
00095 shareContext = NULL;
00096 shareContextID = 0;
00097 }
00098
00099 inline
00100 SbGLShareContext::SbGLShareContext(SoGLContext* _shareContext, int _shareContextID)
00101 {
00102 shareContext = _shareContext;
00103 shareContextID = _shareContextID;
00104 }
00105
00106 inline SoGLContext *
00107 SbGLShareContext::getContext()
00108 {
00109 return shareContext;
00110 }
00111
00112 inline int
00113 SbGLShareContext::getContextGroupId()
00114 {
00115 return shareContextID;
00116 }
00117
00121 namespace SbGlContextHelper
00122 {
00123 #if defined(OIV_HEADLESS)
00124 typedef EGLDisplay Display;
00125 typedef EGLContext GLContext;
00126 typedef EGLConfig VisualInfo;
00127 typedef EGLSurface Drawable;
00128 #elif defined(_WIN32)
00129 typedef HDC Display;
00130 typedef HGLRC GLContext;
00131 typedef PIXELFORMATDESCRIPTOR* VisualInfo;
00132 typedef int Drawable;
00133 #elif defined(__APPLE__)
00134 #undef Display
00135 typedef int Display;
00136 typedef CGLContextObj GLContext;
00137 typedef CGLPixelFormatObj VisualInfo;
00138 typedef void* Drawable;
00139 #else
00140 typedef ::Display* Display;
00141 typedef GLXContext GLContext;
00142 typedef void* VisualInfo;
00143 typedef GLXDrawable Drawable;
00144 #endif
00145
00147 GLContext getCurrentContext();
00148
00150 Display getCurrentDisplay();
00151
00153 Drawable getCurrentDrawable();
00154
00156 bool isValidDisplay(Display dpy);
00157
00163 VisualInfo getWindowVisualInfo(Display dpy, Drawable drawable);
00164
00169 VisualInfo getWindowVisualInfo(Display dpy, Drawable drawable, GLContext ctx);
00170
00171
00173 void releaseVisualInfo(VisualInfo visualInfo);
00174
00182 GLContext createContext(Display dpy, VisualInfo vis, GLContext shareList,
00183 bool direct);
00184
00186 bool destroyContext(Display dpy, GLContext ctx);
00187
00194 bool makeCurrent(Display dpy, Drawable drawable, GLContext ctx);
00195
00204 SoINTERNAL GLContext createContextAttribs(Display dpy, VisualInfo vis, GLContext shareList,
00205 bool direct, const std::vector<int> &attribs);
00206 }
00207
00208 #endif
00209
00210
00211