1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2006 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 // Forget everything if we're not doing a Mac OS X compile
49 #if defined(__APPLE__) || defined(OSG_DO_DOC)
51 #include "OSGCoreGLWindow.h"
55 // Documentation for this class is emitted in the
56 // OSGCoreGLWindowBase.cpp file.
57 // To modify it, please change the .fcd file (OSGCoreGLWindow.fcd) and
58 // regenerate the base file.
60 /***************************************************************************\
62 \***************************************************************************/
64 /***************************************************************************\
66 \***************************************************************************/
68 void CoreGLWindow::initMethod(InitPhase ePhase
)
70 Inherited::initMethod(ePhase
);
72 if(ePhase
== TypeObject::SystemPost
)
78 /***************************************************************************\
80 \***************************************************************************/
82 /*-------------------------------------------------------------------------*\
84 \*-------------------------------------------------------------------------*/
86 /*----------------------- constructors & destructors ----------------------*/
88 CoreGLWindow::CoreGLWindow(void) :
93 CoreGLWindow::CoreGLWindow(const CoreGLWindow
&source
) :
98 CoreGLWindow::~CoreGLWindow(void)
102 /*----------------------------- class specific ----------------------------*/
104 void CoreGLWindow::changed(ConstFieldMaskArg whichField
,
108 Inherited::changed(whichField
, origin
, details
);
111 void CoreGLWindow::dump( UInt32
,
112 const BitVector
) const
114 SLOG
<< "Dump CoreGLWindow NI" << std::endl
;
117 /*-------------------------- your_category---------------------------------*/
119 /*! Init the window: create the context and setup the OpenGL.
121 void CoreGLWindow::init(GLInitFunctor oFunc
)
123 Inherited::init(oFunc
);
126 void CoreGLWindow::terminate(void)
130 // activate the window: bind the OGL context
131 void CoreGLWindow::doActivate(void)
133 CGLSetCurrentContext(getContext());
136 // activate the window: bind the OGL context
137 void CoreGLWindow::doDeactivate(void)
139 CGLSetCurrentContext(0);
142 // swap front and back buffers
143 bool CoreGLWindow::doSwap(void)
145 CGLFlushDrawable(getContext());
149 bool CoreGLWindow::hasContext(void)
151 return (this->getContext() != NULL
);