Removed spaces from end of lines

This commit is contained in:
Robert Osfield 2011-04-19 11:46:05 +00:00
parent 581e6fb630
commit efec8a13a1
6 changed files with 278 additions and 278 deletions

View File

@ -31,7 +31,7 @@ extern "C"
namespace osgViewer {
/** Base class for providing Windowing API agnostic access to creating and managing graphics window and events.
* Note, the GraphicsWindow is subclassed from osg::GraphicsContext, and to provide an implemention you'll need to implement its
* Note, the GraphicsWindow is subclassed from osg::GraphicsContext, and to provide an implemention you'll need to implement its
* range of pure virtual functions, you'll find these all have naming convention methodNameImplemention(..).
* GraphicsWindow adds the event queue on top of the GraphicsContext, thereby adding a mechanism for adapting Windowing events
* as well as basics graphics context work, you should wire up custom GraphicsWindowImplementation to push their events through
@ -39,7 +39,7 @@ namespace osgViewer {
class OSGVIEWER_EXPORT GraphicsWindow : public osg::GraphicsContext, public osgGA::GUIActionAdapter
{
public:
GraphicsWindow() { _eventQueue = new osgGA::EventQueue; _eventQueue->setGraphicsContext(this); }
virtual bool isSameKindAs(const Object* object) const { return dynamic_cast<const GraphicsWindow*>(object)!=0; }
@ -51,16 +51,16 @@ class OSGVIEWER_EXPORT GraphicsWindow : public osg::GraphicsContext, public osgG
const osgGA::EventQueue* getEventQueue() const { return _eventQueue.get(); }
virtual void checkEvents() {}
/** Set the window's position and size.*/
void setWindowRectangle(int x, int y, int width, int height)
{
{
if (setWindowRectangleImplementation(x ,y ,width, height) && _traits.valid())
{
resized(x,y,width,height);
}
}
/** implementation of setWindowRectangle, should be implemented by derived classes */
virtual bool setWindowRectangleImplementation(int /*x*/, int /*y*/, int /*width*/, int /*height*/) { osg::notify(osg::NOTICE)<<"GraphicsWindow::setWindowRectangleImplementation(..) not implemented."<<std::endl; return false; }
@ -69,13 +69,13 @@ class OSGVIEWER_EXPORT GraphicsWindow : public osg::GraphicsContext, public osgG
/** Set Window decoration.*/
void setWindowDecoration(bool flag)
{
{
if (setWindowDecorationImplementation(flag) && _traits.valid())
{
_traits->windowDecoration = flag;
}
}
/** implementation of setWindowDecoration, should be implemented by derived classes */
virtual bool setWindowDecorationImplementation(bool /*flag*/) { osg::notify(osg::NOTICE)<<"GraphicsWindow::setWindowDecorationImplementation(..) not implemented."<<std::endl; return false; }
@ -85,7 +85,7 @@ class OSGVIEWER_EXPORT GraphicsWindow : public osg::GraphicsContext, public osgG
/** Get focus.*/
virtual void grabFocus() { osg::notify(osg::NOTICE)<<"GraphicsWindow::grabFocus(..) not implemented."<<std::endl; }
/** Get focus on if the pointer is in this window.*/
virtual void grabFocusIfPointerInWindow() { osg::notify(osg::NOTICE)<<"GraphicsWindow::grabFocusIfPointerInWindow(..) not implemented."<<std::endl; }
@ -147,7 +147,7 @@ class OSGVIEWER_EXPORT GraphicsWindow : public osg::GraphicsContext, public osgG
/** Return whether a valid and usable GraphicsContext has been created.*/
virtual bool valid() const { osg::notify(osg::NOTICE)<<"GraphicsWindow::valid() not implemented."<<std::endl; return false; }
/** Realize the GraphicsContext implementation,
/** Realize the GraphicsContext implementation,
* Pure virtual - must be implemented by concrete implementations of GraphicsContext. */
virtual bool realizeImplementation() { osg::notify(osg::NOTICE)<<"GraphicsWindow::realizeImplementation() not implemented."<<std::endl; return false; }
@ -162,7 +162,7 @@ class OSGVIEWER_EXPORT GraphicsWindow : public osg::GraphicsContext, public osgG
/** Make this graphics context current implementation.
* Pure virtual - must be implemented by concrete implementations of GraphicsContext. */
virtual bool makeCurrentImplementation() { osg::notify(osg::NOTICE)<<"GraphicsWindow::makeCurrentImplementation() not implemented."<<std::endl; return false;}
/** Make this graphics context current with specified read context implementation.
* Pure virtual - must be implemented by concrete implementations of GraphicsContext. */
virtual bool makeContextCurrentImplementation(GraphicsContext* /*readContext*/) { osg::notify(osg::NOTICE)<<"GraphicsWindow::makeContextCurrentImplementation(..) not implemented."<<std::endl; return false;}
@ -191,22 +191,22 @@ class OSGVIEWER_EXPORT GraphicsWindow : public osg::GraphicsContext, public osgG
protected:
osg::ref_ptr<osgGA::EventQueue> _eventQueue;
};
class GraphicsWindowEmbedded : public GraphicsWindow
{
public:
GraphicsWindowEmbedded(osg::GraphicsContext::Traits* traits=0)
{
_traits = traits;
init();
}
GraphicsWindowEmbedded(int x, int y, int width, int height)
@ -216,7 +216,7 @@ class GraphicsWindowEmbedded : public GraphicsWindow
_traits->y = y;
_traits->width = width;
_traits->height = height;
init();
}
@ -234,7 +234,7 @@ class GraphicsWindowEmbedded : public GraphicsWindow
if (_traits.valid() && _traits->sharedContext)
{
getState()->setContextID( _traits->sharedContext->getState()->getContextID() );
incrementContextIDUsageCount( getState()->getContextID() );
incrementContextIDUsageCount( getState()->getContextID() );
}
else
{

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,11 +35,11 @@ class View;
class OSGVIEWER_EXPORT ViewerBase : public virtual osg::Object
{
public:
ViewerBase();
ViewerBase(const ViewerBase& vb);
/** Set the Stats object used for collect various frame related timing and scene graph stats.*/
virtual void setViewerStats(osg::Stats* stats) = 0;
@ -49,10 +49,10 @@ class OSGVIEWER_EXPORT ViewerBase : public virtual osg::Object
/** Get the Viewers Stats object.*/
virtual const osg::Stats* getViewerStats() const = 0;
/** read the viewer configuration from a configuration file.*/
virtual bool readConfiguration(const std::string& filename) = 0;
/** Get whether at least of one of this viewers windows are realized.*/
virtual bool isRealized() const = 0;
@ -72,7 +72,7 @@ class OSGVIEWER_EXPORT ViewerBase : public virtual osg::Object
/** Set the threading model the rendering traversals will use.*/
virtual void setThreadingModel(ThreadingModel threadingModel);
/** Get the threading model the rendering traversals will use.*/
ThreadingModel getThreadingModel() const { return _threadingModel; }
@ -80,7 +80,7 @@ class OSGVIEWER_EXPORT ViewerBase : public virtual osg::Object
virtual ThreadingModel suggestBestThreadingModel();
/** Set up the threading and processor affinity as per the viewers threading model.*/
virtual void setUpThreading();
virtual void setUpThreading();
/** Return true if viewer threads are running. */
bool areThreadsRunning() const { return _threadsRunning; }
@ -89,14 +89,14 @@ class OSGVIEWER_EXPORT ViewerBase : public virtual osg::Object
virtual void stopThreading();
/** Start any threads required by the viewer.*/
virtual void startThreading();
virtual void startThreading();
enum BarrierPosition
{
BeforeSwapBuffers,
AfterSwapBuffers
};
/** Set the position of the end barrier.
* AfterSwapBuffers may result in slightly higher framerates, but may
* lead to inconsistent swapping between different windows.
@ -107,8 +107,8 @@ class OSGVIEWER_EXPORT ViewerBase : public virtual osg::Object
/** Get the end barrier position.*/
BarrierPosition getEndBarrierPosition() const { return _endBarrierPosition; }
/** Set the done flag to signal the viewer's work is done and should exit the frame loop.*/
void setDone(bool done) { _done = done; }
@ -132,23 +132,23 @@ class OSGVIEWER_EXPORT ViewerBase : public virtual osg::Object
/** get the key event that the viewer checks on each frame to see if the viewer's done flag.*/
int getKeyEventSetsDone() const { return _keyEventSetsDone; }
/** if the flag is true, the viewer set its done flag when a QUIT_APPLICATION is received, false disables this feature */
void setQuitEventSetsDone(bool flag) { _quitEventSetsDone = flag; }
/** @return true if the viewer respond to the QUIT_APPLICATION-event */
bool getQuitEventSetsDone() const { return _quitEventSetsDone; }
/** Hint to tell the renderingTraversals() method whether to call relaseContext() on the last
* context that was made current by the thread calling renderingTraverals(). Note, when
* context that was made current by the thread calling renderingTraverals(). Note, when
* running multi-threaded viewer no threads will be made current or release current.
* Setting this hint to false can enable the frame loop to be lazy about calling makeCurrent
* and releaseContext on each new frame, helping performance. However, if you frame loop
* is managing multiple graphics context all from the main frame thread then this hint must
* be left on, otherwise the wrong context could be left active, introducing errors in rendering.*/
void setReleaseContextAtEndOfFrameHint(bool hint) { _releaseContextAtEndOfFrameHint = hint; }
/** Hint to tell the renderingTraversals() method whether to call relaseContext().*/
bool getReleaseContextAtEndOfFrameHint() const { return _releaseContextAtEndOfFrameHint; }
@ -168,10 +168,10 @@ class OSGVIEWER_EXPORT ViewerBase : public virtual osg::Object
/** Get the Update OperationQueue. */
osg::OperationQueue* getUpdateOperations() { return _updateOperations.get(); }
/** Get the const Update OperationQueue. */
const osg::OperationQueue* getUpdateOperations() const { return _updateOperations.get(); }
/** Add an update operation.*/
void addUpdateOperation(osg::Operation* operation);
@ -184,8 +184,8 @@ class OSGVIEWER_EXPORT ViewerBase : public virtual osg::Object
/** Get the graphics operation to call on realization of the viewers graphics windows.*/
osg::Operation* getRealizeOperation() { return _realizeOperation.get(); }
/** Set the incremental compile operation.
* Used to manage the OpenGL object compilation and merging of subgraphs in a way that avoids overloading
* the rendering of frame with too many new objects in one frame. */
@ -229,7 +229,7 @@ class OSGVIEWER_EXPORT ViewerBase : public virtual osg::Object
virtual void eventTraversal() = 0;
virtual void updateTraversal() = 0;
virtual void renderingTraversals();
typedef std::vector<osg::Camera*> Cameras;
@ -259,7 +259,7 @@ class OSGVIEWER_EXPORT ViewerBase : public virtual osg::Object
/** Get the keyboard and mouse usage of this viewer.*/
virtual void getUsage(osg::ApplicationUsage& usage) const = 0;
protected:
void viewerBaseInit();

View File

@ -1095,7 +1095,7 @@ void CompositeViewer::updateTraversal()
{
osg::View::Slave& slave = view->getSlave(i);
osg::Camera* camera = slave._camera.get();
if(camera && !slave._useMastersSceneData)
if(camera && !slave._useMastersSceneData)
{
camera->accept(*_updateVisitor);
}

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.
*
* This file is Copyright (C) 2007 - André Garneau (andre@pixdev.com) and licensed under OSGPL.
@ -599,7 +599,7 @@ Win32WindowingSystem::~Win32WindowingSystem()
osg::Referenced::getDeleteHandler()->setNumFramesToRetainObjects(0);
osg::Referenced::getDeleteHandler()->flushAll();
}
unregisterWindowClasses();
}
@ -707,10 +707,10 @@ bool Win32WindowingSystem::getSampleOpenGLContext( OpenGLContext& context, HDC w
osgGraphicsWindowWithoutCursorClass.c_str(),
NULL,
WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_DISABLED,
windowOriginX,
windowOriginY,
1,
1,
windowOriginX,
windowOriginY,
1,
1,
NULL,
NULL,
::GetModuleHandle(NULL),
@ -783,7 +783,7 @@ bool Win32WindowingSystem::getSampleOpenGLContext( OpenGLContext& context, HDC w
return true;
}
unsigned int Win32WindowingSystem::getNumScreens( const osg::GraphicsContext::ScreenIdentifier& si )
unsigned int Win32WindowingSystem::getNumScreens( const osg::GraphicsContext::ScreenIdentifier& si )
{
return si.displayNum==0 ? ::GetSystemMetrics(SM_CMONITORS) : 0;
}
@ -923,7 +923,7 @@ bool Win32WindowingSystem::setScreenSettings( const osg::GraphicsContext::Screen
deviceMode.dmFields |= DM_BITSPERPEL;
deviceMode.dmBitsPerPel = static_cast<DWORD>(resolution.colorDepth);
}
return changeScreenSettings(si, displayDevice, deviceMode);
}
@ -1056,7 +1056,7 @@ GraphicsWindowWin32::GraphicsWindowWin32( osg::GraphicsContext::Traits* traits )
else setCursor(NoCursor);
init();
if (valid())
{
setState( new osg::State );
@ -1065,7 +1065,7 @@ GraphicsWindowWin32::GraphicsWindowWin32( osg::GraphicsContext::Traits* traits )
if (_traits.valid() && _traits->sharedContext)
{
getState()->setContextID( _traits->sharedContext->getState()->getContextID() );
incrementContextIDUsageCount( getState()->getContextID() );
incrementContextIDUsageCount( getState()->getContextID() );
}
else
{
@ -1098,10 +1098,10 @@ void GraphicsWindowWin32::init()
_valid = _initialized;
// 2008/10/03
// Few days ago NVidia released WHQL certified drivers ver 178.13.
// These drivers (as well as former beta ver 177.92) were free from the bug described below.
// Few days ago NVidia released WHQL certified drivers ver 178.13.
// These drivers (as well as former beta ver 177.92) were free from the bug described below.
// So it looks like its high time to make the workaround inactive by default.
// If you happen to still use earlier drivers and have problems consider changing to new ones or
// If you happen to still use earlier drivers and have problems consider changing to new ones or
// activate OSG_MULTIMONITOR_MULTITHREAD_WIN32_NVIDIA_WORKAROUND macro def through CMake advanced vars.
#ifdef OSG_MULTIMONITOR_MULTITHREAD_WIN32_NVIDIA_WORKAROUND
@ -1109,14 +1109,14 @@ void GraphicsWindowWin32::init()
// Workaround for Bugs in NVidia drivers for windows XP / multithreaded / dualview / multicore CPU
// affects GeForce 6x00, 7x00, 8x00 boards (others were not tested) driver versions 174.xx - 175.xx
// pre 174.xx had other issues so reverting is not an option (statitistics, fbo)
// drivers release 175.16 is the latest currently available
//
// drivers release 175.16 is the latest currently available
//
// When using OpenGL in threaded app ( main thread sets up context / renderer thread draws using it )
// first wglMakeCurrent seems to not work right and screw OpenGL context driver data:
// 1: succesive drawing shows a number of artifacts in TriangleStrips and TriangleFans
// first wglMakeCurrent seems to not work right and screw OpenGL context driver data:
// 1: succesive drawing shows a number of artifacts in TriangleStrips and TriangleFans
// 2: weird behaviour of FramBufferObjects (glGenFramebuffer generates already generated ids ...)
// Looks like repeating wglMakeCurrent call fixes all these issues
// wglMakeCurrent call can impact performance so I try to minimize number of
// wglMakeCurrent call can impact performance so I try to minimize number of
// wglMakeCurrent calls by checking current HDC and GL context
// and repeat wglMakeCurrent only when they change for current thread
@ -1157,10 +1157,10 @@ bool GraphicsWindowWin32::createWindow()
Win32WindowingSystem::osgGraphicsWindowWithoutCursorClass.c_str(),
_traits->windowName.c_str(),
windowStyle,
_windowOriginXToRealize,
_windowOriginYToRealize,
_windowWidthToRealize,
_windowHeightToRealize,
_windowOriginXToRealize,
_windowOriginYToRealize,
_windowWidthToRealize,
_windowHeightToRealize,
NULL,
NULL,
::GetModuleHandle(NULL),
@ -1289,7 +1289,7 @@ void GraphicsWindowWin32::destroyWindow( bool deleteNativeWindow )
{
if (_destroying) return;
_destroying = true;
if (_graphicsThread && _graphicsThread->isRunning())
{
// find all the viewers that might own use this graphics context
@ -1298,7 +1298,7 @@ void GraphicsWindowWin32::destroyWindow( bool deleteNativeWindow )
{
osgViewer::View* view = dynamic_cast<osgViewer::View*>((*it)->getView());
osgViewer::ViewerBase* viewerBase = view ? view->getViewerBase() : 0;
if (viewerBase && viewerBase->areThreadsRunning())
if (viewerBase && viewerBase->areThreadsRunning())
{
viewerBase->stopThreading();
}
@ -1489,9 +1489,9 @@ static void PreparePixelFormatSpecifications( const osg::GraphicsContext::Traits
case osg::DisplaySettings::SWAP_DEFAULT:
// Wojtek Lewandowski 2010-09-28:
// Keep backward compatibility if no method is selected via traits
// and let wglSwapExchangeARB flag select swap method.
// However, I would rather remove this flag because its
// now redundant to Traits::swapMethod and it looks like
// and let wglSwapExchangeARB flag select swap method.
// However, I would rather remove this flag because its
// now redundant to Traits::swapMethod and it looks like
// WGL_SWAP_EXCHANGE_ARB is the GL default when no WGL_SWAP attrib is given.
// To be precise: At least on Windows 7 and Nvidia it seems to be a default.
if ( allowSwapExchangeARB )
@ -1521,28 +1521,28 @@ static int ChooseMatchingPixelFormat( HDC hdc, int screenNum, const WGLIntegerAt
{
// = openGLContext.getTraits()
reportErrorForScreen("ChooseMatchingPixelFormat() - wglChoosePixelFormatARB extension not found, trying GDI", screenNum, ::GetLastError());
PIXELFORMATDESCRIPTOR pixelFormat = {
sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd
1, // version number
PFD_DRAW_TO_WINDOW | // support window
PFD_SUPPORT_OPENGL | // support OpenGL
(_traits->doubleBuffer ? PFD_DOUBLEBUFFER : NULL) | // double buffered ?
PIXELFORMATDESCRIPTOR pixelFormat = {
sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd
1, // version number
PFD_DRAW_TO_WINDOW | // support window
PFD_SUPPORT_OPENGL | // support OpenGL
(_traits->doubleBuffer ? PFD_DOUBLEBUFFER : NULL) | // double buffered ?
(_traits->swapMethod == osg::DisplaySettings::SWAP_COPY ? PFD_SWAP_COPY : NULL) |
(_traits->swapMethod == osg::DisplaySettings::SWAP_EXCHANGE ? PFD_SWAP_EXCHANGE : NULL),
PFD_TYPE_RGBA, // RGBA type
PFD_TYPE_RGBA, // RGBA type
_traits->red + _traits->green + _traits->blue, // color depth
_traits->red ,0, _traits->green ,0, _traits->blue, 0, // shift bits ignored
_traits->red ,0, _traits->green ,0, _traits->blue, 0, // shift bits ignored
_traits->alpha, // alpha buffer ?
0, // shift bit ignored
0, // no accumulation buffer
0, 0, 0, 0, // accum bits ignored
0, // shift bit ignored
0, // no accumulation buffer
0, 0, 0, 0, // accum bits ignored
_traits->depth, // 32 or 16 bit z-buffer ?
_traits->stencil, // stencil buffer ?
0, // no auxiliary buffer
PFD_MAIN_PLANE, // main layer
0, // reserved
0, 0, 0 // layer masks ignored
};
0, // no auxiliary buffer
PFD_MAIN_PLANE, // main layer
0, // reserved
0, 0, 0 // layer masks ignored
};
int pixelFormatIndex = ::ChoosePixelFormat(hdc, &pixelFormat);
if (pixelFormatIndex == 0)
{
@ -1801,7 +1801,7 @@ bool GraphicsWindowWin32::setWindowDecorationImplementation( bool decorated )
//
::InvalidateRect(NULL, NULL, TRUE);
return true;
}
@ -1885,7 +1885,7 @@ bool GraphicsWindowWin32::realizeImplementation()
reportErrorForScreen("GraphicsWindowWin32::realizeImplementation() - Unable to show window", _traits->screenNum, ::GetLastError());
return false;
}
if (!::UpdateWindow(_hwnd))
{
reportErrorForScreen("GraphicsWindowWin32::realizeImplementation() - Unable to update window", _traits->screenNum, ::GetLastError());
@ -1909,8 +1909,8 @@ bool GraphicsWindowWin32::makeCurrentImplementation()
if( _applyWorkaroundForMultimonitorMultithreadNVidiaWin32Issues )
{
if( ::wglGetCurrentDC() != _hdc ||
::wglGetCurrentContext() != _hglrc )
{
::wglGetCurrentContext() != _hglrc )
{
if (!::wglMakeCurrent(_hdc, _hglrc))
{
reportErrorForScreen("GraphicsWindowWin32::makeCurrentImplementation() - Unable to set current OpenGL rendering context", _traits->screenNum, ::GetLastError());
@ -2050,7 +2050,7 @@ void GraphicsWindowWin32::requestWarpPointer( float x, float y )
return;
}
#endif
getEventQueue()->mouseWarped(x,y);
}
@ -2103,7 +2103,7 @@ void GraphicsWindowWin32::useCursor( bool cursorOn )
if (_traits->useCursor == false)
{
setCursor(NoCursor);
}
}
}
void GraphicsWindowWin32::setCursor( MouseCursor mouseCursor )
@ -2119,10 +2119,10 @@ void GraphicsWindowWin32::setCursorImpl( MouseCursor mouseCursor )
_mouseCursor = mouseCursor;
HCURSOR newCursor = getOrCreateCursor( mouseCursor);
if (newCursor == _currentCursor) return;
_currentCursor = newCursor;
_traits->useCursor = (_currentCursor != NULL) && (_mouseCursor != NoCursor);
if (_mouseCursor != InheritCursor)
::SetCursor(_currentCursor);
}
@ -2203,7 +2203,7 @@ HCURSOR GraphicsWindowWin32::getOrCreateCursor(MouseCursor mouseCursor)
default:
break;
}
return _mouseCursorMap[mouseCursor];
}
@ -2303,10 +2303,10 @@ void GraphicsWindowWin32::adaptKey( WPARAM wParam, LPARAM lParam, int& keySymbol
{
keySymbol = osgGA::GUIEventAdapter::KEY_KP_Enter;
}
unmodifiedKeySymbol = keySymbol;
if ((keySymbol & 0xff00)==0)
if ((keySymbol & 0xff00)==0)
{
char asciiKey[2];
int numChars = ::ToAscii(wParam, (lParam>>16)&0xff, keyState, reinterpret_cast<WORD*>(asciiKey), 0);
@ -2334,13 +2334,13 @@ LRESULT GraphicsWindowWin32::handleNativeWindowingEvent( HWND hwnd, UINT uMsg, W
switch(uMsg)
{
// Wojtek Lewandowski 2010-09-28:
// All web docs on Windows Aero and OpenGL compatibiltiy
// Wojtek Lewandowski 2010-09-28:
// All web docs on Windows Aero and OpenGL compatibiltiy
// suggest WM_ERASEBKGND should be handled with non NULL value return.
// This sugesstion may be irrelevant for our window class
// as default brush pattern is not set so erase flag is forwarded to WM_PAINT
// This sugesstion may be irrelevant for our window class
// as default brush pattern is not set so erase flag is forwarded to WM_PAINT
// and gets ignored when WM_PAINT is handled.
// But it will certainly be safer and not make things worse
// But it will certainly be safer and not make things worse
// if we handle this message to be sure everything is done as suggested.
case WM_ERASEBKGND :
return TRUE;
@ -2397,7 +2397,7 @@ LRESULT GraphicsWindowWin32::handleNativeWindowingEvent( HWND hwnd, UINT uMsg, W
case WM_MBUTTONUP :
case WM_RBUTTONUP :
/////////////////////
{
::ReleaseCapture();
@ -2469,7 +2469,7 @@ LRESULT GraphicsWindowWin32::handleNativeWindowingEvent( HWND hwnd, UINT uMsg, W
if (windowX!=_traits->x || windowY!=_traits->y || windowWidth!=_traits->width || windowHeight!=_traits->height)
{
resized(windowX, windowY, windowWidth, windowHeight);
resized(windowX, windowY, windowWidth, windowHeight);
getEventQueue()->windowResize(windowX, windowY, windowWidth, windowHeight, resizeTime);
}
}
@ -2514,7 +2514,7 @@ LRESULT GraphicsWindowWin32::handleNativeWindowingEvent( HWND hwnd, UINT uMsg, W
//InheritCursor. InheritCursor lets the user manage the cursor externally.
if (_mouseCursor != InheritCursor)
{
if (_traits->useCursor)
if (_traits->useCursor)
::SetCursor( _currentCursor);
else
::SetCursor(NULL);
@ -2526,7 +2526,7 @@ LRESULT GraphicsWindowWin32::handleNativeWindowingEvent( HWND hwnd, UINT uMsg, W
case WM_SETFOCUS :
///////////////////
// Check keys and send a message if the key is pressed when the
// Check keys and send a message if the key is pressed when the
// focus comes back to the window.
// I don't really like this hard-coded loop, but the key codes
// (VK_* constants) seem to go from 0x08 to 0xFE so it should be

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.
*/
@ -273,12 +273,12 @@ Display* GraphicsWindowX11::getDisplayToUse() const
{
return _display;
}
if (OpenThreads::Thread::CurrentThread()==_threadOfLastMakeCurrent)
if (OpenThreads::Thread::CurrentThread()==_threadOfLastMakeCurrent)
{
return _display;
}
else
else
{
return _eventDisplay;
}
@ -321,29 +321,29 @@ bool GraphicsWindowX11::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);
if (_traits->quadBufferStereo) attributes.push_back(GLX_STEREO);
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)
if (_traits->sampleBuffers) { attributes.push_back(GLX_SAMPLE_BUFFERS); attributes.push_back(_traits->sampleBuffers); }
if (_traits->sampleBuffers) { attributes.push_back(GLX_SAMPLES); attributes.push_back(_traits->samples); }
#endif
// TODO
// GLX_AUX_BUFFERS
@ -351,9 +351,9 @@ bool GraphicsWindowX11::createVisualInfo()
// GLX_ACCUM_GREEN_SIZE
// GLX_SAMPLE_BUFFERS
// GLX_SAMPLES
attributes.push_back(None);
_visualInfo = glXChooseVisual( _display, _traits->screenNum, &(attributes.front()) );
#endif
}
@ -438,13 +438,13 @@ bool GraphicsWindowX11::setWindowDecorationImplementation(bool flag)
bool result = false;
if( (atom = XInternAtom( display, "_MOTIF_WM_HINTS", 0 )) != None )
{
wmHints.flags = 0;
wmHints.functions = MWM_FUNC_ALL;
wmHints.decorations = MWM_DECOR_ALL;
wmHints.inputMode = 0;
wmHints.status = 0;
wmHints.status = 0;
if (!flag)
{
wmHints.flags = MWM_HINTS_DECORATIONS;
@ -476,11 +476,11 @@ bool GraphicsWindowX11::setWindowDecorationImplementation(bool flag)
bool GraphicsWindowX11::setWindowRectangleImplementation(int x, int y, int width, int height)
{
if (!_initialized) return false;
Display* display = getDisplayToUse();
XMoveResizeWindow(display, _window, x, y, width, height);
XFlush(display);
XSync(display, 0);
@ -491,7 +491,7 @@ bool GraphicsWindowX11::setWindowRectangleImplementation(int x, int y, int width
// X11 errors.
usleep(100000);
return true;
}
@ -511,7 +511,7 @@ void GraphicsWindowX11::setWindowName(const std::string& name)
XStoreName( display, _window, name.c_str() );
XSetIconName( display, _window, name.c_str() );
XFlush(display);
XFlush(display);
XSync(display,0);
_traits->windowName = name;
@ -684,17 +684,17 @@ void GraphicsWindowX11::init()
return;
}
#endif
// OSG_NOTICE<<"GLX extension, errorBase="<<errorBase<<" eventBase="<<eventBase<<std::endl;
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())
@ -704,7 +704,7 @@ void GraphicsWindowX11::init()
_display = 0;
_valid = false;
return;
}
}
}
// get any shared GLX contexts
@ -715,23 +715,23 @@ void GraphicsWindowX11::init()
_valid = _ownsWindow ? createWindow() : setWindow(windowHandle);
if (!_valid)
if (!_valid)
{
XCloseDisplay( _display );
_display = 0;
return;
}
OSG_NOTICE<<"GraphicsWindowX11::init() - window created ="<<_valid<<std::endl;
EGLConfig eglConfig = 0;
#if defined(OSG_GLES2_AVAILABLE)
#define OSG_EGL_OPENGL_TARGET_BIT EGL_OPENGL_ES2_BIT
#else
#define OSG_EGL_OPENGL_TARGET_BIT EGL_OPENGL_ES_BIT
#endif
EGLint configAttribs[] = {
EGL_SAMPLE_BUFFERS, 0,
EGL_SAMPLES, 0,
@ -786,13 +786,13 @@ void GraphicsWindowX11::init()
}
_initialized = true;
checkEGLError("after eglCreateContext()");
#else
_context = glXCreateContext( _display, _visualInfo, sharedContext, True );
if (!_context)
{
OSG_NOTICE<<"Error: Unable to create OpenGL graphics context."<<std::endl;
@ -806,7 +806,7 @@ void GraphicsWindowX11::init()
_valid = _initialized;
#endif
if (_valid == false)
{
XCloseDisplay( _display );
@ -841,7 +841,7 @@ bool GraphicsWindowX11::createWindow()
{
swatt.override_redirect = true;
mask |= CWOverrideRedirect;
OSG_INFO<<"Setting override redirect"<<std::endl;
}
@ -850,7 +850,7 @@ bool GraphicsWindowX11::createWindow()
_traits->y,
_traits->width, _traits->height, 0,
_visualInfo->depth, InputOutput,
_visualInfo->visual, mask, &swatt );
_visualInfo->visual, mask, &swatt );
if (!_window)
{
@ -884,7 +884,7 @@ bool GraphicsWindowX11::createWindow()
useCursor(_traits->useCursor);
_deleteWindow = XInternAtom (_display, "WM_DELETE_WINDOW", False);
XSetWMProtocols(_display, _window, &_deleteWindow, 1);
XSetWMProtocols(_display, _window, &_deleteWindow, 1);
XFlush( _display );
@ -892,17 +892,17 @@ bool GraphicsWindowX11::createWindow()
// now update the window dimensions to account for any size changes made by the window manager,
XGetWindowAttributes( _display, _window, &watt );
if (_traits->x != watt.x || _traits->y != watt.y
||_traits->width != watt.width || _traits->height != watt.height)
{
resized( watt.x, watt.y, watt.width, watt.height );
}
//OSG_NOTICE<<"After sync apply.x = "<<watt.x<<" watt.y="<<watt.y<<" width="<<watt.width<<" height="<<watt.height<<std::endl;
XSelectInput( _eventDisplay, _window, ExposureMask | StructureNotifyMask |
XSelectInput( _eventDisplay, _window, ExposureMask | StructureNotifyMask |
KeyPressMask | KeyReleaseMask |
PointerMotionMask | ButtonPressMask | ButtonReleaseMask |
KeymapStateMask | FocusChangeMask | EnterWindowMask );
@ -921,13 +921,13 @@ bool GraphicsWindowX11::setWindow(Window window)
OSG_NOTICE << "GraphicsWindowX11::setWindow() - Window already created; it cannot be changed";
return false;
}
if (window==0)
{
OSG_NOTICE << "GraphicsWindowX11::setWindow() - Invalid window handle passed ";
return false;
}
_window = window;
if (_window==0)
{
@ -966,14 +966,14 @@ bool GraphicsWindowX11::realizeImplementation()
}
if (!_initialized) init();
if (!_initialized) return false;
XMapWindow( _display, _window );
// Window temp = _window;
// XSetWMColormapWindows( _display, _window, &temp, 1);
_realized = true;
return true;
@ -1034,7 +1034,7 @@ void GraphicsWindowX11::closeImplementation()
glXDestroyContext( _display, _context );
#endif
}
if (_window && _ownsWindow)
{
XDestroyWindow(_display, _window);
@ -1043,7 +1043,7 @@ void GraphicsWindowX11::closeImplementation()
XFlush( _display );
XSync( _display,0 );
}
_window = 0;
_parent = 0;
_context = 0;
@ -1052,7 +1052,7 @@ void GraphicsWindowX11::closeImplementation()
{
#ifdef OSG_USE_EGL
delete _visualInfo;
#else
#else
XFree(_visualInfo);
#endif
_visualInfo = 0;
@ -1121,7 +1121,7 @@ void GraphicsWindowX11::checkEvents()
double eventTime = baseTime;
double resizeTime = eventTime;
_timeOfLastCheckEvents = getEventQueue()->getTime();
// OSG_NOTICE<<"GraphicsWindowX11::checkEvents() : getEventQueue()->getCurrentEventState()->getGraphicsContext()="<<getEventQueue()->getCurrentEventState()->getGraphicsContext()<<std::endl;
int windowX = _traits->x;
@ -1130,9 +1130,9 @@ void GraphicsWindowX11::checkEvents()
int windowHeight = _traits->height;
bool destroyWindowRequested = false;
Time firstEventTime = 0;
// OSG_NOTICE<<"Check events"<<std::endl;
while( XPending(display) )
{
@ -1169,12 +1169,12 @@ void GraphicsWindowX11::checkEvents()
_realized = false;
_valid = false;
break;
case ConfigureNotify :
{
OSG_INFO<<"ConfigureNotify x="<<ev.xconfigure.x<<" y="<<ev.xconfigure.y<<" width="<<ev.xconfigure.width<<", height="<<ev.xconfigure.height<<std::endl;
if (windowX != ev.xconfigure.x ||
if (windowX != ev.xconfigure.x ||
windowX != ev.xconfigure.y ||
windowWidth != ev.xconfigure.width ||
windowHeight != ev.xconfigure.height)
@ -1189,7 +1189,7 @@ void GraphicsWindowX11::checkEvents()
break;
}
case MapNotify :
{
OSG_INFO<<"MapNotify"<<std::endl;
@ -1197,7 +1197,7 @@ void GraphicsWindowX11::checkEvents()
do
XGetWindowAttributes(display, _window, &watt );
while( watt.map_state != IsViewable );
OSG_INFO<<"MapNotify x="<<watt.x<<" y="<<watt.y<<" width="<<watt.width<<", height="<<watt.height<<std::endl;
if (windowWidth != watt.width || windowHeight != watt.height)
@ -1301,7 +1301,7 @@ void GraphicsWindowX11::checkEvents()
if (firstEventTime==0) firstEventTime = ev.xmotion.time;
Time relativeTime = ev.xmotion.time - firstEventTime;
eventTime = baseTime + static_cast<double>(relativeTime)*0.001;
int wx, wy;
Window win = 0L;
if( ev.xmotion.same_screen )
@ -1345,7 +1345,7 @@ void GraphicsWindowX11::checkEvents()
wx += (screenOrigin_x - dest_x_return);
wy += (screenOrigin_y - dest_y_return);
}
float mx = wx;
float my = wy;
@ -1356,7 +1356,7 @@ void GraphicsWindowX11::checkEvents()
break;
}
case ButtonPress :
{
if (firstEventTime==0) firstEventTime = ev.xmotion.time;
@ -1380,7 +1380,7 @@ void GraphicsWindowX11::checkEvents()
}
break;
}
case ButtonRelease :
{
if (firstEventTime==0) firstEventTime = ev.xmotion.time;
@ -1404,7 +1404,7 @@ void GraphicsWindowX11::checkEvents()
}
break;
}
case KeyPress:
{
if (firstEventTime==0) firstEventTime = ev.xmotion.time;
@ -1420,17 +1420,17 @@ void GraphicsWindowX11::checkEvents()
getEventQueue()->keyPress(keySymbol, eventTime, unmodifiedKeySymbol);
break;
}
case KeyRelease:
{
if (firstEventTime==0) firstEventTime = ev.xmotion.time;
Time relativeTime = ev.xmotion.time - firstEventTime;
eventTime = baseTime + static_cast<double>(relativeTime)*0.001;
#if 1
#if 1
// Check for following KeyPress events and see if
// the pair are the result of auto-repeat. If so, drop
// this one on the floor, to be consistent with
// Windows and Mac ports. The idea comes from libSDL sources.
// Windows and Mac ports. The idea comes from libSDL sources.
XEvent nextev;
if (XPending(display))
{
@ -1448,28 +1448,28 @@ void GraphicsWindowX11::checkEvents()
int keySymbol = 0;
int unmodifiedKeySymbol = 0;
adaptKey(ev.xkey, keySymbol, unmodifiedKeySymbol);
getEventQueue()->keyRelease(keySymbol, eventTime, unmodifiedKeySymbol);
break;
}
default:
OSG_NOTICE<<"Other event "<<ev.type<<std::endl;
break;
}
_lastEventType = ev.type;
}
if (windowX != _traits->x ||
if (windowX != _traits->x ||
windowY != _traits->y ||
windowWidth != _traits->width ||
windowHeight != _traits->height)
{
resized(windowX, windowY, windowWidth, windowHeight);
resized(windowX, windowY, windowWidth, windowHeight);
getEventQueue()->windowResize(windowX, windowY, windowWidth, windowHeight, resizeTime);
}
#if 0
if (destroyWindowRequested)
{
@ -1483,7 +1483,7 @@ void GraphicsWindowX11::grabFocus()
Display* display = getDisplayToUse();
XSetInputFocus( display, _window, RevertToNone, CurrentTime );
XFlush(display);
XFlush(display);
XSync(display,0);
}
@ -1504,7 +1504,7 @@ void GraphicsWindowX11::grabFocusIfPointerInWindow()
{
grabFocus();
}
#else
#else
grabFocus();
#endif
}
@ -1657,19 +1657,19 @@ void GraphicsWindowX11::requestWarpPointer(float x,float y)
Display* display = _eventDisplay; // getDisplayToUse();
XWarpPointer( display,
XWarpPointer( display,
None,
_window,
_window,
0, 0, 0, 0,
static_cast<int>(x), static_cast<int>(y) );
XFlush(display);
XSync(display, 0);
getEventQueue()->mouseWarped(x,y);
}
extern "C"
extern "C"
{
typedef int (*X11ErrorHandler)(Display*, XErrorEvent*);
@ -1718,7 +1718,7 @@ class X11WindowingSystemInterface : public osg::GraphicsContext::WindowingSystem
OSG_NOTICE << "X11WindowingSystemInterface::_setScreen() is not fully implemented (missing depth)."<<std::endl;
Display* display = XOpenDisplay(si.displayName().c_str());
if(display)
{
XRRScreenConfiguration* sc = XRRGetScreenInfo(display, RootWindow(display, si.screenNum));
@ -1735,7 +1735,7 @@ class X11WindowingSystemInterface : public osg::GraphicsContext::WindowingSystem
bool okay = false;
XRRConfigRotations(sc, &currentRot);
// If the width or height are zero, use our defaults.
if(!width || !height)
{
@ -1752,7 +1752,7 @@ class X11WindowingSystemInterface : public osg::GraphicsContext::WindowingSystem
{
short* rates = XRRConfigRates(sc, i, &numRates);
bool rateFound = false;
// Search for our rate in the list of acceptable rates given to us by Xrandr.
// If it's not found, rateFound will still be false and the call will never
// be made to XRRSetScreenConfigAndRate since the rate will be invalid.
@ -1780,9 +1780,9 @@ class X11WindowingSystemInterface : public osg::GraphicsContext::WindowingSystem
}
}
}
XRRFreeScreenConfigInfo(sc);
return okay;
}
else
@ -1795,7 +1795,7 @@ class X11WindowingSystemInterface : public osg::GraphicsContext::WindowingSystem
protected:
bool _errorHandlerSet;
public:
X11WindowingSystemInterface()
@ -1804,10 +1804,10 @@ public:
// Install an X11 error handler, if the application has not already done so.
// Set default handler, and get pointer to current handler.
X11ErrorHandler currentHandler = XSetErrorHandler(NULL);
// Set our handler, and get pointer to default handler.
X11ErrorHandler defHandler = XSetErrorHandler(X11ErrorHandling);
@ -1824,7 +1824,7 @@ public:
_errorHandlerSet = 0;
XSetErrorHandler(currentHandler);
}
#if 0
if (XInitThreads() == 0)
{
@ -1835,7 +1835,7 @@ public:
{
OSG_INFO << "X11WindowingSystemInterface, xInitThreads() multi-threaded X support initialized.\n";
}
#endif
#endif
}
@ -1869,12 +1869,12 @@ public:
}
}
virtual unsigned int getNumScreens(const osg::GraphicsContext::ScreenIdentifier& si)
virtual unsigned int getNumScreens(const osg::GraphicsContext::ScreenIdentifier& si)
{
Display* display = XOpenDisplay(si.displayName().c_str());
if(display)
{
unsigned int numScreens = ScreenCount(display);
unsigned int numScreens = ScreenCount(display);
XCloseDisplay(display);
return numScreens;
@ -1926,7 +1926,7 @@ public:
}
#endif
XCloseDisplay(display);
}
else
@ -1976,7 +1976,7 @@ public:
for(int j=0; j<nrates; ++j)
{
OSG_INFO<<" rates "<<rates[j]<<std::endl;
resolutionList.push_back(osg::GraphicsContext::ScreenSettings(
screenSizes[i].width,
screenSizes[i].height,
@ -1996,7 +1996,7 @@ public:
}
}
}
#endif
#endif
XCloseDisplay(display);
}
@ -2071,7 +2071,7 @@ void GraphicsWindowX11::raiseWindow()
unsigned int nchildren, i=0;
XTextProperty windowName;
bool xraise = false;
XQueryTree(display, _parent, &root_return, &parent_return, &children, &nchildren);
while (!xraise && i<nchildren)
@ -2080,13 +2080,13 @@ void GraphicsWindowX11::raiseWindow()
if ((windowName.nitems != 0) && (strcmp(_traits->windowName.c_str(),(const char *)windowName.value) == 0)) xraise = true;
}
if (xraise) XRaiseWindow(display,_window);
else
else
{
XGetWindowAttributes(display, _window, &winAttrib);
XReparentWindow(display, _window, _parent, winAttrib.x, winAttrib.y);
}
XFree(children);
XFlush(display);
XFlush(display);
XSync(display,0);
}

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.
*/
@ -83,9 +83,9 @@ void ViewerBase::viewerBaseInit()
void ViewerBase::setThreadingModel(ThreadingModel threadingModel)
{
if (_threadingModel == threadingModel) return;
if (_threadsRunning) stopThreading();
_threadingModel = threadingModel;
if (isRealized() && _threadingModel!=SingleThreaded) startThreading();
@ -104,7 +104,7 @@ ViewerBase::ThreadingModel ViewerBase::suggestBestThreadingModel()
Contexts contexts;
getContexts(contexts);
if (contexts.empty()) return SingleThreaded;
#if 0
@ -126,7 +126,7 @@ ViewerBase::ThreadingModel ViewerBase::suggestBestThreadingModel()
if (numProcessors==1) return SingleThreaded;
else return DrawThreadPerContext;
}
#if 1
if (numProcessors >= static_cast<int>(cameras.size()+contexts.size()))
{
@ -150,8 +150,8 @@ void ViewerBase::setUpThreading()
// we'll set processor affinity here to help single threaded apps
// with multiple processor cores, and using the database pager.
int numProcessors = OpenThreads::GetNumberOfProcessors();
bool affinity = numProcessors>1;
if (affinity)
bool affinity = numProcessors>1;
if (affinity)
{
OpenThreads::SetProcessorAffinityOfCurrentThread(0);
@ -164,15 +164,15 @@ void ViewerBase::setUpThreading()
{
if (!_threadsRunning) startThreading();
}
}
void ViewerBase::setEndBarrierPosition(BarrierPosition bp)
{
if (_endBarrierPosition == bp) return;
if (_threadsRunning) stopThreading();
_endBarrierPosition = bp;
if (_threadingModel!=SingleThreaded) startThreading();
@ -203,7 +203,7 @@ void ViewerBase::stopThreading()
if (renderer) renderer->release();
}
// delete all the graphics threads.
// delete all the graphics threads.
for(gcitr = contexts.begin();
gcitr != contexts.end();
++gcitr)
@ -211,7 +211,7 @@ void ViewerBase::stopThreading()
(*gcitr)->setGraphicsThread(0);
}
// delete all the camera threads.
// delete all the camera threads.
for(citr = cameras.begin();
citr != cameras.end();
++citr)
@ -244,9 +244,9 @@ void ViewerBase::stopThreading()
void ViewerBase::startThreading()
{
if (_threadsRunning) return;
OSG_INFO<<"Viewer::startThreading() - starting threading"<<std::endl;
// release any context held by the main thread.
releaseContext();
@ -254,31 +254,31 @@ void ViewerBase::startThreading()
Contexts contexts;
getContexts(contexts);
OSG_INFO<<"Viewer::startThreading() - contexts.size()="<<contexts.size()<<std::endl;
Cameras cameras;
getCameras(cameras);
unsigned int numThreadsOnStartBarrier = 0;
unsigned int numThreadsOnEndBarrier = 0;
switch(_threadingModel)
{
case(SingleThreaded):
case(SingleThreaded):
numThreadsOnStartBarrier = 1;
numThreadsOnEndBarrier = 1;
return;
case(CullDrawThreadPerContext):
case(CullDrawThreadPerContext):
numThreadsOnStartBarrier = contexts.size()+1;
numThreadsOnEndBarrier = contexts.size()+1;
break;
case(DrawThreadPerContext):
case(DrawThreadPerContext):
numThreadsOnStartBarrier = 1;
numThreadsOnEndBarrier = 1;
break;
case(CullThreadPerCameraDrawThreadPerContext):
case(CullThreadPerCameraDrawThreadPerContext):
numThreadsOnStartBarrier = cameras.size()+1;
numThreadsOnEndBarrier = 1;
numThreadsOnEndBarrier = 1;
break;
default:
OSG_NOTICE<<"Error: Threading model not selected"<<std::endl;
@ -305,10 +305,10 @@ void ViewerBase::startThreading()
(*scitr)->getSceneData()->resizeGLObjectBuffers(osg::DisplaySettings::instance()->getMaxNumberOfGraphicsContexts());
}
}
int numProcessors = OpenThreads::GetNumberOfProcessors();
bool affinity = numProcessors>1;
bool affinity = numProcessors>1;
Contexts::iterator citr;
unsigned int numViewerDoubleBufferedRenderingOperation = 0;
@ -335,19 +335,19 @@ void ViewerBase::startThreading()
_endRenderingDispatchBarrier = 0;
_endDynamicDrawBlock = 0;
}
else if (_threadingModel==DrawThreadPerContext ||
else if (_threadingModel==DrawThreadPerContext ||
_threadingModel==CullThreadPerCameraDrawThreadPerContext)
{
_startRenderingBarrier = 0;
_endRenderingDispatchBarrier = 0;
_endDynamicDrawBlock = new osg::EndOfDynamicDrawBlock(numViewerDoubleBufferedRenderingOperation);
#ifndef OSGUTIL_RENDERBACKEND_USE_REF_PTR
if (!osg::Referenced::getDeleteHandler()) osg::Referenced::setDeleteHandler(new osg::DeleteHandler(2));
else osg::Referenced::getDeleteHandler()->setNumFramesToRetainObjects(2);
#endif
}
if (numThreadsOnStartBarrier>1)
{
_startRenderingBarrier = new osg::BarrierOperation(numThreadsOnStartBarrier, osg::BarrierOperation::NO_OPERATION);
@ -372,13 +372,13 @@ void ViewerBase::startThreading()
++citr, ++processNum)
{
osg::GraphicsContext* gc = (*citr);
if (!gc->isRealized())
{
OSG_INFO<<"ViewerBase::startThreading() : Realizng window "<<gc<<std::endl;
gc->realize();
}
gc->getState()->setDynamicObjectRenderingCompletedCallback(_endDynamicDrawBlock.get());
// create the a graphics thread for this context
@ -434,7 +434,7 @@ void ViewerBase::startThreading()
Renderer* renderer = dynamic_cast<Renderer*>(camera->getRenderer());
renderer->setGraphicsThreadDoesCull(false);
camera->getCameraThread()->add(renderer);
if (_endRenderingDispatchBarrier.valid())
{
// add the endRenderingDispatchBarrier
@ -456,13 +456,13 @@ void ViewerBase::startThreading()
}
}
#if 0
if (affinity)
#if 0
if (affinity)
{
OpenThreads::SetProcessorAffinityOfCurrentThread(0);
if (_scene.valid() && _scene->getDatabasePager())
{
#if 0
#if 0
_scene->getDatabasePager()->setProcessorAffinity(1);
#else
_scene->getDatabasePager()->setProcessorAffinity(0);
@ -508,7 +508,7 @@ void ViewerBase::getWindows(Windows& windows, bool onlyValid)
Contexts contexts;
getContexts(contexts, onlyValid);
for(Contexts::iterator itr = contexts.begin();
itr != contexts.end();
++itr)
@ -522,9 +522,9 @@ void ViewerBase::checkWindowStatus()
{
Contexts contexts;
getContexts(contexts);
// OSG_NOTICE<<"Viewer::checkWindowStatus() - "<<contexts.size()<<std::endl;
if (contexts.size()==0)
{
_done = true;
@ -537,7 +537,7 @@ void ViewerBase::addUpdateOperation(osg::Operation* operation)
if (!operation) return;
if (!_updateOperations) _updateOperations = new osg::OperationQueue;
_updateOperations->add(operation);
}
@ -548,19 +548,19 @@ void ViewerBase::removeUpdateOperation(osg::Operation* operation)
if (_updateOperations.valid())
{
_updateOperations->remove(operation);
}
}
}
void ViewerBase::setIncrementalCompileOperation(osgUtil::IncrementalCompileOperation* ico)
{
if (_incrementalCompileOperation == ico) return;
Contexts contexts;
getContexts(contexts, false);
if (_incrementalCompileOperation.valid()) _incrementalCompileOperation->removeContexts(contexts);
// assign new operation
// assign new operation
_incrementalCompileOperation = ico;
Scenes scenes;
@ -628,16 +628,16 @@ void ViewerBase::frame(double simulationTime)
if (_firstFrame)
{
viewerInit();
if (!isRealized())
{
realize();
}
_firstFrame = false;
}
advance(simulationTime);
eventTraversal();
updateTraversal();
renderingTraversals();
@ -664,7 +664,7 @@ void ViewerBase::renderingTraversals()
}
}
}
// check to see if windows are still valid
checkWindowStatus();
@ -677,7 +677,7 @@ void ViewerBase::renderingTraversals()
if (getViewerStats() && getViewerStats()->collectStats("scene"))
{
unsigned int frameNumber = frameStamp ? frameStamp->getFrameNumber() : 0;
Views views;
getViews(views);
for(Views::iterator vitr = views.begin();
@ -685,14 +685,14 @@ void ViewerBase::renderingTraversals()
++vitr)
{
View* view = *vitr;
osg::Stats* stats = view->getStats();
osg::Stats* stats = view->getStats();
osg::Node* sceneRoot = view->getSceneData();
if (sceneRoot && stats)
{
osgUtil::StatsVisitor statsVisitor;
sceneRoot->accept(statsVisitor);
statsVisitor.totalUpStats();
unsigned int unique_primitives = 0;
osgUtil::Statistics::PrimitiveCountMap::iterator pcmitr;
for(pcmitr = statsVisitor._uniqueStats.GetPrimitivesBegin();
@ -737,7 +737,7 @@ void ViewerBase::renderingTraversals()
Scenes scenes;
getScenes(scenes);
for(Scenes::iterator sitr = scenes.begin();
sitr != scenes.end();
++sitr)
@ -748,33 +748,33 @@ void ViewerBase::renderingTraversals()
{
dp->signalBeginFrame(frameStamp);
}
if (scene->getSceneData())
{
// fire off a build of the bounding volumes while we
// fire off a build of the bounding volumes while we
// are still running single threaded.
scene->getSceneData()->getBound();
}
}
// OSG_NOTICE<<std::endl<<"Start frame"<<std::endl;
Contexts contexts;
getContexts(contexts);
Cameras cameras;
getCameras(cameras);
Contexts::iterator itr;
bool doneMakeCurrentInThisThread = false;
if (_endDynamicDrawBlock.valid())
{
_endDynamicDrawBlock->reset();
}
// dispatch the rendering threads
if (_startRenderingBarrier.valid()) _startRenderingBarrier->block();
@ -801,7 +801,7 @@ void ViewerBase::renderingTraversals()
if (_done) return;
if (!((*itr)->getGraphicsThread()) && (*itr)->valid())
{
doneMakeCurrentInThisThread = true;
doneMakeCurrentInThisThread = true;
makeCurrent(*itr);
(*itr)->runOperations();
}
@ -819,8 +819,8 @@ void ViewerBase::renderingTraversals()
if (_done) return;
if (!((*itr)->getGraphicsThread()) && (*itr)->valid())
{
doneMakeCurrentInThisThread = true;
{
doneMakeCurrentInThisThread = true;
makeCurrent(*itr);
(*itr)->swapBuffers();
}
@ -839,13 +839,13 @@ void ViewerBase::renderingTraversals()
}
// wait till the dynamic draw is complete.
if (_endDynamicDrawBlock.valid())
if (_endDynamicDrawBlock.valid())
{
// osg::Timer_t startTick = osg::Timer::instance()->tick();
_endDynamicDrawBlock->block();
// OSG_NOTICE<<"Time waiting "<<osg::Timer::instance()->delta_m(startTick, osg::Timer::instance()->tick())<<std::endl;;
}
if (_releaseContextAtEndOfFrameHint && doneMakeCurrentInThisThread)
{
//OSG_NOTICE<<"Doing release context"<<std::endl;