00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #include <stdlib.h>
00044 #include <stdio.h>
00045
00046 #include <OSGConfig.h>
00047
00048
00049 #ifdef WIN32
00050
00051 #include "OSGWIN32Window.h"
00052
00053 OSG_USING_NAMESPACE
00054
00059
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
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
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
00148 wglMakeCurrent(NULL, NULL);
00149
00150
00151 ReleaseDC(getHwnd(),getHdc());
00152 }
00153
00154
00155 void WIN32Window::swap( void )
00156 {
00157 SwapBuffers(getHdc());
00158 }
00159
00160
00161
00162
00163
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