Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

OSGWIN32Window.cpp

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002  *                                OpenSG                                     *
00003  *                                                                           *
00004  *                                                                           *
00005  *             Copyright (C) 2000-2002 by the OpenSG Forum                   *
00006  *                                                                           *
00007  *                            www.opensg.org                                 *
00008  *                                                                           *
00009  *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          *
00010  *                                                                           *
00011 \*---------------------------------------------------------------------------*/
00012 /*---------------------------------------------------------------------------*\
00013  *                                License                                    *
00014  *                                                                           *
00015  * This library is free software; you can redistribute it and/or modify it   *
00016  * under the terms of the GNU Library General Public License as published    *
00017  * by the Free Software Foundation, version 2.                               *
00018  *                                                                           *
00019  * This library is distributed in the hope that it will be useful, but       *
00020  * WITHOUT ANY WARRANTY; without even the implied warranty of                *
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
00022  * Library General Public License for more details.                          *
00023  *                                                                           *
00024  * You should have received a copy of the GNU Library General Public         *
00025  * License along with this library; if not, write to the Free Software       *
00026  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
00027  *                                                                           *
00028 \*---------------------------------------------------------------------------*/
00029 /*---------------------------------------------------------------------------*\
00030  *                                Changes                                    *
00031  *                                                                           *
00032  *                                                                           *
00033  *                                                                           *
00034  *                                                                           *
00035  *                                                                           *
00036  *                                                                           *
00037 \*---------------------------------------------------------------------------*/
00038 
00039 //---------------------------------------------------------------------------
00040 //  Includes
00041 //---------------------------------------------------------------------------
00042 
00043 #include <stdlib.h>
00044 #include <stdio.h>
00045 
00046 #include <OSGConfig.h>
00047 
00048 // Forget everything if we're not doing a windows compile
00049 #ifdef WIN32
00050 
00051 #include "OSGWIN32Window.h"
00052 
00053 OSG_USING_NAMESPACE
00054 
00059 /*----------------------- constructors & destructors ----------------------*/
00060 
00062 
00063 WIN32Window::WIN32Window(void) :
00064     Inherited()
00065 {
00066 }
00067 
00069 
00070 WIN32Window::WIN32Window(const WIN32Window &source) :
00071     Inherited(source)
00072 {
00073 }
00074 
00076 
00077 WIN32Window::~WIN32Window(void)
00078 {
00079     if(getHglrc() != NULL)
00080         wglDeleteContext(getHglrc());
00081 }
00082 
00083 /*----------------------------- class specific ----------------------------*/
00084 
00086 
00087 void WIN32Window::initMethod (void)
00088 {
00089 }
00090 
00092 
00093 void WIN32Window::changed(BitVector whichField, UInt32 origin)
00094 {
00095     Inherited::changed(whichField, origin);
00096 }
00097 
00099 
00100 void WIN32Window::dump(      UInt32    , 
00101                          const BitVector ) const
00102 {
00103     SLOG << "Dump WIN32Window NI" << std::endl;
00104 }
00105 
00106 /*-------------------------- your_category---------------------------------*/
00107 
00110 void WIN32Window::init( void )
00111 {
00112     setHdc(GetDC(getHwnd()));
00113 
00114     if(getHglrc() == NULL )
00115     {
00116         setHglrc(wglCreateContext(getHdc()));
00117         
00118         if(getHglrc() == NULL)
00119         {
00120             std::cerr << "WIN32Window::init: failed: "
00121                       << GetLastError() 
00122                       << std::endl;        
00123         }
00124     }
00125 
00126     ReleaseDC(getHwnd(),getHdc());
00127     activate();
00128     setupGL();
00129 }
00130 
00133 void WIN32Window::activate( void )
00134 {    
00135     setHdc(GetDC(getHwnd()));
00136 
00137     if(!wglMakeCurrent(getHdc(), getHglrc() ) )
00138     {
00139         std::cerr << "WIN32Window::activate: failed: "
00140                   << GetLastError() 
00141                   << std::endl;        
00142     }
00143 }
00144 
00145 void WIN32Window::deactivate ( void )
00146 {
00147     // unbind the context
00148     wglMakeCurrent(NULL, NULL);
00149 
00150     // release the hardware device context
00151     ReleaseDC(getHwnd(),getHdc());
00152 }
00153 
00154 // swap front and back buffers
00155 void WIN32Window::swap( void )
00156 {
00157     SwapBuffers(getHdc());
00158 }
00159 
00160 
00161 
00162 /*-------------------------------------------------------------------------*/
00163 /*                              cvs id's                                   */
00164 
00165 namespace
00166 {
00167     static char cvsid_cpp[] = "@(#)$Id: $";
00168     static char cvsid_hpp[] = OSGWIN32WINDOW_HEADER_CVSID;
00169     static char cvsid_inl[] = OSGWIN32WINDOW_INLINE_CVSID;
00170 
00171     static Char8 cvsid_fields_hpp[] = OSGWIN32WINDOWFIELDS_HEADER_CVSID;
00172 }
00173 
00174 #endif // WIN32

Generated on Thu Aug 25 04:12:07 2005 for OpenSG by  doxygen 1.4.3