- Timestamp:
- 04/21/10 19:16:13 (3 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgViewer/GraphicsWindowCarbon.cpp
r11263 r11357 346 346 bool GraphicsWindowCarbon::realizeImplementation() 347 347 { 348 349 348 if (!_initialized) init(); 350 349 if (!_initialized) return false; 351 350 if (!_traits) return false; 352 353 OSG_NOTIFY(osg::INFO) << "GraphicsWindowCarbon:: realizeIMplementation" << std::endl;351 352 osg::notify(osg::INFO) << "GraphicsWindowCarbon::realizeImplementation" << std::endl; 354 353 355 354 setWindowDecoration(_traits->windowDecoration); … … 358 357 // move the window to the right screen 359 358 DarwinWindowingSystemInterface* wsi = dynamic_cast<DarwinWindowingSystemInterface*>(osg::GraphicsContext::getWindowingSystemInterface()); 360 int screenLeft (0), screenTop(0);359 int screenLeft = 0, screenTop = 0; 361 360 if (wsi) 362 361 { … … 378 377 379 378 if (err) { 380 OSG_NOTIFY(osg::WARN) << "GraphicsWindowCarbon::realizeImplementation () failed creating awindow: " << err << std::endl;379 OSG_NOTIFY(osg::WARN) << "GraphicsWindowCarbon::realizeImplementation: failed to create window: " << err << std::endl; 381 380 return false; 382 381 } else { 383 OSG_NOTIFY(osg::INFO) << "GraphicsWindowCarbon::realizeImplementation () -window created with bounds(" << bounds.top << ", " << bounds.left << ", " << bounds.bottom << ", " << bounds.right << ")" << std::endl;382 OSG_NOTIFY(osg::INFO) << "GraphicsWindowCarbon::realizeImplementation: window created with bounds(" << bounds.top << ", " << bounds.left << ", " << bounds.bottom << ", " << bounds.right << ")" << std::endl; 384 383 } 385 384 } … … 408 407 409 408 _context = aglCreateContext (_pixelFormat, sharedContextCarbon); 410 411 412 409 if (!_context) { 413 OSG_NOTIFY(osg::WARN) << "GraphicsWindowCarbon::realizeImplementation failed creating acontext: " << aglGetError() << std::endl;410 OSG_NOTIFY(osg::WARN) << "GraphicsWindowCarbon::realizeImplementation: failed to create context: " << aglGetError() << std::endl; 414 411 return false; 415 412 } … … 442 439 if (cgerr != kCGLNoError ) 443 440 { 444 OSG_NOTIFY(osg::INFO) << "GraphicsWindowCarbon:: Multi-threaded OpenGL Execution not available" << std::endl;441 OSG_NOTIFY(osg::INFO) << "GraphicsWindowCarbon::realizeImplementation: multi-threaded OpenGL Execution not available" << std::endl; 445 442 } 446 443 } 447 444 448 445 InitCursor(); 449 450 // enable vsync446 447 // enable vsync 451 448 if (_traits->vsync) { 452 449 GLint swap = 1; 453 450 aglSetInteger (_context, AGL_SWAP_INTERVAL, &swap); 454 451 } 452 _currentVSync = _traits->vsync; 455 453 456 454 _realized = true; … … 486 484 _valid = false; 487 485 _realized = false; 488 486 489 487 // there's a possibility that the MenubarController is destructed already, so prevent a crash: 490 488 MenubarController* mbc = MenubarController::instance(); … … 496 494 _pixelFormat = NULL; 497 495 } 498 496 499 497 if (_context) 500 498 { … … 504 502 _context = NULL; 505 503 } 506 504 507 505 if (_ownsWindow && _window) DisposeWindow(_window); 508 506 _window = NULL; … … 513 511 void GraphicsWindowCarbon::swapBuffersImplementation() 514 512 { 513 // check for vsync change 514 if (_traits.valid() && _traits->vsync != _currentVSync) 515 { 516 const bool on = _traits->vsync; 517 GLint swap = (on ? 1 : 0); 518 aglSetInteger (_context, AGL_SWAP_INTERVAL, &swap); 519 osg::notify(osg::NOTICE) << "GraphicsWindowCarbon: VSync=" << (on ? "on" : "off") << std::endl; 520 _currentVSync = on; 521 } 522 515 523 aglSwapBuffers(_context); 516 524 } … … 567 575 else if (mouseButton==2) mouseButton = 3; 568 576 569 // check tablet pointer device and map it to a m usebutton577 // check tablet pointer device and map it to a mouse button 570 578 TabletProximityRec theTabletRecord; // The Tablet Proximity Record 571 579 // Extract the Tablet Proximity reccord from the event. … … 586 594 break; 587 595 588 case 3: // eraser596 case 3: // eraser 589 597 pointerType = osgGA::GUIEventAdapter::ERASER; 590 598 break; … … 616 624 case kEventMouseDown: 617 625 { 618 float mx = wheresMyMouse.h;619 float my = wheresMyMouse.v;626 float mx = wheresMyMouse.h; 627 float my = wheresMyMouse.v; 620 628 transformMouseXY(mx, my); 621 629 … … 642 650 case kEventMouseUp: 643 651 { 644 float mx = wheresMyMouse.h;645 float my = wheresMyMouse.v;652 float mx = wheresMyMouse.h; 653 float my = wheresMyMouse.v; 646 654 transformMouseXY(mx, my); 647 655 if (lastEmulatedMouseButton > 0) { … … 663 671 664 672 getEventQueue()->penPressure(theTabletRecord.pressure / 65535.0f); 665 666 673 } 667 674 668 float mx = wheresMyMouse.h;669 float my = wheresMyMouse.v;675 float mx = wheresMyMouse.h; 676 float my = wheresMyMouse.v; 670 677 transformMouseXY(mx, my); 671 678 getEventQueue()->mouseMotion(mx, my); … … 706 713 { 707 714 enum 708 {715 { 709 716 kEventParamMouseWheelSmoothVerticalDelta = 'saxy', // typeSInt32 710 717 kEventParamMouseWheelSmoothHorizontalDelta = 'saxx' // typeSInt32 711 };718 }; 712 719 713 720 SInt32 scroll_delta_x = 0; … … 716 723 err = GetEventParameter( theEvent, kEventParamMouseWheelSmoothVerticalDelta, typeLongInteger, NULL, sizeof(scroll_delta_y), NULL, &scroll_delta_y ); 717 724 err = GetEventParameter( theEvent, kEventParamMouseWheelSmoothHorizontalDelta, typeLongInteger, NULL, sizeof(scroll_delta_x), NULL, &scroll_delta_x ); 718 725 719 726 if ((scroll_delta_x != 0) || (scroll_delta_y != 0)) { 720 727 getEventQueue()->mouseScroll2D( scroll_delta_x, scroll_delta_y); … … 722 729 } 723 730 break; 724 731 725 732 default: 726 733 return false; … … 760 767 case kEventRawKeyRepeat: 761 768 { 769 //osg::notify(osg::INFO) << "GraphicsWindowCarbon::keyPress Up" << std::endl; 762 770 //getEventQueue()->getCurrentEventState()->setModKeyMask(modifierMask); 763 OSG_NOTIFY(osg::INFO) << "GraphicsWindowCarbon::keyPress" << std::endl;771 //OSG_NOTIFY(osg::INFO) << "GraphicsWindowCarbon::keyPress" << std::endl; 764 772 getEventQueue()->keyPress(keychar); 765 773 break; … … 768 776 case kEventRawKeyUp: 769 777 { 770 OSG_NOTIFY(osg::INFO) << "GraphicsWindowCarbon::keyPress" << std::endl;778 //OSG_NOTIFY(osg::INFO) << "GraphicsWindowCarbon::keyPress" << std::endl; 771 779 //getEventQueue()->getCurrentEventState()->setModKeyMask(modifierMask); 772 780 getEventQueue()->keyRelease(keychar); … … 941 949 { 942 950 // TODO: implement 943 OSG_NOTIFY(osg::ALWAYS) << "GraphicsWindowCarbon::grabFocusIfPointerInWindow " << std::endl;951 OSG_NOTIFY(osg::ALWAYS) << "GraphicsWindowCarbon::grabFocusIfPointerInWindow: not implemented" << std::endl; 944 952 } 945 953 … … 947 955 void GraphicsWindowCarbon::useCursor(bool cursorOn) 948 956 { 949 950 957 if (_traits.valid()) 951 958 _traits->useCursor = cursorOn; 952 959 DarwinWindowingSystemInterface* wsi = dynamic_cast<DarwinWindowingSystemInterface*>(osg::GraphicsContext::getWindowingSystemInterface()); 953 960 if (wsi == NULL) { 954 OSG_NOTIFY(osg::WARN) << "GraphicsWindowCarbon::useCursor :: could not get OSXCarbonWindowingSystemInterface" << std::endl;961 OSG_NOTIFY(osg::WARN) << "GraphicsWindowCarbon::useCursor: could not get OSXCarbonWindowingSystemInterface" << std::endl; 955 962 return; 956 963 } 957 964 958 965 CGDirectDisplayID displayId = wsi->getDisplayID((*_traits)); 959 CGDisplayErr err = kCGErrorSuccess; 960 switch (cursorOn) 961 { 962 case true: 963 err = CGDisplayShowCursor(displayId); 964 break; 965 case false: 966 err = CGDisplayHideCursor(displayId); 967 break; 968 } 966 CGDisplayErr err = (cursorOn ? CGDisplayShowCursor(displayId) : CGDisplayHideCursor(displayId)); 969 967 if (err != kCGErrorSuccess) { 970 OSG_NOTIFY(osg::WARN) << "GraphicsWindowCarbon::useCursor failed with " << err << std::endl;968 OSG_NOTIFY(osg::WARN) << "GraphicsWindowCarbon::useCursor: failed with " << err << std::endl; 971 969 } 972 970 } … … 976 974 void GraphicsWindowCarbon::setCursor(MouseCursor mouseCursor) 977 975 { 978 UInt32 cursor;979 976 if (_currentCursor == mouseCursor) 980 977 return; 978 979 UInt32 cursor; 981 980 switch (mouseCursor) 982 981 { … … 1010 1009 } 1011 1010 1011 void GraphicsWindowCarbon::setSyncToVBlank(bool on) 1012 { 1013 if (_traits.valid()) { 1014 _traits->vsync = on; 1015 } 1016 } 1012 1017 1013 1018 void GraphicsWindowCarbon::setWindowName (const std::string& name) … … 1027 1032 DarwinWindowingSystemInterface* wsi = dynamic_cast<DarwinWindowingSystemInterface*>(osg::GraphicsContext::getWindowingSystemInterface()); 1028 1033 if (wsi == NULL) { 1029 OSG_NOTIFY(osg::WARN) << "GraphicsWindowCarbon::useCursor :: could not get OSXCarbonWindowingSystemInterface" << std::endl;1034 OSG_NOTIFY(osg::WARN) << "GraphicsWindowCarbon::useCursor: could not get OSXCarbonWindowingSystemInterface" << std::endl; 1030 1035 return; 1031 1036 }
