changed: auto add updateData callback to stages so that stagedata can be updated...
[opensg.git] / Source / WindowSystem / CoreGL / OSGCoreGLWindow.cpp
blob443bdf3c7e615975e061aaf801fd03e33377ab76
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2006 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
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. *
18 * *
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. *
23 * *
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. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 //---------------------------------------------------------------------------
40 // Includes
41 //---------------------------------------------------------------------------
43 #include <cstdlib>
44 #include <cstdio>
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"
53 OSG_BEGIN_NAMESPACE
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 /***************************************************************************\
61 * Class variables *
62 \***************************************************************************/
64 /***************************************************************************\
65 * Class methods *
66 \***************************************************************************/
68 void CoreGLWindow::initMethod(InitPhase ePhase)
70 Inherited::initMethod(ePhase);
72 if(ePhase == TypeObject::SystemPost)
78 /***************************************************************************\
79 * Instance methods *
80 \***************************************************************************/
82 /*-------------------------------------------------------------------------*\
83 - private -
84 \*-------------------------------------------------------------------------*/
86 /*----------------------- constructors & destructors ----------------------*/
88 CoreGLWindow::CoreGLWindow(void) :
89 Inherited()
93 CoreGLWindow::CoreGLWindow(const CoreGLWindow &source) :
94 Inherited(source)
98 CoreGLWindow::~CoreGLWindow(void)
102 /*----------------------------- class specific ----------------------------*/
104 void CoreGLWindow::changed(ConstFieldMaskArg whichField,
105 UInt32 origin,
106 BitVector details)
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());
146 return true;
149 bool CoreGLWindow::hasContext(void)
151 return (this->getContext() != NULL);
154 OSG_END_NAMESPACE
156 #endif // __APPLE__