Ran script to remove trailing spaces and tabs

This commit is contained in:
Robert Osfield
2012-03-21 17:36:20 +00:00
parent 1e35f8975d
commit 14a563dc9f
1495 changed files with 21873 additions and 21873 deletions

View File

@@ -704,7 +704,7 @@ void CompositeViewer::eventTraversal()
if (_views.empty()) return;
double cutOffTime = (_runFrameScheme==ON_DEMAND) ? DBL_MAX : _frameStamp->getReferenceTime();
double beginEventTraversal = osg::Timer::instance()->delta_s(_startTick, osg::Timer::instance()->tick());
// OSG_NOTICE<<"CompositeViewer::frameEventTraversal()."<<std::endl;

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
@@ -33,21 +33,21 @@ using namespace osgDarwin;
// Carbon-Eventhandler to handle the click in the close-widget and the resize of windows
static pascal OSStatus GraphicsWindowEventHandler(EventHandlerCallRef nextHandler, EventRef event, void* userData)
static pascal OSStatus GraphicsWindowEventHandler(EventHandlerCallRef nextHandler, EventRef event, void* userData)
{
WindowRef window;
Rect bounds;
OSStatus result = eventNotHandledErr; /* report failure by default */
OSG_INFO << "GraphicsWindowEventHandler" << std::endl;
GraphicsWindowCarbon* w = (GraphicsWindowCarbon*)userData;
if (!w)
return result;
GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL,
sizeof(window), NULL, &window);
switch(GetEventClass(event))
{
case kEventClassTablet:
@@ -55,38 +55,38 @@ static pascal OSStatus GraphicsWindowEventHandler(EventHandlerCallRef nextHandle
if (w->handleMouseEvent(event))
result = noErr;
break;
case kEventClassKeyboard:
if (w->handleKeyboardEvent(event))
result = noErr;
break;
case kEventClassWindow: {
switch (GetEventKind(event))
{
case kEventWindowBoundsChanging:
// left the code for live-resizing, but it is not used, because of window-refreshing issues...
GetEventParameter( event, kEventParamCurrentBounds, typeQDRectangle, NULL, sizeof(Rect), NULL, &bounds );
w->adaptResize(bounds.left, bounds.top, bounds.right - bounds.left, bounds.bottom - bounds.top);
w->requestRedraw();
result = noErr;
break;
case kEventWindowBoundsChanged:
InvalWindowRect(window, GetWindowPortBounds(window, &bounds));
GetWindowBounds(window, kWindowContentRgn, &bounds);
w->adaptResize(bounds.left, bounds.top, bounds.right - bounds.left, bounds.bottom - bounds.top);
result = noErr;
break;
case kEventWindowClose:
w->requestClose();
result = noErr;
break;
default:
default:
break;
}
}
@@ -94,20 +94,20 @@ static pascal OSStatus GraphicsWindowEventHandler(EventHandlerCallRef nextHandle
//std::cout << "unknown: " << GetEventClass(event) << std::endl;
break;
}
//if (result == eventNotHandledErr)
// result = CallNextEventHandler (nextHandler, event);
return result;
}
static bool s_quit_requested = false;
// Application eventhandler -- listens for a quit-event
// Application eventhandler -- listens for a quit-event
static pascal OSStatus ApplicationEventHandler(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData)
{
HICommand commandStruct;
OSErr err = eventNotHandledErr;
@@ -119,9 +119,9 @@ static pascal OSStatus ApplicationEventHandler(EventHandlerCallRef inHandlerCall
s_quit_requested = true;
err = noErr;
break;
}
return err;
}
@@ -157,7 +157,7 @@ class CarbonKeyboardMap {
_keymap[48 ] = osgGA::GUIEventAdapter::KEY_Tab;
_keymap[49 ] = osgGA::GUIEventAdapter::KEY_Space;
_keymap[117 ] = osgGA::GUIEventAdapter::KEY_Delete;
_keymap[122 ] = osgGA::GUIEventAdapter::KEY_F1;
_keymap[120 ] = osgGA::GUIEventAdapter::KEY_F2;
_keymap[99 ] = osgGA::GUIEventAdapter::KEY_F3;
@@ -170,7 +170,7 @@ class CarbonKeyboardMap {
_keymap[109 ] = osgGA::GUIEventAdapter::KEY_F10;
_keymap[103 ] = osgGA::GUIEventAdapter::KEY_F11;
_keymap[111 ] = osgGA::GUIEventAdapter::KEY_F12;
_keymap[75 ] = osgGA::GUIEventAdapter::KEY_KP_Divide;
_keymap[67 ] = osgGA::GUIEventAdapter::KEY_KP_Multiply;
_keymap[78 ] = osgGA::GUIEventAdapter::KEY_KP_Subtract;
@@ -188,10 +188,10 @@ class CarbonKeyboardMap {
_keymap[65 ] = osgGA::GUIEventAdapter::KEY_KP_Delete;
}
~CarbonKeyboardMap() {
}
unsigned int remapKey(unsigned int key, unsigned int rawkey)
{
KeyMap::iterator itr = _keymap.find(rawkey);
@@ -215,7 +215,7 @@ class CarbonWindowAdapter : public MenubarController::WindowAdapter {
public:
CarbonWindowAdapter(GraphicsWindowCarbon* win) : MenubarController::WindowAdapter(), _win(win) {}
virtual bool valid() {return (_win.valid() && _win->valid()); }
virtual void getWindowBounds(CGRect& rect)
virtual void getWindowBounds(CGRect& rect)
{
Rect windowBounds;
OSErr error = GetWindowBounds(_win->getNativeWindowRef(), kWindowStructureRgn, &windowBounds);
@@ -224,9 +224,9 @@ public:
rect.size.width = windowBounds.right - windowBounds.left;
rect.size.height = windowBounds.bottom - windowBounds.top;
}
osgViewer::GraphicsWindow* getWindow() { return _win.get(); }
private:
private:
osg::observer_ptr<GraphicsWindowCarbon> _win;
};
@@ -237,7 +237,7 @@ void GraphicsWindowCarbon::init()
if (_initialized) return;
// getEventQueue()->setCurrentEventState(osgGA::GUIEventAdapter::getAccumulatedEventState().get());
_lastModifierKeys = 0;
_windowTitleHeight = 0;
_closeRequested = false;
@@ -271,7 +271,7 @@ bool GraphicsWindowCarbon::setWindowDecorationImplementation(bool flag)
else
{
err = ChangeWindowAttributes(getNativeWindowRef(), kWindowNoTitleBarAttribute | kWindowNoShadowAttribute, kWindowStandardDocumentAttributes);
SetWindowBounds(getNativeWindowRef(), kWindowContentRgn, &bounds);
SetWindowBounds(getNativeWindowRef(), kWindowContentRgn, &bounds);
}
if (err != noErr)
@@ -279,18 +279,18 @@ bool GraphicsWindowCarbon::setWindowDecorationImplementation(bool flag)
OSG_WARN << "GraphicsWindowCarbon::setWindowDecoration failed with " << err << std::endl;
return false;
}
// update titlebar-height
Rect titleRect;
GetWindowBounds(_window, kWindowTitleBarRgn, &titleRect);
_windowTitleHeight = abs(titleRect.bottom - titleRect.top);
// sth: I don't know why I have to reattach the context to the window here, If I don't do this I get blank areas, where the titlebar was.
// sth: I don't know why I have to reattach the context to the window here, If I don't do this I get blank areas, where the titlebar was.
// InvalWindowRect doesn't help here :-/
aglSetDrawable(_context, 0);
aglSetDrawable(_context, GetWindowPort(_window));
MenubarController::instance()->update();
}
@@ -299,16 +299,16 @@ bool GraphicsWindowCarbon::setWindowDecorationImplementation(bool flag)
WindowAttributes GraphicsWindowCarbon::computeWindowAttributes(bool useWindowDecoration, bool supportsResize) {
WindowAttributes attr;
if (useWindowDecoration)
WindowAttributes attr;
if (useWindowDecoration)
{
if (supportsResize)
attr = (kWindowStandardDocumentAttributes | kWindowStandardHandlerAttribute);
else
attr = (kWindowStandardDocumentAttributes | kWindowStandardHandlerAttribute) & ~kWindowResizableAttribute;
}
else
else
{
attr = kWindowNoTitleBarAttribute | kWindowNoShadowAttribute | kWindowStandardHandlerAttribute;
if (supportsResize)
@@ -323,7 +323,7 @@ void GraphicsWindowCarbon::installEventHandler() {
EventTypeSpec windEventList[] = {
{ kEventClassWindow, kEventWindowBoundsChanged},
{ kEventClassWindow, kEventWindowClose},
{kEventClassMouse, kEventMouseDown},
{kEventClassMouse, kEventMouseUp},
{kEventClassMouse, kEventMouseMoved},
@@ -338,7 +338,7 @@ void GraphicsWindowCarbon::installEventHandler() {
{kEventClassKeyboard, kEventHotKeyPressed},
{kEventClassKeyboard, kEventHotKeyReleased},
};
InstallWindowEventHandler(_window, NewEventHandlerUPP(GraphicsWindowEventHandler), GetEventTypeCount(windEventList), windEventList, this, NULL);
}
@@ -348,31 +348,31 @@ bool GraphicsWindowCarbon::realizeImplementation()
if (!_initialized) init();
if (!_initialized) return false;
if (!_traits) return false;
OSG_INFO << "GraphicsWindowCarbon::realizeImplementation" << std::endl;
setWindowDecoration(_traits->windowDecoration);
useCursor(_traits->useCursor);
// move the window to the right screen
DarwinWindowingSystemInterface* wsi = dynamic_cast<DarwinWindowingSystemInterface*>(osg::GraphicsContext::getWindowingSystemInterface());
int screenLeft = 0, screenTop = 0;
if (wsi)
if (wsi)
{
wsi->getScreenTopLeft((*_traits), screenLeft, screenTop);
}
WindowData *windowData = ( _traits.get() && _traits->inheritedWindowData.get() ) ? static_cast<osgViewer::GraphicsWindowCarbon::WindowData*>(_traits->inheritedWindowData.get()) : 0;
WindowData *windowData = ( _traits.get() && _traits->inheritedWindowData.get() ) ? static_cast<osgViewer::GraphicsWindowCarbon::WindowData*>(_traits->inheritedWindowData.get()) : 0;
_ownsWindow = (windowData) ? (windowData->getNativeWindowRef() == NULL) : true;
if (_ownsWindow) {
// create the window
Rect bounds = {_traits->y + screenTop, _traits->x + screenLeft, _traits->y + _traits->height + screenTop, _traits->x + _traits->width + screenLeft};
OSStatus err = 0;
WindowAttributes attr = computeWindowAttributes(_useWindowDecoration, _traits->supportsResize);
err = CreateNewWindow(kDocumentWindowClass, attr, &bounds, &_window);
if (err) {
@@ -385,22 +385,22 @@ bool GraphicsWindowCarbon::realizeImplementation()
else {
_window = windowData->getNativeWindowRef();
}
Rect titleRect;
GetWindowBounds(_window, kWindowTitleBarRgn, &titleRect);
_windowTitleHeight = abs(titleRect.bottom - titleRect.top);
if ((_ownsWindow) || (windowData && windowData->installEventHandler()))
installEventHandler();
// set the window title
setWindowName(_traits->windowName);
// create the context
AGLContext sharedContextCarbon = NULL;
GraphicsHandleCarbon* graphicsHandleCarbon = dynamic_cast<GraphicsHandleCarbon*>(_traits->sharedContext);
if (graphicsHandleCarbon)
if (graphicsHandleCarbon)
{
sharedContextCarbon = graphicsHandleCarbon->getAGLContext();
}
@@ -411,16 +411,16 @@ bool GraphicsWindowCarbon::realizeImplementation()
return false;
}
if ( windowData && windowData->getAGLDrawable() ) {
aglSetDrawable(_context, (AGLDrawable)*(windowData->getAGLDrawable()) );
aglSetDrawable(_context, (AGLDrawable)*(windowData->getAGLDrawable()) );
} else {
aglSetDrawable(_context, GetWindowPort(_window));
ShowWindow(_window);
aglSetDrawable(_context, GetWindowPort(_window));
ShowWindow(_window);
MenubarController::instance()->attachWindow( new CarbonWindowAdapter(this) );
}
makeCurrent();
if ((_traits->useMultiThreadedOpenGLEngine) && (OpenThreads::GetNumberOfProcessors() > 1)) {
@@ -435,11 +435,11 @@ bool GraphicsWindowCarbon::realizeImplementation()
// so we'll use the raw value of it to keep things compiling on older
// versions of OSX.
cgerr = CGLEnable( ctx, static_cast <CGLContextEnable>(313) );
#endif
#endif
if (cgerr != kCGLNoError )
{
OSG_INFO << "GraphicsWindowCarbon::realizeImplementation: multi-threaded OpenGL Execution not available" << std::endl;
}
}
}
InitCursor();
@@ -459,7 +459,7 @@ bool GraphicsWindowCarbon::realizeImplementation()
bool GraphicsWindowCarbon::makeCurrentImplementation()
{
return (aglSetCurrentContext(_context) == GL_TRUE);
}
@@ -487,21 +487,21 @@ void GraphicsWindowCarbon::closeImplementation()
// there's a possibility that the MenubarController is destructed already, so prevent a crash:
MenubarController* mbc = MenubarController::instance();
if (mbc) mbc->detachWindow(this);
if (_pixelFormat)
{
aglDestroyPixelFormat(_pixelFormat);
_pixelFormat = NULL;
}
if (_context)
if (_context)
{
aglSetDrawable(_context, NULL);
aglSetCurrentContext(NULL);
aglDestroyContext(_context);
_context = NULL;
}
if (_ownsWindow && _window) DisposeWindow(_window);
_window = NULL;
}
@@ -531,7 +531,7 @@ void GraphicsWindowCarbon::resizedImplementation(int x, int y, int width, int he
aglUpdateContext(_context);
MenubarController::instance()->update();
getEventQueue()->windowResize(x,y,width, height, getEventQueue()->getTime());
}
@@ -541,24 +541,24 @@ bool GraphicsWindowCarbon::handleMouseEvent(EventRef theEvent)
{
static unsigned int lastEmulatedMouseButton = 0;
// mouse down event
// mouse down event
Point wheresMyMouse;
GetEventParameter (theEvent, kEventParamWindowMouseLocation, typeQDPoint, NULL, sizeof(wheresMyMouse), NULL, &wheresMyMouse);
wheresMyMouse.v -= _windowTitleHeight;
if (_useWindowDecoration && (wheresMyMouse.v < 0))
return false;
Point wheresMyMouseGlobal;
GetEventParameter (theEvent, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(wheresMyMouse), NULL, &wheresMyMouseGlobal);
EventMouseButton mouseButton = 0;
GetEventParameter (theEvent, kEventParamMouseButton, typeMouseButton, NULL, sizeof(mouseButton), NULL, &mouseButton);
UInt32 modifierKeys;
GetEventParameter (theEvent,kEventParamKeyModifiers,typeUInt32, NULL,sizeof(modifierKeys), NULL,&modifierKeys);
WindowRef win;
int fwres = FindWindow(wheresMyMouseGlobal, &win);
// return false when Window is inactive; For enabling click-to-active on window by delegating event to default handler
@@ -573,7 +573,7 @@ bool GraphicsWindowCarbon::handleMouseEvent(EventRef theEvent)
// swap right and middle buttons so that middle button is 2, right button is 3.
if (mouseButton==3) mouseButton = 2;
else if (mouseButton==2) mouseButton = 3;
// check tablet pointer device and map it to a mouse button
TabletProximityRec theTabletRecord; // The Tablet Proximity Record
// Extract the Tablet Proximity reccord from the event.
@@ -581,18 +581,18 @@ bool GraphicsWindowCarbon::handleMouseEvent(EventRef theEvent)
typeTabletProximityRec, NULL,
sizeof(TabletProximityRec),
NULL, (void *)&theTabletRecord))
{
{
osgGA::GUIEventAdapter::TabletPointerType pointerType;
switch(theTabletRecord.pointerType)
{
case 1: // pen
pointerType = osgGA::GUIEventAdapter::PEN;
break;
case 2: // puck
pointerType = osgGA::GUIEventAdapter::PUCK;
break;
case 3: // eraser
pointerType = osgGA::GUIEventAdapter::ERASER;
break;
@@ -601,14 +601,14 @@ bool GraphicsWindowCarbon::handleMouseEvent(EventRef theEvent)
pointerType = osgGA::GUIEventAdapter::UNKNOWN;
break;
}
getEventQueue()->penProximity(pointerType, (theTabletRecord.enterProximity != 0));
}
// get tilt and rotation from the pen
TabletPointRec theTabletPointRecord;
if(noErr == GetEventParameter(theEvent, kEventParamTabletPointRec, typeTabletPointRec, NULL,
sizeof(TabletPointRec), NULL, (void *)&theTabletPointRecord))
if(noErr == GetEventParameter(theEvent, kEventParamTabletPointRec, typeTabletPointRec, NULL,
sizeof(TabletPointRec), NULL, (void *)&theTabletPointRecord))
{
int penRotation = (int)theTabletPointRecord.rotation * 9 / 575; //to get angle between 0 to 360 grad
penRotation = -(((penRotation + 180) % 360) - 180) ; //for same range on all plattforms we need -180 to 180
@@ -618,7 +618,7 @@ bool GraphicsWindowCarbon::handleMouseEvent(EventRef theEvent)
penRotation
);
}
switch(GetEventKind(theEvent))
{
case kEventMouseDown:
@@ -626,10 +626,10 @@ bool GraphicsWindowCarbon::handleMouseEvent(EventRef theEvent)
float mx = wheresMyMouse.h;
float my = wheresMyMouse.v;
transformMouseXY(mx, my);
lastEmulatedMouseButton = 0;
if (mouseButton == 1)
if (mouseButton == 1)
{
if( modifierKeys & cmdKey )
{
@@ -640,8 +640,8 @@ bool GraphicsWindowCarbon::handleMouseEvent(EventRef theEvent)
mouseButton = lastEmulatedMouseButton = 2;
}
}
if (clickCount > 1)
if (clickCount > 1)
getEventQueue()->mouseDoubleButtonPress(mx,my, mouseButton);
else
getEventQueue()->mouseButtonPress(mx, my, mouseButton);
@@ -661,24 +661,24 @@ bool GraphicsWindowCarbon::handleMouseEvent(EventRef theEvent)
}
}
break;
case kEventMouseDragged:
{
// get pressure from the pen, only when mouse/pen is dragged
TabletPointRec theTabletRecord;
if(noErr == GetEventParameter(theEvent, kEventParamTabletPointRec, typeTabletPointRec, NULL,
if(noErr == GetEventParameter(theEvent, kEventParamTabletPointRec, typeTabletPointRec, NULL,
sizeof(TabletPointRec), NULL, (void *)&theTabletRecord)) {
getEventQueue()->penPressure(theTabletRecord.pressure / 65535.0f);
}
float mx = wheresMyMouse.h;
float my = wheresMyMouse.v;
transformMouseXY(mx, my);
getEventQueue()->mouseMotion(mx, my);
}
break;
case kEventMouseMoved:
{
float mx = wheresMyMouse.h;
@@ -687,7 +687,7 @@ bool GraphicsWindowCarbon::handleMouseEvent(EventRef theEvent)
getEventQueue()->mouseMotion(mx, my);
}
break;
// mouse with scroll-wheels
case kEventMouseWheelMoved:
{
@@ -707,7 +707,7 @@ bool GraphicsWindowCarbon::handleMouseEvent(EventRef theEvent)
}
}
break;
// new trackpads and mighty mouse, (not officially documented, see http://developer.apple.com/qa/qa2005/qa1453.html )
case 11:
{
@@ -716,7 +716,7 @@ bool GraphicsWindowCarbon::handleMouseEvent(EventRef theEvent)
kEventParamMouseWheelSmoothVerticalDelta = 'saxy', // typeSInt32
kEventParamMouseWheelSmoothHorizontalDelta = 'saxx' // typeSInt32
};
SInt32 scroll_delta_x = 0;
SInt32 scroll_delta_y = 0;
OSErr err = noErr;
@@ -728,12 +728,12 @@ bool GraphicsWindowCarbon::handleMouseEvent(EventRef theEvent)
}
}
break;
default:
return false;
}
}
return true;
}
@@ -742,25 +742,25 @@ bool GraphicsWindowCarbon::handleMouseEvent(EventRef theEvent)
bool GraphicsWindowCarbon::handleKeyboardEvent(EventRef theEvent)
{
handleModifierKeys(theEvent);
OSStatus status;
UInt32 rawkey;
GetEventParameter (theEvent,kEventParamKeyCode,typeUInt32, NULL,sizeof(rawkey), NULL,&rawkey);
// OSG_INFO << "key code: " << rawkey << " modifiers: " << modifierKeys << std::endl;
UInt32 dataSize;
/* jbw check return status so that we don't allocate a huge array */
status = GetEventParameter( theEvent, kEventParamKeyUnicodes, typeUnicodeText, NULL, 0, &dataSize, NULL );
if (status != noErr) return false;
if (dataSize<=1) return false;
UniChar* uniChars = new UniChar[dataSize+1];
GetEventParameter( theEvent, kEventParamKeyUnicodes, typeUnicodeText, NULL, dataSize, NULL, (void*)uniChars );
unsigned int keychar = remapCarbonKey(static_cast<unsigned long>(uniChars[0]), rawkey);
switch(GetEventKind(theEvent))
{
case kEventRawKeyDown:
@@ -772,18 +772,18 @@ bool GraphicsWindowCarbon::handleKeyboardEvent(EventRef theEvent)
getEventQueue()->keyPress(keychar);
break;
}
case kEventRawKeyUp:
{
{
//OSG_INFO << "GraphicsWindowCarbon::keyPress" << std::endl;
//getEventQueue()->getCurrentEventState()->setModKeyMask(modifierMask);
getEventQueue()->keyRelease(keychar);
break;
}
default:
break;
}
delete[] uniChars;
@@ -797,14 +797,14 @@ void GraphicsWindowCarbon::handleModifierKey(UInt32 modifierKey, UInt32 modifier
{
getEventQueue()->keyPress(keySymbol);
}
if (!(modifierKey & modifierMask) && (_lastModifierKeys & modifierMask))
{
getEventQueue()->keyRelease(keySymbol);
}
}
bool GraphicsWindowCarbon::handleModifierKeys(EventRef theEvent)
bool GraphicsWindowCarbon::handleModifierKeys(EventRef theEvent)
{
UInt32 modifierKeys;
GetEventParameter (theEvent,kEventParamKeyModifiers,typeUInt32, NULL,sizeof(modifierKeys), NULL,&modifierKeys);
@@ -812,25 +812,25 @@ bool GraphicsWindowCarbon::handleModifierKeys(EventRef theEvent)
//std::cout << modifierKeys << std::endl;
if (_lastModifierKeys == modifierKeys)
return false;
handleModifierKey(modifierKeys, shiftKey, osgGA::GUIEventAdapter::KEY_Shift_L);
handleModifierKey(modifierKeys, controlKey, osgGA::GUIEventAdapter::KEY_Control_L);
handleModifierKey(modifierKeys, optionKey, osgGA::GUIEventAdapter::KEY_Alt_L);
handleModifierKey(modifierKeys, cmdKey, osgGA::GUIEventAdapter::KEY_Super_L);
// Caps lock needs some special handling, i did not find a way to get informed when the caps-lock-key gets released
// Caps lock needs some special handling, i did not find a way to get informed when the caps-lock-key gets released
if ((modifierKeys & alphaLock) && !(_lastModifierKeys & alphaLock))
{
getEventQueue()->keyPress(osgGA::GUIEventAdapter::KEY_Caps_Lock);
getEventQueue()->keyRelease(osgGA::GUIEventAdapter::KEY_Caps_Lock);
}
if (!(modifierKeys & alphaLock) && (_lastModifierKeys & alphaLock))
{
getEventQueue()->keyPress(osgGA::GUIEventAdapter::KEY_Caps_Lock);
getEventQueue()->keyRelease(osgGA::GUIEventAdapter::KEY_Caps_Lock);
}
_lastModifierKeys = modifierKeys;
return true;
}
@@ -840,22 +840,22 @@ bool GraphicsWindowCarbon::handleModifierKeys(EventRef theEvent)
void GraphicsWindowCarbon::checkEvents()
{
if (!_realized) return;
EventRef theEvent;
EventTargetRef theTarget = GetEventDispatcherTarget();
while (ReceiveNextEvent(0, NULL, 0,true, &theEvent)== noErr)
{
switch(GetEventClass(theEvent))
{
case kEventClassMouse:
case kEventClassMouse:
{
// handle the menubar
Point wheresMyMouse;
GetEventParameter (theEvent, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(wheresMyMouse), NULL, &wheresMyMouse);
EventMouseButton mouseButton = 0;
GetEventParameter (theEvent, kEventParamMouseButton, typeMouseButton, NULL, sizeof(mouseButton), NULL, &mouseButton);
WindowRef win;
int fwres = FindWindow(wheresMyMouse, &win);
@@ -874,8 +874,8 @@ void GraphicsWindowCarbon::checkEvents()
break;
}
break;
case kEventClassAppleEvent:
case kEventClassAppleEvent:
{
EventRecord eventRecord;
ConvertEventRefToEventRecord(theEvent, &eventRecord);
@@ -886,16 +886,16 @@ void GraphicsWindowCarbon::checkEvents()
}
SendEventToEventTarget (theEvent, theTarget);
ReleaseEvent(theEvent);
}
ReleaseEvent(theEvent);
}
if (_closeRequested)
getEventQueue()->closeWindow();
if (s_quit_requested) {
getEventQueue()->quitApplication();
s_quit_requested = false;
}
}
@@ -903,11 +903,11 @@ bool GraphicsWindowCarbon::setWindowRectangleImplementation(int x, int y, int wi
{
int screenLeft(0), screenTop(0);
DarwinWindowingSystemInterface* wsi = dynamic_cast<DarwinWindowingSystemInterface*>(osg::GraphicsContext::getWindowingSystemInterface());
if (wsi)
if (wsi)
{
wsi->getScreenTopLeft((*_traits), screenLeft, screenTop);
}
Rect bounds = {y + screenTop, x + screenLeft, y + height + screenTop, x + width + screenLeft};
SetWindowBounds(getNativeWindowRef(), kWindowContentRgn, &bounds);
aglUpdateContext(_context);
@@ -922,17 +922,17 @@ void GraphicsWindowCarbon::adaptResize(int x, int y, int w, int h)
DarwinWindowingSystemInterface* wsi = dynamic_cast<DarwinWindowingSystemInterface*>(osg::GraphicsContext::getWindowingSystemInterface());
int screenLeft(0), screenTop(0);
if (wsi) {
// get the screen containing the window
unsigned int screenNdx = wsi->getScreenContaining(x,y,w,h);
// update traits
_traits->screenNum = screenNdx;
// get top left of screen
wsi->getScreenTopLeft((*_traits), screenLeft, screenTop);
}
resized(x-screenLeft,y-screenTop,w,h);
}
@@ -961,7 +961,7 @@ void GraphicsWindowCarbon::useCursor(bool cursorOn)
OSG_WARN << "GraphicsWindowCarbon::useCursor: could not get OSXCarbonWindowingSystemInterface" << std::endl;
return;
}
CGDirectDisplayID displayId = wsi->getDisplayID((*_traits));
CGDisplayErr err = (cursorOn ? CGDisplayShowCursor(displayId) : CGDisplayHideCursor(displayId));
if (err != kCGErrorSuccess) {
@@ -977,7 +977,7 @@ void GraphicsWindowCarbon::setCursor(MouseCursor mouseCursor)
return;
UInt32 cursor;
switch (mouseCursor)
switch (mouseCursor)
{
case NoCursor:
HideCursor();
@@ -1002,7 +1002,7 @@ void GraphicsWindowCarbon::setCursor(MouseCursor mouseCursor)
cursor = kThemeArrowCursor;
OSG_WARN << "GraphicsWindowCarbon::setCursor doesn't implement cursor: type = " << mouseCursor << std::endl;
}
_currentCursor = mouseCursor;
SetThemeCursor(cursor);
ShowCursor();
@@ -1015,10 +1015,10 @@ void GraphicsWindowCarbon::setSyncToVBlank(bool on)
}
}
void GraphicsWindowCarbon::setWindowName (const std::string& name)
void GraphicsWindowCarbon::setWindowName (const std::string& name)
{
_traits->windowName = name;
if (!_traits->windowName.empty())
if (!_traits->windowName.empty())
{
CFStringRef windowtitle = CFStringCreateWithBytes( kCFAllocatorDefault, (const UInt8*)(_traits->windowName.c_str()), _traits->windowName.length(),kCFStringEncodingUTF8, false );
SetWindowTitleWithCFString( _window, windowtitle );
@@ -1068,7 +1068,7 @@ public:
{
}
virtual osg::GraphicsContext* createGraphicsContext(osg::GraphicsContext::Traits* traits)
virtual osg::GraphicsContext* createGraphicsContext(osg::GraphicsContext::Traits* traits)
{
_init();

View File

@@ -2193,7 +2193,7 @@ void GraphicsWindowWin32::useCursor( bool cursorOn )
if (_traits.valid())
_traits->useCursor = cursorOn;
// note, we are using setCursorImpl to set the cursor, so we can use
// note, we are using setCursorImpl to set the cursor, so we can use
// _appMouseCursor to cache the current mouse-cursor
setCursorImpl(cursorOn ? _appMouseCursor : NoCursor);
}

View File

@@ -453,7 +453,7 @@ bool GraphicsWindowX11::setWindowDecorationImplementation(bool flag)
// if traits says not resize we want to set the functions to exlude MWM_FUNC_RESIZE,
// but this bitmask needs to be set if the MWM_FUNC_ALL bit is already set in order to toggle it off.
if (_traits.valid() && !_traits->supportsResize) wmHints.functions = wmHints.functions | MWM_FUNC_RESIZE;
}
else
{
@@ -463,7 +463,7 @@ bool GraphicsWindowX11::setWindowDecorationImplementation(bool flag)
wmHints.inputMode = 0;
wmHints.status = 0;
}
XChangeProperty( display, _window, atom, atom, 32, PropModeReplace, (unsigned char *)&wmHints, 5 );
result = true;
}
@@ -494,7 +494,7 @@ bool GraphicsWindowX11::setWindowRectangleImplementation(int x, int y, int width
XFlush(display);
XSync(display, 0);
// add usleep here to give window manager a chance to handle the request, if
// we don't add this sleep then any X11 calls right afterwards can produce
// X11 errors.
@@ -758,7 +758,7 @@ void GraphicsWindowX11::init()
if (_traits->samples) { attributes.push_back(EGL_SAMPLES); attributes.push_back(_traits->samples); }
attributes.push_back(EGL_RENDERABLE_TYPE); attributes.push_back(OSG_EGL_OPENGL_TARGET_BIT);
attributes.push_back(EGL_NONE);
attributes.push_back(EGL_NONE);
@@ -915,7 +915,7 @@ bool GraphicsWindowX11::createWindow()
doFullSceenWorkAround = true;
}
}
_window = XCreateWindow( _display, _parent,
x,
y,
@@ -952,7 +952,7 @@ bool GraphicsWindowX11::createWindow()
setWindowDecoration(_traits->windowDecoration);
useCursor(_traits->useCursor);
_deleteWindow = XInternAtom (_display, "WM_DELETE_WINDOW", False);
@@ -1206,7 +1206,7 @@ void GraphicsWindowX11::checkEvents()
double resizeTime = eventTime;
_timeOfLastCheckEvents = getEventQueue()->getTime();
if (baseTime>_timeOfLastCheckEvents) baseTime = _timeOfLastCheckEvents;
// OSG_NOTICE<<"GraphicsWindowX11::checkEvents() : getEventQueue()->getCurrentEventState()->getGraphicsContext()="<<getEventQueue()->getCurrentEventState()->getGraphicsContext()<<std::endl;

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
@@ -42,10 +42,10 @@ bool HelpHandler::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapt
{
osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa);
if (!view) return false;
osgViewer::ViewerBase* viewer = view->getViewerBase();
if (!viewer) return false;
if (ea.getHandled()) return false;
switch(ea.getEventType())
@@ -85,7 +85,7 @@ void HelpHandler::setUpHUDCamera(osgViewer::ViewerBase* viewer)
osgViewer::GraphicsWindow* window = dynamic_cast<osgViewer::GraphicsWindow*>(_camera->getGraphicsContext());
if (!window)
{
{
osgViewer::Viewer::Windows windows;
viewer->getWindows(windows);
@@ -156,7 +156,7 @@ void HelpHandler::setUpScene(osgViewer::ViewerBase* viewer)
}
const osg::ApplicationUsage::UsageMap& keyboardBinding = _applicationUsage->getKeyboardMouseBindings();
for(osg::ApplicationUsage::UsageMap::const_iterator itr = keyboardBinding.begin();
itr != keyboardBinding.end();
++itr)
@@ -196,9 +196,9 @@ void HelpHandler::setUpScene(osgViewer::ViewerBase* viewer)
float ratio = 1.0;
if (width > 1024.0f) ratio = 1024.0f/width;
if (height*ratio > 800.0f) ratio = 800.0f/height;
_camera->setViewMatrix(osg::Matrix::translate(-bb.center()) *
osg::Matrix::scale(ratio,ratio,ratio) *
_camera->setViewMatrix(osg::Matrix::translate(-bb.center()) *
osg::Matrix::scale(ratio,ratio,ratio) *
osg::Matrix::translate(osg::Vec3(640.0f, 520.0f, 0.0f)));
}
}

View File

@@ -6,7 +6,7 @@
* Copyright 2007 __MyCompanyName__. All rights reserved.
*
*/
#if defined (__APPLE__) && (!__LP64__)
#include <osg/observer_ptr>
@@ -19,31 +19,31 @@ using namespace osgViewer;
/** creates a pixelformat from a Trait */
/** creates a pixelformat from a Trait */
AGLPixelFormat PixelBufferCarbon::createPixelFormat(osg::GraphicsContext::Traits* traits) {
std::vector<GLint> attributes;
attributes.push_back(AGL_NO_RECOVERY);
attributes.push_back(AGL_RGBA);
if (!traits->pbuffer)
if (!traits->pbuffer)
attributes.push_back(AGL_COMPLIANT);
else
attributes.push_back(AGL_CLOSEST_POLICY);
if (traits->doubleBuffer) attributes.push_back(AGL_DOUBLEBUFFER);
if (traits->quadBufferStereo) attributes.push_back(AGL_STEREO);
attributes.push_back(AGL_RED_SIZE); attributes.push_back(traits->red);
attributes.push_back(AGL_GREEN_SIZE); attributes.push_back(traits->green);
attributes.push_back(AGL_BLUE_SIZE); attributes.push_back(traits->blue);
attributes.push_back(AGL_DEPTH_SIZE); attributes.push_back(traits->depth);
if (traits->alpha) { attributes.push_back(AGL_ALPHA_SIZE); attributes.push_back(traits->alpha); }
if (traits->stencil) { attributes.push_back(AGL_STENCIL_SIZE); attributes.push_back(traits->stencil); }
// TODO
// TODO
// missing accumulation-buffer-stuff
#if defined(AGL_SAMPLE_BUFFERS_ARB) && defined (AGL_SAMPLES_ARB)
@@ -53,7 +53,7 @@ AGLPixelFormat PixelBufferCarbon::createPixelFormat(osg::GraphicsContext::Traits
#endif
attributes.push_back(AGL_NONE);
return aglChoosePixelFormat(NULL, 0, &(attributes.front()));
}
@@ -69,40 +69,40 @@ void PixelBufferCarbon::init()
/** This is the class we need to create for pbuffers, note its not a GraphicsWindow as it won't need any of the event handling and window mapping facilities.*/
/** Realise the GraphicsContext implementation,
/** Realise the GraphicsContext implementation,
* Pure virtual - must be implemented by concrate implementations of GraphicsContext. */
bool PixelBufferCarbon::realizeImplementation()
bool PixelBufferCarbon::realizeImplementation()
{
if (!_valid) {
OSG_WARN << "PixelBufferCarbon::realizeImplementation() aglChoosePixelFormat failed! " << aglErrorString(aglGetError()) << std::endl;
return false;
}
AGLContext sharedContext = NULL;
// get any shared AGL contexts
// get any shared AGL contexts
GraphicsHandleCarbon* graphicsHandleCarbon = dynamic_cast<GraphicsHandleCarbon*>(_traits->sharedContext);
if (graphicsHandleCarbon)
if (graphicsHandleCarbon)
{
sharedContext = graphicsHandleCarbon->getAGLContext();
}
_context = aglCreateContext (_pixelformat, sharedContext);
if (!_context) {
OSG_WARN << "PixelBufferCarbon::realizeImplementation() aglCreateContext failed! " << aglErrorString(aglGetError()) << std::endl;
return false;
}
_realized = aglCreatePBuffer (_traits->width, _traits->height, _traits->target, GL_RGBA, _traits->level, &(_pbuffer));
if (!_realized) {
OSG_WARN << "PixelBufferCarbon::realizeImplementation() aglCreatePBuffer failed! " << aglErrorString(aglGetError()) << std::endl;
}
makeCurrentImplementation();
_realized = aglSetPBuffer(_context, _pbuffer, _traits->face, _traits->level, 0);
if (!_realized) {
OSG_WARN << "PixelBufferCarbon::realizeImplementation() aglSetPBuffer failed! " << aglErrorString(aglGetError()) << std::endl;
@@ -110,55 +110,55 @@ bool PixelBufferCarbon::realizeImplementation()
return _realized;
}
void PixelBufferCarbon::closeImplementation()
{
void PixelBufferCarbon::closeImplementation()
{
if (_pbuffer) aglDestroyPBuffer(_pbuffer);
if (_context) aglDestroyContext(_context);
if (_pixelformat) aglDestroyPixelFormat(_pixelformat);
_pbuffer = NULL;
_context = NULL;
_pixelformat = NULL;
_valid = _realized = false;
}
/** Make this graphics context current implementation.
* Pure virtual - must be implemented by concrate implementations of GraphicsContext. */
bool PixelBufferCarbon::makeCurrentImplementation()
{
bool PixelBufferCarbon::makeCurrentImplementation()
{
return (_realized) ? (aglSetCurrentContext(_context) == GL_TRUE) : false;
}
/** Make this graphics context current with specified read context implementation.
* Pure virtual - must be implemented by concrate implementations of GraphicsContext. */
bool PixelBufferCarbon::makeContextCurrentImplementation(GraphicsContext* /*readContext*/) {
bool PixelBufferCarbon::makeContextCurrentImplementation(GraphicsContext* /*readContext*/) {
return makeCurrentImplementation();
}
/** Release the graphics context.*/
bool PixelBufferCarbon::releaseContextImplementation()
{
bool PixelBufferCarbon::releaseContextImplementation()
{
return (aglSetCurrentContext(NULL) == GL_TRUE);
}
/** Pure virtual, Bind the graphics context to associated texture implementation.
* Pure virtual - must be implemented by concrate implementations of GraphicsContext. */
void PixelBufferCarbon::bindPBufferToTextureImplementation( GLenum buffer ){
void PixelBufferCarbon::bindPBufferToTextureImplementation( GLenum buffer ){
OSG_NOTICE<<"GraphicsWindow::void bindPBufferToTextureImplementation(..) not implemented."<<std::endl;
OSG_NOTICE<<"GraphicsWindow::void bindPBufferToTextureImplementation(..) not implemented."<<std::endl;
}
/** Swap the front and back buffers implementation.
* Pure virtual - must be implemented by Concrate implementations of GraphicsContext. */
void PixelBufferCarbon::swapBuffersImplementation()
{
void PixelBufferCarbon::swapBuffersImplementation()
{
aglSwapBuffers(_context);
}
PixelBufferCarbon::~PixelBufferCarbon()
PixelBufferCarbon::~PixelBufferCarbon()
{
close(true);
}

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*
* Some elements of GraphicsWindowWin32 have used the Producer implementation as a reference.
@@ -151,7 +151,7 @@ DECLARE_HANDLE(HPBUFFERARB);
#define WGL_SAMPLES_ARB 0x2042
#endif
namespace
namespace
{
static std::string sysError()
@@ -166,7 +166,7 @@ static std::string sysError()
err,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,\
0,NULL
0,NULL
);
std::ostringstream msgResult;
@@ -179,7 +179,7 @@ static std::string sysError()
{
msgResult << "Error code " << err;
}
return msgResult.str();
}
@@ -205,13 +205,13 @@ public:
protected:
~TemporaryWindow();
TemporaryWindow(const TemporaryWindow &):
_handle(0),
_dc(0),
_context(0),
_instance(0) {}
TemporaryWindow &operator=(const TemporaryWindow &) { return *this; }
void create();
@@ -232,10 +232,10 @@ void TemporaryWindow::create()
_classname = oss.str();
_instance = GetModuleHandle(0);
WNDCLASS wndclass;
wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wndclass.lpfnWndProc = DefWindowProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
@@ -243,7 +243,7 @@ void TemporaryWindow::create()
wndclass.hCursor = 0;
wndclass.hIcon = 0;
wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wndclass.lpszMenuName = 0;
wndclass.lpszMenuName = 0;
wndclass.lpszClassName = _classname.c_str();
if (!RegisterClass(&wndclass))
@@ -274,27 +274,27 @@ void TemporaryWindow::create()
return;
}
PIXELFORMATDESCRIPTOR pfd = {
PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW |
PFD_SUPPORT_OPENGL,
PFD_TYPE_RGBA,
24,
0, 0, 0, 0, 0, 0,
0,
0,
0,
0, 0, 0, 0,
1,
PFD_DRAW_TO_WINDOW |
PFD_SUPPORT_OPENGL,
PFD_TYPE_RGBA,
24,
0, 0, 0, 0, 0, 0,
0,
0,
0,
0, 0, 0, 0,
16,
0,
0,
PFD_MAIN_PLANE,
0,
0, 0, 0
};
0,
0,
PFD_MAIN_PLANE,
0,
0, 0, 0
};
int visual_id = ChoosePixelFormat(_dc, &pfd);
int visual_id = ChoosePixelFormat(_dc, &pfd);
if (!SetPixelFormat(_dc, visual_id, &pfd))
{
@@ -421,7 +421,7 @@ bool WGLExtensions::isValid()
WGLExtensions *WGLExtensions::instance()
{
HGLRC context = wglGetCurrentContext();
// Get wgl function pointers for the current graphics context, or if there is no
// current context then use a temporary window.
@@ -466,7 +466,7 @@ PixelBufferWin32::PixelBufferWin32( osg::GraphicsContext::Traits* traits ):
if (_traits.valid() && _traits->sharedContext )
{
getState()->setContextID( _traits->sharedContext->getState()->getContextID() );
incrementContextIDUsageCount( getState()->getContextID() );
incrementContextIDUsageCount( getState()->getContextID() );
}
else
{
@@ -479,7 +479,7 @@ PixelBufferWin32::~PixelBufferWin32()
{
closeImplementation();
}
void PixelBufferWin32::init()
{
if (_initialized) return;
@@ -640,7 +640,7 @@ void PixelBufferWin32::init()
_traits->height = iHeight;
}
_initialized = true;
_initialized = true;
_valid = true;
return;
@@ -655,13 +655,13 @@ bool PixelBufferWin32::realizeImplementation()
}
if (!_initialized) init();
if (!_initialized) return false;
if ( _traits->sharedContext )
{
GraphicsHandleWin32* graphicsHandleWin32 = dynamic_cast<GraphicsHandleWin32*>(_traits->sharedContext);
if (graphicsHandleWin32)
if (graphicsHandleWin32)
{
if ( !wglShareLists(graphicsHandleWin32->getWGLContext(), _hglrc) )
{
@@ -719,7 +719,7 @@ bool PixelBufferWin32::makeCurrentImplementation()
// If the pbuffer is bound to a texture then release it. This operation requires a current context, so
// do it after the MakeCurrent.
if ( _boundBuffer!=0 )
{
WGLExtensions* wgle = WGLExtensions::instance();
@@ -735,7 +735,7 @@ bool PixelBufferWin32::makeCurrentImplementation()
return result;
}
bool PixelBufferWin32::makeContextCurrentImplementation( GraphicsContext* readContext )
{
WGLExtensions* wgle = WGLExtensions::instance();
@@ -747,7 +747,7 @@ bool PixelBufferWin32::makeContextCurrentImplementation( GraphicsContext* readCo
}
GraphicsHandleWin32* graphicsHandleWin32 = dynamic_cast<GraphicsHandleWin32*>(readContext);
if (graphicsHandleWin32)
if (graphicsHandleWin32)
{
return wgle->wglMakeContextCurrentARB(_hdc, graphicsHandleWin32->getHDC(), _hglrc);
}
@@ -768,7 +768,7 @@ bool PixelBufferWin32::releaseContextImplementation()
void PixelBufferWin32::bindPBufferToTextureImplementation( GLenum buffer )
{
WGLExtensions* wgle = WGLExtensions::instance();
if ( !wgle || !wgle->wglBindTexImageARB )
{
OSG_NOTICE << "PixelBufferWin32, wglBindTexImageARB not available" << std::endl;
@@ -788,7 +788,7 @@ void PixelBufferWin32::bindPBufferToTextureImplementation( GLenum buffer )
default:
bindBuffer = static_cast<int>(buffer);
}
if ( bindBuffer != _boundBuffer )
{
if ( _boundBuffer != 0 && !wgle->wglReleaseTexImageARB(reinterpret_cast<HPBUFFERARB>(_hwnd), _boundBuffer) )
@@ -801,10 +801,10 @@ void PixelBufferWin32::bindPBufferToTextureImplementation( GLenum buffer )
OSG_NOTICE << "PixelBufferWin32::bindPBufferToTextureImplementation, wglBindTexImageARB error: " << sysError() << std::endl;
}
_boundBuffer = bindBuffer;
}
}
}
void PixelBufferWin32::swapBuffersImplementation()
void PixelBufferWin32::swapBuffersImplementation()
{
SwapBuffers( _hdc );
}

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
@@ -37,7 +37,7 @@ PixelBufferX11::PixelBufferX11(osg::GraphicsContext::Traits* traits)
_traits = traits;
init();
if (valid())
{
setState( new osg::State );
@@ -46,7 +46,7 @@ PixelBufferX11::PixelBufferX11(osg::GraphicsContext::Traits* traits)
if (_traits.valid() && _traits->sharedContext)
{
getState()->setContextID( _traits->sharedContext->getState()->getContextID() );
incrementContextIDUsageCount( getState()->getContextID() );
incrementContextIDUsageCount( getState()->getContextID() );
}
else
{
@@ -66,20 +66,20 @@ bool PixelBufferX11::createVisualInfo()
{
typedef std::vector<int> Attributes;
Attributes attributes;
attributes.push_back(GLX_USE_GL);
attributes.push_back(GLX_RGBA);
if (_traits->doubleBuffer) attributes.push_back(GLX_DOUBLEBUFFER);
attributes.push_back(GLX_RED_SIZE); attributes.push_back(_traits->red);
attributes.push_back(GLX_GREEN_SIZE); attributes.push_back(_traits->green);
attributes.push_back(GLX_BLUE_SIZE); attributes.push_back(_traits->blue);
attributes.push_back(GLX_DEPTH_SIZE); attributes.push_back(_traits->depth);
if (_traits->alpha) { attributes.push_back(GLX_ALPHA_SIZE); attributes.push_back(_traits->alpha); }
if (_traits->stencil) { attributes.push_back(GLX_STENCIL_SIZE); attributes.push_back(_traits->stencil); }
#if defined(GLX_SAMPLE_BUFFERS) && defined (GLX_SAMPLES)
@@ -92,9 +92,9 @@ bool PixelBufferX11::createVisualInfo()
// GLX_AUX_BUFFERS
// GLX_ACCUM_RED_SIZE
// GLX_ACCUM_GREEN_SIZE
attributes.push_back(None);
_visualInfo = glXChooseVisual( _display, _traits->screenNum, &(attributes.front()) );
return _visualInfo != 0;
@@ -109,7 +109,7 @@ void PixelBufferX11::init()
_valid = false;
return;
}
if (_traits->target != 0)
{
// we don't support Pbuffer render to texture under GLX.
@@ -119,7 +119,7 @@ void PixelBufferX11::init()
_display = XOpenDisplay(_traits->displayName().c_str());
unsigned int screen = _traits->screenNum;
if (!_display)
@@ -194,15 +194,15 @@ void PixelBufferX11::init()
return;
}
if (!createVisualInfo())
{
_traits->red /= 2;
_traits->green /= 2;
_traits->blue /= 2;
_traits->alpha /= 2;
_traits->depth /= 2;
_traits->red /= 2;
_traits->green /= 2;
_traits->blue /= 2;
_traits->alpha /= 2;
_traits->depth /= 2;
OSG_INFO<<"Relaxing traits"<<std::endl;
if (!createVisualInfo())
@@ -212,9 +212,9 @@ void PixelBufferX11::init()
_display = 0;
_valid = false;
return;
}
}
}
// get any shared GLX contexts
GraphicsHandleX11* graphicsHandleX11 = dynamic_cast<GraphicsHandleX11*>(_traits->sharedContext);
Context sharedContext = graphicsHandleX11 ? graphicsHandleX11->getContext() : 0;
@@ -229,7 +229,7 @@ void PixelBufferX11::init()
_valid = false;
return;
}
#ifdef GLX_VERSION_1_3
// First try the regular glx extension if we have a new enough version available.
if (haveGLX1_3)
@@ -244,7 +244,7 @@ void PixelBufferX11::init()
if ( !_pbuffer && (unsigned int)visual_id == _visualInfo->visualid )
{
typedef std::vector <int> AttributeList;
AttributeList attributes;
attributes.push_back( GLX_PBUFFER_WIDTH );
attributes.push_back( _traits->width );
@@ -253,7 +253,7 @@ void PixelBufferX11::init()
attributes.push_back( GLX_LARGEST_PBUFFER );
attributes.push_back( GL_TRUE );
attributes.push_back( 0L );
_pbuffer = glXCreatePbuffer(_display, fbconfigs[i], &attributes.front() );
_useGLX1_3 = true;
}
@@ -285,12 +285,12 @@ void PixelBufferX11::init()
{
GLXFBConfigSGIX fbconfig = glXGetFBConfigFromVisualSGIX( _display, _visualInfo );
typedef std::vector <int> AttributeList;
AttributeList attributes;
attributes.push_back( GLX_LARGEST_PBUFFER_SGIX );
attributes.push_back( GL_TRUE );
attributes.push_back( 0L );
_pbuffer = glXCreateGLXPbufferSGIX(_display, fbconfig, _traits->width, _traits->height, &attributes.front() );
if (_pbuffer)
{
@@ -298,7 +298,7 @@ void PixelBufferX11::init()
int iHeight = 0;
glXQueryGLXPbufferSGIX(_display, _pbuffer, GLX_WIDTH_SGIX , (unsigned int *)&iWidth);
glXQueryGLXPbufferSGIX(_display, _pbuffer, GLX_HEIGHT_SGIX, (unsigned int *)&iHeight);
if (_traits->width != iWidth || _traits->height != iHeight)
{
OSG_NOTICE << "PixelBufferX11::init(), SGIX_pbuffer created with different size then requsted" << std::endl;
@@ -339,7 +339,7 @@ void PixelBufferX11::closeImplementation()
{
glXDestroyContext(_display, _context );
}
if (_pbuffer)
{
if (_useGLX1_3)
@@ -359,7 +359,7 @@ void PixelBufferX11::closeImplementation()
XFlush( _display );
XSync( _display,0 );
}
_pbuffer = 0;
_context = 0;
@@ -414,7 +414,7 @@ bool PixelBufferX11::realizeImplementation()
}
if (!_initialized) init();
if (!_initialized) return false;
_realized = true;

View File

@@ -53,7 +53,7 @@ class OSGVIEWER_EXPORT EXTQuerySupport : public OpenGLQuerySupport
typedef std::pair<GLuint, unsigned int> QueryFrameNumberPair;
typedef std::list<QueryFrameNumberPair> QueryFrameNumberList;
typedef std::vector<GLuint> QueryList;
QueryFrameNumberList _queryFrameNumberList;
QueryList _availableQueryObjects;
double _previousQueryTime;
@@ -147,7 +147,7 @@ class ARBQuerySupport : public OpenGLQuerySupport
public:
virtual void checkQuery(osg::Stats* stats, osg::State* state,
osg::Timer_t startTick);
virtual void beginQuery(unsigned int frameNumber, osg::State* state);
virtual void endQuery(osg::State* state);
virtual void initialize(osg::State* state, osg::Timer_t startTick);
@@ -377,7 +377,7 @@ Renderer::Renderer(osg::Camera* camera):
osgViewer::ViewerBase* viewer = view ? view->getViewerBase() : 0;
osgUtil::IncrementalCompileOperation* ico = viewer ? viewer->getIncrementalCompileOperation() : 0;
bool automaticFlush = (ico==NULL);
osg::DisplaySettings* ds = _camera->getDisplaySettings() ? _camera->getDisplaySettings() :
((view && view->getDisplaySettings()) ? view->getDisplaySettings() : osg::DisplaySettings::instance().get());
@@ -501,7 +501,7 @@ void Renderer::updateSceneView(osgUtil::SceneView* sceneView)
bool automaticFlush = (ico==NULL);
sceneView->setAutomaticFlush(automaticFlush);
osgDB::DatabasePager* databasePager = view ? view->getDatabasePager() : 0;
sceneView->getCullVisitor()->setDatabaseRequestHandler(databasePager);
@@ -540,7 +540,7 @@ void Renderer::compile()
glov.setState(sceneView->getState());
sceneView->getSceneData()->accept(glov);
}
sceneView->getState()->checkGLErrors("After Renderer::compile");
}
@@ -731,7 +731,7 @@ void Renderer::draw()
}
_availableQueue.add(sceneView);
if (acquireGPUStats)
{
_querySupport->endQuery(state);

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
@@ -35,7 +35,7 @@ Scene::Scene():
{
setDatabasePager(osgDB::DatabasePager::create());
setImagePager(new osgDB::ImagePager);
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(getSceneCacheMutex());
getSceneCache().push_back(this);
}
@@ -120,10 +120,10 @@ Scene* Scene::getScene(osg::Node* node)
Scene* Scene::getOrCreateScene(osg::Node* node)
{
if (!node) return 0;
if (!node) return 0;
osgViewer::Scene* scene = getScene(node);
if (!scene)
if (!scene)
{
scene = new Scene;
scene->setSceneData(node);

View File

@@ -266,8 +266,8 @@ void StatsHandler::reset()
_camera->removeChildren( 0, _camera->getNumChildren() );
}
void StatsHandler::addUserStatsLine(const std::string& label, const osg::Vec4& textColor, const osg::Vec4& barColor,
const std::string& timeTakenName, float multiplier, bool average, bool averageInInverseSpace,
void StatsHandler::addUserStatsLine(const std::string& label, const osg::Vec4& textColor, const osg::Vec4& barColor,
const std::string& timeTakenName, float multiplier, bool average, bool averageInInverseSpace,
const std::string& beginTimeName, const std::string& endTimeName, float maxValue)
{
_userStatsLines.push_back(UserStatsLine(label, textColor, barColor, timeTakenName, multiplier, average, averageInInverseSpace, beginTimeName, endTimeName, maxValue));
@@ -1226,16 +1226,16 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer)
pos.x() = _leftPos;
UserStatsLine& line = _userStatsLines[i];
createTimeStatsLine(line.label, pos, line.textColor, line.barColor, viewer->getViewerStats(), viewer->getViewerStats(),
createTimeStatsLine(line.label, pos, line.textColor, line.barColor, viewer->getViewerStats(), viewer->getViewerStats(),
line.timeTakenName, line.multiplier, line.average, line.averageInInverseSpace, line.beginTimeName, line.endTimeName);
pos.y() -= _characterSize*_lineHeight;
}
{
pos.x() = _leftPos;
createTimeStatsLine("Event", pos, colorUpdate, colorUpdateAlpha, viewer->getViewerStats(), viewer->getViewerStats(),
createTimeStatsLine("Event", pos, colorUpdate, colorUpdateAlpha, viewer->getViewerStats(), viewer->getViewerStats(),
"Event traversal time taken", 1000.0, true, false, "Event traversal begin time", "Event traversal end time");
pos.y() -= _characterSize*_lineHeight;
@@ -1244,7 +1244,7 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer)
{
pos.x() = _leftPos;
createTimeStatsLine("Update", pos, colorUpdate, colorUpdateAlpha, viewer->getViewerStats(), viewer->getViewerStats(),
createTimeStatsLine("Update", pos, colorUpdate, colorUpdateAlpha, viewer->getViewerStats(), viewer->getViewerStats(),
"Update traversal time taken", 1000.0, true, false, "Update traversal begin time", "Update traversal end time");
pos.y() -= _characterSize*_lineHeight;
@@ -1617,9 +1617,9 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase* viewer)
}
void StatsHandler::createTimeStatsLine(const std::string& lineLabel,
osg::Vec3 pos, const osg::Vec4& textColor, const osg::Vec4& barColor,
osg::Stats* viewerStats, osg::Stats* stats,
const std::string& timeTakenName, float multiplier, bool average, bool averageInInverseSpace,
osg::Vec3 pos, const osg::Vec4& textColor, const osg::Vec4& barColor,
osg::Stats* viewerStats, osg::Stats* stats,
const std::string& timeTakenName, float multiplier, bool average, bool averageInInverseSpace,
const std::string& beginTimeName, const std::string& endTimeName)
{
osg::ref_ptr<osgText::Text> label = new osgText::Text;
@@ -1678,7 +1678,7 @@ void StatsHandler::createCameraTimeStats(osg::Vec3& pos, bool acquireGPUStats, o
{
pos.x() = _leftPos;
createTimeStatsLine("Cull", pos, colorCull, colorCullAlpha, viewerStats, stats,
createTimeStatsLine("Cull", pos, colorCull, colorCullAlpha, viewerStats, stats,
"Cull traversal time taken", 1000.0, true, false, "Cull traversal begin time", "Cull traversal end time");
pos.y() -= _characterSize*_lineHeight;
@@ -1687,7 +1687,7 @@ void StatsHandler::createCameraTimeStats(osg::Vec3& pos, bool acquireGPUStats, o
{
pos.x() = _leftPos;
createTimeStatsLine("Draw", pos, colorDraw, colorDrawAlpha, viewerStats, stats,
createTimeStatsLine("Draw", pos, colorDraw, colorDrawAlpha, viewerStats, stats,
"Draw traversal time taken", 1000.0, true, false, "Draw traversal begin time", "Draw traversal end time");
pos.y() -= _characterSize*_lineHeight;
@@ -1697,7 +1697,7 @@ void StatsHandler::createCameraTimeStats(osg::Vec3& pos, bool acquireGPUStats, o
{
pos.x() = _leftPos;
createTimeStatsLine("GPU", pos, colorGPU, colorGPUAlpha, viewerStats, stats,
createTimeStatsLine("GPU", pos, colorGPU, colorGPUAlpha, viewerStats, stats,
"GPU draw time taken", 1000.0, true, false, "GPU draw begin time", "GPU draw end time");
pos.y() -= _characterSize*_lineHeight;

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#include <osgViewer/Version>

View File

@@ -286,7 +286,7 @@ void View::setSceneData(osg::Node* node)
getSceneData()->getOrCreateStateSet();
getSceneData()->accept(sgv);
#endif
// now make sure the scene graph is set up with the correct DataVariance to protect the dynamic elements of
// the scene graph from being run in parallel.
osgUtil::Optimizer::StaticObjectDetectionVisitor sodv;
@@ -369,7 +369,7 @@ void View::home()
void View::addEventHandler(osgGA::GUIEventHandler* eventHandler)
{
{
EventHandlers::iterator itr = std::find(_eventHandlers.begin(), _eventHandlers.end(), eventHandler);
if (itr == _eventHandlers.end())
{
@@ -459,7 +459,7 @@ void View::setUpViewAcrossAllScreens()
traits->windowDecoration = false;
traits->doubleBuffer = true;
traits->sharedContext = 0;
osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
_camera->setGraphicsContext(gc.get());

View File

@@ -637,7 +637,7 @@ void Viewer::eventTraversal()
if (_done) return;
double cutOffTime = (_runFrameScheme==ON_DEMAND) ? DBL_MAX : _frameStamp->getReferenceTime();
double beginEventTraversal = osg::Timer::instance()->delta_s(_startTick, osg::Timer::instance()->tick());
// OSG_NOTICE<<"Viewer::frameEventTraversal()."<<std::endl;

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
@@ -77,7 +77,7 @@ bool WindowSizeHandler::handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActio
{
osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa);
if (!view) return false;
osgViewer::ViewerBase* viewer = view->getViewerBase();
if (viewer == NULL)
@@ -160,7 +160,7 @@ void WindowSizeHandler::toggleFullscreen(osgViewer::GraphicsWindow *window)
{
osg::GraphicsContext::WindowingSystemInterface *wsi = osg::GraphicsContext::getWindowingSystemInterface();
if (wsi == NULL)
if (wsi == NULL)
{
OSG_NOTICE << "Error, no WindowSystemInterface available, cannot toggle window fullscreen." << std::endl;
return;
@@ -206,7 +206,7 @@ void WindowSizeHandler::changeWindowedResolution(osgViewer::GraphicsWindow *wind
{
osg::GraphicsContext::WindowingSystemInterface *wsi = osg::GraphicsContext::getWindowingSystemInterface();
if (wsi == NULL)
if (wsi == NULL)
{
OSG_NOTICE << "Error, no WindowSystemInterface available, cannot toggle window fullscreen." << std::endl;
return;
@@ -316,7 +316,7 @@ bool ThreadingHandler::handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIAction
{
osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa);
if (!view) return false;
osgViewer::ViewerBase* viewerBase = view->getViewerBase();
osgViewer::Viewer* viewer = dynamic_cast<Viewer*>(viewerBase);
@@ -356,11 +356,11 @@ bool ThreadingHandler::handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIAction
viewerBase->setThreadingModel(osgViewer::ViewerBase::SingleThreaded);
OSG_NOTICE<<"Threading model 'SingleThreaded' selected."<<std::endl;
break;
#if 1
#if 1
case(osgViewer::ViewerBase::AutomaticSelection):
viewerBase->setThreadingModel(osgViewer::ViewerBase::SingleThreaded);
OSG_NOTICE<<"Threading model 'SingleThreaded' selected."<<std::endl;
#else
#else
case(osgViewer::ViewerBase::AutomaticSelection):
viewerBase->setThreadingModel(viewer->suggestBestThreadingModel());
OSG_NOTICE<<"Threading model 'AutomaticSelection' selected."<<std::endl;
@@ -447,7 +447,7 @@ bool RecordCameraPathHandler::handle(const osgGA::GUIEventAdapter &ea, osgGA::GU
if (_animPath.valid() && _currentlyRecording && _delta >= _interval)
{
const osg::Matrixd& m = view->getCamera()->getInverseViewMatrix();
double animationPathTime = osg::Timer::instance()->delta_s(_animStartTime, time);
double animationPathTime = osg::Timer::instance()->delta_s(_animStartTime, time);
_animPath->insert(animationPathTime, osg::AnimationPath::ControlPoint(m.getTrans(), m.getRotate()));
_delta = 0.0f;
@@ -459,7 +459,7 @@ bool RecordCameraPathHandler::handle(const osgGA::GUIEventAdapter &ea, osgGA::GU
}
else _delta += delta;
return true;
}
@@ -478,7 +478,7 @@ bool RecordCameraPathHandler::handle(const osgGA::GUIEventAdapter &ea, osgGA::GU
_currentlyRecording = true;
_animStartTime = osg::Timer::instance()->tick();
_animPath = new osg::AnimationPath();
if (!_filename.empty())
{
std::stringstream ss;
@@ -489,7 +489,7 @@ bool RecordCameraPathHandler::handle(const osgGA::GUIEventAdapter &ea, osgGA::GU
_autoinc++;
}
ss << "."<<osgDB::getFileExtension(_filename);
OSG_NOTICE << "Recording camera path to file " << ss.str() << std::endl;
_fout.open( ss.str().c_str() );
@@ -547,7 +547,7 @@ bool RecordCameraPathHandler::handle(const osgGA::GUIEventAdapter &ea, osgGA::GU
if (!_currentlyPlaying)
{
if (_animPath.valid() && !_animPath->empty())
{
{
_animPathManipulator = new osgGA::AnimationPathManipulator(_animPath.get());
_animPathManipulator->home(ea,aa);
@@ -562,7 +562,7 @@ bool RecordCameraPathHandler::handle(const osgGA::GUIEventAdapter &ea, osgGA::GU
}
}
}
// The user has requested to STOP playback.
else
{
@@ -573,7 +573,7 @@ bool RecordCameraPathHandler::handle(const osgGA::GUIEventAdapter &ea, osgGA::GU
}
return true;
}
}
break;
}
@@ -636,7 +636,7 @@ void LODScaleHandler::getUsage(osg::ApplicationUsage& usage) const
ostr<<char(_keyEventIncreaseLODScale);
usage.addKeyboardMouseBinding(ostr.str(),"Increase LODScale.");
}
{
std::ostringstream ostr;
ostr<<char(_keyEventDecreaseLODScale);
@@ -653,14 +653,14 @@ bool ToggleSyncToVBlankHandler::handle(const osgGA::GUIEventAdapter& ea, osgGA::
{
osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa);
if (!view) return false;
osgViewer::ViewerBase* viewer = view->getViewerBase();
if (viewer == NULL)
{
return false;
}
if (ea.getHandled()) return false;
switch(ea.getEventType())
@@ -729,7 +729,7 @@ InteractiveImageHandler::InteractiveImageHandler(osg::Image* image, osg::Texture
}
}
bool InteractiveImageHandler::computeIntersections(osgViewer::View* view, float x,float y, const osg::NodePath& nodePath, osgUtil::LineSegmentIntersector::Intersections& intersections,osg::Node::NodeMask traversalMask) const
bool InteractiveImageHandler::computeIntersections(osgViewer::View* view, float x,float y, const osg::NodePath& nodePath, osgUtil::LineSegmentIntersector::Intersections& intersections,osg::Node::NodeMask traversalMask) const
{
float local_x, local_y = 0.0;
const osg::Camera* camera;
@@ -818,7 +818,7 @@ bool InteractiveImageHandler::mousePosition(osgViewer::View* view, osg::NodeVisi
{
osg::Vec2 tc(0.5f,0.5f);
// use the nearest intersection
// use the nearest intersection
const osgUtil::LineSegmentIntersector::Intersection& intersection = *(intersections.begin());
osg::Drawable* drawable = intersection.drawable.get();
osg::Geometry* geometry = drawable ? drawable->asGeometry() : 0;
@@ -843,7 +843,7 @@ bool InteractiveImageHandler::mousePosition(osgViewer::View* view, osg::NodeVisi
osg::Vec2Array* texcoords_Vec2Array = dynamic_cast<osg::Vec2Array*>(texcoords);
if (texcoords_Vec2Array)
{
// we have tex coord array so now we can compute the final tex coord at the point of intersection.
// we have tex coord array so now we can compute the final tex coord at the point of intersection.
osg::Vec2 tc1 = (*texcoords_Vec2Array)[i1];
osg::Vec2 tc2 = (*texcoords_Vec2Array)[i2];
osg::Vec2 tc3 = (*texcoords_Vec2Array)[i3];
@@ -893,7 +893,7 @@ bool InteractiveImageHandler::mousePosition(osgViewer::View* view, osg::NodeVisi
bool InteractiveImageHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa, osg::Object*, osg::NodeVisitor* nv)
{
if (ea.getHandled()) return false;
if (!_image) return false;
switch(ea.getEventType())
@@ -917,11 +917,11 @@ bool InteractiveImageHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUI
osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa);
int x,y;
bool sendKeyEvent = mousePosition(view, nv, ea, x, y);
if (sendKeyEvent)
{
return _image->sendKeyEvent(ea.getKey(), ea.getEventType()==osgGA::GUIEventAdapter::KEYDOWN);
}
}
break;
}
case (osgGA::GUIEventAdapter::RESIZE):
@@ -959,7 +959,7 @@ void InteractiveImageHandler::resize(int width, int height)
_image->scaleImage(width, height, 1);
}
// Make sure the texture does not rescale the image because
// Make sure the texture does not rescale the image because
// it thinks it should still be the previous size...
if (_texture.valid())
_texture->setTextureSize(width, height);