1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 //---------------------------------------------------------------------------
41 //---------------------------------------------------------------------------
46 #include "OSGConfig.h"
48 #if defined(OSG_WITH_GLUT) || defined(OSG_DO_DOC)
50 #define OSG_COMPILEWINDOWGLUTINST
52 #include "OSGGLUTWindow.h"
56 #include "OSGViewport.h"
57 #include "OSGCamera.h"
58 #include "OSGBackground.h"
59 #include "OSGGLUTWindow.h"
60 #include "OSGRenderActionBase.h"
61 #include "OSGRenderActionTask.h"
67 #include "OSGCocoaWindowWrapper.h"
72 // Documentation for this class is emited in the
73 // OSGGLUTWindowBase.cpp file.
74 // To modify it, please change the .fcd file (OSGGLUTWindow.fcd) and
75 // regenerate the base file.
77 /*----------------------- constructors & destructors ----------------------*/
80 GLUTWindow::GLUTWindow(void) :
84 (_sfDrawMode
.getValue() & ~Window::ContextMask
) |
85 (Window::ExternalContext
& Window::ContextMask
) );
89 GLUTWindow::GLUTWindow(const GLUTWindow
&source
) :
93 (_sfDrawMode
.getValue() & ~Window::ContextMask
) |
94 (Window::ExternalContext
& Window::ContextMask
) );
98 GLUTWindow::~GLUTWindow(void)
102 /*----------------------------- class specific ----------------------------*/
104 //! initialize the static features of the class, e.g. action callbacks
106 void GLUTWindow::initMethod(InitPhase ePhase
)
108 Inherited::initMethod(ePhase
);
111 //! react to field changes
112 void GLUTWindow::changed(ConstFieldMaskArg whichField
,
116 Inherited::changed(whichField
, origin
, details
);
119 //! output the instance for debug purposes
121 void GLUTWindow::dump( UInt32
,
122 const BitVector
) const
124 SLOG
<< "Dump GLUTWindow NI" << std::endl
;
127 /* ------------- Window functions -----------------------*/
129 // init the window: create the context
130 void GLUTWindow::init(GLInitFunctor oFunc
)
133 Inherited::setHdc (wglGetCurrentDC ());
134 Inherited::setHglrc(wglGetCurrentContext());
135 Inherited::setHwnd (WindowFromDC(Inherited::getHdc()));
136 #elif defined(__APPLE__)
137 Inherited::setContext(cocoaWrapperCurrentContext());
139 glutSetWindow(getGlutId());
141 Inherited::setDisplay(glXGetCurrentDisplay ());
142 Inherited::setContext(glXGetCurrentContext ());
143 Inherited::setWindow (glXGetCurrentDrawable());
145 this->doDeactivate();
150 void GLUTWindow::activate(void)
152 if((_sfDrawMode
.getValue() & PartitionDrawMask
) == SequentialPartitionDraw
)
154 if(glutGetWindow() != getGlutId())
155 glutSetWindow(getGlutId());
157 Inherited::doActivate();
161 void GLUTWindow::terminate(void)
163 Window::doTerminate();
165 Inherited::setContext(NULL
);
170 #endif // OSG_WITH_GLUT