fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / WindowSystem / EGL / OSGEGLWindow.cpp
blobfcd0b79356ba3a3a46934ce0ebe0dcbbd5b41ec1
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2002 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 windows compile
49 #ifdef OSG_USE_EGL
51 #include "OSGEGLWindow.h"
53 #include "gles/egl.h"
55 OSG_USING_NAMESPACE
57 // Documentation for this class is emited in the
58 // OSGEGLWindowBase.cpp file.
59 // To modify it, please change the .fcd file (OSGEGLWindow.fcd) and
60 // regenerate the base file.
62 /*----------------------- constructors & destructors ----------------------*/
64 //! Constructor
66 EGLWindow::EGLWindow(void) :
67 Inherited()
71 //! Copy Constructor
73 EGLWindow::EGLWindow(const EGLWindow &source) :
74 Inherited(source)
78 //! Destructor
80 EGLWindow::~EGLWindow(void)
82 #if 0
83 if(getHglrc() != NULL)
84 wglDeleteContext(getHglrc());
85 #endif
88 /*----------------------------- class specific ----------------------------*/
90 //! initialize the static features of the class, e.g. action callbacks
92 void EGLWindow::initMethod(InitPhase ePhase)
94 Inherited::initMethod(ePhase);
97 //! react to field changes
99 void EGLWindow::changed(ConstFieldMaskArg whichField,
100 UInt32 origin,
101 BitVector details)
103 Inherited::changed(whichField, origin, details);
106 //! output the instance for debug purposes
108 void EGLWindow::dump( UInt32 ,
109 const BitVector ) const
111 SLOG << "Dump EGLWindow NI" << std::endl;
114 /*-------------------------- your_category---------------------------------*/
116 /*! init the window: create the HDC and HGLRC
118 void EGLWindow::init( void )
120 activate();
121 setupGL();
124 /*! activate the window: set the HDC and bind the OGL context
126 void EGLWindow::activate(void)
128 if(!eglMakeCurrent(getDisplay(), getWindow(), getWindow(), getContext()))
131 std::cerr << "EGLWindow::activate: failed: "
132 << GetLastError()
133 << std::endl;
138 void EGLWindow::deactivate(void)
140 eglMakeCurrent(getDisplay(),
141 EGL_NO_SURFACE,
142 EGL_NO_SURFACE,
143 EGL_NO_CONTEXT);
146 // swap front and back buffers
147 bool EGLWindow::swap( void )
149 return eglSwapBuffers(getDisplay(), getWindow());
152 #endif // OSG_USE_EGL