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
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #include <stdlib.h>
00044 #include <stdio.h>
00045
00046 #include <OSGConfig.h>
00047
00048 #define OSG_COMPILEWINDOWXINST
00049
00050 #include "OSGXWindow.h"
00051
00052 OSG_USING_NAMESPACE
00053
00060
00061
00063
00064 XWindow::XWindow(void) :
00065 Inherited()
00066 {
00067 }
00068
00070
00071 XWindow::XWindow(const XWindow &source) :
00072 Inherited(source)
00073 {
00074 }
00075
00077
00078 XWindow::~XWindow(void)
00079 {
00080 }
00081
00082
00083
00085
00086 void XWindow::initMethod (void)
00087 {
00088 }
00089
00091
00092 void XWindow::changed(BitVector whichField, UInt32 origin)
00093 {
00094 Inherited::changed(whichField, origin);
00095 }
00096
00098
00099 void XWindow::dump( UInt32 ,
00100 const BitVector ) const
00101 {
00102 SLOG << "Dump XWindow NI" << std::endl;
00103 }
00104
00105
00106
00109 void XWindow::init(void)
00110 {
00111 XVisualInfo *vi, visInfo;
00112 XWindowAttributes winAttr;
00113
00114 XGetWindowAttributes(getDisplay(), getWindow(), &winAttr);
00115
00116
00117 memset(&visInfo, 0, sizeof(XVisualInfo));
00118 visInfo.visualid = XVisualIDFromVisual(winAttr.visual);
00119
00120
00121 if(getDisplay() == NULL)
00122 {
00123 setDisplay(XOpenDisplay(DisplayString(getDisplay())));
00124 }
00125
00126
00127 int nvis;
00128 vi = XGetVisualInfo(getDisplay(), VisualIDMask, &visInfo, &nvis);
00129
00130
00131 int useGL;
00132 glXGetConfig(getDisplay(),
00133 vi,
00134 GLX_USE_GL,
00135 &useGL );
00136 if (!useGL)
00137 {
00138 SFATAL << "Visual is not OpenGL-capable!" << std::endl;
00139 }
00140
00141 XWindowPtr win(*this);
00142 beginEditCP(win, ContextFieldMask);
00143
00144 setContext(glXCreateContext(getDisplay(), vi, None, GL_TRUE));
00145 endEditCP (win, ContextFieldMask);
00146
00147 glXMakeCurrent(getDisplay(), getWindow(), getContext());
00148 setupGL();
00149 }
00150
00151
00152 void XWindow::activate( void )
00153 {
00154 glXMakeCurrent(getDisplay(), getWindow(), getContext());
00155 }
00156
00157
00158 void XWindow::deactivate( void )
00159 {
00160 glXMakeCurrent(getDisplay(), None, NULL);
00161 }
00162
00163
00164 void XWindow::swap( void )
00165 {
00166 glXSwapBuffers(getDisplay(), getWindow());
00167 }
00168
00169 #include <OSGMFieldTypeDef.inl>
00170 #include <OSGSFieldTypeDef.inl>
00171
00172 OSG_BEGIN_NAMESPACE
00173
00174
00175 #ifndef OSG_DO_DOC
00176
00177 DataType FieldDataTraits<DisplayP> ::_type("DisplayP", NULL);
00178 DataType FieldDataTraits<X11Window> ::_type("X11Window", NULL);
00179 DataType FieldDataTraits1<GLXContext>::_type("GLXContext", NULL);
00180
00181 #endif
00182
00183 OSG_DLLEXPORT_SFIELD_DEF1(DisplayP, OSG_WINDOWXLIB_DLLTMPLMAPPING);
00184 OSG_DLLEXPORT_MFIELD_DEF1(DisplayP, OSG_WINDOWXLIB_DLLTMPLMAPPING);
00185 OSG_DLLEXPORT_SFIELD_DEF1(X11Window, OSG_WINDOWXLIB_DLLTMPLMAPPING);
00186 OSG_DLLEXPORT_MFIELD_DEF1(X11Window, OSG_WINDOWXLIB_DLLTMPLMAPPING);
00187 OSG_DLLEXPORT_SFIELD_DEF2(GLXContext, 1, OSG_WINDOWXLIB_DLLTMPLMAPPING);
00188 OSG_DLLEXPORT_MFIELD_DEF2(GLXContext, 1, OSG_WINDOWXLIB_DLLTMPLMAPPING);
00189
00190 OSG_END_NAMESPACE
00191
00192
00193
00194
00195 #ifdef __sgi
00196 #pragma set woff 1174
00197 #endif
00198
00199 #ifdef OSG_LINUX_ICC
00200 #pragma warning( disable : 177 )
00201 #endif
00202
00203 namespace
00204 {
00205 static char cvsid_cpp[] = "@(#)$Id: $";
00206 static char cvsid_hpp[] = OSGXWINDOW_HEADER_CVSID;
00207 static char cvsid_inl[] = OSGXWINDOW_INLINE_CVSID;
00208
00209 static char cvsid_fields_hpp[] = OSGWINDOWXFIELDS_HEADER_CVSID;
00210 }
00211