From 581e6fb630e3af33fd8f7f0c0021c3f9153cabab Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 19 Apr 2011 11:40:22 +0000 Subject: [PATCH] Ran svn propset -R svn:eol-style native . on the OpenSceneGraph --- CMakeLists.txt | 2 +- .../VisualStudio_Syntax_Highlighting.txt | 42 +- examples/osgdirectinput/DirectInputRegistry | 148 +++--- .../osgdirectinput/DirectInputRegistry.cpp | 420 +++++++++--------- examples/osgdirectinput/osgdirectinput.cpp | 230 +++++----- .../osgdrawinstanced/osgdrawinstanced.cpp | 300 ++++++------- examples/osgshadergen/CMakeLists.txt | 12 +- examples/osgviewerMFC/res/MFC_OSG_MDI.rc2 | 26 +- examples/osgviewerQt/osgviewerQtContext.cpp | 194 ++++---- include/osg/Version | 2 +- src/osgDB/MimeTypes.cpp | 254 +++++------ 11 files changed, 815 insertions(+), 815 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e4f8d5718..9d4da2eba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,7 @@ PROJECT(OpenSceneGraph) SET(OPENSCENEGRAPH_MAJOR_VERSION 2) SET(OPENSCENEGRAPH_MINOR_VERSION 9) -SET(OPENSCENEGRAPH_PATCH_VERSION 12) +SET(OPENSCENEGRAPH_PATCH_VERSION 13) SET(OPENSCENEGRAPH_SOVERSION 73) # set to 0 when not a release candidate, non zero means that any generated diff --git a/PlatformSpecifics/Windows/VisualStudio_Syntax_Highlighting.txt b/PlatformSpecifics/Windows/VisualStudio_Syntax_Highlighting.txt index 86080c4be..f4391ce81 100644 --- a/PlatformSpecifics/Windows/VisualStudio_Syntax_Highlighting.txt +++ b/PlatformSpecifics/Windows/VisualStudio_Syntax_Highlighting.txt @@ -1,21 +1,21 @@ -Mapping extensionless header files to C++ in Visual Studio -============================================================================= - -Previous versions of the OSG included registry files which enabled syntax -highlighting for OSG's extensionless headers in Visual Studio. These are not -needed anymore, because starting with Visual Studio 2002 (7.0), there is a -setting that will map extensionless files to a certain language in the -options. This also works for the Express Editions. - -1. Go to Tools-Options. -2. Open the Text Editor section, and click on File Extension. -3. At the bottom of the window, check the Map Extensionless Files To - checkbox, and select Microsoft Visual C++ in the list to the right. - -Note that if you use this feature for other languages, you will have to -change it when needed. If that is too cumbersome you may want to generate -the registry files and do it that way instead. Please see the -.reg files in previous versions of OSG in the VisualStudio directory for -a guide on how to do that (hint: check the location of the registry key -to make sure the added values end up in the right place for your version -of Visual Studio). +Mapping extensionless header files to C++ in Visual Studio +============================================================================= + +Previous versions of the OSG included registry files which enabled syntax +highlighting for OSG's extensionless headers in Visual Studio. These are not +needed anymore, because starting with Visual Studio 2002 (7.0), there is a +setting that will map extensionless files to a certain language in the +options. This also works for the Express Editions. + +1. Go to Tools-Options. +2. Open the Text Editor section, and click on File Extension. +3. At the bottom of the window, check the Map Extensionless Files To + checkbox, and select Microsoft Visual C++ in the list to the right. + +Note that if you use this feature for other languages, you will have to +change it when needed. If that is too cumbersome you may want to generate +the registry files and do it that way instead. Please see the +.reg files in previous versions of OSG in the VisualStudio directory for +a guide on how to do that (hint: check the location of the registry key +to make sure the added values end up in the right place for your version +of Visual Studio). diff --git a/examples/osgdirectinput/DirectInputRegistry b/examples/osgdirectinput/DirectInputRegistry index f55a4bc5d..3a699cee7 100644 --- a/examples/osgdirectinput/DirectInputRegistry +++ b/examples/osgdirectinput/DirectInputRegistry @@ -1,74 +1,74 @@ -/* OpenSceneGraph example, osgdirectinput. -* -* Permission is hereby granted, free of charge, to any person obtaining a copy -* of this software and associated documentation files (the "Software"), to deal -* in the Software without restriction, including without limitation the rights -* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -* copies of the Software, and to permit persons to whom the Software is -* furnished to do so, subject to the following conditions: -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -* THE SOFTWARE. -*/ - -#ifndef OSGDIRECTINPUT_H -#define OSGDIRECTINPUT_H - -#define DIRECTINPUT_VERSION 0x0800 -#include -#include -#include - -class JoystickEvent : public osg::Referenced -{ -public: - JoystickEvent() {} - virtual ~JoystickEvent() {} - DIJOYSTATE2 _js; -}; - -class DirectInputRegistry : public osg::Referenced -{ -public: - static DirectInputRegistry* instance() - { - static osg::ref_ptr s_registry = new DirectInputRegistry; - return s_registry.get(); - } - - LPDIRECTINPUT8& getDevice() { return _inputDevice; } - LPDIRECTINPUTDEVICE8& getKeyboard() { return _keyboard; } - LPDIRECTINPUTDEVICE8& getMouse() { return _mouse; } - LPDIRECTINPUTDEVICE8& getJoyStick() { return _joystick; } - - bool valid() const { return _supportDirectInput; } - - bool initKeyboard( HWND handle ); - bool initMouse( HWND handle ); - bool initJoystick( HWND handle ); - - void updateState( osgGA::EventQueue* eventQueue ); - -protected: - DirectInputRegistry(); - virtual ~DirectInputRegistry(); - - bool initImplementation( HWND handle, LPDIRECTINPUTDEVICE8 device, LPCDIDATAFORMAT format ); - void pollDevice( LPDIRECTINPUTDEVICE8 device ); - void releaseDevice( LPDIRECTINPUTDEVICE8 device ); - - static BOOL CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* didInstance, VOID* ); - - LPDIRECTINPUT8 _inputDevice; - LPDIRECTINPUTDEVICE8 _keyboard; - LPDIRECTINPUTDEVICE8 _mouse; - LPDIRECTINPUTDEVICE8 _joystick; - bool _supportDirectInput; -}; - -#endif +/* OpenSceneGraph example, osgdirectinput. +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +#ifndef OSGDIRECTINPUT_H +#define OSGDIRECTINPUT_H + +#define DIRECTINPUT_VERSION 0x0800 +#include +#include +#include + +class JoystickEvent : public osg::Referenced +{ +public: + JoystickEvent() {} + virtual ~JoystickEvent() {} + DIJOYSTATE2 _js; +}; + +class DirectInputRegistry : public osg::Referenced +{ +public: + static DirectInputRegistry* instance() + { + static osg::ref_ptr s_registry = new DirectInputRegistry; + return s_registry.get(); + } + + LPDIRECTINPUT8& getDevice() { return _inputDevice; } + LPDIRECTINPUTDEVICE8& getKeyboard() { return _keyboard; } + LPDIRECTINPUTDEVICE8& getMouse() { return _mouse; } + LPDIRECTINPUTDEVICE8& getJoyStick() { return _joystick; } + + bool valid() const { return _supportDirectInput; } + + bool initKeyboard( HWND handle ); + bool initMouse( HWND handle ); + bool initJoystick( HWND handle ); + + void updateState( osgGA::EventQueue* eventQueue ); + +protected: + DirectInputRegistry(); + virtual ~DirectInputRegistry(); + + bool initImplementation( HWND handle, LPDIRECTINPUTDEVICE8 device, LPCDIDATAFORMAT format ); + void pollDevice( LPDIRECTINPUTDEVICE8 device ); + void releaseDevice( LPDIRECTINPUTDEVICE8 device ); + + static BOOL CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* didInstance, VOID* ); + + LPDIRECTINPUT8 _inputDevice; + LPDIRECTINPUTDEVICE8 _keyboard; + LPDIRECTINPUTDEVICE8 _mouse; + LPDIRECTINPUTDEVICE8 _joystick; + bool _supportDirectInput; +}; + +#endif diff --git a/examples/osgdirectinput/DirectInputRegistry.cpp b/examples/osgdirectinput/DirectInputRegistry.cpp index 2990a06f5..aa8de2df3 100644 --- a/examples/osgdirectinput/DirectInputRegistry.cpp +++ b/examples/osgdirectinput/DirectInputRegistry.cpp @@ -1,210 +1,210 @@ -/* OpenSceneGraph example, osgdirectinput. -* -* Permission is hereby granted, free of charge, to any person obtaining a copy -* of this software and associated documentation files (the "Software"), to deal -* in the Software without restriction, including without limitation the rights -* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -* copies of the Software, and to permit persons to whom the Software is -* furnished to do so, subject to the following conditions: -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -* THE SOFTWARE. -*/ - -#include -#include -#include "DirectInputRegistry" - -typedef std::pair KeyValue; -typedef std::map KeyMap; -KeyMap g_keyMap; - -void buildKeyMap() -{ - // TODO: finish the key map as you wish - g_keyMap[DIK_ESCAPE] = KeyValue(osgGA::GUIEventAdapter::KEY_Escape, 0); - g_keyMap[DIK_1] = KeyValue('1', 0); - g_keyMap[DIK_2] = KeyValue('2', 0); - g_keyMap[DIK_3] = KeyValue('3', 0); - g_keyMap[DIK_4] = KeyValue('4', 0); - g_keyMap[DIK_5] = KeyValue('5', 0); - g_keyMap[DIK_6] = KeyValue('6', 0); - g_keyMap[DIK_7] = KeyValue('7', 0); - g_keyMap[DIK_8] = KeyValue('8', 0); - g_keyMap[DIK_9] = KeyValue('9', 0); - g_keyMap[DIK_0] = KeyValue('0', 0); - g_keyMap[DIK_MINUS] = KeyValue('-', 0); - g_keyMap[DIK_EQUALS] = KeyValue('=', 0); - g_keyMap[DIK_BACK] = KeyValue(osgGA::GUIEventAdapter::KEY_BackSpace, 0); - g_keyMap[DIK_TAB] = KeyValue(osgGA::GUIEventAdapter::KEY_Tab, 0); - g_keyMap[DIK_SPACE] = KeyValue(osgGA::GUIEventAdapter::KEY_Space, 0); -} - -bool DirectInputRegistry::initKeyboard( HWND handle ) -{ - if ( !_inputDevice ) return false; - - HRESULT hr = _inputDevice->CreateDevice( GUID_SysKeyboard, &_keyboard, NULL ); - if ( FAILED(hr) || _keyboard==NULL ) - { - osg::notify(osg::WARN) << "Unable to create keyboard." << std::endl; - return false; - } - buildKeyMap(); - return initImplementation( handle, _keyboard, &c_dfDIKeyboard ); -} - -bool DirectInputRegistry::initMouse( HWND handle ) -{ - if ( !_inputDevice ) return false; - - HRESULT hr = _inputDevice->CreateDevice( GUID_SysMouse, &_mouse, NULL ); - if ( FAILED(hr) || _mouse==NULL ) - { - osg::notify(osg::WARN) << "Unable to create mouse." << std::endl; - return false; - } - return initImplementation( handle, _mouse, &c_dfDIMouse2 ); -} - -bool DirectInputRegistry::initJoystick( HWND handle ) -{ - if ( !_inputDevice ) return false; - - HRESULT hr = _inputDevice->EnumDevices( DI8DEVCLASS_GAMECTRL, EnumJoysticksCallback, - NULL, DIEDFL_ATTACHEDONLY ); - if ( FAILED(hr) || _joystick==NULL ) - { - osg::notify(osg::WARN) << "Unable to enumerate joysticks." << std::endl; - return false; - } - return initImplementation( handle, _joystick, &c_dfDIJoystick2 ); -} - -void DirectInputRegistry::updateState( osgGA::EventQueue* eventQueue ) -{ - HRESULT hr; - if ( !_supportDirectInput || !eventQueue ) return; - - if ( _keyboard ) - { - pollDevice( _keyboard ); - - char buffer[256] = {0}; - hr = _keyboard->GetDeviceState( sizeof(buffer), &buffer ); - if ( SUCCEEDED(hr) ) - { - for ( KeyMap::iterator itr=g_keyMap.begin(); itr!=g_keyMap.end(); ++itr ) - { - KeyValue& key = itr->second; - char value = buffer[itr->first]; - if ( key.second==value ) continue; - - key.second = value; - if ( value&0x80 ) - eventQueue->keyPress( key.first ); - else - eventQueue->keyRelease( key.first ); - } - } - } - - if ( _mouse ) - { - pollDevice( _mouse ); - - DIMOUSESTATE2 mouseState; - hr = _mouse->GetDeviceState( sizeof(DIMOUSESTATE2), &mouseState ); - - // TODO: add mouse handlers - } - - if ( _joystick ) - { - pollDevice( _joystick ); - - osg::ref_ptr event = new JoystickEvent; - hr = _joystick->GetDeviceState( sizeof(DIJOYSTATE2), &(event->_js) ); - if ( SUCCEEDED(hr) ) eventQueue->userEvent( event.get() ); - } -} - -DirectInputRegistry::DirectInputRegistry() -: _keyboard(0), _mouse(0), _joystick(0), - _supportDirectInput(true) -{ - HRESULT hr = DirectInput8Create( GetModuleHandle(NULL), DIRECTINPUT_VERSION, - IID_IDirectInput8, (VOID**)&_inputDevice, NULL ); - if ( FAILED(hr) ) - { - osg::notify(osg::WARN) << "Unable to create DirectInput object." << std::endl; - _supportDirectInput = false; - } -} - -DirectInputRegistry::~DirectInputRegistry() -{ - releaseDevice( _keyboard ); - releaseDevice( _mouse ); - releaseDevice( _joystick ); - if ( _inputDevice ) _inputDevice->Release(); -} - -bool DirectInputRegistry::initImplementation( HWND handle, LPDIRECTINPUTDEVICE8 device, LPCDIDATAFORMAT format ) -{ - _supportDirectInput = true; - HRESULT hr = device->SetDataFormat( format ); - if ( FAILED(hr) ) - { - osg::notify(osg::WARN) << "Unable to set device data format." << std::endl; - _supportDirectInput = false; - } - - hr = device->SetCooperativeLevel( handle, DISCL_EXCLUSIVE|DISCL_FOREGROUND ); - if ( FAILED(hr) ) - { - osg::notify(osg::WARN) << "Unable to attach device to window." << std::endl; - _supportDirectInput = false; - } - - device->Acquire(); - return _supportDirectInput; -} - -void DirectInputRegistry::pollDevice( LPDIRECTINPUTDEVICE8 device ) -{ - HRESULT hr = device->Poll(); - if ( FAILED(hr) ) - { - device->Acquire(); - if ( hr==DIERR_INPUTLOST ) - osg::notify(osg::WARN) << "Device lost." << std::endl; - } -} - -void DirectInputRegistry::releaseDevice( LPDIRECTINPUTDEVICE8 device ) -{ - if ( device ) - { - device->Unacquire(); - device->Release(); - } -} - -BOOL CALLBACK DirectInputRegistry::EnumJoysticksCallback( const DIDEVICEINSTANCE* didInstance, VOID* ) -{ - HRESULT hr; - LPDIRECTINPUT8 device = DirectInputRegistry::instance()->getDevice(); - if ( device ) - { - hr = device->CreateDevice( didInstance->guidInstance, - &(DirectInputRegistry::instance()->getJoyStick()), NULL ); - } - if ( FAILED(hr) ) return DIENUM_CONTINUE; - return DIENUM_STOP; -} +/* OpenSceneGraph example, osgdirectinput. +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +#include +#include +#include "DirectInputRegistry" + +typedef std::pair KeyValue; +typedef std::map KeyMap; +KeyMap g_keyMap; + +void buildKeyMap() +{ + // TODO: finish the key map as you wish + g_keyMap[DIK_ESCAPE] = KeyValue(osgGA::GUIEventAdapter::KEY_Escape, 0); + g_keyMap[DIK_1] = KeyValue('1', 0); + g_keyMap[DIK_2] = KeyValue('2', 0); + g_keyMap[DIK_3] = KeyValue('3', 0); + g_keyMap[DIK_4] = KeyValue('4', 0); + g_keyMap[DIK_5] = KeyValue('5', 0); + g_keyMap[DIK_6] = KeyValue('6', 0); + g_keyMap[DIK_7] = KeyValue('7', 0); + g_keyMap[DIK_8] = KeyValue('8', 0); + g_keyMap[DIK_9] = KeyValue('9', 0); + g_keyMap[DIK_0] = KeyValue('0', 0); + g_keyMap[DIK_MINUS] = KeyValue('-', 0); + g_keyMap[DIK_EQUALS] = KeyValue('=', 0); + g_keyMap[DIK_BACK] = KeyValue(osgGA::GUIEventAdapter::KEY_BackSpace, 0); + g_keyMap[DIK_TAB] = KeyValue(osgGA::GUIEventAdapter::KEY_Tab, 0); + g_keyMap[DIK_SPACE] = KeyValue(osgGA::GUIEventAdapter::KEY_Space, 0); +} + +bool DirectInputRegistry::initKeyboard( HWND handle ) +{ + if ( !_inputDevice ) return false; + + HRESULT hr = _inputDevice->CreateDevice( GUID_SysKeyboard, &_keyboard, NULL ); + if ( FAILED(hr) || _keyboard==NULL ) + { + osg::notify(osg::WARN) << "Unable to create keyboard." << std::endl; + return false; + } + buildKeyMap(); + return initImplementation( handle, _keyboard, &c_dfDIKeyboard ); +} + +bool DirectInputRegistry::initMouse( HWND handle ) +{ + if ( !_inputDevice ) return false; + + HRESULT hr = _inputDevice->CreateDevice( GUID_SysMouse, &_mouse, NULL ); + if ( FAILED(hr) || _mouse==NULL ) + { + osg::notify(osg::WARN) << "Unable to create mouse." << std::endl; + return false; + } + return initImplementation( handle, _mouse, &c_dfDIMouse2 ); +} + +bool DirectInputRegistry::initJoystick( HWND handle ) +{ + if ( !_inputDevice ) return false; + + HRESULT hr = _inputDevice->EnumDevices( DI8DEVCLASS_GAMECTRL, EnumJoysticksCallback, + NULL, DIEDFL_ATTACHEDONLY ); + if ( FAILED(hr) || _joystick==NULL ) + { + osg::notify(osg::WARN) << "Unable to enumerate joysticks." << std::endl; + return false; + } + return initImplementation( handle, _joystick, &c_dfDIJoystick2 ); +} + +void DirectInputRegistry::updateState( osgGA::EventQueue* eventQueue ) +{ + HRESULT hr; + if ( !_supportDirectInput || !eventQueue ) return; + + if ( _keyboard ) + { + pollDevice( _keyboard ); + + char buffer[256] = {0}; + hr = _keyboard->GetDeviceState( sizeof(buffer), &buffer ); + if ( SUCCEEDED(hr) ) + { + for ( KeyMap::iterator itr=g_keyMap.begin(); itr!=g_keyMap.end(); ++itr ) + { + KeyValue& key = itr->second; + char value = buffer[itr->first]; + if ( key.second==value ) continue; + + key.second = value; + if ( value&0x80 ) + eventQueue->keyPress( key.first ); + else + eventQueue->keyRelease( key.first ); + } + } + } + + if ( _mouse ) + { + pollDevice( _mouse ); + + DIMOUSESTATE2 mouseState; + hr = _mouse->GetDeviceState( sizeof(DIMOUSESTATE2), &mouseState ); + + // TODO: add mouse handlers + } + + if ( _joystick ) + { + pollDevice( _joystick ); + + osg::ref_ptr event = new JoystickEvent; + hr = _joystick->GetDeviceState( sizeof(DIJOYSTATE2), &(event->_js) ); + if ( SUCCEEDED(hr) ) eventQueue->userEvent( event.get() ); + } +} + +DirectInputRegistry::DirectInputRegistry() +: _keyboard(0), _mouse(0), _joystick(0), + _supportDirectInput(true) +{ + HRESULT hr = DirectInput8Create( GetModuleHandle(NULL), DIRECTINPUT_VERSION, + IID_IDirectInput8, (VOID**)&_inputDevice, NULL ); + if ( FAILED(hr) ) + { + osg::notify(osg::WARN) << "Unable to create DirectInput object." << std::endl; + _supportDirectInput = false; + } +} + +DirectInputRegistry::~DirectInputRegistry() +{ + releaseDevice( _keyboard ); + releaseDevice( _mouse ); + releaseDevice( _joystick ); + if ( _inputDevice ) _inputDevice->Release(); +} + +bool DirectInputRegistry::initImplementation( HWND handle, LPDIRECTINPUTDEVICE8 device, LPCDIDATAFORMAT format ) +{ + _supportDirectInput = true; + HRESULT hr = device->SetDataFormat( format ); + if ( FAILED(hr) ) + { + osg::notify(osg::WARN) << "Unable to set device data format." << std::endl; + _supportDirectInput = false; + } + + hr = device->SetCooperativeLevel( handle, DISCL_EXCLUSIVE|DISCL_FOREGROUND ); + if ( FAILED(hr) ) + { + osg::notify(osg::WARN) << "Unable to attach device to window." << std::endl; + _supportDirectInput = false; + } + + device->Acquire(); + return _supportDirectInput; +} + +void DirectInputRegistry::pollDevice( LPDIRECTINPUTDEVICE8 device ) +{ + HRESULT hr = device->Poll(); + if ( FAILED(hr) ) + { + device->Acquire(); + if ( hr==DIERR_INPUTLOST ) + osg::notify(osg::WARN) << "Device lost." << std::endl; + } +} + +void DirectInputRegistry::releaseDevice( LPDIRECTINPUTDEVICE8 device ) +{ + if ( device ) + { + device->Unacquire(); + device->Release(); + } +} + +BOOL CALLBACK DirectInputRegistry::EnumJoysticksCallback( const DIDEVICEINSTANCE* didInstance, VOID* ) +{ + HRESULT hr; + LPDIRECTINPUT8 device = DirectInputRegistry::instance()->getDevice(); + if ( device ) + { + hr = device->CreateDevice( didInstance->guidInstance, + &(DirectInputRegistry::instance()->getJoyStick()), NULL ); + } + if ( FAILED(hr) ) return DIENUM_CONTINUE; + return DIENUM_STOP; +} diff --git a/examples/osgdirectinput/osgdirectinput.cpp b/examples/osgdirectinput/osgdirectinput.cpp index 8546da4c0..c47cd7042 100644 --- a/examples/osgdirectinput/osgdirectinput.cpp +++ b/examples/osgdirectinput/osgdirectinput.cpp @@ -1,115 +1,115 @@ -/* OpenSceneGraph example, osgdirectinput. -* -* Permission is hereby granted, free of charge, to any person obtaining a copy -* of this software and associated documentation files (the "Software"), to deal -* in the Software without restriction, including without limitation the rights -* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -* copies of the Software, and to permit persons to whom the Software is -* furnished to do so, subject to the following conditions: -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -* THE SOFTWARE. -*/ - -#include -#include -#include -#include -#include -#include -#include "DirectInputRegistry" - -class CustomViewer : public osgViewer::Viewer -{ -public: - CustomViewer() : osgViewer::Viewer() {} - virtual ~CustomViewer() {} - - virtual void eventTraversal() - { - DirectInputRegistry::instance()->updateState( _eventQueue.get() ); - osgViewer::Viewer::eventTraversal(); - } - -protected: - virtual void viewerInit() - { - osgViewer::GraphicsWindowWin32* windowWin32 = - dynamic_cast( _camera->getGraphicsContext() ); - if ( windowWin32 ) - { - HWND hwnd = windowWin32->getHWND(); - DirectInputRegistry::instance()->initKeyboard( hwnd ); - //DirectInputRegistry::instance()->initMouse( hwnd ); - DirectInputRegistry::instance()->initJoystick( hwnd ); - } - osgViewer::Viewer::viewerInit(); - } -}; - -class JoystickHandler : public osgGA::GUIEventHandler -{ -public: - JoystickHandler() {} - - bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa ) - { - switch ( ea.getEventType() ) - { - case osgGA::GUIEventAdapter::KEYDOWN: - std::cout << "*** Key 0x" << std::hex << ea.getKey() << std::dec << " down ***" << std::endl; - break; - case osgGA::GUIEventAdapter::KEYUP: - std::cout << "*** Key 0x" << std::hex << ea.getKey() << std::dec << " up ***" << std::endl; - break; - case osgGA::GUIEventAdapter::USER: - { - const JoystickEvent* event = dynamic_cast( ea.getUserData() ); - if ( !event ) break; - - const DIJOYSTATE2& js = event->_js; - for ( unsigned int i=0; i<128; ++i ) - { - if ( js.rgbButtons[i] ) - std::cout << "*** Joystick Btn" << i << " = " << (int)js.rgbButtons[i] << std::endl; - } - - if ( js.lX==0x0000 ) std::cout << "*** Joystick X-" << std::endl; - else if ( js.lX==0xffff ) std::cout << "*** Joystick X+" << std::endl; - - if ( js.lY==0 ) std::cout << "*** Joystick Y-" << std::endl; - else if ( js.lY==0xffff ) std::cout << "*** Joystick Y+" << std::endl; - } - return true; - default: - break; - } - return false; - } -}; - -int main( int argc, char** argv ) -{ - osg::ArgumentParser arguments( &argc, argv ); - osg::Node* model = osgDB::readNodeFiles( arguments ); - if ( !model ) model = osgDB::readNodeFile( "cow.osg" ); - if ( !model ) - { - std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl; - return 1; - } - - CustomViewer viewer; - viewer.addEventHandler( new JoystickHandler ); - viewer.addEventHandler( new osgViewer::StatsHandler ); - viewer.addEventHandler( new osgViewer::WindowSizeHandler ); - viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) ); - viewer.setSceneData( model ); - viewer.setUpViewInWindow( 250, 50, 800, 600 ); - return viewer.run(); -} +/* OpenSceneGraph example, osgdirectinput. +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ + +#include +#include +#include +#include +#include +#include +#include "DirectInputRegistry" + +class CustomViewer : public osgViewer::Viewer +{ +public: + CustomViewer() : osgViewer::Viewer() {} + virtual ~CustomViewer() {} + + virtual void eventTraversal() + { + DirectInputRegistry::instance()->updateState( _eventQueue.get() ); + osgViewer::Viewer::eventTraversal(); + } + +protected: + virtual void viewerInit() + { + osgViewer::GraphicsWindowWin32* windowWin32 = + dynamic_cast( _camera->getGraphicsContext() ); + if ( windowWin32 ) + { + HWND hwnd = windowWin32->getHWND(); + DirectInputRegistry::instance()->initKeyboard( hwnd ); + //DirectInputRegistry::instance()->initMouse( hwnd ); + DirectInputRegistry::instance()->initJoystick( hwnd ); + } + osgViewer::Viewer::viewerInit(); + } +}; + +class JoystickHandler : public osgGA::GUIEventHandler +{ +public: + JoystickHandler() {} + + bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa ) + { + switch ( ea.getEventType() ) + { + case osgGA::GUIEventAdapter::KEYDOWN: + std::cout << "*** Key 0x" << std::hex << ea.getKey() << std::dec << " down ***" << std::endl; + break; + case osgGA::GUIEventAdapter::KEYUP: + std::cout << "*** Key 0x" << std::hex << ea.getKey() << std::dec << " up ***" << std::endl; + break; + case osgGA::GUIEventAdapter::USER: + { + const JoystickEvent* event = dynamic_cast( ea.getUserData() ); + if ( !event ) break; + + const DIJOYSTATE2& js = event->_js; + for ( unsigned int i=0; i<128; ++i ) + { + if ( js.rgbButtons[i] ) + std::cout << "*** Joystick Btn" << i << " = " << (int)js.rgbButtons[i] << std::endl; + } + + if ( js.lX==0x0000 ) std::cout << "*** Joystick X-" << std::endl; + else if ( js.lX==0xffff ) std::cout << "*** Joystick X+" << std::endl; + + if ( js.lY==0 ) std::cout << "*** Joystick Y-" << std::endl; + else if ( js.lY==0xffff ) std::cout << "*** Joystick Y+" << std::endl; + } + return true; + default: + break; + } + return false; + } +}; + +int main( int argc, char** argv ) +{ + osg::ArgumentParser arguments( &argc, argv ); + osg::Node* model = osgDB::readNodeFiles( arguments ); + if ( !model ) model = osgDB::readNodeFile( "cow.osg" ); + if ( !model ) + { + std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl; + return 1; + } + + CustomViewer viewer; + viewer.addEventHandler( new JoystickHandler ); + viewer.addEventHandler( new osgViewer::StatsHandler ); + viewer.addEventHandler( new osgViewer::WindowSizeHandler ); + viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) ); + viewer.setSceneData( model ); + viewer.setUpViewInWindow( 250, 50, 800, 600 ); + return viewer.run(); +} diff --git a/examples/osgdrawinstanced/osgdrawinstanced.cpp b/examples/osgdrawinstanced/osgdrawinstanced.cpp index 9b2a6b9a7..2c1b7a516 100644 --- a/examples/osgdrawinstanced/osgdrawinstanced.cpp +++ b/examples/osgdrawinstanced/osgdrawinstanced.cpp @@ -1,150 +1,150 @@ -/* OpenSceneGraph example, osgdrawinstanced. -* -* Permission is hereby granted, free of charge, to any person obtaining a copy -* of this software and associated documentation files (the "Software"), to deal -* in the Software without restriction, including without limitation the rights -* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -* copies of the Software, and to permit persons to whom the Software is -* furnished to do so, subject to the following conditions: -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -* THE SOFTWARE. -*/ -// -// This code is copyright (c) 2008 Skew Matrix Software LLC. You may use -// the code under the licensing terms described above. -// - -#include -#include -#include -#include - -#include - -#include - -void -createDAIGeometry( osg::Geometry& geom, int nInstances=1 ) -{ - const float halfDimX( .5 ); - const float halfDimZ( .5 ); - - osg::Vec3Array* v = new osg::Vec3Array; - v->resize( 4 ); - geom.setVertexArray( v ); - - // Geometry for a single quad. - (*v)[ 0 ] = osg::Vec3( -halfDimX, 0., -halfDimZ ); - (*v)[ 1 ] = osg::Vec3( halfDimX, 0., -halfDimZ ); - (*v)[ 2 ] = osg::Vec3( halfDimX, 0., halfDimZ ); - (*v)[ 3 ] = osg::Vec3( -halfDimX, 0., halfDimZ ); - - // Use the DrawArraysInstanced PrimitiveSet and tell it to draw 1024 instances. - geom.addPrimitiveSet( new osg::DrawArrays( GL_QUADS, 0, 4, nInstances ) ); -} - - -osg::StateSet* -createStateSet() -{ - osg::ref_ptr< osg::StateSet > ss = new osg::StateSet; - - // Create a vertex program that references the gl_InstanceID to - // render each instance uniquely. gl_InstanceID will be in the range - // 0 to numInstances-1 (1023 in our case). - std::string vertexSource = - "uniform sampler2D osgLogo; \n" - "uniform float osg_SimulationTime; \n" - - "void main() \n" - "{ \n" - // Using the instance ID, generate "texture coords" for this instance. - "vec2 tC; \n" - "float r = float(gl_InstanceID) / 32.; \n" - "tC.s = fract( r ); tC.t = floor( r ) / 32.; \n" - // Get the color from the OSG logo. - "gl_FrontColor = texture2D( osgLogo, tC ); \n" - - // Use the (scaled) tex coord to translate the position of the vertices. - "vec4 pos = vec4( tC.s * 48., 0., tC.t * 48., 1. ); \n" - - // Compute a rotation angle from the instanceID and elapsed time. - "float timeOffset = gl_InstanceID / (32. * 32.); \n" - "float angle = ( osg_SimulationTime - timeOffset ) * 6.283; \n" - "float sa = sin( angle ); \n" - "float ca = cos( angle ); \n" - // New orientation, rotate around z axis. - "vec4 newX = vec4( ca, sa, 0., 0. ); \n" - "vec4 newY = vec4( sa, ca, 0., 0. ); \n" - "vec4 newZ = vec4( 0., 0., 1., 0. ); \n" - "mat4 mV = mat4( newX, newY, newZ, pos ); \n" - "gl_Position = ( gl_ModelViewProjectionMatrix * mV * gl_Vertex ); \n" - "} \n"; - - osg::ref_ptr< osg::Shader > vertexShader = new osg::Shader(); - vertexShader->setType( osg::Shader::VERTEX ); - vertexShader->setShaderSource( vertexSource ); - - osg::ref_ptr< osg::Program > program = new osg::Program(); - program->addShader( vertexShader.get() ); - - ss->setAttribute( program.get(), - osg::StateAttribute::ON | osg::StateAttribute::PROTECTED ); - - osg::ref_ptr< osg::Image> iLogo = osgDB::readImageFile( "Images/osg128.png" ); - if( !iLogo.valid() ) - { - osg::notify( osg::ALWAYS ) << "Can't open image file osg128.png" << std::endl; - return( NULL ); - } - osg::Texture2D* texLogo = new osg::Texture2D( iLogo.get() ); - texLogo->setFilter( osg::Texture2D::MIN_FILTER, osg::Texture2D::LINEAR ); - texLogo->setFilter( osg::Texture2D::MAG_FILTER, osg::Texture2D::LINEAR ); - - ss->setTextureAttribute( 0, texLogo ); - - osg::ref_ptr< osg::Uniform > texLogoUniform = - new osg::Uniform( "osgLogo", 0 ); - ss->addUniform( texLogoUniform.get() ); - - return( ss.release() ); -} - - -int main( int argc, char **argv ) -{ - osg::ArgumentParser arguments(&argc, argv); - - // Make a scene graph consisting of a single Geode, containing - // a single Geometry, and a single PrimitiveSet. - osg::ref_ptr< osg::Geode > geode = new osg::Geode; - - osg::ref_ptr< osg::Geometry > geom = new osg::Geometry; - // Configure the Geometry for use with EXT_draw_arrays: - // DL off and buffer objects on. - geom->setUseDisplayList( false ); - geom->setUseVertexBufferObjects( true ); - // OSG has no clue where out vertex shader will place the geometric data, - // so specify an initial bound to allow proper culling and near/far computation. - osg::BoundingBox bb( -1., -.1, -1., 49., 1., 49. ); - geom->setInitialBound( bb ); - // Add geometric data and the PrimitiveSet. Specify numInstances as 32*32 or 1024. - createDAIGeometry( *geom, 32*32 ); - geode->addDrawable( geom.get() ); - - // Create a StateSet to render the instanced Geometry. - osg::ref_ptr< osg::StateSet > ss = createStateSet(); - geode->setStateSet( ss.get() ); - - // osgDB::writeNodeFile(*geode, "instanced.osg"); - - osgViewer::Viewer viewer(arguments); - viewer.setSceneData( geode.get() ); - return viewer.run(); -} +/* OpenSceneGraph example, osgdrawinstanced. +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ +// +// This code is copyright (c) 2008 Skew Matrix Software LLC. You may use +// the code under the licensing terms described above. +// + +#include +#include +#include +#include + +#include + +#include + +void +createDAIGeometry( osg::Geometry& geom, int nInstances=1 ) +{ + const float halfDimX( .5 ); + const float halfDimZ( .5 ); + + osg::Vec3Array* v = new osg::Vec3Array; + v->resize( 4 ); + geom.setVertexArray( v ); + + // Geometry for a single quad. + (*v)[ 0 ] = osg::Vec3( -halfDimX, 0., -halfDimZ ); + (*v)[ 1 ] = osg::Vec3( halfDimX, 0., -halfDimZ ); + (*v)[ 2 ] = osg::Vec3( halfDimX, 0., halfDimZ ); + (*v)[ 3 ] = osg::Vec3( -halfDimX, 0., halfDimZ ); + + // Use the DrawArraysInstanced PrimitiveSet and tell it to draw 1024 instances. + geom.addPrimitiveSet( new osg::DrawArrays( GL_QUADS, 0, 4, nInstances ) ); +} + + +osg::StateSet* +createStateSet() +{ + osg::ref_ptr< osg::StateSet > ss = new osg::StateSet; + + // Create a vertex program that references the gl_InstanceID to + // render each instance uniquely. gl_InstanceID will be in the range + // 0 to numInstances-1 (1023 in our case). + std::string vertexSource = + "uniform sampler2D osgLogo; \n" + "uniform float osg_SimulationTime; \n" + + "void main() \n" + "{ \n" + // Using the instance ID, generate "texture coords" for this instance. + "vec2 tC; \n" + "float r = float(gl_InstanceID) / 32.; \n" + "tC.s = fract( r ); tC.t = floor( r ) / 32.; \n" + // Get the color from the OSG logo. + "gl_FrontColor = texture2D( osgLogo, tC ); \n" + + // Use the (scaled) tex coord to translate the position of the vertices. + "vec4 pos = vec4( tC.s * 48., 0., tC.t * 48., 1. ); \n" + + // Compute a rotation angle from the instanceID and elapsed time. + "float timeOffset = gl_InstanceID / (32. * 32.); \n" + "float angle = ( osg_SimulationTime - timeOffset ) * 6.283; \n" + "float sa = sin( angle ); \n" + "float ca = cos( angle ); \n" + // New orientation, rotate around z axis. + "vec4 newX = vec4( ca, sa, 0., 0. ); \n" + "vec4 newY = vec4( sa, ca, 0., 0. ); \n" + "vec4 newZ = vec4( 0., 0., 1., 0. ); \n" + "mat4 mV = mat4( newX, newY, newZ, pos ); \n" + "gl_Position = ( gl_ModelViewProjectionMatrix * mV * gl_Vertex ); \n" + "} \n"; + + osg::ref_ptr< osg::Shader > vertexShader = new osg::Shader(); + vertexShader->setType( osg::Shader::VERTEX ); + vertexShader->setShaderSource( vertexSource ); + + osg::ref_ptr< osg::Program > program = new osg::Program(); + program->addShader( vertexShader.get() ); + + ss->setAttribute( program.get(), + osg::StateAttribute::ON | osg::StateAttribute::PROTECTED ); + + osg::ref_ptr< osg::Image> iLogo = osgDB::readImageFile( "Images/osg128.png" ); + if( !iLogo.valid() ) + { + osg::notify( osg::ALWAYS ) << "Can't open image file osg128.png" << std::endl; + return( NULL ); + } + osg::Texture2D* texLogo = new osg::Texture2D( iLogo.get() ); + texLogo->setFilter( osg::Texture2D::MIN_FILTER, osg::Texture2D::LINEAR ); + texLogo->setFilter( osg::Texture2D::MAG_FILTER, osg::Texture2D::LINEAR ); + + ss->setTextureAttribute( 0, texLogo ); + + osg::ref_ptr< osg::Uniform > texLogoUniform = + new osg::Uniform( "osgLogo", 0 ); + ss->addUniform( texLogoUniform.get() ); + + return( ss.release() ); +} + + +int main( int argc, char **argv ) +{ + osg::ArgumentParser arguments(&argc, argv); + + // Make a scene graph consisting of a single Geode, containing + // a single Geometry, and a single PrimitiveSet. + osg::ref_ptr< osg::Geode > geode = new osg::Geode; + + osg::ref_ptr< osg::Geometry > geom = new osg::Geometry; + // Configure the Geometry for use with EXT_draw_arrays: + // DL off and buffer objects on. + geom->setUseDisplayList( false ); + geom->setUseVertexBufferObjects( true ); + // OSG has no clue where out vertex shader will place the geometric data, + // so specify an initial bound to allow proper culling and near/far computation. + osg::BoundingBox bb( -1., -.1, -1., 49., 1., 49. ); + geom->setInitialBound( bb ); + // Add geometric data and the PrimitiveSet. Specify numInstances as 32*32 or 1024. + createDAIGeometry( *geom, 32*32 ); + geode->addDrawable( geom.get() ); + + // Create a StateSet to render the instanced Geometry. + osg::ref_ptr< osg::StateSet > ss = createStateSet(); + geode->setStateSet( ss.get() ); + + // osgDB::writeNodeFile(*geode, "instanced.osg"); + + osgViewer::Viewer viewer(arguments); + viewer.setSceneData( geode.get() ); + return viewer.run(); +} diff --git a/examples/osgshadergen/CMakeLists.txt b/examples/osgshadergen/CMakeLists.txt index d58a4dc3b..dd45259b3 100644 --- a/examples/osgshadergen/CMakeLists.txt +++ b/examples/osgshadergen/CMakeLists.txt @@ -1,6 +1,6 @@ -#this file is automatically generated - - -SET(TARGET_SRC osgshadergen.cpp ) -#### end var setup ### -SETUP_EXAMPLE(osgshadergen) +#this file is automatically generated + + +SET(TARGET_SRC osgshadergen.cpp ) +#### end var setup ### +SETUP_EXAMPLE(osgshadergen) diff --git a/examples/osgviewerMFC/res/MFC_OSG_MDI.rc2 b/examples/osgviewerMFC/res/MFC_OSG_MDI.rc2 index 2df74c228..252788a0f 100644 --- a/examples/osgviewerMFC/res/MFC_OSG_MDI.rc2 +++ b/examples/osgviewerMFC/res/MFC_OSG_MDI.rc2 @@ -1,13 +1,13 @@ -// -// MFC_OSG_MDI.RC2 - resources Microsoft Visual C++ does not edit directly -// - -#ifdef APSTUDIO_INVOKED -#error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// Add manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// +// +// MFC_OSG_MDI.RC2 - resources Microsoft Visual C++ does not edit directly +// + +#ifdef APSTUDIO_INVOKED +#error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// Add manually edited resources here... + +///////////////////////////////////////////////////////////////////////////// diff --git a/examples/osgviewerQt/osgviewerQtContext.cpp b/examples/osgviewerQt/osgviewerQtContext.cpp index 340a88ed9..cd197dbb1 100644 --- a/examples/osgviewerQt/osgviewerQtContext.cpp +++ b/examples/osgviewerQt/osgviewerQtContext.cpp @@ -1,97 +1,97 @@ -#include -#include -#include - -#include -#include - -#include - -#include - -#include - -#include - -class ViewerWidget : public QWidget, public osgViewer::CompositeViewer -{ -public: - ViewerWidget() : QWidget() - { - setThreadingModel(osgViewer::CompositeViewer::SingleThreaded); - - QWidget* widget1 = addViewWidget( createCamera(0,0,100,100), osgDB::readNodeFile("cow.osg") ); - QWidget* widget2 = addViewWidget( createCamera(0,0,100,100), osgDB::readNodeFile("glider.osg") ); - QWidget* widget3 = addViewWidget( createCamera(0,0,100,100), osgDB::readNodeFile("axes.osg") ); - QWidget* widget4 = addViewWidget( createCamera(0,0,100,100), osgDB::readNodeFile("fountain.osg") ); - QWidget* popupWidget = addViewWidget( createCamera(900,100,320,240,"Popup window",true), - osgDB::readNodeFile("dumptruck.osg") ); - popupWidget->show(); - - QGridLayout* grid = new QGridLayout; - grid->addWidget( widget1, 0, 0 ); - grid->addWidget( widget2, 0, 1 ); - grid->addWidget( widget3, 1, 0 ); - grid->addWidget( widget4, 1, 1 ); - setLayout( grid ); - - connect( &_timer, SIGNAL(timeout()), this, SLOT(update()) ); - _timer.start( 10 ); - } - - QWidget* addViewWidget( osg::Camera* camera, osg::Node* scene ) - { - osgViewer::View* view = new osgViewer::View; - view->setCamera( camera ); - addView( view ); - - view->setSceneData( scene ); - view->addEventHandler( new osgViewer::StatsHandler ); - view->setCameraManipulator( new osgGA::TrackballManipulator ); - - osgQt::GraphicsWindowQt* gw = dynamic_cast( camera->getGraphicsContext() ); - return gw ? gw->getGraphWidget() : NULL; - } - - osg::Camera* createCamera( int x, int y, int w, int h, const std::string& name="", bool windowDecoration=false ) - { - osg::DisplaySettings* ds = osg::DisplaySettings::instance().get(); - osg::ref_ptr traits = new osg::GraphicsContext::Traits; - traits->windowName = name; - traits->windowDecoration = windowDecoration; - traits->x = x; - traits->y = y; - traits->width = w; - traits->height = h; - traits->doubleBuffer = true; - traits->alpha = ds->getMinimumNumAlphaBits(); - traits->stencil = ds->getMinimumNumStencilBits(); - traits->sampleBuffers = ds->getMultiSamples(); - traits->samples = ds->getNumMultiSamples(); - - osg::ref_ptr camera = new osg::Camera; - camera->setGraphicsContext( new osgQt::GraphicsWindowQt(traits.get()) ); - - camera->setClearColor( osg::Vec4(0.2, 0.2, 0.6, 1.0) ); - camera->setViewport( new osg::Viewport(0, 0, traits->width, traits->height) ); - camera->setProjectionMatrixAsPerspective( - 30.0f, static_cast(traits->width)/static_cast(traits->height), 1.0f, 10000.0f ); - return camera.release(); - } - - virtual void paintEvent( QPaintEvent* event ) - { frame(); } - -protected: - - QTimer _timer; -}; - -int main( int argc, char** argv ) -{ - QApplication app(argc, argv); - ViewerWidget* viewWidget = new ViewerWidget; - viewWidget->setGeometry( 100, 100, 800, 600 ); - viewWidget->show(); - return app.exec(); -} +#include +#include +#include + +#include +#include + +#include + +#include + +#include + +#include + +class ViewerWidget : public QWidget, public osgViewer::CompositeViewer +{ +public: + ViewerWidget() : QWidget() + { + setThreadingModel(osgViewer::CompositeViewer::SingleThreaded); + + QWidget* widget1 = addViewWidget( createCamera(0,0,100,100), osgDB::readNodeFile("cow.osg") ); + QWidget* widget2 = addViewWidget( createCamera(0,0,100,100), osgDB::readNodeFile("glider.osg") ); + QWidget* widget3 = addViewWidget( createCamera(0,0,100,100), osgDB::readNodeFile("axes.osg") ); + QWidget* widget4 = addViewWidget( createCamera(0,0,100,100), osgDB::readNodeFile("fountain.osg") ); + QWidget* popupWidget = addViewWidget( createCamera(900,100,320,240,"Popup window",true), + osgDB::readNodeFile("dumptruck.osg") ); + popupWidget->show(); + + QGridLayout* grid = new QGridLayout; + grid->addWidget( widget1, 0, 0 ); + grid->addWidget( widget2, 0, 1 ); + grid->addWidget( widget3, 1, 0 ); + grid->addWidget( widget4, 1, 1 ); + setLayout( grid ); + + connect( &_timer, SIGNAL(timeout()), this, SLOT(update()) ); + _timer.start( 10 ); + } + + QWidget* addViewWidget( osg::Camera* camera, osg::Node* scene ) + { + osgViewer::View* view = new osgViewer::View; + view->setCamera( camera ); + addView( view ); + + view->setSceneData( scene ); + view->addEventHandler( new osgViewer::StatsHandler ); + view->setCameraManipulator( new osgGA::TrackballManipulator ); + + osgQt::GraphicsWindowQt* gw = dynamic_cast( camera->getGraphicsContext() ); + return gw ? gw->getGraphWidget() : NULL; + } + + osg::Camera* createCamera( int x, int y, int w, int h, const std::string& name="", bool windowDecoration=false ) + { + osg::DisplaySettings* ds = osg::DisplaySettings::instance().get(); + osg::ref_ptr traits = new osg::GraphicsContext::Traits; + traits->windowName = name; + traits->windowDecoration = windowDecoration; + traits->x = x; + traits->y = y; + traits->width = w; + traits->height = h; + traits->doubleBuffer = true; + traits->alpha = ds->getMinimumNumAlphaBits(); + traits->stencil = ds->getMinimumNumStencilBits(); + traits->sampleBuffers = ds->getMultiSamples(); + traits->samples = ds->getNumMultiSamples(); + + osg::ref_ptr camera = new osg::Camera; + camera->setGraphicsContext( new osgQt::GraphicsWindowQt(traits.get()) ); + + camera->setClearColor( osg::Vec4(0.2, 0.2, 0.6, 1.0) ); + camera->setViewport( new osg::Viewport(0, 0, traits->width, traits->height) ); + camera->setProjectionMatrixAsPerspective( + 30.0f, static_cast(traits->width)/static_cast(traits->height), 1.0f, 10000.0f ); + return camera.release(); + } + + virtual void paintEvent( QPaintEvent* event ) + { frame(); } + +protected: + + QTimer _timer; +}; + +int main( int argc, char** argv ) +{ + QApplication app(argc, argv); + ViewerWidget* viewWidget = new ViewerWidget; + viewWidget->setGeometry( 100, 100, 800, 600 ); + viewWidget->show(); + return app.exec(); +} diff --git a/include/osg/Version b/include/osg/Version index 5cd6c9d1b..e85e82d94 100644 --- a/include/osg/Version +++ b/include/osg/Version @@ -20,7 +20,7 @@ extern "C" { #define OPENSCENEGRAPH_MAJOR_VERSION 2 #define OPENSCENEGRAPH_MINOR_VERSION 9 -#define OPENSCENEGRAPH_PATCH_VERSION 12 +#define OPENSCENEGRAPH_PATCH_VERSION 13 #define OPENSCENEGRAPH_SOVERSION 73 /* Convenience macro that can be used to decide whether a feature is present or not i.e. diff --git a/src/osgDB/MimeTypes.cpp b/src/osgDB/MimeTypes.cpp index 6af022926..2b86bba71 100644 --- a/src/osgDB/MimeTypes.cpp +++ b/src/osgDB/MimeTypes.cpp @@ -1,127 +1,127 @@ -/* -*-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 - * (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 - * OpenSceneGraph Public License for more details. -*/ -const char* builtinMimeTypeExtMappings[] = -{ - "application/dxf","dxf", - "application/gnutar","tgz", - "application/pdf","pdf", - "application/plain","text", - "application/postscript","ps", - "application/x-bzip","bz", - "application/x-bzip2","bz2", - "application/x-compressed","zip", - "application/x-gzip","gz", - "application/x-inventor","iv", - "application/x-javascript","js", - "application/xml","xml", - "application/x-tar","tar", - "application/x-vrml","wrl", - "application/x-world","wrl", - "application/x-zip-compressed","zip", - "application/zip","zip", - "drawing/x-dwf(old)","dwf", - "image/bmp","bmp", - "image/cmu-raster","ras", - "image/fif","fif", - "image/florian","flo", - "image/g3fax","g3", - "image/gif","gif", - "image/ief","ief", - "image/jpeg","jpg", - "image/jutvision","jut", - "image/naplps","nap", - "image/naplps","naplps", - "image/pict","pic", - "image/pjpeg","jpg", - "image/png","png", - "image/tiff","tif", - "image/vasa","mcf", - "image/vnd.dwg","dxf", - "image/vnd.fpx","fpx", - "image/vnd.net-fpx","fpx", - "image/vnd.rn-realflash","rf", - "image/vnd.rn-realpix","rp", - "image/vnd.wap.wbmp","wbmp", - "image/vnd.xiff","xif", - "image/xbm","xbm", - "image/x-cmu-raster","ras", - "image/x-dwg","dxf", - "image/x-icon","ico", - "image/x-jg","art", - "image/x-jps","jps", - "image/x-niff","nif", - "image/x-pcx","pcx", - "image/x-pict","pct", - "image/xpm","xpm", - "image/x-portable-anymap","pnm", - "image/x-portable-bitmap","pbm", - "image/x-portable-graymap","pgm", - "image/x-portable-greymap","pgm", - "image/x-portable-pixmap","ppm", - "image/x-quicktime","qif", - "image/x-rgb","rgb", - "image/x-tiff","tif", - "image/x-windows-bmp","bmp", - "image/x-xbitmap","xbm", - "image/x-xbm","xbm", - "image/x-xpixmap","xpm", - "image/x-xwd","xwd", - "image/x-xwindowdump","xwd", - "i-world/i-vrml","ivr", - "model/iges","igs", - "model/vnd.dwf","dwf", - "model/vrml","wrl", - "model/x-pov","pov", - "multipart/x-gzip","gzip", - "multipart/x-ustar","ustar", - "multipart/x-zip","zip", - "video/animaflex","afl", - "video/avi","avi", - "video/avs-video","avs", - "video/dl","dl", - "video/fli","fli", - "video/gl","gl", - "video/mpeg","mpg", - "video/msvideo","avi", - "video/quicktime","qt", - "video/vdo","vdo", - "video/vivo","viv", - "video/vnd.rn-realvideo","rv", - "video/vnd.vivo","viv", - "video/vosaic","vos", - "video/x-amt-demorun","xdr", - "video/x-amt-showrun","xsr", - "video/x-atomic3d-feature","fmf", - "video/x-dl","dl", - "video/x-dv","dv", - "video/x-fli","fli", - "video/x-gl","gl", - "video/x-isvideo","isu", - "video/x-motion-jpeg","mjpg", - "video/x-mpeg","mp3", - "video/x-mpeq2a","mp2", - "video/x-ms-asf","asf", - "video/x-ms-asf-plugin","asx", - "video/x-msvideo","avi", - "video/x-qtc","qtc", - "video/x-scm","scm", - "video/x-sgi-movie","movie", - "windows/metafile","wmf", - "xgl/drawing","xgz", - "xgl/movie","xmz", - "x-world/x-3dmf","3dm", - "x-world/x-svr","svr", - "x-world/x-vrml","wrl", - "x-world/x-vrt","vrt", - "" // end of list -}; +/* -*-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 + * (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 + * OpenSceneGraph Public License for more details. +*/ +const char* builtinMimeTypeExtMappings[] = +{ + "application/dxf","dxf", + "application/gnutar","tgz", + "application/pdf","pdf", + "application/plain","text", + "application/postscript","ps", + "application/x-bzip","bz", + "application/x-bzip2","bz2", + "application/x-compressed","zip", + "application/x-gzip","gz", + "application/x-inventor","iv", + "application/x-javascript","js", + "application/xml","xml", + "application/x-tar","tar", + "application/x-vrml","wrl", + "application/x-world","wrl", + "application/x-zip-compressed","zip", + "application/zip","zip", + "drawing/x-dwf(old)","dwf", + "image/bmp","bmp", + "image/cmu-raster","ras", + "image/fif","fif", + "image/florian","flo", + "image/g3fax","g3", + "image/gif","gif", + "image/ief","ief", + "image/jpeg","jpg", + "image/jutvision","jut", + "image/naplps","nap", + "image/naplps","naplps", + "image/pict","pic", + "image/pjpeg","jpg", + "image/png","png", + "image/tiff","tif", + "image/vasa","mcf", + "image/vnd.dwg","dxf", + "image/vnd.fpx","fpx", + "image/vnd.net-fpx","fpx", + "image/vnd.rn-realflash","rf", + "image/vnd.rn-realpix","rp", + "image/vnd.wap.wbmp","wbmp", + "image/vnd.xiff","xif", + "image/xbm","xbm", + "image/x-cmu-raster","ras", + "image/x-dwg","dxf", + "image/x-icon","ico", + "image/x-jg","art", + "image/x-jps","jps", + "image/x-niff","nif", + "image/x-pcx","pcx", + "image/x-pict","pct", + "image/xpm","xpm", + "image/x-portable-anymap","pnm", + "image/x-portable-bitmap","pbm", + "image/x-portable-graymap","pgm", + "image/x-portable-greymap","pgm", + "image/x-portable-pixmap","ppm", + "image/x-quicktime","qif", + "image/x-rgb","rgb", + "image/x-tiff","tif", + "image/x-windows-bmp","bmp", + "image/x-xbitmap","xbm", + "image/x-xbm","xbm", + "image/x-xpixmap","xpm", + "image/x-xwd","xwd", + "image/x-xwindowdump","xwd", + "i-world/i-vrml","ivr", + "model/iges","igs", + "model/vnd.dwf","dwf", + "model/vrml","wrl", + "model/x-pov","pov", + "multipart/x-gzip","gzip", + "multipart/x-ustar","ustar", + "multipart/x-zip","zip", + "video/animaflex","afl", + "video/avi","avi", + "video/avs-video","avs", + "video/dl","dl", + "video/fli","fli", + "video/gl","gl", + "video/mpeg","mpg", + "video/msvideo","avi", + "video/quicktime","qt", + "video/vdo","vdo", + "video/vivo","viv", + "video/vnd.rn-realvideo","rv", + "video/vnd.vivo","viv", + "video/vosaic","vos", + "video/x-amt-demorun","xdr", + "video/x-amt-showrun","xsr", + "video/x-atomic3d-feature","fmf", + "video/x-dl","dl", + "video/x-dv","dv", + "video/x-fli","fli", + "video/x-gl","gl", + "video/x-isvideo","isu", + "video/x-motion-jpeg","mjpg", + "video/x-mpeg","mp3", + "video/x-mpeq2a","mp2", + "video/x-ms-asf","asf", + "video/x-ms-asf-plugin","asx", + "video/x-msvideo","avi", + "video/x-qtc","qtc", + "video/x-scm","scm", + "video/x-sgi-movie","movie", + "windows/metafile","wmf", + "xgl/drawing","xgz", + "xgl/movie","xmz", + "x-world/x-3dmf","3dm", + "x-world/x-svr","svr", + "x-world/x-vrml","wrl", + "x-world/x-vrt","vrt", + "" // end of list +};