Changeset 13041 for OpenSceneGraph/trunk/src/osgViewer/PixelBufferWin32.cpp
- Timestamp:
- 03/21/12 18:36:20 (15 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgViewer/PixelBufferWin32.cpp
r12370 r13041 1 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 2 2 * 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 5 5 * (at your option) any later version. The full license is in LICENSE file 6 6 * included with this distribution, and on the openscenegraph.org website. 7 * 7 * 8 8 * This library is distributed in the hope that it will be useful, 9 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 11 * OpenSceneGraph Public License for more details. 12 12 * … … 152 152 #endif 153 153 154 namespace 154 namespace 155 155 { 156 156 … … 167 167 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language 168 168 (LPTSTR) &lpMsgBuf,\ 169 0,NULL 169 0,NULL 170 170 ); 171 171 … … 180 180 msgResult << "Error code " << err; 181 181 } 182 182 183 183 return msgResult.str(); 184 184 } … … 206 206 protected: 207 207 ~TemporaryWindow(); 208 208 209 209 TemporaryWindow(const TemporaryWindow &): 210 210 _handle(0), … … 212 212 _context(0), 213 213 _instance(0) {} 214 214 215 215 TemporaryWindow &operator=(const TemporaryWindow &) { return *this; } 216 216 … … 233 233 234 234 _instance = GetModuleHandle(0); 235 235 236 236 WNDCLASS wndclass; 237 238 wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; 237 238 wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; 239 239 wndclass.lpfnWndProc = DefWindowProc; 240 240 wndclass.cbClsExtra = 0; … … 244 244 wndclass.hIcon = 0; 245 245 wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); 246 wndclass.lpszMenuName = 0; 246 wndclass.lpszMenuName = 0; 247 247 wndclass.lpszClassName = _classname.c_str(); 248 248 … … 275 275 } 276 276 277 PIXELFORMATDESCRIPTOR pfd = { 277 PIXELFORMATDESCRIPTOR pfd = { 278 278 sizeof(PIXELFORMATDESCRIPTOR), 279 1, 280 PFD_DRAW_TO_WINDOW | 281 PFD_SUPPORT_OPENGL, 282 PFD_TYPE_RGBA, 283 24, 284 0, 0, 0, 0, 0, 0, 285 0, 286 0, 287 0, 288 0, 0, 0, 0, 279 1, 280 PFD_DRAW_TO_WINDOW | 281 PFD_SUPPORT_OPENGL, 282 PFD_TYPE_RGBA, 283 24, 284 0, 0, 0, 0, 0, 0, 285 0, 286 0, 287 0, 288 0, 0, 0, 0, 289 289 16, 290 0, 291 0, 292 PFD_MAIN_PLANE, 293 0, 294 0, 0, 0 295 }; 296 297 int visual_id = ChoosePixelFormat(_dc, &pfd); 290 0, 291 0, 292 PFD_MAIN_PLANE, 293 0, 294 0, 0, 0 295 }; 296 297 int visual_id = ChoosePixelFormat(_dc, &pfd); 298 298 299 299 if (!SetPixelFormat(_dc, visual_id, &pfd)) … … 422 422 { 423 423 HGLRC context = wglGetCurrentContext(); 424 424 425 425 // Get wgl function pointers for the current graphics context, or if there is no 426 426 // current context then use a temporary window. … … 467 467 { 468 468 getState()->setContextID( _traits->sharedContext->getState()->getContextID() ); 469 incrementContextIDUsageCount( getState()->getContextID() ); 469 incrementContextIDUsageCount( getState()->getContextID() ); 470 470 } 471 471 else … … 480 480 closeImplementation(); 481 481 } 482 482 483 483 void PixelBufferWin32::init() 484 484 { … … 641 641 } 642 642 643 _initialized = true; 643 _initialized = true; 644 644 _valid = true; 645 645 … … 656 656 657 657 if (!_initialized) init(); 658 658 659 659 if (!_initialized) return false; 660 660 … … 662 662 { 663 663 GraphicsHandleWin32* graphicsHandleWin32 = dynamic_cast<GraphicsHandleWin32*>(_traits->sharedContext); 664 if (graphicsHandleWin32) 664 if (graphicsHandleWin32) 665 665 { 666 666 if ( !wglShareLists(graphicsHandleWin32->getWGLContext(), _hglrc) ) … … 720 720 // If the pbuffer is bound to a texture then release it. This operation requires a current context, so 721 721 // do it after the MakeCurrent. 722 722 723 723 if ( _boundBuffer!=0 ) 724 724 { … … 736 736 return result; 737 737 } 738 738 739 739 bool PixelBufferWin32::makeContextCurrentImplementation( GraphicsContext* readContext ) 740 740 { … … 748 748 749 749 GraphicsHandleWin32* graphicsHandleWin32 = dynamic_cast<GraphicsHandleWin32*>(readContext); 750 if (graphicsHandleWin32) 750 if (graphicsHandleWin32) 751 751 { 752 752 return wgle->wglMakeContextCurrentARB(_hdc, graphicsHandleWin32->getHDC(), _hglrc); … … 769 769 { 770 770 WGLExtensions* wgle = WGLExtensions::instance(); 771 771 772 772 if ( !wgle || !wgle->wglBindTexImageARB ) 773 773 { … … 789 789 bindBuffer = static_cast<int>(buffer); 790 790 } 791 791 792 792 if ( bindBuffer != _boundBuffer ) 793 793 { … … 802 802 } 803 803 _boundBuffer = bindBuffer; 804 } 805 } 806 807 void PixelBufferWin32::swapBuffersImplementation() 804 } 805 } 806 807 void PixelBufferWin32::swapBuffersImplementation() 808 808 { 809 809 SwapBuffers( _hdc );
