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
00030 #if defined(_WIN32)
00031 #elif defined(__APPLE__)
00032 typedef struct _CGLContextObject *CGLContextObj;
00033 typedef struct _CGLPixelFormatObject *CGLPixelFormatObj;
00034 typedef unsigned int CGDirectDisplayID;
00035 #else
00036 typedef struct _XDisplay Display;
00037 typedef unsigned long GLXDrawable;
00038 typedef unsigned long GLXPixmap;
00039 #ifdef __sun
00040 typedef struct __glXContextRec *GLXContext;
00041 #else
00042 typedef struct __GLXcontextRec *GLXContext;
00043 #endif
00044 typedef unsigned long GLXFBConfigID;
00045 typedef unsigned long GLXWindow;
00046 typedef unsigned long GLXPbuffer;
00047 typedef unsigned long Colormap;
00048 typedef unsigned long Pixmap;
00049 typedef unsigned long Window;
00050 #if !defined(BUILDING_SB_GL_CONTEXT_HELPER)
00051 typedef struct __GLXFBConfigRec *GLXFBConfig;
00052 #endif
00053 #endif
00054
00055 class SoGLContext;
00056
00061 class SbGLShareContext
00062 {
00063 public:
00065 SoGLContext *shareContext;
00070 int shareContextID;
00071
00072 private:
00073
00074
00075 SbGLShareContext();
00076
00077
00078 SbGLShareContext(SoGLContext *shareContext, int shareContextID);
00079
00080
00081 SoGLContext * getContext();
00082
00083
00084 int getContextGroupId();
00085 };
00086
00087
00088 inline
00089 SbGLShareContext::SbGLShareContext()
00090 {
00091 shareContext = NULL;
00092 shareContextID = 0;
00093 }
00094
00095 inline
00096 SbGLShareContext::SbGLShareContext(SoGLContext* _shareContext, int _shareContextID)
00097 {
00098 shareContext = _shareContext;
00099 shareContextID = _shareContextID;
00100 }
00101
00102 inline SoGLContext *
00103 SbGLShareContext::getContext()
00104 {
00105 return shareContext;
00106 }
00107
00108 inline int
00109 SbGLShareContext::getContextGroupId()
00110 {
00111 return shareContextID;
00112 }
00113
00117 namespace SbGlContextHelper
00118 {
00119 #ifdef _WIN32
00120 typedef HDC Display;
00121 typedef HGLRC GLContext;
00122 typedef PIXELFORMATDESCRIPTOR* VisualInfo;
00123 typedef int Drawable;
00124 #elif defined(__APPLE__)
00125 #undef Display
00126 typedef int Display;
00127 typedef CGLContextObj GLContext;
00128 typedef CGLPixelFormatObj VisualInfo;
00129 typedef void* Drawable;
00130 #else
00131 typedef ::Display* Display;
00132 typedef GLXContext GLContext;
00133 typedef void* VisualInfo;
00134 typedef GLXDrawable Drawable;
00135 #endif
00136
00138 GLContext getCurrentContext();
00139
00141 Display getCurrentDisplay();
00142
00144 Drawable getCurrentDrawable();
00145
00147 bool isValidDisplay(Display dpy);
00148
00154 VisualInfo getWindowVisualInfo(Display dpy, Drawable drawable);
00155
00161 VisualInfo getWindowVisualInfo(Display dpy, Drawable drawable, GLContext ctx);
00162
00163
00165 void releaseVisualInfo(VisualInfo visualInfo);
00166
00175 GLContext createContext(Display dpy, VisualInfo vis, GLContext shareList,
00176 bool direct, int layer = 0);
00177
00179 bool destroyContext(Display dpy, GLContext ctx);
00180
00187 bool makeCurrent(Display dpy, Drawable drawable, GLContext ctx);
00188
00197 bool shareContext( Display dpy, GLContext srcCtx, GLContext newCtx );
00198 }
00199
00200 #endif
00201
00202
00203