/*! init the window: create the HDC and HGLRC */ void WIN32Window::init(GLInitFunctor oFunc) { setHdc(GetDC(getHwnd())); if(getHglrc() == NULL) { setHglrc(wglCreateContext(getHdc())); if(getHglrc() == NULL) { std::cerr << "WIN32Window::init: failed: " << GetLastError() << std::endl; } } Inherited::init(oFunc); if(getHdc() != NULL) { ReleaseDC(getHwnd(), getHdc()); setHdc(NULL); } }
// swap front and back buffers bool WIN32Window::doSwap(void) { if(getHdc() == NULL) setHdc(GetDC(getHwnd())); return SwapBuffers(getHdc()); }
/*! activate the window: set the HDC and bind the OGL context */ void WIN32Window::activate( void ) { setHdc(GetDC(getHwnd())); if(!wglMakeCurrent(getHdc(), getHglrc() ) ) { SFATAL << "WIN32Window::activate: failed: " << GetLastError() << endLog; } }
void WIN32Window::doDeactivate ( void ) { // unbind the context wglMakeCurrent(NULL, NULL); // release the hardware device context if(getHdc() != NULL) { ReleaseDC(getHwnd(), getHdc()); setHdc(NULL); } }
/*! activate the window: set the HDC and bind the OGL context */ void WIN32Window::doActivate( void ) { if(getHdc() == NULL) setHdc(GetDC(getHwnd())); if(!wglMakeCurrent(getHdc(), getHglrc())) { std::cerr << "WIN32Window::activate: failed: " << GetLastError() << std::endl; } }
/*! init the window: create the HDC and HGLRC */ void WIN32Window::init( void ) { setHdc(GetDC(getHwnd())); if(getHglrc() == NULL ) { setHglrc(wglCreateContext(getHdc())); if(getHglrc() == NULL) { SFATAL << "WIN32Window::init: failed: " << GetLastError() << endLog; } } ReleaseDC(getHwnd(),getHdc()); activate(); setupGL(); }