Compare commits

..

434 Commits

Author SHA1 Message Date
Robert Osfield
e5fe55956e Release OpenSceneGraph-2.6.0 2008-08-05 21:36:16 +00:00
Robert Osfield
98ce387440 Merged addition osgWidget to doxygen doc build using:
svn merge -r 8746:8747 http://www.openscenegraph.org/svn/osg/OpenSceneGraph/trunk .
2008-08-05 20:07:20 +00:00
Robert Osfield
744c1cc464 From Eric Sokolowski, release notes for OSX. 2008-08-05 19:57:22 +00:00
Robert Osfield
2be018230d Merged improvements to namespace doxygen comments from svn/trunk. 2008-08-05 19:23:38 +00:00
Robert Osfield
e84e2b0025 Merged in from svn/trunk of Eric Sokolowski's disabling of 64bit build under OSX. Merge command:
svn merge -r 8741:8742 http://www.openscenegraph.org/svn/osg/OpenSceneGraph/trunk .
2008-08-05 16:10:49 +00:00
Robert Osfield
46afd39b51 merged changes in from svn/trunk using :
svn merge -r 8736:8738 http://www.openscenegraph.org/svn/osg/OpenSceneGraph/trunk .
2008-08-05 15:32:03 +00:00
Robert Osfield
822fec0302 Updated READE for 2.6.0 release 2008-08-05 15:31:17 +00:00
Robert Osfield
3ae660c8eb Updated NEWS for 2.6.0 release 2008-08-05 14:05:56 +00:00
Robert Osfield
0a82439a9c Updated ChangeLog, Authors file and tweak to osgversion to prevent inappropriate class names being added to authors file 2008-08-05 13:52:51 +00:00
Robert Osfield
b2db19e976 Updated wrappers 2008-08-05 10:31:05 +00:00
Robert Osfield
5d8ec3027e Updated SO version number to reflect typo fixes changing the API 2008-08-05 10:23:31 +00:00
Robert Osfield
24b608cacb Added support for both the old autoScaleTransistionWidthRatio (note typo) and newly fixed autoScaleTransitionWidthRatio in the .osg parsing 2008-08-05 10:20:20 +00:00
Paul MELIS
af9ccc5596 - Fixes for two spelling mistakes 2008-08-05 09:58:31 +00:00
Robert Osfield
cc3d0903db Added -losgWidget to lib list, change merged in from svn trunk, using : svn merge -r 8727:8728 http://www.openscenegraph.org/svn/osg/OpenSceneGraph/trunk . 2008-08-04 20:50:20 +00:00
Robert Osfield
faef4cea61 From Sherman Wilcox, "Minor change to bool setGLExtensionFuncPtr(T& t, const char* str1) and
setGLExtensionFuncPtr(T& t, const char* str1, const char* str2) -
functions returned false even on success."

Note, merged from svn/trunk using:

  svn merge -r 8725:8726 http://www.openscenegraph.org/svn/osg/OpenSceneGraph/trunk .
2008-08-04 17:10:20 +00:00
Robert Osfield
c3e42eda62 Updated ChangeLog for 2.6.0-rc2 2008-08-04 15:30:07 +00:00
Robert Osfield
62ed1a838b Updated NEWS and AUTHORS for 2.6.0-rc2 from osg trunk, using "svn merge -r 8719:8722 http://www.openscenegraph.org/svn/osg/OpenSceneGraph/trunk ." 2008-08-04 15:21:32 +00:00
Robert Osfield
a0e4779d76 merged Philip Pulman's Centos 5 compile fix from trunk using : svn merge -r 8717:8718 http://www.openscenegraph.org/svn/osg/OpenSceneGraph/trunk . 2008-08-04 14:04:14 +00:00
Robert Osfield
c3e394ba3e Merged multi-threaded crash fix to PrecipitationEffect, using "svn merge -r 8715:8716 http://www.openscenegraph.org/svn/osg/OpenSceneGraph/trunk ." 2008-08-04 12:48:31 +00:00
Robert Osfield
5c312685cd Merged from svn/trunk the removal of debugging info 2008-08-04 12:39:59 +00:00
Robert Osfield
d801620b6c Merged LineSegment and Quicktime fixes from svn/trunk, using : merge -r 8709:8712 http://www.openscenegraph.org/svn/osg/OpenSceneGraph/trunk . 2008-08-04 09:07:21 +00:00
Robert Osfield
22246158a5 Merged KdTree update from svn trunk using "svn merge -r 8706:8707 http://www.openscenegraph.org/svn/osg/OpenSceneGraph/trunk ." 2008-08-03 17:02:32 +00:00
Paul MARTZ
bbd40ca107 From Jean-Sebastien Guay. Fix for stuck keys problem when viewer loses focus. Equivalent to Melchior Franz's fix for the same issue in GraphicsWindowX11. When the application loses focus, all currently pressed keys are released. When it regains focus, keys are queried to see which are currently pressed and keydown messages are sent for those.
Also, from Daniel Olivier. Fix for windows based on GraphicsWindowWin32 not switching to the resize mouse cursors when the mouse goes close to window borders.
2008-07-31 17:47:09 +00:00
Paul MARTZ
2e11d93587 From Philip Lowman. #define WIN32_WINNT 0x400, consistent with other code in OpenThreads. Resolves a compile warning on mingw. 2008-07-31 14:43:16 +00:00
Paul MARTZ
48e70c0948 From Philip Lowman: The osgWidget/Window header file is missing a few export (declspec) declarations on some namespace functions. I noticed because MinGW is failing to link the osgwidgetbox example. 2008-07-30 15:45:28 +00:00
Paul MARTZ
38c14644d2 From Philip Lowman: Add #include <stdlib.h> for mingw build. 2008-07-30 15:37:50 +00:00
Paul MARTZ
1f7febfa92 From Glenn Waldron: Just downgrading a notify message in SpatializeGroupsVisitor ... one-line change. 2008-07-30 15:10:34 +00:00
Paul MARTZ
ed722b5fc7 From Glenn Waldron: The enum value for osgUtil::OptimizerOptions::FLATTEN_STATIC_TRANSFORMS_DUPLICATING_SHARED_SUBGRAPHS is set to 0x100, but it should probably be 0x10000. (From Paul Martz: changed enums to use "1 << n"-style values.) 2008-07-30 15:03:41 +00:00
Robert Osfield
f9fda5d081 Made 2.6 branch 2008-07-25 21:16:14 +00:00
Robert Osfield
97cb28ea8e Release OpenSceneGraph-2.6.0-rc1 2008-07-25 21:14:22 +00:00
Robert Osfield
abed295566 Updated ChangeLog and AUTHORS.txt file for relese candidate 2008-07-25 21:09:37 +00:00
Robert Osfield
5b5e3e5f78 Updated version numbers to 2.6.0 2008-07-25 21:01:57 +00:00
Robert Osfield
f2e87d6188 Updated REAME and NEWS for 2.6 branch 2008-07-25 21:00:12 +00:00
Robert Osfield
bdd558af3b Updated wrappers 2008-07-25 20:50:59 +00:00
Robert Osfield
5cac386fa6 Renamed enums in osgWidget from ALLCAPITALS to normal OSG conventional of AllCapital 2008-07-25 20:50:42 +00:00
Robert Osfield
eed365aef4 Added PluginQuery function to wrappers 2008-07-25 20:49:17 +00:00
Robert Osfield
f4d74b66cf Added OSGPL Copyright notices 2008-07-25 20:04:41 +00:00
Robert Osfield
ff5da51dcb Restructured classes to better fit with style of the rest of the OSG. 2008-07-25 19:57:17 +00:00
Robert Osfield
727925a1c2 Added include to help wrapper building 2008-07-25 19:53:18 +00:00
Robert Osfield
e525dd21bf Improved handling of PAGE_AND_RETAIN_IMAGES 2008-07-25 18:44:13 +00:00
Robert Osfield
65d5ef608d Reverted back to using std::list<std::String> 2008-07-25 17:42:37 +00:00
Robert Osfield
d137394169 Added Mode support 2008-07-25 16:23:00 +00:00
Robert Osfield
d0890ab250 Updated wrappers, and further refined the ImageSequence API 2008-07-25 16:11:51 +00:00
Robert Osfield
d8d2bc4193 From Ulrich Hertlein, "as I hinted at on osg-users in the "obj loader: map_* only reads last component" thread, this submission broke material/texture loading for some files I have that specify texture matrix scaling.
The following link shows a very comprehensive list of .mtl file options:
http://local.wasp.uwa.edu.au/~pbourke/dataformats/mtl/

Attached is a patch that should fix spacey filenames and optional texture scale/offset.  I have tested it with files I have that I modified to contain spaces in the texture filenames."
2008-07-25 15:45:40 +00:00
Stephan Maximilian HUBER
55199b8e38 From Stephan Huber: updated XCode-project 2008-07-25 15:38:12 +00:00
Robert Osfield
ec4d189b64 Added ImageSequence to .ive plugin, added support for multiple ImageThreads in osgDB::ImagePager 2008-07-25 13:45:07 +00:00
Robert Osfield
0d1656055c Moved PluginQuery from osgconv into osgDB 2008-07-25 10:18:36 +00:00
Robert Osfield
5cdb5c055c Added extension docs 2008-07-25 10:18:14 +00:00
Robert Osfield
7c6aba874b Added option docs 2008-07-25 09:46:05 +00:00
Robert Osfield
7cb4c46908 Added missing returns 2008-07-24 17:38:50 +00:00
Robert Osfield
79fbab4a95 From Paul Martz, "Not sure about the descriptions, so I left those blank. But at least "osgconv --formats" will display the .ive options now." 2008-07-24 13:25:49 +00:00
Robert Osfield
c8d3e81e08 Updated wrappers 2008-07-24 12:48:25 +00:00
Robert Osfield
2cf44741d7 Added getCurrentCamera/getCurrentRenderStage methods 2008-07-24 12:47:55 +00:00
Robert Osfield
6915bce1a2 Added a getCurrentRenderStage() and getCurrentCamera() convninience methods, and
converted the CullVisitor::apply(OcclusionQueryNode&) implementation to use the
new getCurrentCamera method.
2008-07-24 12:18:49 +00:00
Robert Osfield
53aad98d09 Improved the feedback for when a plugin isn't available. 2008-07-24 12:06:05 +00:00
Robert Osfield
7dabdf5d7e Added supportOptions() entry docs 2008-07-24 12:01:45 +00:00
Robert Osfield
efd20ea643 Added --format extname and --plugin pluginname extensions, and improved formating 2008-07-24 12:01:23 +00:00
Robert Osfield
ea309e2677 From Bob Kuehne, "fix for filenames that have spaces within their name."
Note form Robert, changed std::cout to osg::notify(osg::INFO)
2008-07-24 11:22:43 +00:00
Robert Osfield
4fe8907748 Updated wrappers 2008-07-23 22:19:37 +00:00
Robert Osfield
ec9218ad1f Refactored OverlayData so that its possible to subclass OverlayNode/OverlayData. 2008-07-23 22:19:29 +00:00
Robert Osfield
820586a3d0 Added wrappers 2008-07-23 21:52:03 +00:00
Robert Osfield
dc05f2ef95 Moved helper classes into Protected section 2008-07-23 21:49:07 +00:00
Robert Osfield
86ca0860cc From Paul Martz, typo fixes 2008-07-23 21:25:09 +00:00
Robert Osfield
bfcc7473b8 Applied filename fix suggested by Andrew Bettison. 2008-07-23 19:06:14 +00:00
Robert Osfield
daa3d2381a Implemented ImagePager internals 2008-07-23 19:04:46 +00:00
Robert Osfield
6488ff23a5 Fixed unitialized variable 2008-07-23 15:42:02 +00:00
Robert Osfield
cc2af85c96 Further work on ImageSequence 2008-07-22 20:20:16 +00:00
Robert Osfield
c9dc578186 Added support for pruning old images, recording the Duration in the .osg file, and -o filename output support in osgimagesequence. 2008-07-22 16:44:49 +00:00
Robert Osfield
66c2add024 Improved position when multiple videos are provided 2008-07-22 15:58:40 +00:00
Robert Osfield
ec13321bd7 Updated wrappers 2008-07-22 15:21:24 +00:00
Robert Osfield
669d6be0b2 Fixed handling of TextureCubeMap's with mipmapped/ImageSequence/PBO's. 2008-07-22 14:47:59 +00:00
Robert Osfield
14771d3a4d Added ImageSequence IO support in Texture classes 2008-07-22 12:40:02 +00:00
Robert Osfield
5ab73e9f80 Added support for ImageSequence to all Texture classes 2008-07-22 12:28:46 +00:00
Robert Osfield
74a1b7881e Disabled the setting of Texture::setUnrefImageOnApply(true) when the imagery is
an ImageStream.
2008-07-22 10:13:57 +00:00
Robert Osfield
f513700450 From Mario Valle, "The attached osgWidget source solves three compilation warnings on VC 7.1 on WindowsXP (OSG 2.5.5).
BTW the construct is absolutely legal C++, but VC 7.1 has a different idea..."
2008-07-22 09:02:44 +00:00
Robert Osfield
19e3b1624d Moved osgViewer::ScreenCaptureHandler's WindowCaptureCallback from head into .cpp
to clean up headers and avoid wrapper build issues.

Updated wrappers
2008-07-21 23:42:59 +00:00
Robert Osfield
e8344a614d Removed the reducent non const get methods 2008-07-21 22:38:11 +00:00
Robert Osfield
cad2f6d4fc From Jean-Sebastien Guay, "Changes attached so that the CaptureOperation is passed in the constructor of the ScreenCaptureHandler (default 0 = default CaptureOperation). This way, you can do:
viewer.addEventHandler(new osgViewer::ScreenCaptureHandler(
   new osgViewer::WriteToFileCaptureOperation("filename", "jpg")));

and the filename will be what you want. The WriteToFileCaptureOperation will add the context ID and the file number (if in SEQUENTIAL_NUMBER mode) to the file name.

(The attached also clarifies some notify messages, and corrects the comment when adding the handler in osgviewer.cpp)

I also remembered, the current architecture could allow a different CaptureOperation for each context, but currently the API only allows setting one CaptureOperation for all contexts. This could be improved if need be.

"
2008-07-21 21:28:48 +00:00
Robert Osfield
5e80c3856f From Ruth Lang, "using osg version 2.5.5 and compiling my program under OpenSUSE 11.0
with  gcc (version 4.3.1) I got the following error message in
include/osgUtil/TriStripVisitor and Tessellator

error: type qualifiers ignored on function return type

The errors belong all to a INLINE function definition. Find attached my
modified version."
2008-07-21 21:20:21 +00:00
Robert Osfield
573044ceea From Mario Valle, signed/unsgined warning fix 2008-07-21 21:17:05 +00:00
Robert Osfield
041a06b89d Further work on osg::ImageSequence/osgDB::ImagePager 2008-07-21 21:00:57 +00:00
Robert Osfield
73bcc2613c Upated version number for dev release 2008-07-21 20:44:37 +00:00
Robert Osfield
e4b22e44d2 Moved the ~Record body into the .cpp to avoid a MipsPro compile error (due to a compiler bug) 2008-07-21 19:23:03 +00:00
Robert Osfield
34a085a1bd Added call to OpenThreads::Thread::cancel(); 2008-07-21 17:45:28 +00:00
Robert Osfield
6796b4f70d Updated wrappers 2008-07-21 17:39:55 +00:00
Robert Osfield
acd7e65687 Added basic image sequencing 2008-07-21 17:28:22 +00:00
Robert Osfield
f088d113f6 Added non const getAuthenticationMap(). 2008-07-21 17:27:59 +00:00
Robert Osfield
2125c9843b Moved the if (!buffer) check to infront of the memory initialization 2008-07-21 16:17:41 +00:00
Robert Osfield
dc19bcc7e0 Added --login <url> <username> <password> http authentication. 2008-07-21 15:05:08 +00:00
Robert Osfield
7ec7b8d9cb Added --login url username password http authentication option 2008-07-21 15:04:19 +00:00
Robert Osfield
ac61676368 Initial cut of osgimagesequence example 2008-07-21 10:57:06 +00:00
Stephan Maximilian HUBER
d930308de4 From Stephan Huber: updated XCode-project 2008-07-21 10:48:14 +00:00
Robert Osfield
09e7bcdf4e Added ImagePager first cut, and updated wrappers 2008-07-21 10:10:01 +00:00
Robert Osfield
c2432b22da Added first cut of ImageStream IO wrapper 2008-07-21 09:55:15 +00:00
Robert Osfield
d12708e6f6 First cut of osgDB::ImagePager for updating osg::ImageSequence 2008-07-21 09:47:39 +00:00
Robert Osfield
d17a255d8e First cut of osg::ImageSequence class 2008-07-21 09:46:53 +00:00
Robert Osfield
3814731c27 From Adrain Elgi, added osgGA to link list 2008-07-18 21:17:35 +00:00
Robert Osfield
18e9d2d53b Introduce a custom atof function that always assumes data comes in form 10.10 with
the full stop used as a decimal place.
2008-07-18 11:39:06 +00:00
Robert Osfield
46796978fd From Jean-Sebastien Guay and Robert Osfiled, osgViewer::ScreenCaptureHandler for
taking screenshots
2008-07-17 16:12:39 +00:00
Robert Osfield
198ae2ba56 Updated version and AUTHORS.txt for 2.5.5 release 2008-07-17 14:25:04 +00:00
Robert Osfield
c7b2578d5f Updated ChangeLog for 2.5.5 release 2008-07-17 14:18:59 +00:00
Robert Osfield
43e2c5fadf Updated wrappers 2008-07-17 14:13:13 +00:00
Robert Osfield
4aed0a7eac From Ulrich Hertlein, "attached are some minor tweaks:
- fixed typos in osgViewer/ViewerBase
- const-ness in include/osg/View findSlaveIndexForCamera
- supported options for STL reader, fixed return values to reflect proper errors
- supported options for DirectX reader, fixed return values
- normals pseudo-loader: scaling normals to a const (but variable) fraction of the bounding sphere radius
"
2008-07-17 13:51:14 +00:00
Robert Osfield
dd9364df0e Updated ChangeLog 2008-07-17 13:32:47 +00:00
Stephan Maximilian HUBER
1274feb66b From Stephan Huber: updated XCode project 2008-07-17 13:23:43 +00:00
Robert Osfield
8751bdbc97 Updated wrappers 2008-07-17 12:26:42 +00:00
Robert Osfield
969884e6c2 Moved AuthenticalMap/AuthenticationDetails out in their own files 2008-07-17 12:13:04 +00:00
Robert Osfield
adaf71fa19 Added osgDB::AuthenticationMap/Details to osgDB and curl plugin to add the ability
to authenticate http transfers
2008-07-17 11:55:55 +00:00
Robert Osfield
a6c72dc21c Removed net plugin for Xcode projects 2008-07-16 19:07:01 +00:00
Robert Osfield
cacb509f60 Moved .net plugin out into Deprecated section of osg svn repostitory 2008-07-16 16:19:54 +00:00
Robert Osfield
b0d1f419e3 Fixed path to font 2008-07-16 16:19:19 +00:00
Robert Osfield
2fefc911fd Set the default setting of LineWidth to 2.0 to ensure that old default behavior
is maintained.
2008-07-16 16:05:43 +00:00
Robert Osfield
c3a4237e3a From Vincent Bourdier, removed line with setWidth(2.0) as this code prevents
user settings of line with.
2008-07-16 16:04:27 +00:00
Robert Osfield
c33f7e5720 Cleaned up the updateStateSet code 2008-07-16 15:58:51 +00:00
Robert Osfield
b068777c22 Refactored the MultiTextureControl node callback so that the update is now
done as an update callback, with the elevation aquired via a cull callback
2008-07-16 15:58:15 +00:00
Robert Osfield
270a671c75 Updated wrappers 2008-07-16 13:29:35 +00:00
Robert Osfield
5f0f80cab2 Changed int's to unsigned int's to avoid warnings 2008-07-16 13:26:06 +00:00
Robert Osfield
850034ab75 Moved the _textureObjectBuffer assignment to after the imagery has been download to avoid crashes under multi-threaded compile of texture objects (was causing a crash with 3D Textures, but is something that would happen with other Texture types as well.) 2008-07-16 13:23:58 +00:00
Stephan Maximilian HUBER
ccf22f6a15 From Stephan Huber: updated XCode-project, included osgWidget-Framework 2008-07-16 12:53:58 +00:00
Robert Osfield
41bd615f3a Removed a division by precomputing the associated values 2008-07-16 11:40:01 +00:00
Robert Osfield
a20e5791d9 From Jeremy Moles, Updated file references to reflect new data in OpenSceneGraph-Data 2008-07-15 22:30:51 +00:00
Robert Osfield
a8cb408213 Added osgWidget wrappers 2008-07-15 22:13:35 +00:00
Robert Osfield
8fe0820bb8 Converted tabs to four spaces 2008-07-15 22:03:59 +00:00
Robert Osfield
e6c99b0434 Fixed typo 2008-07-15 21:28:22 +00:00
Robert Osfield
e9368c6fa3 Moved the private sections int protected to allow subclasses acces to all methods/members.
Moved public section to top of the class definition to make it more consistent with the rest of the OSG.
2008-07-15 20:30:56 +00:00
Robert Osfield
a383f7ee34 Fixed name of lib 2008-07-15 19:42:49 +00:00
Robert Osfield
47255490a9 Changed IMPORT to "Import option", and "EXPORT:" to "Export option:" in supportsOptions() docs make it a little more friendly and understandable 2008-07-15 19:28:30 +00:00
Robert Osfield
115787f8e9 From Paul Martz, "Here's documentation for the export options of the FLT plugin. I also labeled the import options as such." 2008-07-15 19:26:20 +00:00
Robert Osfield
f4cb039a3c Updated version number to 2.5.5 in prep for dev release 2008-07-15 19:24:48 +00:00
Robert Osfield
abe16fa571 Changed the version setup code to be consistent with the rest of the OSG 2008-07-15 19:24:22 +00:00
Robert Osfield
b343cbfc5f Removed now redundent example 2008-07-15 19:23:48 +00:00
Robert Osfield
c989b98f2e From Gino van den Bergen, "The VRML plugin in the current 2.5.4 release will not compile under VC8.0 when the project file is generated using CMake 2.6. The attached CMakeLists.txt will fix this problem. The file replaces the CMakeLists.txt file in src/osgPlugins/vrml.
NB: It is assumed that the antlr and regex libs are located in $(OPENVRML_DIR)/lib.
 "
2008-07-15 19:02:20 +00:00
Robert Osfield
f1138fa684 From Jean-Sebastian Guay, "Here are the CMakeLists.txt files for the osgWidget examples, changed to use SETUP_EXAMPLE like the other examples." 2008-07-15 18:53:16 +00:00
Robert Osfield
43cedf9eb4 Fixed typo 2008-07-15 18:12:17 +00:00
Robert Osfield
c2b77aa08e From Jeremy Moles, import of the osgWidget NodeKit, sourced from the original http://osgwidget.googlecode.com/svn/trunk
Notes from Robert Osfield, I've merged osgWidget trunk, and added/changed CMakeLists.txt file to make it suitable for inclusion in the core OSG, and moved imagery/scripts/shaders out into OpenSceneGraph-Data
2008-07-15 17:21:25 +00:00
Robert Osfield
0c3d119cea Updated wrappers 2008-07-15 14:24:46 +00:00
Robert Osfield
35bc9c7dd2 From Art Trevs, Removed GLeunm version setAttachment() to avoid ambigiuity with
whether to enable MRT.
2008-07-15 14:24:21 +00:00
Robert Osfield
c88d34ee97 Renamed Archive::ArchiveStatus to ReaderWriter::ArchiveStatus 2008-07-15 14:15:42 +00:00
Robert Osfield
59f6e0cdcf Updated wrappers 2008-07-15 10:45:07 +00:00
Robert Osfield
3e96a9d448 Missing check-ins 2008-07-15 09:55:33 +00:00
Robert Osfield
f22c06acbe Added --plugins and --formats query support into osgconv to help with querying the
available plugins and the file formats/protocols they support
2008-07-14 20:22:38 +00:00
Robert Osfield
5ab4af80c5 Added missing ac3d supportsExtensions() constructor 2008-07-14 20:11:37 +00:00
Robert Osfield
042c823278 Added initial cut at plugin query code 2008-07-14 08:48:49 +00:00
Robert Osfield
02b456bcfa Converted plugins to use the new supportsExtension()/supportsOptions/supportsProtocl() methods
to help enable better querying of supported features
2008-07-13 22:18:59 +00:00
Robert Osfield
cb98cddc31 Added new ReaderWriter methods for recording what protocols, extensions and options are
support by ReaderWriters
2008-07-13 15:24:45 +00:00
Robert Osfield
6aa604f31a From Paul Martz, removed uneccessary libraries from link line 2008-07-13 12:34:06 +00:00
Robert Osfield
8babab1f42 Updated date for 2.5.4 release 2008-07-12 17:44:51 +00:00
Robert Osfield
a3e28a795f Added an OSG_EXPORT 2008-07-12 17:30:17 +00:00
Robert Osfield
bbc98be4f9 Updated Authors for dev release 2008-07-12 16:11:14 +00:00
Robert Osfield
a2f9aef0fc Updated ChangeLog for dev release 2008-07-12 15:29:30 +00:00
Robert Osfield
4ca61c38f0 From Doug McCorkle, "Attached is patch that corrects/improves the following issues with the OBJ loader:
1. Added options to control wether the osgUtil::Tessellator or osgUtil::TriStripVisitor are run. By default they still run just as before.
2. Added support for the Emissive material. The data was being read from the mtl file but was never being applied to the model.
3. This is the main bug addressed, when a model is read in with an alpha value specified like:

newmtl Material__8
       Ns 24
       d 0.33
       illum 2
       Kd 0.204 0.204 0.204
       Ks 0 0 0
       Ka 0.153 0.153 0.153

where the alpha value is d. The loader would then overwrite the alpha value when reading the diffuse, specular, and ambient colors. I have changed all the material color readers to only set the values they read and to use the default colors specified in the constructor of the obj class. With these changes, the obj reader now handles opacity correctly if the alpha value is specified before the material colo"
2008-07-12 12:00:58 +00:00
Robert Osfield
ccb50019e4 Cleaned up osgkdtree example 2008-07-12 11:19:25 +00:00
Robert Osfield
de33a031d4 Updated version numbers for dev release 2008-07-11 20:01:12 +00:00
Robert Osfield
2b5708888e From Adrain Egli, "i added a default scene with 7 different draggers attached. it's more easy to test the draggers." 2008-07-11 19:52:25 +00:00
Robert Osfield
360e7629d0 From Christophe Loustaunau, "For our application, we need to write tiff file in floats. I have change a little bit the readerWritterTiff :
It check the data type of the image ( img.getDataType() ) and if it's GL_FLOAT :It save the tiff with float values.
Otherwise it does the same thing as before."
2008-07-11 19:43:01 +00:00
Robert Osfield
0e2dea9a39 From Liang Aibin, " In lastest svn version of OSG, the .ive plugin missing osg::Light, it
does not process I/O for osg::Light. Now I have fixed it as follows:
 
2. In DataInputStream.cpp, I add support code in DataInputStream::readStateAttribute
    for osg::Light.
 
3. In DataOutputStream.cpp, I add support code in DataOutputStream::writeStateAttribute
    for osg::Light.
 "
2008-07-11 19:23:49 +00:00
Robert Osfield
ef1ee63f03 From Joakim Simmonson,
"Opcodes.h:
* Added INVALID_OP as -1 in the Opcodes enum. Note that INVALID_OP is not an actual opcode defined in the OpenFlight format. The purpose of INVALID_OP is to mark an opcode variable as invalid or uninitialized.

ReaderWriterFLT.cpp:
* The header node is returned if it exists, even if the file does not contain a node hierarchy. The old behaviour returned a ERROR_IN_READING_FILE error.
* Changed opcodes initialized to -1 to the new enum value INVALID_OP."
2008-07-11 17:46:30 +00:00
Robert Osfield
1489eeb228 From Joakim Simmonsson, fixed various spelling typos in comments 2008-07-11 17:41:50 +00:00
Robert Osfield
161e01dc5d From Mathias Froehlich, "Due to the recent data variance changes/discussion:
Change the ac3d loader that can as such only deliver static models to set the
data variance to static for the returned model.
"
2008-07-11 17:35:13 +00:00
Robert Osfield
45b2fb8db7 Increased the buffer and fixed the buffer calculation when moving backwards into objects 2008-07-11 17:07:05 +00:00
Robert Osfield
61a81d8e06 Updated KdTree code to refect new cleaned up API 2008-07-11 16:51:11 +00:00
Robert Osfield
9866eb93f8 Tweaked the KdTree intersection performance testing code block 2008-07-11 16:50:43 +00:00
Robert Osfield
8a6c25425e Updated wrappers 2008-07-11 16:48:55 +00:00
Robert Osfield
a856459a86 Moved the building and intersecting of the KdTree into the .cpp, and cleaned up
the header to ready it for wider usage
2008-07-11 16:48:39 +00:00
Robert Osfield
d3fd43cc6f Streamlined KdTree implementation 2008-07-10 15:50:10 +00:00
Robert Osfield
29d66125e2 Updated wrappers 2008-07-09 19:43:02 +00:00
Robert Osfield
8edee96275 Cleaned up KdTree implementation 2008-07-09 19:42:15 +00:00
Robert Osfield
7be3d1ae02 Reordered KdLeaf/KdNode so that the first element to be accessed is first in the data structure 2008-07-09 19:41:36 +00:00
Robert Osfield
c41ca3d6a0 Introduced code for doing dummy test traversals - used for benchmarking KdTree code. 2008-07-09 19:40:10 +00:00
Robert Osfield
15e5bdbcae Added range of camera manipulators and a center of screen test intersection that
is insticated by pressing 'c' key
2008-07-09 19:28:00 +00:00
Robert Osfield
cbf5429c19 Introduce a intersecion performance testing code path, #if def'd out for now. 2008-07-09 19:26:40 +00:00
Robert Osfield
a00f94ac18 Updated wrappers 2008-07-09 12:37:59 +00:00
Robert Osfield
ee9b23f670 Fixed set method 2008-07-08 18:02:09 +00:00
Robert Osfield
2851429333 Added optional control of whether to use KdTrees for intersections 2008-07-08 17:35:10 +00:00
Robert Osfield
134c86c2d5 Implement hierachy culling in KdTree::intersect(..) 2008-07-07 20:27:56 +00:00
Robert Osfield
f1db402f2b Improved the handling of KdTree intersections 2008-07-07 14:27:58 +00:00
Robert Osfield
d05236bfb4 Implemented intial KdTree triangle intersection code, but without culling implemented 2008-07-07 13:21:37 +00:00
Robert Osfield
e8487b8830 Added KdTreeBuilder calls into FindCompileableGLObjectsVisitor, and an alternative
path that explictly calls the KdTreeBuilde when required in cases when no pre compile of GL objects is required.
2008-07-07 10:46:22 +00:00
Robert Osfield
682be50e2a Changed types to avoid warnings under Windows 2008-07-07 09:40:30 +00:00
Robert Osfield
c4e8d6ee42 Changed the DatabasePager so that it bypasses the Registry::readNode() method and calls
readNodeImplementation() directly to avoid calling the KdTreeBuilder.   

Updated wrappers.
2008-07-06 18:27:10 +00:00
Robert Osfield
3965fe357b Moved KdTree build code into osg::KdTree 2008-07-06 12:14:19 +00:00
Robert Osfield
10595e49e3 Added handling of co-incident start and end points. 2008-07-05 17:29:07 +00:00
Robert Osfield
9a9c543ffa Ported intersection code to use new osgUtil::LineSegmentIntersector/IntersectionVisitor. 2008-07-05 16:39:28 +00:00
Robert Osfield
e70e3a6d5d Converted TerrainManipulator to use osgUtil::InterectionVisitor rather than the
old IntersectVisitor
2008-07-04 19:16:19 +00:00
Robert Osfield
db57d2504e Added KdTree intersection support into LineSegmentIntersector 2008-07-04 17:02:02 +00:00
Robert Osfield
44d144997e Added prelimnary KdTree data structure and automatic kdtree build support
into osgDB::Registry/osgTerrain so that newly created subgraphs can have 
KdTree built on all osg::Geometry automatically on load/creation.
2008-07-04 15:57:48 +00:00
Robert Osfield
bc1032653c Moved vertex indicies method into a single block with deprecated doc lines 2008-07-04 11:51:55 +00:00
Robert Osfield
e2ae39c8f6 Introduced bounding boxes to KDLeaf and KDNode structs 2008-07-03 17:18:14 +00:00
Robert Osfield
178d6ff423 Added new data structure + build algorithm that places triangles into leaves
without being shared, but with varying the boundaries of leaves so that they
may overlap.
2008-07-03 15:49:28 +00:00
Robert Osfield
3f025bec5d From Mario Valle, "xed the following warning on Linux 64 bits Athlon:
/users/mvalle/OSG/OpenSceneGraph/src/osg/BufferObject.cpp: In member function `virtual void osg::ElementBufferObject::compileBuffer(osg::State&) const':
/users/mvalle/OSG/OpenSceneGraph/src/osg/BufferObject.cpp:600: warning: cast to pointer from integer of different size"
2008-07-03 15:01:04 +00:00
Robert Osfield
14c86a5389 From Mario Valle, removed extraneous spaces 2008-07-03 14:59:07 +00:00
Robert Osfield
7db303b16b Added header guards 2008-07-03 11:23:44 +00:00
Robert Osfield
f0defbd824 Refactored example so that the example will be able to run different kdtree data strucutres/algorithms. 2008-07-03 11:22:23 +00:00
Robert Osfield
d62a4ef6d0 From Eric Sokolowsky, "The check for Leopard to build 4-way binaries by default was broken. Here is an updated CMakeLists.txt file to fix the problem." 2008-07-03 11:07:59 +00:00
Robert Osfield
1729ec0819 Implement an experiemental triangle kdtree building support 2008-07-03 10:24:20 +00:00
Robert Osfield
45d5376503 Set the DataVariance on FadeText to DYNAMIC to reflect their nature 2008-07-03 10:03:06 +00:00
Robert Osfield
a65b74d287 Updated wrappers 2008-07-02 10:00:09 +00:00
Robert Osfield
201522feb3 Introduced support for UNSCPECIFIED and STATIC DataVariance of StateSet/Textures 2008-07-02 09:25:08 +00:00
Robert Osfield
aa593fcd2d From Colin McDonald, "There is a problem reading bmp files containing a colour palette,
due to an incorrect scan line length calculation.  Attached is a fix,
and a little bmp file which demonstrates the problem."
2008-07-01 19:04:29 +00:00
Robert Osfield
dba344feba From Lilin Xiong, "I change ive plugin a little for osgText inout, so the ive plugin supports backdrop setting,
and Text3D, FadeText inout :

1. in DataInputStream.cpp, add 1286--1293 lines;
2. in Text.cpp, add some code for text's Backdrop setting;
3. in IveVersion.h, add line 39,  increase the VERSION to VERSION_028(line 41)
4. in ReadWrite.h,  add line 146,147
5. add file FadeText.h, FadeText.cpp, Text3D.h, Text3D.cpp."
2008-07-01 18:37:13 +00:00
Robert Osfield
82ed445a31 Added Vec3Array arrange pointer to avoid dynamic cast 2008-07-01 13:56:02 +00:00
Robert Osfield
c6ba70e3ad From Mathias Froehlich, "It appears not to be sufficient to set a cmake variable to get a define in
such a config file. Instead set that variable to 1. Also included a small compile fix, that appears to be required  than ..."
2008-07-01 09:40:06 +00:00
Robert Osfield
bec0fc9c32 Added guards against FBO not being supported/setup 2008-06-30 16:53:06 +00:00
Robert Osfield
55ea6e5e23 Updated README date for 2.5.3 dev release 2008-06-29 13:41:07 +00:00
Robert Osfield
5e0169f664 Changed the Optimizer::StateVisitor so that it can individually decide whether
to optimize away duplicate state with dynamic, static and unspecified DataVarience.  By default
the code now optimizes away duplicate state with either static and unspecied state, previously 
it was just handling static state.
2008-06-29 12:22:50 +00:00
Robert Osfield
8820d0bb1d Added realize of new graphics contexts to handle new views being added with
unrealized windows
2008-06-28 16:59:26 +00:00
Robert Osfield
fec2a8fabe Changed back to use an std::vector<> rather than a std::list for RequestQueue to
avoid member template problems under Solaris.
2008-06-27 19:40:52 +00:00
Robert Osfield
a9b05e0815 Refactored the sort of the requestQueue so that there is single code path for doing the sort. 2008-06-27 18:59:27 +00:00
Robert Osfield
214491dd94 From Mathias Froehlich, "Update to the configure check for msvc 7.1.
MemoryBarrier() is used in the implementation, so it should be checked.
This in effect disables the faster atomic ops on msvc 7.1 and older, even if
only the MemoryBarrier() call is missing. But it ensures for the fist cut
that it will build everywhere. If somebody cares for msvc 7.1 enough and has
one for testing installed, he might provide the apropriate defines to guard
that MemoryBarrier() call.

I tested that msvc8 32/64bit still passes the configure tests and compiles.
"
2008-06-27 16:47:43 +00:00
Robert Osfield
1057d74a11 Simplified the MixinVector class so that it no longer supports custom allocators,
instead just uses std::vector<>'s default allocators.
2008-06-27 12:44:41 +00:00
Robert Osfield
34f58482e6 Moved the apply(&) default implementations from the header into the NodeVisitor.cpp,
and changed the casts to use static_cast<>.
2008-06-27 12:35:56 +00:00
Stephan Maximilian HUBER
46931464ef from Stephan Huber: updated XCode project 2008-06-27 11:47:06 +00:00
Robert Osfield
9a80c331a2 From Andre Normann, "with version 8504, I am not able to compile osgwrappers under Windows, because there are some DLL export macros missing. I fixed it and put the files in the attached zip file.
"
2008-06-27 10:17:38 +00:00
Robert Osfield
1a8017fecf Updated authors and osgversion 2008-06-26 19:51:24 +00:00
Robert Osfield
1b433f808b Updated ChangeLog 2008-06-26 19:47:00 +00:00
Robert Osfield
6d53566654 Updated wrappers 2008-06-26 19:21:54 +00:00
Robert Osfield
8dc1143263 From Paul Martz, "The method IntersectionVisitor::apply(osg::PagedLOD&) appears to attempt to identify a "highest res" child of the PagedLOD and only allow intersection on that child. The implementation appears to be flawed in two cases:
1) The "highest res" child is assumed to be the child with index "getNumFileNames()-1" or "getNumChildren()-1". As a result, PagedLODs that do not sort children from furthest to nearest will intersect with the wrong child. (see attached "case1.osg" to reproduce this problem.)
 
2) The code assumes there is only one highest res child. As a result. PagedLODs with multiple children at the same highest res range can only intersect one of those children. ("case2.osg" demonstrates this issue; you can only pick the quad on the right.)
 
I've attached a modified IntersectionVisitor.cpp that attempts to resolve these issues. It identifies a highest res range based on the range mode, then continues traversal on all valid children corresponding to that range description. Only in the case of a malformed PagedLOD does the code fall back to getting the last child in the list.
 "
2008-06-26 18:34:01 +00:00
Robert Osfield
f523515aed From Morten Haukness, "When cloning effects osg crashes because the copy constructur tries to run av pure virtual method (setUpEmitterAndProgram). The right thing to do when cloning an effect is to run the inherited version og buildEffect and setUpEmitterAndProgram.
"
2008-06-26 18:06:24 +00:00
Robert Osfield
44c125a801 Changed the removeCamera() method so that it now actively calls releaseGLObjects()
on all children of a camera that aren't shared with other cameras on that context.

This change fixes problems with allocating and deleting views.
2008-06-26 16:45:50 +00:00
Robert Osfield
53636db5bc From Mathias Froehlich, updated CMakeLists.txt to build the Atomic.cpp 2008-06-26 15:06:44 +00:00
Robert Osfield
e48fad59dd From Eric Sokolowski, added enforcement of CMake 2.6.0 under OSX. 2008-06-26 13:09:54 +00:00
Robert Osfield
12044a43d9 From Eric Sokolowski, Cmake support for osgviewerCocoa 2008-06-26 13:08:24 +00:00
Robert Osfield
260d0d384f From Mathias Froehlich, build fixes for various unices 2008-06-26 12:08:37 +00:00
Robert Osfield
c32ee85d3d From Mathias Froehlich, added do not edit comments to Config.in so that the autogenerated
Config files have an appropriate warning notice
2008-06-26 10:33:47 +00:00
Robert Osfield
5a4ce5a387 From Mathias Froechlich, "Attached is a change to that atomic stuff to move the win32, msvc
implementation of the atomic increment and decrement into a implementation
file.
This way inlining and compiler optimization can no longer happen for these
implementations, but it fixes compilation on win32 msvc targets. I expect
that this is still faster than with with mutexes.

Also the i386 gcc target gets atomic operations with this patch. By using an
implementation file we can guarantee that we have the right compiler flags
available."
2008-06-26 10:27:16 +00:00
Robert Osfield
37765805ff Fixed pedantic warning 2008-06-23 15:11:37 +00:00
Robert Osfield
0b6e605795 From Mathias Froehlich, "fixed win32/win64 configure check and win32/win64
atomic related compile failures with msvs2005. Attached changes to make win32
really use the atomic stuff. There are pointer typecast problems and some
historic alignment restrictions that I just took from a previous similar
implementation of mine without looking deep enough. "
2008-06-23 14:51:34 +00:00
Robert Osfield
62fb2d4634 From Mathieu Marache, "Suibject: CMakeList ADD_DEFINITION for CMAKE_DEBUG_POSTFIX broken
I needed a -DCMAKE_DEBUG_POSTFIX="d" not a -D"CMAKE_DEBUG_POSTFIX=d".

This corrects the build for the CMake 2.4 and 2.6 series

The error was in compiling osgDB/Registry.cpp
"
2008-06-23 11:14:06 +00:00
Robert Osfield
87b74c1f54 Commented out the explict install of the Config files as including these files into
the header list allows the normal Cmake install support to install them.
2008-06-23 10:18:04 +00:00
Robert Osfield
275811d02a From Eric Sokolowsky, "I have made a number of changes intended to get a few things working better on OSX. However, since I'm still pretty new at Mac development and cmake I'm not entirely certain that the changes I have made are benign on other platforms. I have tested these changes on Leopard with CMake 2.6 generating Xcode 3.0 projects, compiling on ppc and i386 for 10.5 and 10.4, and on Linux (CentOS) and everything still seems to work ok. Here are the changes I made (against OSG svn as of this afternoon):
- Added osgviewerCocoa example to APPLE builds
- Fixed corrupt Xcode project generation with CMake 2.6 dealing with ADD_DEFINITIONS and CMake Policy CMP0005 on Leopard
- Resolved CMP0006 warning for examples and programs by setting BUNDLE DESTINATION to same as RUNTIME DESTINATION with CMake 2.6
- Fixed freetype plugin on Leopard to avoid OpenGL linking problem
- Figured out how to use a custom Info.plist included in the project (see osgviewerCocoa application CMakeLists.txt)"
2008-06-23 09:57:45 +00:00
Stephan Maximilian HUBER
6766039ef7 From Stephan Huber: added missing config files and updated xcode-project 2008-06-23 08:06:07 +00:00
Robert Osfield
1e3183a355 Quietened down debug info 2008-06-21 17:56:38 +00:00
Robert Osfield
af271f99ec Added support for X11's overrideRedirect functionality 2008-06-21 17:50:58 +00:00
Robert Osfield
113a77b219 Converted tabs to four spaces 2008-06-21 11:34:01 +00:00
Robert Osfield
415d45525c Changed the include/osg/Config and include/OpenThreads/Config references to use the assocaited CMake variable for these headers 2008-06-20 19:52:14 +00:00
Robert Osfield
e56ff4d5c6 Updated ChangeLog 2008-06-20 19:51:21 +00:00
Robert Osfield
ff811736fc From Terry Welsh, added missing MixinVector header 2008-06-20 17:32:27 +00:00
Robert Osfield
779a7c46ac Added OSG_WINDOWING_SYSTEM cmake option string to allow toggling between X11 and Carbon under OSX. 2008-06-20 16:57:22 +00:00
Robert Osfield
a71939c5bb From Mathias Froehlich, moved optional config variables into include/osg/Config file that
is automatically created by cmake according to its own settings.
2008-06-20 15:50:53 +00:00
Robert Osfield
7b19b987ec Updated ChangeLog 2008-06-20 15:49:15 +00:00
Robert Osfield
8aa7c330f8 Changed const double* to const Matrix::value_type* to ensure changes in Matrix type don't break the build 2008-06-20 15:28:38 +00:00
Robert Osfield
be185cb3af From Terry Welsh, new flatten static transforms visitor that duplicates subgraphs that are shared beneath differnt static transforms
From Robert Osfield, made a range of changes to Terry's visitor integrating it into osgUtil::Optimizer and 
changing the code to use a style more like the rest of the OSG.
2008-06-20 13:16:35 +00:00
Robert Osfield
ce13510b47 From Mathias Froehlich, made the include of bin directory for include/OpenThreads/Config only used when doing out of source builds 2008-06-20 11:16:06 +00:00
Robert Osfield
bc6e5b5da2 Updated version numbers for dev releases 2008-06-20 11:11:47 +00:00
Robert Osfield
0e7920f144 From Mathias Froehlich, "Fixes a compile of src/osgSim/ShapeAttribute.cpp on suse 10.2." 2008-06-20 10:46:33 +00:00
Robert Osfield
3672ba51e7 From Melchior Franz, fixed typo on variable name 2008-06-20 09:46:45 +00:00
Robert Osfield
5db501941d From Mathias Froehlich, add search path to enable out of source builds to find include/OpenThreads/Config. 2008-06-20 09:42:57 +00:00
Robert Osfield
96a80666c9 Updated wrappers 2008-06-19 20:42:10 +00:00
Robert Osfield
2011028ee7 From Neil Groves,
"I have taken the liberty of updating a few files so that there is no longer any derivation from std::vector. I have done this by adding a new file osg/MixinVector and by updating only two others: osg/PrimitiveSet and osg/Array. You will notice that this actually removes what is acknowledged as a \u2018hack\u2019 in osg/PrimitiveSet.

With the original code I did manage to find memory leaks with some compiler options on VC 8 and 9, as well as Intel compiler. I determined the leak existence by instrumenting the destructor code, and by use of a garbage collector as a leak detector (in a similar manner to the Firefox project). Hence in contrast to what I said originally, it is exhibiting symptoms on at least some platforms.

Since I am trying to be a good OSG citizen I got out my editor and started hacking! I have built and tested on Linux (Ubuntu) with GCC 4.x and Windows VC 8 SP1. It appears that nothing is broken, and that I\u2019m using less memory J"
2008-06-19 20:38:38 +00:00
Robert Osfield
d6469b87c1 From Mathieu Marache, "submission for inclusion to support mpg and avi files when using the quicktime plugin on windows" 2008-06-19 17:35:45 +00:00
Robert Osfield
936edacc92 From Mathias Froehlich, added support for using OpenThreads::Atomic for thread safe ref/unref. 2008-06-19 17:30:38 +00:00
Robert Osfield
2ba5f002d2 from Andrew Bettison, LineStipple support for .ive 2008-06-19 14:57:36 +00:00
Robert Osfield
0faaf93dc2 From Adrian Egli, "Improvements to the PSSM implementation" 2008-06-19 14:45:54 +00:00
Robert Osfield
cc9d12f34f From Rudolf Weidemann, "in the OpenFlight format materials can have editable names.
In the OSG OpenFlight plugin these names are ignored when reading, and
empty strings are written.

As we need these names in the OSG scene graph by our application, I
changed the plugin code, so the names are now stored in class
"osg::Material" (derived from "osg::Object") by
 material->setName();
(see "PaletteRecords.cpp, line 195) when reading the file, and written
to file by
 dos.writeString( m.Material->getName(), 12 );
(see MaterialPaletteManager.cpp, line 80).

As these names otherwise get lost when reading an OpenFlight file and
writing it again e.g. by
 osgconv example.flt converted_example.flt
these changes make the plugin more complete.

The changes were made to OSG revision 8425, and were tested by
 osgconv example.flt converted_example.flt
comparing the material palettes of both files inside Multigen Creator."
2008-06-19 14:35:18 +00:00
Robert Osfield
dd13893861 From Farshid Lashkari, "I noticed some problems when setting up CameraNodes that inherit
viewport settings in stereo mode. It seems that the SceneView::cull()
method will pass the full size viewport to the left/right
cullvisitors, instead of the modified stereo viewport. I made quite a
few changes to SceneView to fix the issue. The SceneView::cullStage()
method will now receive the viewport as an argument, instead of using
the global viewport. The SceneView::cull() method will pass the
modifed viewport to cullStage when rendering in stereo.

There are 2 new private methods computeLeftEyeViewport() and
computeRightEyeViewport() that will compute the stereo viewports. I
also modified the draw() function so it applies the correct viewport
to the prerender stages. These changes are only necessary for
horizontal/vertical split stereo."
2008-06-19 14:29:38 +00:00
Robert Osfield
c3c727b822 From Andrew Bettison, "Attached are changes for src/osgPlugins/ive (version 2.4.0) that implement LineStipple read/write support for the ive file format." 2008-06-19 14:14:20 +00:00
Robert Osfield
37d81679b7 From Paul Melis, "Here is a reworked version of the osgviewerWX example. It changes the GraphicsWindowWX to only inherit from osgViewer::GraphicsWindow and adds a standalone widget, called OSGCanvas, that derives from wxGLCanvas. This solves a problem with the GraphicsWindowWX instance being destructed twice (see "Crash in osgviewerWX" of June 12th on osg-users). At program exit, the main frame deletes all of its children widgets and therefore calls GraphicsWindowWX's destructor, bypassing OSG's reference counting. The GraphicsWindowWX instance is then later destructed a second time when the reference held by osg::Camera goes to zero. This bug isn't exposed by the example directly, but if people are going to use the example as a basis (like the poster in the mentioned thread) they very likely will run into this problem.
"
2008-06-19 13:49:36 +00:00
Robert Osfield
4c9b3de4a1 Updated wrappers to fix OpenThreads::Atomic build issues. 2008-06-19 13:28:33 +00:00
Robert Osfield
a94cfccdce From Michael Platings, fixed typo error in renderbin assignment 2008-06-19 12:02:20 +00:00
Robert Osfield
061be3d084 In Program::PerContextProgram changed const Uniform* to osg::ref_ptr<const Uniform*> to avoid the possibility of a uniform being deleted
and another being created and assigned at the same address which previously confused the uniform tracking code and introduced a bug.
2008-06-19 11:58:34 +00:00
Robert Osfield
174f9bbfe0 From Michael Platings and Robert Osfield, added support for controlling,
via StateSet::setNestedRenderBin(bool) whether the new RenderBin should be nested
with the existing RenderBin, or be nested with the enclosing RenderStage.
2008-06-19 11:09:20 +00:00
Robert Osfield
0abf539b60 Updated wrappers 2008-06-18 20:27:06 +00:00
Robert Osfield
f06d50a7eb From Michael Platings, implemented check against max number of supported samples to ensure that the number of samples is safely capped to what the hardware is capable of, avoiding GL errors and graceful fallback 2008-06-18 20:24:12 +00:00
Robert Osfield
45fcb25765 From Liang Aibin:
"1. Location: <OSG_SOURCE_ROOT>\src\osgPlugins\osg\Fog.cpp
   Reason: ".osg" writter plugins output incorrected string for osg::Fog's Mode.
   How to Fix:
     Line 138 in Fog.cpp: case(Fog::LINEAR): return "NERVER";
     Change to:           case(Fog::LINEAR): return "LINEAR";
2. Location: <OSG_SOURCE_ROOT>\src\osgPlugins\ive\
   Reason: ".ive" writter plugins missing to process "osg::Fog".
   How to Fix:
   (1). Line 86 in ReadWrite.h:
        Add: #define IVEFOG                          0x00001133
   (2). In CMakeLists.txt
        "SET(TARGET_SRC" section Add: Fog.cpp
        "SET(TARGET_H" section Add: Fog.h
   (3). In DataInputStream.cpp
        Line 54,Add:    #include "Fog.h"
        Line 1185,Add:  else if(attributeID == IVEFOG){
                            attribute = new osg::Fog();
                            ((ive::Fog*)(attribute))->read(this);
                        }
   (4). In DataOutputStream.cpp
        Line 57,Add:    #include "Fog.h"
        Line 832,Add:   // This is a Fog
                        else if(dynamic_cast<const osg::Fog*>(attribute)){
                            ((ive::Fog*)(attribute))->write(this);
                        }
   (5). Add newly created ive::Fog Object in Fog.h and Fog.cpp.
"
2008-06-18 20:17:13 +00:00
Robert Osfield
0a0034aebb Updated wrappers 2008-06-18 16:46:38 +00:00
Robert Osfield
1e5783ece7 Added a wrapString(const char*) which automatically handles null strings. 2008-06-18 16:45:21 +00:00
Robert Osfield
959c01557c Convert string handling to use strdup and free rather then awkward new char[]
code paths
2008-06-18 16:28:52 +00:00
Robert Osfield
7ae28bea0d Added --fbo-samples value and --color-samples value command line paramters for enabling fbo multisampling 2008-06-18 14:21:22 +00:00
Robert Osfield
90ea0bd95f From Michael Platings and Paul Palumbo, multi-sample FBO support 2008-06-18 14:09:11 +00:00
Robert Osfield
7bef1bd16a From Jean-Sebastien Guay, "When copying a node that had uniforms on it, the copy constructor of osg::Uniform would not copy the array of the original uniform (either _intArray or _floatArray) because none had been allocated and the copy constructor checks that *both* this's array and rhs's array are valid.
I added a call to allocateDataArray() if rhs has (at least) one valid array, which should allocate the right array according to the type. Since the type was copied from rhs, it should create the same array as rhs has, so then it should copy the data in the following lines.
"
2008-06-18 12:01:52 +00:00
Robert Osfield
df87106d4b From Bob Kuehne, "added multi-texture support (alpha/trans images)" 2008-06-18 11:56:50 +00:00
Robert Osfield
b82e24b08d Updated wrappers 2008-06-18 11:51:22 +00:00
Robert Osfield
dd137c2442 From Bob Kuehne, "this submission extends the osgViewer::RecordCameraPathHandler to have an optionally-enabled auto-incrementing filename. default behavior is still the same, but there's one new method to enable autoincrementing filenames."
From Robert Osfield, modified the above so that the number increments come after the filename rather than before.
2008-06-18 11:13:51 +00:00
Robert Osfield
bc79df7cd8 From Gino van den Bergen, "Added support for vrml primitive caching" 2008-06-18 10:51:02 +00:00
Robert Osfield
7dc3ad4b5e From David Callu, "fixed bounding box bug" 2008-06-18 10:46:05 +00:00
Robert Osfield
d7e9e5e495 From Mathias Froehlich, OpenThreads::Atomic support 2008-06-17 17:43:59 +00:00
Robert Osfield
7cfe00d3d9 Added overriding of CullSettings::inheritCullSettings() into osg::Camera to
properly inherit the clear colour.
2008-06-16 20:22:16 +00:00
Robert Osfield
4e7dd7f0db Changed class to struct 2008-06-16 16:06:01 +00:00
Robert Osfield
f10cb3c388 Added mutex to serialize access to the trpager 2008-06-16 13:20:51 +00:00
Robert Osfield
68e750626a Checking in missing header changes 2008-06-16 09:32:22 +00:00
Robert Osfield
b7a548923c Refactored the management of the request queues so that the appropraite mutex is locked when DatabaseRequest objects are modified 2008-06-12 16:33:24 +00:00
Robert Osfield
fac838f791 Updated wrappers, authors and readme for 2.5.2 dev release 2008-06-06 19:57:56 +00:00
Robert Osfield
5c98e1609d Updated ChangeLog 2008-06-06 19:41:28 +00:00
Robert Osfield
3585375d59 Updated versions for 2.5.2 dev release 2008-06-06 17:45:33 +00:00
Robert Osfield
20e6ec7b23 From Jean-Sebastien Guay, "The new osgscreencapture example was being installed to bin instead of to share/OpenSceneGraph/bin, this is because the CMakeLists.txt used SETUP_APPLICATION instead of SETUP_EXAMPLE. Corrected CMakeLists.txt attached.
"
2008-06-06 16:45:07 +00:00
Robert Osfield
239f4e5c42 From Stephane Lamoliatte, "fix to reading of DatabasePath property" 2008-06-06 16:41:24 +00:00
Robert Osfield
1ee9b09e06 From Glenn Waldron, "I'm using an IntersectionVisitor with a PagedLOD database, employing a ReadCallback to allow the intersector to traverse the paged nodes. I discovered that if the visitor is unable (for any reason) to load a subtile via the ReadCallback, the intersection fails. However, I had the requirement to "fall back" on the lower-resolution parent tile and settle for that intersection.
This was easy to implement simply by overriding IntersectionVisitor::apply(PagedLOD). My question is: Are there any opinions on whether this should be the default behavior? If it makes sense, I will submit the change; if not, no worries."
2008-06-06 16:28:27 +00:00
Robert Osfield
01c284429b From Paul Melis, "Here's an updated include/osgText/Text3D that forces recomputation of the glyph repr when the character depth is updated, also when the rendering mode is set.
This caused a Text3D object read from a .osg file to not have the correct depth."
2008-06-06 16:25:14 +00:00
Robert Osfield
c2a4825afa From Mathieu Marache, "I have made the logo plugin work again (a simple copy and paste problem) and added the path of the logo file (if not empty) to the data file path in order to be able to find images relatively." 2008-06-06 14:59:17 +00:00
Robert Osfield
b6a0f3d8d0 Cleaned up implementation to only use simple structure 2008-06-06 14:10:20 +00:00
Robert Osfield
6fb62b9604 Renamed _rendergraph to _stateGraph to better reflect its function 2008-06-06 13:21:57 +00:00
Robert Osfield
ed45e32355 Introduce a lower overhead data structure for leaves. 2008-06-06 13:21:27 +00:00
Robert Osfield
aa73e1d1d4 Added update traversal to run prior to doing kdtree build to make sure that
costs in build osgTerrain databases isn't incurred during the build traversal.
2008-06-06 10:51:23 +00:00
Robert Osfield
238d482230 Quitened down the release context message 2008-06-06 09:08:16 +00:00
Robert Osfield
cf97035a45 Added OSGDB_EXPORT 2008-06-06 08:42:37 +00:00
Robert Osfield
ac068178aa Added timing code 2008-06-05 18:52:29 +00:00
Robert Osfield
a9b1ea660d Basic implementation of kdtree generation based on vertices 2008-06-05 17:28:06 +00:00
Robert Osfield
abfb5bbb8d Added accep(Shape&) 2008-06-05 13:46:19 +00:00
Robert Osfield
9212d4dd95 Further work on fleshing out basic classes 2008-06-04 17:59:39 +00:00
Robert Osfield
c57b288e54 Updated wrappers 2008-06-04 16:53:17 +00:00
Robert Osfield
282fa84789 Added support for optionally calling releaseContext at the end of each
renderinTraversals() to help with cases where uses are driving multiple
contexts from mulitple viewers in a single threaded frame loop.
2008-06-04 16:46:14 +00:00
Robert Osfield
338be0b926 Fleshed out some basic kd-tree data structures. 2008-06-03 17:29:27 +00:00
Robert Osfield
8d0c7890ce First cut of osgkdtree example, this will be used as a base of the development of
native kdtree support to help speed up intersection testing.
2008-06-03 16:13:49 +00:00
Robert Osfield
a32d336c90 Added missing updateBlock() 2008-06-03 15:49:59 +00:00
Robert Osfield
71187a2c56 From Mario Valle, fixed warnings 2008-06-03 13:07:40 +00:00
Robert Osfield
6873d4237c Ran merge to get rid of tabs 2008-06-03 13:06:54 +00:00
Robert Osfield
ef601e6add From Marco Lehmann and Robert Osfield, this fix was implemented by Robert but
is based on suggested fix from Marco for fixing a crash due to lack of
thread safety in std::ofstream("/dev/null");  The fix is to use a custom stream
buffer that just discards all data.  The implementation is also twice as fast
as the old /dev/null based approach.
2008-06-03 11:31:42 +00:00
Robert Osfield
5711964481 Added unit test to smoke out a thread issue with using ofstream("/dev/null") inside
osg::notify()
2008-06-03 11:28:16 +00:00
Robert Osfield
e09e07d45b Added support for assigning GraphicsContext to individual GUIEventAdapter events,
and use of this within osgViewer::View to better track the sources of events.
2008-06-02 17:34:47 +00:00
Robert Osfield
213a2d8d13 Changed FIND_PACKAGE(PkgConfig) to INCLUDE(FindPkgConfig OPTIONAL) as per
suggestion from Philip Lowman.
2008-05-31 08:47:15 +00:00
Robert Osfield
840eab0109 Updated authors and version file for 2.5.1 dev release 2008-05-30 21:23:49 +00:00
Robert Osfield
af974b2590 Updated ChangeLog 2008-05-30 21:12:44 +00:00
Robert Osfield
03d12b4b94 Added version check on FIND_PACKAGE(PkgConfig) to attempt to fix build with older versions of CMake 2008-05-30 21:08:28 +00:00
Robert Osfield
65772e451c Added applyMaskAction(CLEAR_COLOR) to Camera::setClearColor() to enable proper inheritance 2008-05-30 20:15:31 +00:00
Robert Osfield
c714e46ff6 Updated ChangeLog 2008-05-30 17:03:32 +00:00
Robert Osfield
5c30b98785 From Jean-Sebastien Guay, "This is a fix for the warning we've been discussing on osg-users. CMake 2.6.0 allows quotes to be unescaped in strings in ADD_DEFINITIONS statements, where we had to escape them before (CMake 2.4.x). Setting CMake policy CMP0005 to OLD removes the warning for 2.6.0, and the quotes are still escaped, so it still works with 2.4.x.
"
2008-05-30 16:53:45 +00:00
Robert Osfield
0a6b4d5709 From Luc Frauciel, Added support for osgTerrain::ValidDataOperator.
From Robert Osfield, added versioning to the above.
2008-05-30 12:59:49 +00:00
Robert Osfield
9cd56609db Updated packgage number for 2.5.1 developer release 2008-05-30 11:44:06 +00:00
Robert Osfield
0cc38108a5 Fixed cirular reference in DatabaseRequest 2008-05-30 11:43:04 +00:00
Robert Osfield
f07d106366 Moved enum to public scope and rebuilt wrappers to fix wrapper build error 2008-05-29 13:54:59 +00:00
Robert Osfield
7a2c403992 Added code to catch erroneous Dof axis settings 2008-05-29 11:45:31 +00:00
Robert Osfield
e1eeabcea0 Improved the NaN depth detection within CullVisitor and debug output. 2008-05-29 11:13:29 +00:00
Robert Osfield
2a11d25bbc Improved the NaN error detection and reporting. 2008-05-29 11:09:56 +00:00
Robert Osfield
4745ab040b Added catch for NaN depth values 2008-05-28 17:56:22 +00:00
Robert Osfield
7c23951ee1 From Wojiech Lewandowski, Workaround for wglMakeCurrent bug in NVidia drivers by
calling wglMakeCurrent twice.

This bug has been reported to NVidia, confirmed and fixed by NVidia but awaits verifiaction and release if a driver which fixes this bug.
2008-05-28 16:14:08 +00:00
Robert Osfield
3ca777f31e Updated wrappers 2008-05-28 14:37:50 +00:00
Robert Osfield
1047f970bb From Adrian Egli, improvements to ParallelSplitShadowMap implementation 2008-05-28 14:11:22 +00:00
Robert Osfield
8e91926ca5 From Thibault Genessay, "The PNG plugin crashes when you try to read a malformed file (attached
is an example). This can happen in circumstances that are not
manageable by the OSG itself (e.g. 3rd party buggy program) but one
would expect the plugin to be able to recover by returning
ReadResult::ERROR_IN_READING_FILE.

libpng provides two callbacks for warnings and errors - those are
currently unused. By default, they point to function that call exit()
or something similar (the default error callback never returns). This
patch registers the callbacks using libpng's mechanisms, makes the
warning callback emit an osg::notify(osg::WARN) message and the error
callback throw an error. The reading process is enclosed in a
try...catch block. Upon error, the memory is freed and
ReadResult::ERROR_IN_READING_FILE is returned.
"
2008-05-28 13:51:56 +00:00
Robert Osfield
7e0184f080 From Thibault Genessay, "On Windows, when setting a cursor through
osgViewer::GraphicsWindow::setCursor() the new cursor type is recorded
but not applied until windows sends another WM_SETCURSOR message. This
delays the application of the cursor to the next mouse event.

The attached file fixes this by setting the new cursor with a call to
::SetCursor() immediately.
"
2008-05-28 13:45:40 +00:00
Robert Osfield
8573194aa0 From Michael Platings, "Yes it's definitely a driver problem - I submitted a bug report to
nvidia 6 months ago and the issue is still "in progress". I've given up
waiting for them!

Platform - various Intel Windows XP SP2 PCs with various nvidia cards
including GeForce 8800 GTS and Quadro FX 4500, and various driver
versions including the latest WHQL 175.16.

I investigated your concerns about glGenerateMipmapEXT being slower than
GL_GENERATE_MIPMAP_SGIS, and for power-of-two textures, to my surprise
it is. For a 512*512 texture, glGenerateMipmapEXT takes on average 10ms,
while GL_GENERATE_MIPMAP_SGIS takes on average 6ms. Therefore I have
modified the code to only use glGenerateMipmapEXT if the texture has a
non-power-of-two width or height. I am resubmitting all the files
previously submitted (only "Texture.cpp" has significant changes since
my previous submission, I've also replaced tabs with spaces in
"Texture").
"
2008-05-28 13:01:44 +00:00
Robert Osfield
712b6cb2d9 From Mathieu Marache,
first post:

"I had the problem that debug and release version of the plugins had the same name under linux. These minors modification to Registry and the CMake support files enable to have both Release and Debug version of the plugins to coexist and be found by there respective runtimes."

follow up post:

"I've gone ahead and added a preprocessor directive with the editable CMAKE_DEBUG_POSTFIX. I modified Registry.cpp to take this new preprocessor directive called OSG_DEBUG_POSTFIX while looking for libraries in Debug mode for the windows (msvc) and the linux platforms.

MinGW, cygwin and Apple are still left out this proposal."


Notes from Robert Osfield, completed the work in change d entries to use OSG_DEBUG_POSTFIX
2008-05-28 12:49:47 +00:00
Robert Osfield
e68e474c90 Updated wrappers 2008-05-28 11:58:46 +00:00
Robert Osfield
8677c4d6d6 From Michael Platings, "On nvidia cards mipmap generation for non-power-of-two textures with
GL_GENERATE_MIPMAP_SGIS is very slow (over half a second for a 720*576
texture). However, glGenerateMipmapEXT() performs well (16ms for the
same texture), so I have modified the attached files to use
Texture::generateMipmap() if glGenerateMipmapEXT is supported, instead
of enabling & disabling GL_GENERATE_MIPMAP_SGIS."

Notes, from Robert Osfield, I've tested the out of the previous path using
GL_GENERATE_MIPMAP_SGIS and non power of two textures on NVidia 7800GT and
Nvidia linux drivers with the image size 720x576 and only get compile times
of 56ms, so the above half second speed looks to be a driver bug.  With
Muchael's changes the cost goes done to less than 5ms, so it's certainly 
an effective change, even given that Michael's poor expereiences with
GL_GENERATE_MIP_SGIS do look to be a driver bug.
2008-05-28 11:19:41 +00:00
Robert Osfield
20f3e74643 From Brad Anderegg, "This submission fixes two bugs and helps some performance problems we have been having with txp databases.
The first bug is that the terrain tiles will page out to a lower LOD when they are right in front of you.  The issue appears to be with the blacklisting heuristic which forces a tile to LOD 1, commenting out the usage of blacklisting with the LOD Nodes fixes our problem.  This code change was made to line 29 of TXPPageLOD.cpp.

 

The second bug we were experiencing is that the database reader options never make it through to the archive loader.  The use case for us appeared when the FID codes for the terrain were no longer on the materials.  As it turns out the archive was being created twice, once by TXPNode and once by the ReaderWriterTXP on getArchive() so the options never actually got set on the archive that was being loaded.  The fix is to first create the archive by calling getArchive on the ReaderWriterTXP, which stores it in a map for reference later, and then passing that archive into the TXPNode for it to set its internal member.  With this code change we only create one archive (not sure what creating two did) and our options flags get set properly on the database.

 

The changes made are in TXPNode.h line 72 where the TXPArchive is now passed in.  In the TXPNode.cpp the loadArchive(TXPArchive*) was changed to have the default behavior if NULL is passed in, if an archive is passed in then it does not load it since all the loading is done in the ReaderWriterTXP::getArchive().  The only other place that loadArchive is called is in TXPIO.cpp where a modification was made to pass in NULL which will have the same behavior as it used to.  The last change is the little block of code starting on line 57 of ReaderWriterTXP.cpp, this was changed so that it first calls getArchive() which caches the archives in a map does some loading stuff and returns a pointer to it which is then passed in as a parameter to TXPNode::loadArchive().

 

The performance changes were made to TXPParser.cpp line 163 where we use to osgUtil::Optimizer on the node before passing it off, and on line 1456 we changed the geometry to use display lists.  These small changes actually made drastic performance increases for us, as much as 1000% on certain laptops.

 

As far as testing goes, we have tested these changes with at least 5 txp databases on a variety of different computers including Mac OS and Linux.  The base version used is 2.4."
2008-05-27 20:53:43 +00:00
Robert Osfield
6877a814fb From Cedric Pinson, "By default it's the normal behaviour, it means it's "d" extension for debug library and executable. But if you want to change that you can.
The reason is if you want to build an application that use a library that use openscenegraph you have to build the full chain in debug or in release.
On windows you have no choice, but on linux you can link with both version without rebuilding everything ...

The patch consist only to change the line on one line
SET(CMAKE_DEBUG_POSTFIX "d")
with
SET(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "add a postfix, usually d on windows")"
2008-05-27 17:42:56 +00:00
Robert Osfield
e427d50d9a From Lars Nilson, bug fix to Sector::computeMatrix() 2008-05-27 17:32:26 +00:00
Robert Osfield
7ab1219ea3 Added handling of \ within srings by using \\ 2008-05-27 16:32:17 +00:00
Robert Osfield
526f8cd8dc Updated wrappers 2008-05-27 15:42:40 +00:00
Robert Osfield
4d60d73eca Reorginized the TerrainTile/TerrainTechnique dirty mechanism so that TerrainTile
now holds the dirty flag and enables/disables event traversal in response dirty
being set/unset.  This allows terrain to be automatically updated in response
to Terrain scale and sample ratio changes.
2008-05-27 15:30:20 +00:00
Robert Osfield
aee0e8dc37 Introduced a TerrainHandler that adjust the sameple ratio and vertical scale
of terrain interactively using the 'r','R' and 'v','V' keys respecitvely.
2008-05-27 15:28:39 +00:00
Robert Osfield
1519d0d546 From John Vidar Larring, "Added vertical scale as a property of osgTerrain::Terrain. Lets you configure vertical scale when initializing the terrain model. E.g:
osgTerrain::Terrain* terrain = findTopMostNodeOfType<osgTerrain::Terrain>(model.get());
  if (!terrain)
  {
      terrain = new osgTerrain::Terrain;
      terrain->addChild(model.get());
      terrain->setVerticalScale(2.0f);
      model = terrain;
  }
  viewerWindow->setSceneData(model.get());
"
2008-05-27 13:11:47 +00:00
Robert Osfield
b41404546e Updated version numbers in prep for 2.5.1 release 2008-05-27 12:07:58 +00:00
Robert Osfield
169b1a02ad From Gino van den Bergen, "I've refactored the single ReadedWriterVRML2.cpp into multiple files. The reason for doing this was to break up the horribly long function
osg::ref_ptr<osg::Node> ReaderWriterVRML2::convertFromVRML(openvrml::node *obj)
 
The fixes are:
 
* Added the source's parent directory as search directory for image files.
* The material properties are now set in the stateset of the Geode rather than the Geometry. This will allow geometries to be reused with different material properties in future updates.
 
NB: I planned for a caching scheme in which multiple occurences of the same primitive (e.g., Cylinders with radius 0.8 and height 1.2), would use the same Geometry object. Unfortunately, my planning moved me to other areas, but I might still finish the caching scheme in a quiet hour. For the time being I decided it would be a good thing to already submit my current changes.
 "
2008-05-27 12:06:50 +00:00
Robert Osfield
7230d54011 From Mathias Froehlich, "Included a fix for my past pbuffer change. The version test fo 'need at least
glx 1.1' was broken, even if no implementation had yet a chance to trigger
that :)

Attached a fix for that broken test.
Based on rev 8358"
2008-05-27 11:13:16 +00:00
Robert Osfield
dd6d04e088 From Andrew Bettison, "Problem: the LineStipple pattern when read from an OSG node file is always 0xFFFF, even though specified otherwise in the OSG file.
Cause: possibly a copy/paste typo in src/osgPlugins/osg/LineStipple.cc, line 61:
  if (fr[0].matchWord("functionMask") && fr[1].getUInt(mask))

Solution: change to:
  if (fr[0].matchWord("pattern") && fr[1].getUInt(mask))"
2008-05-27 11:07:52 +00:00
Robert Osfield
3c6b6e4d97 From Stephane Lamoliatte, "Here is a patch that fix the strange bug describe on the osg-user group.
Finally it seems to not come from the empty geode. The origin of the problem seems to be the uniform initialization during the building of the program which call a glUseProgram.
If your scene never display the node that contains the shader and if there is no other shader on the scene, this "glUseProgram" is the only one that is called during your simulation. So, this shader is applied on all the scene.

I fix this bug by switching off the shader (by calling glUseProgram(0) ) during the compilation of a state which does not contain the shader.
"
2008-05-27 11:04:52 +00:00
Robert Osfield
66a1996a5a From Wang Rui, "I have just done some changes on the classic osgdb_gif plugin (based on OSG 2.5.0). I wish our developers may use the newly written GIF reading plugin to attach animate GIF files as textures now! In my opinion, a GIF is much smaller than AVI and MOVs, and much more efficient sometimes.
Changes includes:
1. A new GifImageStream class (inherit from osg::ImageStream and OpenThreads::Thread) have already been added to implement different operations of a GIF movie, such like playing, pausing, rewinding, setting time and so on.
2. Some small changes to decode_row() and gif_read_stream(), which make the transparency of GIF images correctly.
3. Just a few changes to the ReaderWriterGIF::readGIFStream() function, which ensure that animate GIFs are loaded by GifImageStream (and the function returns GifImageStream objects) and static GIFs unchanged (still use the old method and returns osg::Image objects!).
 
Attachments are the cpp file and an animate GIF file for further test. Just rebuild the osgdb_gif project and use osgviewer or osgmovie to view it.
The plugin has been tested on Windows and Arch Linux."
2008-05-27 10:50:26 +00:00
Robert Osfield
476cb5373e From Philip Lowman, post 1:
"Here is a collection of changes which should fix issues building the OSG with CMake 2.6.0 (along with some other changes)

CMakeLists.txt:
* Set CMP0003 to supress warning about linking against -lpthread (which is a
  non-absolute library location).  (CMake 2.6.x fix)
* Modified the WIN32_USE_MP and a couple of other Visual Studio specific flags
  to be in an IF(MSVC) block  (minor tweak to reduce exposing this stuff on MinGW builds)
* Includes my second set of glu tesselator autodetection changes that you
seemed to want but haven't committed yet.

src/OpenThreads/pthreads/CMakeLists.txt:
* Eliminates warning when compiling on Linux about spaces in link line (CMake 2.6.x fix)

CMakeModules/OsgMacroUtils.cmake:
* Tweaks to make the macros behave properly under CMake 2.6.0 (doesn't change behavior under CMake 2.4.x)

CMakeModules/Find3rdPartyDependencies.cmake:
* Adds the NO_DEFAULT_PATH option to all of the search options so that things in C:\Program Files\OpenSceneGraph aren't accidently picked up during configure time and instead only things in the "3rdParty" folder are discovered. (general bugfix)
"

post 2:
"Ok, hold the presses.  I just discovered that for some odd reason the osgdb_* plugins under Linux aren't getting put under the osgPlugins-2.5.0 folder.  Not exactly sure why this broke, the folder was there, just empty.  I'll have to look into it this evening."

post 3:

"Fixed, was caused by the switch to CMAKE_LIBRARY_OUTPUT_DIRECTORY and some code in osgPlugins/CMakeLists.txt that effectively overrides LIBRARY_OUTPUT_PATH on non-MSVC compilers to dump the plugins in the plugins folder.  I tweaked it to override CMAKE_LIBRARY_OUTPUT_DIRECTORY as well.  Seems to work fine."
2008-05-26 22:36:58 +00:00
Robert Osfield
51dd9676db From Paul Martz, "When exporting a DrawArrays PrimitiveSet, the DAE plugin computes an incorrect nbVerticesPerPoly if the first index is not zero. The issue can be reproduced easily with:
osgconv cessna.osg cessna.dae
 
Examination of the resulting .dae file reveals several out-of-range tristrip indices; viewing the .dae file in osgviewer causes a crash when OSG tries to lookup those indices.
 
Attached resolves this issue."
2008-05-26 22:34:06 +00:00
Robert Osfield
804c91c8c1 From Art Tevs, "I've attached a patch for the Texture2DArray which solves problems of loading image data into the texture array. So here are a small description:
- Solves issues of loading image data into the texture memory
- Print a warning if images are of different dimensions or have different internal formats (GL specification requires images to be the same)


Patch is tested and seems to work fine. It shouldn't break any other functionality. It should go into include/osg and src/osg
"
2008-05-26 21:53:57 +00:00
Robert Osfield
1f8ff7916c Fixed copyright notice typo 2008-05-26 21:44:14 +00:00
Robert Osfield
4c81aa0aa7 From Paul Martz, "The attached code changes StateSet::merge() so that it copies RenderBin data such as the rendering hint and RenderBin details from rhs into "this", only if "this" has RenderBin mode set to INHERIT.
It replaces a comment by you indicating something along these lines should be done. To me, this seems like the right thing to do."
2008-05-26 21:33:41 +00:00
Robert Osfield
8f6ca1dc6c From Gino, "According to the 1.4.1 COLLADA spec (2nd ed) the standard behavior for fx_sampler_wrap_common is as follows
CLAMP ->GL_CLAMP_TO_EDGE
NONE->GL_CLAMP_TO_BORDER

The current 2.5.0 daePlugin assumes the following binding

CLAMP ->GL_CLAMP
NONE->GL_REPEAT

Notably the GL_CLAMP binding will result in visible black seams on input files that use otherwise matching textures. Replacing GL_CLAMP by GL_CLAMP_TO_EDGE solves this problem. I've updated both the read and write functions.
"
2008-05-26 21:32:05 +00:00
Robert Osfield
ee6f055bc5 From Philip Lowman, "I changed the test name to be a little easier to understand and defaulted Linux & Windows builds to false and to skip the compile check as you desired.
"
2008-05-26 21:18:41 +00:00
Robert Osfield
3d163c3412 Updated wrappers 2008-05-26 21:10:10 +00:00
Robert Osfield
ae303e38e9 From Paul Melis, "Here is an update to the osgviewerWX example. Keyboard events were not always received because the GraphicsWindowWX wasn't receiving focus. It now receives focus when the mouse enters the window.
* I split the mouse handling from a monolithic method to separate ones, slightly cleaner than a whole bunch of if()'s, especially with another case of the mouse entering the canvas.
* I changed the EVT_KEY_DOWN handler to an EVT_CHAR handler, although that now makes the up and down handler assymetric. The new down-handler returns translated key codes, so when you press the S key (without anything else), it actually returns 's' and not 'S' as the EVT_KEY_DOWN did. This means that statistics can be called up in the viewer window, while the example previously only printed a "Stats output:" line to the console. I'm not truly happy that the up handler returns _untranslated_ key codes. But solving this completely would probably mean adding some table that translated from wxWidgets' untranslated key codes to OSG's internal ones. This might be interesting to add, as anyone using OSG + wxWidgets in any serious manner would also have to add this.
* I commented out the evt.Skip()'s in the keyboard handlers as these would only be necessary if there were some key events that are not handled. But currently all key events are simply forwarded.
* I changed the handling of a mouse drag to a more general mouse move"
2008-05-26 21:09:54 +00:00
Robert Osfield
189049f9bd From Colin McDonald, "I had to tighten a declaration in OpenFlight/FltWriteResult.h, as the Solaris SunStudio 11 compiler was being picky and wouldn't compile." 2008-05-26 21:04:47 +00:00
Robert Osfield
55e98d390e Added debug block to output the location of the master camera for each View in a Viewer. 2008-05-26 20:46:21 +00:00
Robert Osfield
cac6e2facb Added continuous recording of the animation path to the RecordAnimationPathHandler 2008-05-26 17:30:43 +00:00
Robert Osfield
7592e50cde Introduce --pbuffer-only width height option, and added fps reporting to stats output 2008-05-26 16:25:31 +00:00
Robert Osfield
57ce3f820e Added basic --pbuffer width height support 2008-05-26 15:41:54 +00:00
Robert Osfield
7aac7ef381 Added better stats reporting 2008-05-26 14:30:48 +00:00
Robert Osfield
bb1f6ff7c1 Added feedback of pixel format chosen for read back 2008-05-26 12:01:24 +00:00
Robert Osfield
8ed9b303f1 Added automatic selection of the pixel type according to the window type 2008-05-26 11:59:25 +00:00
Robert Osfield
d2afe3e956 Added option for doing triple buffering, and set the default read format
to GL_RGBA
2008-05-26 11:53:51 +00:00
Robert Osfield
dc7db11e63 Switch to using an inital draw callback when use --start-frame 2008-05-25 22:06:41 +00:00
Robert Osfield
5664c51cf0 Added option for setting whether the front or back buffer should be read using
--front and --back command line options.
2008-05-25 21:52:32 +00:00
Robert Osfield
28fd4b07c9 Added option for controlling whether the front buffer is read at the start of the
frame or the back buffer at the end of the frame.
2008-05-25 21:35:39 +00:00
Robert Osfield
c1f7c766ef Added check for pkg-config so that build only use related package checks when
it's supported
2008-05-25 11:21:40 +00:00
Robert Osfield
a88567a852 Added #define's for PixelBufferObject extensions.
Added docs for Camera::DrawCallback
2008-05-24 11:05:10 +00:00
Robert Osfield
9623731185 Added RenderStage::setClear*() methods from Camera::getClear*() sources 2008-05-24 09:24:37 +00:00
Robert Osfield
cc07d064bf Changed default format to GL_BGR 2008-05-24 08:13:55 +00:00
Robert Osfield
90308d22aa Added single buffered and double buffered PBO support, and --no-pbo,
--single-pbo and --double-pbo command line parameters
2008-05-23 16:26:03 +00:00
Robert Osfield
f9f1aab67d Added basic glReadPixels code 2008-05-22 17:50:22 +00:00
Robert Osfield
fd76054eac Added camera final callback attachment code. 2008-05-22 15:43:01 +00:00
Robert Osfield
0a3737eb2c Fixed name of source file 2008-05-22 13:11:23 +00:00
Robert Osfield
29d067639c Added new osgscreencapture example folder, implementation to follow 2008-05-22 13:10:40 +00:00
Robert Osfield
6a16cbfca4 Reorginaized the DatabaseQueue's to avoid warnings under Windows 2008-05-22 12:38:36 +00:00
Robert Osfield
e6e4074143 Fixed warning by adding in missing return 2008-05-22 11:21:04 +00:00
Robert Osfield
58f5ebab19 Checking in missed header 2008-05-22 08:31:56 +00:00
Robert Osfield
7b003b24ea Refactored DatabasePager and related classes to introduce support for
multi-threaded paging, where the Pager manages threads of reading local
and http files via seperate threads.  This makes it possible to smoothly
browse large databases where parts of the data are locally cached while
others are on a remote server.  Previously with this type of dataset 
the pager would stall all paging while http requests were being served,
even when parts of the models are still loadable virtue of being in the 
local cache.

Also as part of the refactoring the DatabaseRequest are now stored in the
ProxyNode/PagedLOD nodes to facilitate quite updating in the cull traversal,
with the new code avoiding mutex locks and searches.  Previous on big 
databases the overhead involved in make database requests could accumulate
to a point where it'd cause the cull traversal to break frame.  The overhead
now is negligable.

Finally OSG_FILE_CACHE support has been moved from the curl plugin into
the DatabasePager.  Eventually this functionality will be moved out into
osgDB for more general usage.
2008-05-21 21:09:45 +00:00
Robert Osfield
100cc12ecb Moved the compile to after the updateSceneView 2008-05-20 09:28:44 +00:00
Robert Osfield
24fec21002 Updated wrappers 2008-05-14 20:22:01 +00:00
Robert Osfield
646fc43747 Introduced preliminary support for asynchronous file read requests,
ReaderWriter::ReadResult now has a FILE_REQUEST enum.
  ReaderWriter::Options now has a s/getAsynchronousFileReadHint() parameter methods.

  libcurl based plugin now detects enabing of the AsynchronousFileReadHint, but
  as yet does not handle async requests - handling everything syncronously.
  
  DatabasePager now by default will enable AsynchronousFileReadHint for http
  based file requests
2008-05-14 17:03:57 +00:00
Robert Osfield
d7c4e6f26e Moved the cache file writing into StreamObject so that the cache file is only
created once data is being read.
2008-05-14 14:59:50 +00:00
Robert Osfield
6be1928447 Introduced a thread safe map which manages a single EasyCurl object per thread. 2008-05-14 13:16:36 +00:00
Robert Osfield
094dcd9bfd Refactor curl usage so that a new EasyCurl class wraps up the curl handle and
reading from curl.
2008-05-14 12:47:26 +00:00
Robert Osfield
5f443e75a9 Fixed lat/long ordering 2008-05-13 18:28:26 +00:00
Robert Osfield
e28ae8c7f3 Added support for -e level minX minY maxX maxY extents controls 2008-05-13 17:27:29 +00:00
Robert Osfield
83f6f13914 Added --file-cache directoryname command line option support to readNodeFiles(ArgumentParser&)
to make it easier to specify a local file cache, in place of the default OSG_FILE_CACHE
env var.
2008-05-13 14:08:32 +00:00
Robert Osfield
0ed71961d4 Further work on computing of lat/long range of PagedLOD subgraphs 2008-05-13 12:36:39 +00:00
Robert Osfield
f3d36055ef From Steven Thomas, "Subject: Collada fix
There was a problem converting a file to Collada by using osgconv like this:

osgconv file.osg file.dae

You would get an error message:

I/O error : Permission denied
I/O error : Permission denied
error : xmlNewTextWriterFilename : out of memory!
Error: daeLIBXMLPlugin::write(file://cessna.dae) failed
Warning: Error in writing to "cessna.dae".

This was due to some bad URI processing code in the Collada plugin. The attached file fixes this by using the Collada DOM's URI processing functions. After this change the file will convert successfully in the local directory.
"
2008-05-13 10:56:10 +00:00
Robert Osfield
c81b02bca4 Added signal handling code, and prelimary lat/long computation 2008-05-12 16:59:04 +00:00
Robert Osfield
61f630e163 Added missing getBound() method 2008-05-12 15:42:20 +00:00
Robert Osfield
7e8e7587be Update ChangeLog and wrappers for 2.5.0 dev release 2008-05-12 12:16:58 +00:00
Robert Osfield
d2c5142ecc Updated AUTHORS for 2.5.0 release 2008-05-12 12:16:14 +00:00
Robert Osfield
7a074acd49 From Mathias Froehlich, Fixed FrameBufferObject attachement code to handle cases
where no texture or image is attached
2008-05-12 11:39:02 +00:00
Robert Osfield
1d2bd834a4 Updated version number for 2.5.0 dev release 2008-05-12 11:01:54 +00:00
Robert Osfield
965c72f5bd From Eric Sokolowski and Robert Osfield, moved command line option usage setup
from osgviewer example into osg::ArgumentParser and osgViewer::Viewer to make
them more universally available.
2008-05-12 10:55:55 +00:00
Robert Osfield
61cb0833b9 From Bob Kuehne, "* add easy multiple texture targets support for obj by refactoring texture
load into it's own method.

* use new method from step 1 to load 'map_opacity' textures from .mtl files"
2008-05-12 10:18:41 +00:00
Robert Osfield
db2cf75b23 From Mathias Froehlich, fixed typo 2008-05-12 10:16:40 +00:00
Robert Osfield
a7e5972f82 Added CARIO_FOUND into svg plugins checks 2008-05-11 14:26:27 +00:00
Robert Osfield
13acf6420f From Miguel Escriva, Here you will find a SVG Image Reader. It renders a SVG file as an osg::Image using cairo and rsvg. 2008-05-11 14:23:19 +00:00
Robert Osfield
412717c151 From Paul Martz, "This change adds support for osg::Billboards to the OpenFlight exporter.
It might seem odd that the change actually removes the stub apply(Billboard&) method, but it turns out Billboards are easily supported in subordinate routines of the existing apply(Geode&) method with s dynamic_cast, so there's no need for a separate apply(Billboard&)."
2008-05-10 17:25:42 +00:00
Robert Osfield
e9589ebb49 From Paul Martz, "Another round of plugin enhancements.
3DC: Output now uses osg::notify.
JPEG: Now returns correct error code for empty input file.
FreeType: Prevent possible crash if Options is NULL."
2008-05-10 17:23:12 +00:00
Robert Osfield
4d7b2edd4c Moved compile setup from osgViewer::ViewerBase into osgViewer::Renderer to
avoid threading issues associated with compile running in a parallel with 
update/cull on the first frame.

Also added automatic recompile when a new SceneData is applied to a View.
2008-05-10 17:04:02 +00:00
Robert Osfield
0dfba5dbe5 Added --file-cache command line option to compliment -c 2008-05-09 17:22:49 +00:00
Robert Osfield
b12069e14c Initial cut of file cache population app 2008-05-09 17:08:31 +00:00
Robert Osfield
ebf653369a From Art Trevs, set the _geometryVerticesOut to default to 1 as a workaround
for OpenGL driver bug that incorrectly reports a warning when value is 0.
2008-05-09 11:54:24 +00:00
Robert Osfield
61e3285ffc From Paul Martz, "Attached are some minor plugin fixes. PNM, RGB, and JPEG would all crash if attempting to read an empty file, and FLT would go into an infinite loop. All are fixed with this change.
I also fixed some return values for a couple of these, changing FILE_NOT_HANDLED to ERROR_IN_READING_FILE where appropriate."
2008-05-09 11:27:03 +00:00
Robert Osfield
01f58ffbb2 From Jeremy Moles, fixed window resize problem 2008-05-09 10:27:59 +00:00
Robert Osfield
f733bf17e9 Added missing check against handling invalid bounding sphere's 2008-05-08 17:02:08 +00:00
Robert Osfield
59653bcc08 From Eric Sokolowsky, "I found one compilation error in OSG 2.4 in the Inventor plugin, where one node (SoTextureCoordinate3) was assumed to be available in all versions of Inventor but is actually only available in Coin. The use of the node is now protected by #ifdef __COIN__ constructs. The attachment is based on OSG 2.4, not SVN." 2008-05-08 16:48:49 +00:00
Robert Osfield
9e6c3a7628 From Melchior Franz, "In KDE I switch desktops with Super-Tab, and occasionally I
get an excess Tab key report when switching back to an OSG
application (usually FlightGear :-). Although KDE has consumed
the Tab, it's sometimes still in the XKeymapEvent's key_vector,
and followed by a Tab KeyRelease event.

Avoid this artifact by
- asking for a "fresh" keymap (via XQueryKeymap()), rather than
 using the unreliable(?) XKeymapEvent's key_vector, and by
- flushing all key events on focus-in (to avoid the KeyRelease)

After Super-press, Tab-press, Super-release, Tab-release (note
the wrong release order!) I still get an extra Tab event. But
this is not surprising and not exactly wrong either. Also it's
hard to avoid, as we can't see what happened to the keyboard
before we regained focus.

Files changed:
 src/osgViewer/GraphicsWindowX11.cpp
 include/osgViewer/api/X11/GraphicsWindowX11"
2008-05-08 16:45:59 +00:00
Robert Osfield
4345382316 From Jeremy Moles, osgviewerGTK example 2008-05-08 16:39:10 +00:00
Robert Osfield
ebf3804c84 From Sebastien Messerschmidt, "attached you'll find a patch for the shp-plugin.
I've spotted huge memory leaks int ShapeParser and fixed them.
Also, there was a missing destructor (PolygonM) and a missing member initialization (PolygonZ)
Would be nice if someone could test the changes.

To release the memory just if no reading error happened (and therefore the arrays would be valid) I've added an macro to release and reset the pointers at once. I'm not using macros myself very often as I don't like them, but I think it doesn't hurt in this code.

"
2008-05-08 15:17:53 +00:00
Robert Osfield
dc0355fc84 Updated ChangeLog and osgversion to catch Raymond de Vries name correctly 2008-05-08 15:14:13 +00:00
Robert Osfield
b9359048d6 From Raymond de Vries, "This fix tests the right variable before it is allocated. Fortunately, until now it tested another variable (_particleSizeUniform, which is, at that moment, not allocated as well) and everything went ok. So it does not fix a crash or so, it is a matter of correct code.
Line 353 is changed from

if (!_particleSizeUniform)

to

if (!_particleColorUniform)
"
2008-05-08 14:00:00 +00:00
Robert Osfield
6d61e554b4 From Paul Martz, "As I discovered prior to the 2.4 release, the FLT export geometry backend was using some old turn-on code, originally written just to enable other development but not intended for actual release. Sadly, my OSG training commitments prevented me from fixing this prior to 2.4.
In essence, the FLT exporter was emitting a full set of Mesh records each time it encountered a PrimitiveSet.
 
Attached is a fix. The code now emits the Mesh set up records, then iterates over all PrimitiveSets and emits a Mesh Primitive record per PrimitiveSet.
 
It also loops over PrimitiveSets twice, first writing Face records according to the mode, the writing Mesh records (again according to the mode).
 
The final change included here is support for GL_POINTS as single-vertex Face records.
 
Billboards are still to come."
2008-05-08 13:56:28 +00:00
Robert Osfield
0df8d414f4 Updated wrappers 2008-05-08 13:46:58 +00:00
Robert Osfield
dd1a2bcaec From Roland Smeenk, "Small typo and implementation fix for setInitialDrawCallback." 2008-05-08 13:22:52 +00:00
Robert Osfield
47814e50a4 From Philip Lowman, "Attached is a patch to the toplevel CMakeLists.txt which adds an automated test for OSG_GLU_TESS_CALLBACK_TRIPLEDOT. This should help ease initial configuration on OS X systems." 2008-05-08 12:55:01 +00:00
Robert Osfield
973f104704 From Garrett Potts and Robert Osfield, changes to build against Collada DOM 2.x 2008-05-08 12:36:07 +00:00
Robert Osfield
38133f8772 Updated the doxygen docs to explain the deprecated status of SceneView 2008-05-08 09:16:24 +00:00
Robert Osfield
5fbb582856 Commented out checking of DISPLAY env var 2008-05-07 17:06:36 +00:00
Robert Osfield
fd6a812dd0 Updated wrappers 2008-05-07 14:32:39 +00:00
Robert Osfield
22c7699fa1 From Bob Kuehne, Added doxygen docs clarification of ReadResult enum values 2008-05-07 14:30:58 +00:00
Robert Osfield
01f58e2b76 From Donald Cipperly, "This is a fix to eliminate >> errors in VS 7.1" 2008-05-07 14:24:14 +00:00
Robert Osfield
96f2062115 From Miguel Escriva, "Attached to this mail you will find some files to work with the Philips WOWvx displays.
It's implemented in the same way that 3D Spherical Display and Panoramic Spherical Display.

You can test it running:
   osgviewer --wowvx-20 cow.osg
   osgviewer --wowvx-42 cow.osg
depending on the size of your Philips WOWvx display (20" or 42")

Other arguments you can use to control the 3D effect are:

--wow-content <value>
   This value defines the kind of content that can be:
      0: No depth
      1: Signage
      2: Movie
      3: CGI
      4: Still

--wow-factor <value>
   Percentage of the display recommended depth value. Default 64, Range [0-255]

--wow-offset <value>
   Amount of range behind the screen. Default 128, Range [0-255]
      0: Range is shifted in the direction of the viewer.
      128: Range is equally divided in front and behind the screen.
      255: Range is shifted away from the viewer.
      "
2008-05-07 14:17:15 +00:00
Robert Osfield
7c94ff2b6d From Terry Welsh, fixed typo of getEnd() 2008-05-07 13:49:32 +00:00
Robert Osfield
4f881b9a09 From Jeremy Moles,"Here's a small example I us to test text rendering in osgWidget; I
figured it might be helpful to folks in OSG who need to do the same.
"
2008-05-07 13:46:24 +00:00
Robert Osfield
10c3044499 From Farshid Lashkari, "I've added hardware mipmap support to Texture3D." 2008-05-07 13:42:29 +00:00
Robert Osfield
14a7b5dd08 Added doxygen comments for attach 2008-05-07 11:59:15 +00:00
Robert Osfield
6ef7e6dcaf Updated package numbers for OSG-2.4, OT-2.2.1 release 2008-04-26 11:13:08 +00:00
530 changed files with 38086 additions and 8991 deletions

View File

@@ -1,113 +1,118 @@
OpenSceneGraph Library 2.4.0
OpenSceneGraph Library 2.6.0
307 Contributors:
324 Contributors:
Firstname Surname
-----------------
Robert Osfield
Don Burns
Marco Jez
Mike Weiblen
Paul Martz
Mike Weiblen
Eric Wing
Brede Johansen
Geoff Michel
Stephan Huber
Geoff Michel
Farshid Lashkari
Bob Kuehne
Mathias Fr<46>hlich
Eric Sokolowsky
Ulrich Hertlein
Martin Lavery
Eric Sokolowsky
Mathias Fr<46>hlich
Tree
David Callu
Tree
Jean-Sebastien Guay
Luigi Calori
Trajce Nikolov
Mike Wittman
Jean-Sebastien Guay
Pavel Moloshtan
Colin McDonald
Tom Jolley
Andy Skinner
Roger James
Norman Vine
Colin McDonald
Jeremy Moles
Alberto Farre
Andr<EFBFBD> Garneau
Wojciech Lewandowski
Ruben Lopez
Randall Hopper
Wojciech Lewandowski
Art Tevs
Olaf Flebbe
Gideon May
Don Tidrow
Romano Jos<6F> Magacho da Silva
Philip Lowman
Paul Melis
Michael Platings
Michael Gronager
Daniel Sj<53>lie
Chris Hanson
Adrian Egli
Sherman Wilcox
Per Fahlberg
Jeremy Moles
J.P. Delport
David Spilling
Art Tevs
Sherman Wilcox
Melchior Franz
Joran Jessurun
Joakim Simonsson
Jason Beverage
Paul Melis
Jason Daly
Frederic Marmond
David Fries
Boris Bralo
Yefei He
Terry Welsh
Sondra Iverson
Serge Lages
Rune Schmidt Jensen
Rainer Oder
Mike Connell
Melchior Franz
Joakim Simonsson
Mathieu Marache
Glenn Waldron
Carlo Camporesi
Ben Discoe
Andreas Ekstrand
Adrian Egli
Stephane Lamoliatte
Sasa Bistrovic
Martin Naylor
Martin Aumueller
Markus Trenkwalder
Mario Valle
Loic Dachary
Joseph Steel
John Shue
Jan Peciva
Jan Ciger
Gordon Tomlinson
Gino van den Bergen
Bryan Thrall
Brad Colbert
Vivek Rajan
Thibault Genessay
Sean Spicer
Ravi Mathur
Nikolaus Hanekamp
Neil Salter
Mihai Radu
Michael Platings
Michael Hartman
Luc Frauciel
Laurens Voerman
David Guthrie
Corbin Holtz
Cedric Pinson
Brad Christiansen
Toshiyuki Takahei
Thom DeCarlo
Terry Welsh
Stephane Lamoliatte
Simon Julier
Sebastien Grignard
Romano Magacho
Philip Lowman
Roland Smeenk
Paul de Repentigny
Luc Frauciel
Leandro Motta Barros
John Kelso
Glenn Waldron
Daniel Larimer
Colin Dunlop
Cedric Pinson
Bruce Clay
Alberto Luaces
Alberto Barbati
@@ -115,28 +120,28 @@ Vladimir Shabanov
Uwe Woessner
Tony Horrobin
Tim Moore
Thibault Genessay
Sohey Yamamoto
Roland Smeenk
Richard Schmidt
Rafa Gaitan
Phil Atkin
Peter Hrenka
Neil Hughes
Neil Groves
Mattias Linde
Mattias Helsing
Mathieu Marache
Maria Ten
Ken Sewell
Julian Ortiz
Jeremy Bell
James French
Garrett Potts
Gabor Dorka
Donn Mielcarek
Donald Cipperly
Domenico Mangieri
Charles Cole
Blake Williams
Antoine Hue
Andrew Bettison
Anders Backman
Ali Botorabi
Zach Deedler
@@ -149,15 +154,19 @@ Steve Lunsford
Stephane Simon
Stephan Eilemann
Stanislav Blinov
Sebastian Messerschmidt
Rudolf Wiedemann
Riccardo Corsi
Ralf Kern
Perry Miller
Nathan Monteleone
Miguel Escriva
Michael Henheffer
Maya Leonard
Max Behensky
Mathew May
Martijn Kragtwijk
Liang Aibin
Kevin Moiule
Keith Steffen
Joseph Winston
@@ -165,28 +174,29 @@ John Aughey
Johan Nouvel
Igor Kravtchenko
Gustavo Wagner
Gino van den Bergen
Gerrick Bivins
George Tarantilis
Garret Potts
Fabio Mierlo
Edgar Ellis
Donald Cipperly
Doug McCorkle
David Ergo
Daniel Trstenjak
Csaba Halasz
Brad Anderegg
Andrew Sampson
Andrew Lorino
Andreas Goebel
Zbigniew Sroczynski
Yuri Vilmanis
Warren Macchi
Wang Rui
Wang Lam
Walter J. Altice
Volker Walkiewicz
Vladimir Vukicevic
Vlad Danciu
Vincent Vivanloc
Vincent Bourdier
Vasily Radostev
Vaclav Bilek
Tyge
@@ -197,18 +207,19 @@ Thom Carlo
Tery Welsh
Tatsuhiro Nishioka
Tanguy Fautr<74>
Steven Thomas
Sid Byce
Shuxing Xiao
Shane Arnott
Sebastien Kuntz
Sebastian Messerschimdt
Rudolf Wiedemann
Ruth Lang
Ronny Krueger
Robert Swain
Rick Pingry
Rene Molenaar
Reinhard Sainitzer
Rein Kadijk
Raymond de Vries
Qing Shen
Philipp Siemoleit
Philipp M<>chler
@@ -219,7 +230,9 @@ Panagiotis Papadakos
Orhun Birsoy
Ole-Morten Duesund
Nicolas Brodu
Neil Hughes
Nathan Cournia
Morten Haukness
Morn<EFBFBD> Pistorius
Mirko Viviani
Mikkel Gjøl
@@ -236,15 +249,18 @@ Mathia Walker
Mason Menninger
Martin Spott
Martin Amueller
Mario Valle
Mario Guimaraes
Marin Lavery
Marco Lehmann
Louis Hamilton
Lilin Xiong
Lewis Harmon
Lars Nilson
Kristopher Bixler
Karsten Weiss
Karl Heijdenberg
Josh Portway
John Vidar Larring
John Tan
John Grant
John Donovan
@@ -278,23 +294,23 @@ Duvan Cope
Duncan Cavens
Drew Whitehouse
Douglas A. Pouk
Doug McCorkle
Dean Iverson
David Jung
David Gurhrie
Daniel Stien
Daniel Olivier
Dan Minor
Cyril Brulebois
Clay Fowler
Chuck Sembroski
Chuck Seberion
Christophe Loustaunau
Christian Kaser
Chris McGlone
Carlos Garcea
Bruno Herbelin
Brian Keener
Brandon Hamm
Brad Anderegg
Bora Utka
Blasius Czink
Benoit Laniel
@@ -303,6 +319,7 @@ Bart Gallet
Axel Volley
Andrew Reyonolds
Andreas Jochens
Andre Normann
Almalric Alexandre
Allen Bierbaum
Alexandre Amalric

View File

@@ -2,7 +2,7 @@ IF(WIN32)
CMAKE_MINIMUM_REQUIRED(VERSION 2.4.6 FATAL_ERROR)
ELSE(WIN32)
IF(APPLE)
CMAKE_MINIMUM_REQUIRED(VERSION 2.4.6 FATAL_ERROR)
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR)
IF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4 AND ${CMAKE_PATCH_VERSION} LESS 7)
MESSAGE("Warning: A critical CMake bug exists in 2.4.6 and below. Trying to build Universal Binaries will result in a compile error that seems unrelated. Either avoid building Universal Binaries by changing the CMAKE_OSX_ARCHITECTURES field to list only your architecture, or upgrade to the current CVS version of CMake or a newer stable version if it exists.")
ENDIF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4 AND ${CMAKE_PATCH_VERSION} LESS 7)
@@ -11,13 +11,22 @@ ELSE(WIN32)
ENDIF(APPLE)
ENDIF(WIN32)
if(COMMAND cmake_policy)
# Works around warnings libraries linked against that don't
# have absolute paths (e.g. -lpthreads)
cmake_policy(SET CMP0003 NEW)
# Works around warnings about escaped quotes in ADD_DEFINITIONS
# statements.
cmake_policy(SET CMP0005 NEW)
endif(COMMAND cmake_policy)
PROJECT(OpenSceneGraph)
SET(OPENSCENEGRAPH_MAJOR_VERSION 2)
SET(OPENSCENEGRAPH_MINOR_VERSION 4)
SET(OPENSCENEGRAPH_MINOR_VERSION 6)
SET(OPENSCENEGRAPH_PATCH_VERSION 0)
SET(OPENSCENEGRAPH_SOVERSION 35)
SET(OPENSCENEGRAPH_SOVERSION 44)
SET(OPENSCENEGRAPH_VERSION ${OPENSCENEGRAPH_MAJOR_VERSION}.${OPENSCENEGRAPH_MINOR_VERSION}.${OPENSCENEGRAPH_PATCH_VERSION})
@@ -56,20 +65,20 @@ ENDIF(USING_OSG_OP_OT_TRIPLE_SET)
# Okay, here's the problem: On some platforms, linking against OpenThreads
# is not enough and explicit linking to the underlying thread library
# is not enough and explicit linking to the underlying thread library
# is also required (e.g. FreeBSD). But OpenThreads may be built with different
# backends (Pthreads, Sproc, Windows) so we don't know what the underlying
# thread library is because some platforms support multiple backends (e.g.
# IRIX supports Sproc and Pthreads). Linking all libraries won't work
# backends (Pthreads, Sproc, Windows) so we don't know what the underlying
# thread library is because some platforms support multiple backends (e.g.
# IRIX supports Sproc and Pthreads). Linking all libraries won't work
# because the libraries may be incompatible.
# So the current solution is to attempt best guess linking and exempt certain
# So the current solution is to attempt best guess linking and exempt certain
# cases. With IRIX, we're going to hope explicit linking to the underlying
# library is not necessary. We currently don't case for pthreads on Windows
# which might be an issue on things like Cygwin. This may need to be fixed.
FIND_PACKAGE(Threads)
IF(CMAKE_SYSTEM MATCHES IRIX)
# Erase CMAKE_THREAD_LIBS_INIT and hope it works
SET(CMAKE_THREAD_LIBS_INIT "" CACHE INTERNAL "")
SET(CMAKE_THREAD_LIBS_INIT "" CACHE INTERNAL "")
ENDIF(CMAKE_SYSTEM MATCHES IRIX)
# Find OpenGL
@@ -87,49 +96,37 @@ IF(UNIX)
# Some Unicies need explicit linkage to the Math library or the build fails.
FIND_LIBRARY(MATH_LIBRARY m)
ENDIF(UNIX)
# Make the headers visible to everything
IF(NOT ${PROJECT_BINARY_DIR} EQUAL ${PROJECT_SOURCE_DIR})
INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR}/include)
ENDIF(NOT ${PROJECT_BINARY_DIR} EQUAL ${PROJECT_SOURCE_DIR})
INCLUDE_DIRECTORIES(
${OpenSceneGraph_SOURCE_DIR}/include
${OPENGL_INCLUDE_DIR}
)
# Common global definitions
#ADD_DEFINITIONS(-D)
# Platform specific definitions
IF(NOT DEFAULT_GLU_TESS_CALLBACK_TRIPLEDOT)
SET(DEFAULT_GLU_TESS_CALLBACK_TRIPLEDOT OFF)
IF (CMAKE_SYSTEM MATCHES "AIX.*")
SET(DEFAULT_GLU_TESS_CALLBACK_TRIPLEDOT ON)
ENDIF(CMAKE_SYSTEM MATCHES "AIX.*")
IF (APPLE)
SET(DEFAULT_GLU_TESS_CALLBACK_TRIPLEDOT ON)
ENDIF(APPLE)
ENDIF(NOT DEFAULT_GLU_TESS_CALLBACK_TRIPLEDOT)
OPTION(OSG_GLU_TESS_CALLBACK_TRIPLEDOT "Set to ON to build build with (...) version of GLU tesselator callback" ${DEFAULT_GLU_TESS_CALLBACK_TRIPLEDOT})
IF (OSG_GLU_TESS_CALLBACK_TRIPLEDOT)
ADD_DEFINITIONS(-DGLU_TESS_CALLBACK_TRIPLEDOT)
ENDIF(OSG_GLU_TESS_CALLBACK_TRIPLEDOT)
IF(WIN32)
# This option is to enable the /MP switch for Visual Studio 2005 and above compilers
OPTION(WIN32_USE_MP "Set to ON to build OpenSceneGraph with the /MP option (Visual Studio 2005 and above)." OFF)
MARK_AS_ADVANCED(WIN32_USE_MP)
IF(WIN32_USE_MP)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
ENDIF(WIN32_USE_MP)
IF(MSVC)
# This option is to enable the /MP switch for Visual Studio 2005 and above compilers
OPTION(WIN32_USE_MP "Set to ON to build OpenSceneGraph with the /MP option (Visual Studio 2005 and above)." OFF)
MARK_AS_ADVANCED(WIN32_USE_MP)
IF(WIN32_USE_MP)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
ENDIF(WIN32_USE_MP)
# More MSVC specific compilation flags
ADD_DEFINITIONS(-D_SCL_SECURE_NO_WARNINGS)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
ENDIF(MSVC)
ADD_DEFINITIONS(-D_SCL_SECURE_NO_WARNINGS)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
#needed for net plugin
SET (OSG_SOCKET_LIBS wsock32)
# Both Cygwin and Msys need -DNOMINMAX ???
@@ -138,12 +135,12 @@ IF(WIN32)
ENDIF(UNIX)
########################################################################################################
# the foolowing options are MSVC specific,
# the first OSG_MSVC_VERSIONED_DLL activate a custom build-time layout that should allow to run examples and application
# the first OSG_MSVC_VERSIONED_DLL activate a custom build-time layout that should allow to run examples and application
# fron bin folder without requiring installation step.
# it also prepend "osg${OPENSCENEGRAPH_SOVERSION}-" to only .dll files, leaving .lib files untouched in lib
# it also use a hack to get rid of Debug and Release folder in MSVC projects
# it also use a hack to get rid of Debug and Release folder in MSVC projects
# all the .dll and .pdb are in bin and all the .lib and .exp are in lib
#
#
# the second option disable incremental linking in debug build , that is enabled by default by CMake
##########################################################################################################
@@ -187,27 +184,25 @@ ENDIF(WIN32)
OPTION(OSG_USE_FLOAT_MATRIX "Set to ON to build OpenSceneGraph with float Matrix instead of double." OFF)
MARK_AS_ADVANCED(OSG_USE_FLOAT_MATRIX)
IF(OSG_USE_FLOAT_MATRIX)
ADD_DEFINITIONS(-DOSG_USE_FLOAT_MATRIX)
ENDIF(OSG_USE_FLOAT_MATRIX)
OPTION(OSG_USE_FLOAT_PLANE "Set to ON to build OpenSceneGraph with float Plane instead of double." OFF)
MARK_AS_ADVANCED(OSG_USE_FLOAT_PLANE)
IF(OSG_USE_FLOAT_PLANE)
ADD_DEFINITIONS(-DOSG_USE_FLOAT_PLANE)
ENDIF(OSG_USE_FLOAT_PLANE)
OPTION(OSG_USE_FLOAT_BOUNDINGSPHERE "Set to ON to build OpenSceneGraph with float BoundingSphere instead of double." ON)
MARK_AS_ADVANCED(OSG_USE_FLOAT_BOUNDINGSPHERE)
IF(NOT OSG_USE_FLOAT_BOUNDINGSPHERE)
ADD_DEFINITIONS(-DOSG_USE_DOUBLE_BOUNDINGSPHERE)
ENDIF(NOT OSG_USE_FLOAT_BOUNDINGSPHERE)
OPTION(OSG_USE_FLOAT_BOUNDINGBOX "Set to ON to build OpenSceneGraph with float BoundingBox instead of double." ON)
MARK_AS_ADVANCED(OSG_USE_FLOAT_BOUNDINGBOX)
IF(NOT OSG_USE_FLOAT_BOUNDINGBOX)
ADD_DEFINITIONS(-DOSG_USE_DOUBLE_BOUNDINGBOX)
ENDIF(NOT OSG_USE_FLOAT_BOUNDINGBOX)
################################################################################
# Set Config file
SET(OPENSCENEGRAPH_CONFIG_HEADER "${PROJECT_BINARY_DIR}/include/osg/Config")
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/src/osg/Config.in"
"${OPENSCENEGRAPH_CONFIG_HEADER}")
# INSTALL_FILES(/include/osg/ FILES "${OPENSCENEGRAPH_CONFIG_HEADER}")
################################################################################
# 3rd Party Dependency Stuff
@@ -243,26 +238,82 @@ IF (DESIRED_QT_VERSION)
ELSE(DESIRED_QT_VERSION MATCHES 4)
FIND_PACKAGE(Qt3)
ENDIF(DESIRED_QT_VERSION MATCHES 4)
ELSE(DESIRED_QT_VERSION)
FIND_PACKAGE(Qt4)
IF (NOT QT4_FOUND)
FIND_PACKAGE(Qt3)
ENDIF(NOT QT4_FOUND)
ENDIF(DESIRED_QT_VERSION)
#use pkg-config to find various modues
INCLUDE(FindPkgConfig OPTIONAL)
IF(PKG_CONFIG_FOUND)
INCLUDE(FindPkgConfig)
PKG_CHECK_MODULES(GTK gtk+-2.0)
IF(WIN32)
PKG_CHECK_MODULES(GTKGL gtkglext-win32-1.0)
ELSE(WIN32)
PKG_CHECK_MODULES(GTKGL gtkglext-x11-1.0)
ENDIF(WIN32)
PKG_CHECK_MODULES(RSVG librsvg-2.0)
PKG_CHECK_MODULES(CAIRO cairo)
ENDIF(PKG_CONFIG_FOUND)
#
# Test to determine if we want the "tripledot" form of the GLU tesselator callback.
#
IF(NOT DEFAULT_GLU_TESS_CALLBACK_TRIPLEDOT)
IF(WIN32 OR CMAKE_SYSTEM_NAME MATCHES "Linux")
# Skip the compile check for platforms that never need the variable
# form.
SET(DEFAULT_GLU_TESS_CALLBACK_TRIPLEDOT false)
ELSE(WIN32 OR CMAKE_SYSTEM_NAME MATCHES "Linux")
# For other platforms perform the check
INCLUDE(CheckCXXSourceCompiles)
SET(CMAKE_REQUIRED_DEFINITIONS -DGLU_TESS_CALLBACK_TRIPLEDOT)
SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/include ${GLUT_INCLUDE_DIR} ${GL_INCLUDE_DIR})
SET(CMAKE_REQUIRED_LIBRARIES ${GLUT_LIBRARY} ${GL_LIBRARY})
CHECK_CXX_SOURCE_COMPILES(
"#include <osg/GL>
#include <osg/GLU>
static void testcb(GLvoid *, void*) { }
int main() {
GLUtesselator *t = gluNewTess();
gluTessCallback(t, GLU_TESS_VERTEX_DATA, (GLU_TESS_CALLBACK) testcb);
return 0;
}"
GLU_Tesselator_Needs_Variable_Parameter_Callback_Convention_Failure_Means_No)
SET(DEFAULT_GLU_TESS_CALLBACK_TRIPLEDOT
${GLU_Tesselator_Needs_Variable_Parameter_Callback_Convention_Failure_Means_No})
ENDIF(WIN32 OR CMAKE_SYSTEM_NAME MATCHES "Linux")
ENDIF(NOT DEFAULT_GLU_TESS_CALLBACK_TRIPLEDOT)
OPTION(OSG_GLU_TESS_CALLBACK_TRIPLEDOT "Set to ON to build build with variable parameter (...) version of GLU tesselator callback" ${DEFAULT_GLU_TESS_CALLBACK_TRIPLEDOT})
IF(OSG_GLU_TESS_CALLBACK_TRIPLEDOT)
ADD_DEFINITIONS(-DGLU_TESS_CALLBACK_TRIPLEDOT)
ENDIF(OSG_GLU_TESS_CALLBACK_TRIPLEDOT)
# Platform specific:
# (We can approach this one of two ways. We can try to FIND everything
# and simply check if we found the packages before actually building
# or we can hardcode the cases. The advantage of the former is that
# or we can hardcode the cases. The advantage of the former is that
# packages that are installed on platforms that don't require them
# will still get built (presuming no compatibility issues). But this
# also means modules that are redundant may get built. For example,
# will still get built (presuming no compatibility issues). But this
# also means modules that are redundant may get built. For example,
# OS X doesn't need GIF, JPEG, PNG, TIFF, etc because it uses QuickTime.
# Also, it will clutter the CMake menu with "NOT_FOUND".
# The downside to the latter is that it is harder to build those
@@ -280,8 +331,8 @@ IF(NOT APPLE)
IF(WIN32)
FIND_PACKAGE(QuickTime)
ENDIF(WIN32)
ELSE(NOT APPLE)
ELSE(NOT APPLE)
FIND_PACKAGE(QuickTime)
ENDIF(NOT APPLE)
@@ -296,7 +347,18 @@ ENDIF("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
################################################################################
# Installation stuff
SET(CMAKE_DEBUG_POSTFIX "d")
SET(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "add a postfix, usually d on windows")
IF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4)
ADD_DEFINITIONS(-DOSG_DEBUG_POSTFIX="${CMAKE_DEBUG_POSTFIX}")
ELSE(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4)
ADD_DEFINITIONS(-DOSG_DEBUG_POSTFIX='\"${CMAKE_DEBUG_POSTFIX}\"')
ENDIF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4)
IF(UNIX AND NOT WIN32 AND NOT APPLE)
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
ADD_DEFINITIONS("-D_DEBUG")
ENDIF(CMAKE_BUILD_TYPE STREQUAL "Debug")
ENDIF(UNIX AND NOT WIN32 AND NOT APPLE)
IF(UNIX AND NOT WIN32 AND NOT APPLE)
IF(CMAKE_SIZEOF_VOID_P MATCHES "8")
@@ -307,7 +369,10 @@ ENDIF(UNIX AND NOT WIN32 AND NOT APPLE)
IF(NOT DEFINED LIB_POSTFIX)
SET(LIB_POSTFIX "")
ENDIF(NOT DEFINED LIB_POSTFIX)
# Here we apparantly do some funky stuff with making the bin/ and lib/
# folders which is probably needed to work around a very old CMake bug?
#SET(OUTPUT_BINDIR ${PROJECT_BINARY_DIR}/bin/${CMAKE_SYSTEM_NAME})
SET(OUTPUT_BINDIR ${PROJECT_BINARY_DIR}/bin)
MAKE_DIRECTORY(${OUTPUT_BINDIR})
@@ -315,17 +380,32 @@ IF(MSVC AND NOT MSVC_IDE)
MAKE_DIRECTORY(${OUTPUT_BINDIR}/${OSG_PLUGINS})
ENDIF(MSVC AND NOT MSVC_IDE)
SET(EXECUTABLE_OUTPUT_PATH ${OUTPUT_BINDIR})
#SET(OUTPUT_LIBDIR ${PROJECT_BINARY_DIR}/lib/${CMAKE_SYSTEM_NAME})
SET(OUTPUT_LIBDIR ${PROJECT_BINARY_DIR}/lib)
MAKE_DIRECTORY(${OUTPUT_LIBDIR})
IF(NOT MSVC)
MAKE_DIRECTORY(${OUTPUT_LIBDIR}/${OSG_PLUGINS})
ENDIF(NOT MSVC)
SET(LIBRARY_OUTPUT_PATH ${OUTPUT_LIBDIR})
# On CMake 2.4.x use EXECUTABLE_OUTPUT_PATH and LIBRARY_OUTPUT_PATH and later
# we work around the DLL placement by use of the PREFIX target property hack
#
# On CMake 2.6.x use the newly minted CMAKE_LIBRARY_OUTPUT_DIRECTORY,
# CMAKE_ARCHIVE_OUTPUT_DIRECTORY & CMAKE_RUNTIME_OUTPUT_DIRECTORY
IF(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION GREATER 4)
# If CMake >= 2.6.0
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_LIBDIR})
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_BINDIR})
IF(WIN32)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_BINDIR})
ELSE(WIN32)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_LIBDIR})
ENDIF(WIN32)
ELSE(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION GREATER 4)
SET(EXECUTABLE_OUTPUT_PATH ${OUTPUT_BINDIR})
SET(LIBRARY_OUTPUT_PATH ${OUTPUT_LIBDIR})
ENDIF(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION GREATER 4)
#SET(INSTALL_BINDIR OpenSceneGraph/bin)
#SET(INSTALL_INCDIR OpenSceneGraph/include)
@@ -381,20 +461,20 @@ IF (BUILD_OSG_EXAMPLES)
ADD_SUBDIRECTORY(examples)
ENDIF(BUILD_OSG_EXAMPLES)
# This is for an advanced option to give aggressive warnings
# This is for an advanced option to give aggressive warnings
# under different compilers. If yours is not implemented, this option
# will not be made available.
IF(CMAKE_COMPILER_IS_GNUCXX)
# To be complete, we might also do GNUCC flags,
# To be complete, we might also do GNUCC flags,
# but everything here is C++ code.
# -Wshadow and -Woverloaded-virtual are also interesting flags, but OSG
# returns too many hits.
# FYI, if we do implement GNUCC, then -Wmissing-prototypes in another
# FYI, if we do implement GNUCC, then -Wmissing-prototypes in another
# interesting C-specific flag.
# Also, there is a bug in gcc 4.0. Under C++, -pedantic will create
# errors instead of warnings for certain issues, including superfluous
# semicolons and commas, and the use of long long. -fpermissive seems
# to be the workaround.
# to be the workaround.
SET(OSG_AGGRESSIVE_WARNING_FLAGS "-Wall -Wparentheses -Wformat=2 -Wno-long-long -Wno-import -pedantic -Wreturn-type -Wmissing-braces -Wunknown-pragmas -Wunused -fpermissive")
ELSE(CMAKE_COMPILER_IS_GNUCXX)
IF(MSVC)
@@ -402,11 +482,11 @@ ELSE(CMAKE_COMPILER_IS_GNUCXX)
# And do we need to further subcase this for different versions of VS?
# CMake variables: MSVC60, MSVC70, MSVC71, MSVC80, CMAKE_COMPILER_2005
SET(OSG_AGGRESSIVE_WARNING_FLAGS "/Wall /W4")
ELSE(MSVC)
# CMake lacks an elseif, so other non-gcc, non-VS compilers need
# to be listed below. If unhandled, OSG_AGGRESSIVE_WARNING_FLAGS should
# to be listed below. If unhandled, OSG_AGGRESSIVE_WARNING_FLAGS should
# remain unset.
ENDIF(MSVC)
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
@@ -424,7 +504,7 @@ IF(OSG_AGGRESSIVE_WARNING_FLAGS)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OSG_AGGRESSIVE_WARNING_FLAGS}" CACHE STRING "Flags used by the compiler during all build types." FORCE)
ENDIF(NOT "${OLD_CMAKE_CXX_FLAGS_WAS_SET}")
ELSE(OSG_USE_AGGRESSIVE_WARNINGS)
# FIXME: This will lose any changes made after OLD_CMAKE_CXX_FLAGS was
# FIXME: This will lose any changes made after OLD_CMAKE_CXX_FLAGS was
# set. The better way would be to parse the string and remove each
# option explicitly.
IF("${OLD_CMAKE_CXX_FLAGS_WAS_SET}")
@@ -434,24 +514,28 @@ IF(OSG_AGGRESSIVE_WARNING_FLAGS)
ENDIF(OSG_USE_AGGRESSIVE_WARNINGS)
ENDIF(OSG_AGGRESSIVE_WARNING_FLAGS)
# Set defaults for Universal Binaries. We want 32-bit Intel/PPC on 10.4
# Set defaults for Universal Binaries. We want 32-bit Intel/PPC on 10.4
# and 32/64-bit Intel/PPC on >= 10.5. Anything <= 10.3 doesn't support.
IF(APPLE)
# These are just defaults/recommendations, but how we want to build
# out of the box. But the user needs to be able to change these options.
# So we must only set the values the first time CMake is run, or we
# So we must only set the values the first time CMake is run, or we
# will overwrite any changes the user sets.
# FORCE is used because the options are not reflected in the UI otherwise.
# Seems like a good place to add version specific compiler flags too.
IF(NOT OSG_CONFIG_HAS_BEEN_RUN_BEFORE)
# This is really fragile, but CMake doesn't provide the OS system
# version information we need. (Darwin versions can be changed
# This is really fragile, but CMake doesn't provide the OS system
# version information we need. (Darwin versions can be changed
# independently of OS X versions.)
# It does look like CMake handles the CMAKE_OSX_SYSROOT automatically.
IF(EXISTS /Developer/SDKs/10.5.sdk)
SET(CMAKE_OSX_ARCHITECTURES "ppc;i386;ppc64;x86_64" CACHE STRING "Build architectures for OSX" FORCE)
IF(EXISTS /Developer/SDKs/MacOSX10.5.sdk)
# 64-bit compiles are not supported with Carbon. We should enable
# 64-bit compilation by default once osgviewer has been
# rewritten with Cocoa.
#SET(CMAKE_OSX_ARCHITECTURES "ppc;i386;ppc64;x86_64" CACHE STRING "Build architectures for OSX" FORCE)
SET(CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "Build architectures for OSX" FORCE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.5 -ftree-vectorize -fvisibility-inlines-hidden" CACHE STRING "Flags used by the compiler during all build types." FORCE)
ELSE(EXISTS /Developer/SDKs/10.5.sdk)
ELSE(EXISTS /Developer/SDKs/MacOSX10.5.sdk)
IF(EXISTS /Developer/SDKs/MacOSX10.4u.sdk)
SET(CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "Build architectures for OSX" FORCE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.4 -ftree-vectorize -fvisibility-inlines-hidden" CACHE STRING "Flags used by the compiler during all build types." FORCE)
@@ -460,11 +544,11 @@ IF(APPLE)
# Should break down further to set the -mmacosx-version-min,
# but the SDK detection is too unreliable here.
ENDIF(EXISTS /Developer/SDKs/MacOSX10.4u.sdk)
ENDIF(EXISTS /Developer/SDKs/10.5.sdk)
ENDIF(EXISTS /Developer/SDKs/MacOSX10.5.sdk)
ENDIF(NOT OSG_CONFIG_HAS_BEEN_RUN_BEFORE)
OPTION(OSG_BUILD_APPLICATION_BUNDLES "Enable the building of applications and examples as OSX Bundles" OFF)
ENDIF(APPLE)
OPTION(BUILD_REF_DOCS "Build OpenSceneGraph reference documentation using doxygen (use: make DoxygenDoc)" OFF)
@@ -476,7 +560,7 @@ IF(BUILD_REF_DOCS)
ENDIF(BUILD_REF_DOCS)
# For Doxygen
#FIXME: I haven't figured out what to do with OSG's multiple doxyfiles
#FIXME: I haven't figured out what to do with OSG's multiple doxyfiles
# and footer.
INCLUDE(${CMAKE_ROOT}/Modules/Documentation.cmake OPTIONAL)
OPTION(BUILD_DOCUMENTATION "Build osg documentation" OFF)
@@ -490,13 +574,13 @@ IF(BUILD_DOCUMENTATION)
ELSE(BUILD_REF_DOCS_SEARCHENGINE)
SET(SEARCHENGINE NO)
ENDIF(BUILD_REF_DOCS_SEARCHENGINE)
IF(BUILD_REF_DOCS_TAGFILE)
SET(GENERATE_TAGFILE "doc/OpenSceneGraphReferenceDocs/osg.tag")
ELSE(BUILD_REF_DOCS_TAGFILE)
SET(GENERATE_TAGFILE "")
ENDIF(BUILD_REF_DOCS_TAGFILE)
IF(DOT)
SET(HAVE_DOT YES)
ELSE(DOT)

View File

@@ -0,0 +1,95 @@
# Check for availability of atomic operations
# This module defines
# OPENTHREADS_HAVE_ATOMIC_OPS
INCLUDE(CheckCXXSourceRuns)
# Do step by step checking,
CHECK_CXX_SOURCE_RUNS("
#include <cstdlib>
int main()
{
unsigned value = 0;
void* ptr = &value;
__sync_add_and_fetch(&value, 1);
__sync_synchronize();
__sync_sub_and_fetch(&value, 1);
if (!__sync_bool_compare_and_swap(&value, 0, 1))
return EXIT_FAILURE;
if (!__sync_bool_compare_and_swap(&ptr, ptr, ptr))
return EXIT_FAILURE;
return EXIT_SUCCESS;
}
" _OPENTHREADS_ATOMIC_USE_GCC_BUILTINS)
CHECK_CXX_SOURCE_RUNS("
#include <stdlib.h>
int main(int, const char**)
{
unsigned value = 0;
void* ptr = &value;
__add_and_fetch(&value, 1);
__synchronize(value);
__sub_and_fetch(&value, 1);
if (!__compare_and_swap(&value, 0, 1))
return EXIT_FAILURE;
if (!__compare_and_swap((unsigned long*)&ptr, (unsigned long)ptr, (unsigned long)ptr))
return EXIT_FAILURE;
return EXIT_SUCCESS;
}
" _OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS)
CHECK_CXX_SOURCE_RUNS("
#include <atomic.h>
#include <cstdlib>
int main(int, const char**)
{
uint_t value = 0;
void* ptr = &value;
atomic_inc_uint_nv(&value);
membar_consumer();
atomic_dec_uint_nv(&value);
if (0 != atomic_cas_uint(&value, 0, 1))
return EXIT_FAILURE;
if (ptr != atomic_cas_ptr(&ptr, ptr, ptr))
return EXIT_FAILURE;
return EXIT_SUCCESS;
}
" _OPENTHREADS_ATOMIC_USE_SUN)
CHECK_CXX_SOURCE_RUNS("
#include <windows.h>
#include <cstdlib>
int main(int, const char**)
{
volatile long value = 0;
long data = 0;
long* volatile ptr = &data;
InterlockedIncrement(&value);
MemoryBarrier();
InterlockedDecrement(&value);
if (0 != InterlockedCompareExchange(&value, 1, 0))
return EXIT_FAILURE;
if (ptr != InterlockedCompareExchangePointer((PVOID volatile*)&ptr, (PVOID)ptr, (PVOID)ptr))
return EXIT_FAILURE;
return EXIT_SUCCESS;
}
" _OPENTHREADS_ATOMIC_USE_WIN32_INTERLOCKED)
IF(NOT _OPENTHREADS_ATOMIC_USE_GCC_BUILTINS AND NOT _OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS AND NOT _OPENTHREADS_ATOMIC_USE_SUN AND NOT _OPENTHREADS_ATOMIC_USE_WIN32_INTERLOCKED)
SET(_OPENTHREADS_ATOMIC_USE_MUTEX 1)
ENDIF(NOT _OPENTHREADS_ATOMIC_USE_GCC_BUILTINS AND NOT _OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS AND NOT _OPENTHREADS_ATOMIC_USE_SUN AND NOT _OPENTHREADS_ATOMIC_USE_WIN32_INTERLOCKED)

View File

@@ -5,8 +5,8 @@
MACRO(FIND_DEPENDENCY DEPNAME INCLUDEFILE LIBRARY_NAMES SEARCHPATHLIST DEBUGSUFFIX)
MESSAGE(STATUS "searching ${DEPNAME} -->${INCLUDEFILE}<-->${LIBRARY}<-->${SEARCHPATHLIST}<--")
MESSAGE(STATUS "searching ${DEPNAME} -->${INCLUDEFILE}<-->${LIBRARY_NAMES}<-->${SEARCHPATHLIST}<--")
SET(MY_PATH_INCLUDE )
SET(MY_PATH_LIB )
@@ -14,9 +14,10 @@ MACRO(FIND_DEPENDENCY DEPNAME INCLUDEFILE LIBRARY_NAMES SEARCHPATHLIST DEBUGSUFF
SET(MY_PATH_INCLUDE ${MY_PATH_INCLUDE} ${MYPATH}/include)
SET(MY_PATH_LIB ${MY_PATH_LIB} ${MYPATH}/lib)
ENDFOREACH( MYPATH ${SEARCHPATHLIST} )
FIND_PATH("${DEPNAME}_INCLUDE_DIR" ${INCLUDEFILE}
${MY_PATH_INCLUDE}
NO_DEFAULT_PATH
)
MARK_AS_ADVANCED("${DEPNAME}_INCLUDE_DIR")
#MESSAGE( " ${DEPNAME}_INCLUDE_DIR --> ${${DEPNAME}_INCLUDE_DIR}<--")
@@ -24,6 +25,7 @@ MACRO(FIND_DEPENDENCY DEPNAME INCLUDEFILE LIBRARY_NAMES SEARCHPATHLIST DEBUGSUFF
FIND_LIBRARY("${DEPNAME}_LIBRARY"
NAMES ${LIBRARY_NAMES}
PATHS ${MY_PATH_LIB}
NO_DEFAULT_PATH
)
SET(LIBRARY_NAMES_DEBUG "")
FOREACH(LIBNAME ${LIBRARY_NAMES})
@@ -32,6 +34,7 @@ MACRO(FIND_DEPENDENCY DEPNAME INCLUDEFILE LIBRARY_NAMES SEARCHPATHLIST DEBUGSUFF
FIND_LIBRARY("${DEPNAME}_LIBRARY_DEBUG"
NAMES ${LIBRARY_NAMES_DEBUG}
PATHS ${MY_PATH_LIB}
NO_DEFAULT_PATH
)
MARK_AS_ADVANCED("${DEPNAME}_LIBRARY")
#MESSAGE( " ${DEPNAME}_LIBRARY --> ${${DEPNAME}_LIBRARY}<--")

View File

@@ -18,7 +18,9 @@ FIND_PATH(COLLADA_INCLUDE_DIR dae.h
~/Library/Frameworks
/Library/Frameworks
/usr/local/include
/usr/include
/usr/local/include/colladadom
/usr/include/
/usr/include/colladadom
/sw/include # Fink
/opt/local/include # DarwinPorts
/opt/csw/include # Blastwave
@@ -28,7 +30,7 @@ FIND_PATH(COLLADA_INCLUDE_DIR dae.h
)
FIND_LIBRARY(COLLADA_LIBRARY
NAMES collada_dom
NAMES collada_dom collada14dom
PATHS
$ENV{COLLADA_DIR}/lib
$ENV{COLLADA_DIR}/lib-dbg
@@ -39,7 +41,9 @@ FIND_LIBRARY(COLLADA_LIBRARY
~/Library/Frameworks
/Library/Frameworks
/usr/local/lib
/usr/local/lib64
/usr/lib
/usr/lib64
/sw/lib
/opt/local/lib
/opt/csw/lib

View File

@@ -21,22 +21,26 @@ MACRO(LINK_WITH_VARIABLES TRGTNAME)
ENDMACRO(LINK_WITH_VARIABLES TRGTNAME)
MACRO(LINK_INTERNAL TRGTNAME)
FOREACH(LINKLIB ${ARGN})
IF(MSVC AND OSG_MSVC_VERSIONED_DLL)
#when using versioned names, the .dll name differ from .lib name, there is a problem with that:
#CMake 2.4.7, at least seem to use PREFIX instead of IMPORT_PREFIX for computing linkage info to use into projects,
# so we full path name to specify linkage, this prevent automatic inferencing of dependencies, so we add explicit depemdencies
#to library targets used
IF(NOT MSVC_IDE)
TARGET_LINK_LIBRARIES(${TRGTNAME} optimized "${OUTPUT_LIBDIR}/${LINKLIB}.lib" debug "${OUTPUT_LIBDIR}/${LINKLIB}${CMAKE_DEBUG_POSTFIX}.lib")
ELSE(NOT MSVC_IDE)
TARGET_LINK_LIBRARIES(${TRGTNAME} optimized "${OUTPUT_LIBDIR}/${LINKLIB}" debug "${OUTPUT_LIBDIR}/${LINKLIB}${CMAKE_DEBUG_POSTFIX}")
ENDIF(NOT MSVC_IDE)
ADD_DEPENDENCIES(${TRGTNAME} ${LINKLIB})
ELSE(MSVC AND OSG_MSVC_VERSIONED_DLL)
TARGET_LINK_LIBRARIES(${TRGTNAME} optimized "${LINKLIB}" debug "${LINKLIB}${CMAKE_DEBUG_POSTFIX}")
ENDIF(MSVC AND OSG_MSVC_VERSIONED_DLL)
ENDFOREACH(LINKLIB)
IF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4)
TARGET_LINK_LIBRARIES(${TRGTNAME} ${ARGN})
ELSE(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4)
FOREACH(LINKLIB ${ARGN})
IF(MSVC AND OSG_MSVC_VERSIONED_DLL)
#when using versioned names, the .dll name differ from .lib name, there is a problem with that:
#CMake 2.4.7, at least seem to use PREFIX instead of IMPORT_PREFIX for computing linkage info to use into projects,
# so we full path name to specify linkage, this prevent automatic inferencing of dependencies, so we add explicit depemdencies
#to library targets used
IF(NOT MSVC_IDE)
TARGET_LINK_LIBRARIES(${TRGTNAME} optimized "${OUTPUT_LIBDIR}/${LINKLIB}.lib" debug "${OUTPUT_LIBDIR}/${LINKLIB}${CMAKE_DEBUG_POSTFIX}.lib")
ELSE(NOT MSVC_IDE)
TARGET_LINK_LIBRARIES(${TRGTNAME} optimized "${OUTPUT_LIBDIR}/${LINKLIB}" debug "${OUTPUT_LIBDIR}/${LINKLIB}${CMAKE_DEBUG_POSTFIX}")
ENDIF(NOT MSVC_IDE)
ADD_DEPENDENCIES(${TRGTNAME} ${LINKLIB})
ELSE(MSVC AND OSG_MSVC_VERSIONED_DLL)
TARGET_LINK_LIBRARIES(${TRGTNAME} optimized "${LINKLIB}" debug "${LINKLIB}${CMAKE_DEBUG_POSTFIX}")
ENDIF(MSVC AND OSG_MSVC_VERSIONED_DLL)
ENDFOREACH(LINKLIB)
ENDIF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4)
ENDMACRO(LINK_INTERNAL TRGTNAME)
MACRO(LINK_EXTERNAL TRGTNAME)
@@ -118,7 +122,7 @@ ENDMACRO(SETUP_LINK_LIBRARIES)
MACRO(SETUP_PLUGIN PLUGIN_NAME)
SET(TARGET_NAME ${PLUGIN_NAME} )
SET(TARGET_NAME ${PLUGIN_NAME} )
#MESSAGE("in -->SETUP_PLUGIN<-- ${TARGET_NAME}-->${TARGET_SRC} <--> ${TARGET_H}<--")
@@ -131,7 +135,7 @@ MACRO(SETUP_PLUGIN PLUGIN_NAME)
SET(TARGET_LABEL "${TARGET_DEFAULT_LABEL_PREFIX} ${TARGET_NAME}")
ENDIF(NOT TARGET_LABEL)
# here we use the command to generate the library
# here we use the command to generate the library
IF (DYNAMIC_OPENSCENEGRAPH)
ADD_LIBRARY(${TARGET_TARGETNAME} MODULE ${TARGET_SRC} ${TARGET_H})
@@ -141,40 +145,57 @@ MACRO(SETUP_PLUGIN PLUGIN_NAME)
#not sure if needed, but for plugins only Msvc need the d suffix
IF(NOT MSVC)
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES DEBUG_POSTFIX "")
IF(NOT UNIX)
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES DEBUG_POSTFIX "")
ENDIF(NOT UNIX)
ELSE(NOT MSVC)
IF(OSG_MSVC_VERSIONED_DLL)
IF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4)
IF(NOT MSVC_IDE)
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "${OSG_PLUGINS}/")
ELSE(NOT MSVC_IDE)
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "../${OSG_PLUGINS}/")
ENDIF(NOT MSVC_IDE)
ELSE(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4)
IF(OSG_MSVC_VERSIONED_DLL)
#this is a hack... the build place is set to lib/<debug or release> by LIBARARY_OUTPUT_PATH equal to OUTPUT_LIBDIR
#the .lib will be crated in ../ so going straight in lib by the IMPORT_PREFIX property
#because we want dll placed in OUTPUT_BINDIR ie the bin folder sibling of lib, we can use ../../bin to go there,
#it is hardcoded, we should compute OUTPUT_BINDIR position relative to OUTPUT_LIBDIR ... to be implemented
#changing bin to something else breaks this hack
#the dll are placed in bin/${OSG_PLUGINS}
IF(NOT MSVC_IDE)
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "../bin/${OSG_PLUGINS}/")
ELSE(NOT MSVC_IDE)
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "../../bin/${OSG_PLUGINS}/" IMPORT_PREFIX "../")
ENDIF(NOT MSVC_IDE)
ELSE(OSG_MSVC_VERSIONED_DLL)
#in standard mode (unversioned) the .lib and .dll are placed in lib/<debug or release>/${OSG_PLUGINS}.
#here the PREFIX property has been used, the same result would be accomplidhe by prepending ${OSG_PLUGINS}/ to OUTPUT_NAME target property
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "${OSG_PLUGINS}/")
ENDIF(OSG_MSVC_VERSIONED_DLL)
ELSE(OSG_MSVC_VERSIONED_DLL)
#in standard mode (unversioned) the .lib and .dll are placed in lib/<debug or release>/${OSG_PLUGINS}.
#here the PREFIX property has been used, the same result would be accomplidhe by prepending ${OSG_PLUGINS}/ to OUTPUT_NAME target property
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "${OSG_PLUGINS}/")
ENDIF(OSG_MSVC_VERSIONED_DLL)
ENDIF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4)
ENDIF(NOT MSVC)
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PROJECT_LABEL "${TARGET_LABEL}")
SETUP_LINK_LIBRARIES()
#the installation path are differentiated for win32 that install in bib versus other architecture that install in lib${LIB_POSTFIX}/${OSG_PLUGINS}
IF(WIN32)
INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib/${OSG_PLUGINS} LIBRARY DESTINATION bin/${OSG_PLUGINS} )
INSTALL(TARGETS ${TARGET_TARGETNAME}
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib/${OSG_PLUGINS}
LIBRARY DESTINATION bin/${OSG_PLUGINS} )
ELSE(WIN32)
INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib${LIB_POSTFIX}/${OSG_PLUGINS} LIBRARY DESTINATION lib${LIB_POSTFIX}/${OSG_PLUGINS} )
INSTALL(TARGETS ${TARGET_TARGETNAME}
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib${LIB_POSTFIX}/${OSG_PLUGINS}
LIBRARY DESTINATION lib${LIB_POSTFIX}/${OSG_PLUGINS} )
ENDIF(WIN32)
ENDMACRO(SETUP_PLUGIN)
@@ -227,12 +248,15 @@ MACRO(SETUP_EXE IS_COMMANDLINE_APP)
ADD_EXECUTABLE(${TARGET_TARGETNAME} ${PLATFORM_SPECIFIC_CONTROL} ${TARGET_SRC} ${TARGET_H})
ENDIF(${IS_COMMANDLINE_APP})
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PROJECT_LABEL "${TARGET_LABEL}")
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}")
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES OUTPUT_NAME ${TARGET_NAME})
IF(MSVC_IDE AND OSG_MSVC_VERSIONED_DLL)
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES PREFIX "../")
ENDIF(MSVC_IDE AND OSG_MSVC_VERSIONED_DLL)
SETUP_LINK_LIBRARIES()
ENDMACRO(SETUP_EXE)
@@ -250,7 +274,11 @@ MACRO(SETUP_APPLICATION APPLICATION_NAME)
SETUP_EXE(${IS_COMMANDLINE_APP})
INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION bin )
IF(APPLE)
INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION bin BUNDLE DESTINATION bin)
ELSE(APPLE)
INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION bin )
ENDIF(APPLE)
ENDMACRO(SETUP_APPLICATION)
@@ -273,7 +301,11 @@ MACRO(SETUP_EXAMPLE EXAMPLE_NAME)
SETUP_EXE(${IS_COMMANDLINE_APP})
INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION share/OpenSceneGraph/bin )
IF(APPLE)
INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION share/OpenSceneGraph/bin BUNDLE DESTINATION share/OpenSceneGraph/bin )
ELSE(APPLE)
INSTALL(TARGETS ${TARGET_TARGETNAME} RUNTIME DESTINATION share/OpenSceneGraph/bin )
ENDIF(APPLE)
ENDMACRO(SETUP_EXAMPLE)
@@ -286,12 +318,12 @@ ENDMACRO(SETUP_COMMANDLINE_EXAMPLE)
# Takes two optional arguments -- osg prefix and osg version
MACRO(HANDLE_MSVC_DLL)
#this is a hack... the build place is set to lib/<debug or release> by LIBARARY_OUTPUT_PATH equal to OUTPUT_LIBDIR
#the .lib will be crated in ../ so going straight in lib by the IMPORT_PREFIX property
#because we want dll placed in OUTPUT_BINDIR ie the bin folder sibling of lib, we can use ../../bin to go there,
#it is hardcoded, we should compute OUTPUT_BINDIR position relative to OUTPUT_LIBDIR ... to be implemented
#changing bin to something else breaks this hack
#the dll are versioned by prefixing the name with osg${OPENSCENEGRAPH_SOVERSION}-
#this is a hack... the build place is set to lib/<debug or release> by LIBARARY_OUTPUT_PATH equal to OUTPUT_LIBDIR
#the .lib will be crated in ../ so going straight in lib by the IMPORT_PREFIX property
#because we want dll placed in OUTPUT_BINDIR ie the bin folder sibling of lib, we can use ../../bin to go there,
#it is hardcoded, we should compute OUTPUT_BINDIR position relative to OUTPUT_LIBDIR ... to be implemented
#changing bin to something else breaks this hack
#the dll are versioned by prefixing the name with osg${OPENSCENEGRAPH_SOVERSION}-
# LIB_PREFIX: use "osg" by default, else whatever we've been given.
IF(${ARGC} GREATER 0)

2469
ChangeLog

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,75 @@
OSG News
========
= !OpenSceneGraph 2.6 release adds osgWidget library, KdTree intersections, Anti-aliased FBOsand much more. =
PERTHSHIRE, Scotland - 5th August 2008 - !OpenSceneGraph Professional Services announces the release of !OpenSceneGraph 2.6, the industry's leading open-source scene graph technology, designed to accelerate application development and improve 3D graphics performance. !OpenSceneGraph 2.6 written entirely in Standard C++ and built upon OpenGL, offers developers working in the visual simulation, game development, virtual reality, scientific visualization and modeling markets - a real-time visualization tool which eclipses commercial scene graph toolkits in functionality, stability and performance. !OpenSceneGraph 2.6 runs on all Microsoft Windows platforms, Apple OS/X, GNU/Linux, IRIX, Solaris, HP-UX, AIX and FreeBSD operating systems.
=== Open-source development delivers industry-leading features and performance ===
The !OpenSceneGraph 2.6 release is the culmination of 9 years of work by the lead developers and the open-source community that has grown up around the project. The real-time graphics industry and academia embraced it from the very beginning, deploying it in real-world applications, and actively participating in its development, testing and refinement. The end result is a high-quality library with a feature set relevant to application developers' needs.
=== Updates include: ===
* New osgWidget library for scene graph based graphics user interface elements (beta release).
* KdTree support, with automatic KdTree generation on load and use of KdTree during line intersections which massively improves intersection speeds.
* Precision improvements to line intersections, provide accurate whole earth intersection.
* OpenGL Multi-sample FrameBufferObject support.
* New osg::ImageSequence class for doing texture animation of a series of image files.
* New database optimizer that is able to remove static transforms by duplicating shared geometries.
* Use glGenerateMipmap to speed up mipmap generation in non power-of-two textures.
* New osgViewer::ScreenCaptureHandler for adding screen shot support to osgViewer applications.
* New osgscreencapture example that demonstrates use of double buffer PixelBufferObject's for streaming of imagery from the screen.
* New utility application osgfilecache which can be used to populate the local cache for given lat/lon ranges and levels.
* Rewritten DatabasePager that now supports multiple database reading threads. This includes handling of HTTP requests via a separate reading thread, vastly improving the speed of updates when handling HTTP hosted databases that have already partially been downloaded to local file cache.
* Support for a file cache for locally caching paged databases hosted over HTTP.
* Support for http authentication in osgDB and the libcurl plugin
* New osgconv --format <fmt>, --formats and --plugins command line options for listing available plugins and the file formats/options they support.
* Performance improvements in handling TerraPage.
* Animated GIF support.
* New SVG image loader.
* Improvements to the .obj loader to support a wider range of .obj files and material properties.
* Support for thread safe Atomic reference counting.
* Support for COLLADA DOM 2.x
* Support for Philips WOWvx 3D auto-stereoscopic displays
* New include/osg/Config and include/OpenThreads/Config configuration files, that are automatically generated by CMake, which make more straight forward to build end users applications against OpenSceneGraph versions built with non default build options.
* Support for CMake 2.6
* A wide range of build and bug fixes
=== Downloads and Licensing ===
!OpenSceneGraph is open-source so full source code is provided, and can be copied, modified and used free of charge for commercial and non-commercial use. Access to the source allows end users greater flexibility in how they develop, debug and deploy their applications. They gain productivity and freedom by being able to leverage the tool chain in accordance with their own release cycles. Downloads of binaries and source can be found in the [http://www.openscenegraph.org/projects/osg/wiki/Downloads Downloads] section of the openscenegraph.org website.
!OpenSceneGraph is released under the [http://www.openscenegraph.org/projects/osg/wiki/Legal OpenSceneGraph Public License], which is based on the Lesser GNU Public License (LGPL), permitting the software to be used free of charge across the full spectrum of commercial and open-source applications. Furthermore, it allows both static and dynamic linking of the !OpenSceneGraph libraries without restricting the licensing of the user's software.
=== !OpenSceneGraph Books now available ===
The !OpenSceneGraph Quick Start Guide is now available in Chinese as well as English, and alongside the Reference Manual books can be found at [http://www.osgbooks.com OsgBooks].
=== Professional support and services ===
!OpenSceneGraph project is backed up with professional services by [http://openscenegraph.com OpenSceneGraph Professional Services], based in Scotland, and [http://www.skew-matrix.com Skew-Matrix] and [http://www.blue-newt.com Blue-Newt Software] both based in the USA, and a range of [wiki:Community/Contractors Contractors] from around the world. Services available include:
* Confidential Professional Support
* Bespoke development
* Consultancy
* Training
=== Community support and contributions ===
The diverse and growing community of over 1900 developers is centred around the public osg-users mailing list, where members discuss how best to use !OpenSceneGraph, provide mutual support, and coordinate development of new features and bug fixes. Members of this community come from many different countries with backgrounds ranging from some of the world's largest aerospace companies, game companies, and visual simulation specialists to university researchers, students and hobbyists.
The !OpenSceneGraph project owes a great deal to the community for its development and support, in particular we wish to thank the [http://www.openscenegraph.org/projects/osg/wiki/Support/Contributors/TwoPointSix 324 individuals] from around the world that have directly contributed to the development and refinement of the !OpenSceneGraph code base.
----
About !OpenSceneGraph:[[BR]]
!OpenSceneGraph Project was founded in September 1999 by Don Burns and Robert Osfield.
Further information, screenshots, downloads, documentation, and support links can be found on the !OpenSceneGraph project website http://www.openscenegraph.org.
About !OpenSceneGraph Professional Services:[[BR]]
!OpenSceneGraph Professional Services, founded by project lead Robert Osfield in April 2001, is based in Callander, Perhshire, Scotland, and provides professional services on top of !OpenSceneGraph. Further information about the services it provides can be found at http://www.openscenegraph.com.
----------------------------------------------------------------------------------------
= !OpenSceneGraph 2.4 release adds geometry shaders, multiple render targets, support for terrabyte scale terrain databases, writing to !OpenFlight and much more. =
PERTHSHIRE, Scotland - 25th April 2008 - !OpenSceneGraph Professional Services announces the release of !OpenSceneGraph 2.4, the industry's leading open-source scene graph technology, designed to accelerate application development and improve 3D graphics performance. !OpenSceneGraph 2.4 written entirely in Standard C++ and built upon OpenGL, offers developers working in the visual simulation, game development, virtual reality, scientific visualization and modeling markets - a real-time visualization tool which eclipses commercial scene graph toolkits in functionality, stability and performance. !OpenSceneGraph 2.4 runs on all Microsoft Windows platforms, Apple OS/X, GNU/Linux, IRIX, Solaris, HP-UX, AIX and FreeBSD operating systems.

View File

@@ -15,7 +15,7 @@ subscribe to our public mailing list:
Robert Osfield.
Project Lead.
25th April 2008.
5th August 2008.
--
@@ -66,9 +66,82 @@ system should help guide you through the process:
Under OSX you can either use the CMake build system above, or use the
Xcode projects that you will find in the OpenSceneGraph/Xcode
directory.
directory. See release notes on OSX CMake build below.
For further details on compilation, installation and platform-specific
information read "Getting Started" guide:
http://www.openscenegraph.org/projects/osg/wiki/Support/GettingStarted
-- Release notes on OSX build, by Eric Sokolowsky, August 5, 2008
There are several ways to compile OpenSceneGraph under OSX. The
recommended way is to use CMake 2.6 to generate Xcode projects, then use
Xcode to build the library. The default project will be able to build
Debug or Release libraries, examples, and sample applications. Here are
some key settings to consider when using CMake:
BUILD_OSG_EXAMPLES - By default this is turned off. Turn this setting on
to compile many great example programs.
CMAKE_OSX_ARCHITECTURES - Xcode can create applications, executables,
libraries, and frameworks that can be run on more than one architecture.
Use this setting to indicate the architectures on which to build OSG.
Possibilities include ppc, ppc64, i386, and x86_64. Building OSG using
either of the 64-bit options (ppc64 and x86_64) has its own caveats
below.
OSG_BUILD_APPLICATION_BUNDLES - Normally only executable binaries are
created for the examples and sample applications. Turn this option on if
you want to create real OSX .app bundles. There are caveats to creating
.app bundles, see below.
OSG_WINDOWING_SYSTEM - You have the choice to use Carbon or X11 when
building applications on OSX. Under Leopard and later, X11 applications,
when started, will automatically launch X11 when needed. However,
full-screen X11 applications will still show the menu bar at the top of
the screen. Since many parts of the Carbon user interface are not
64-bit, X11 is the only supported option for OSX applications compiled
for ppc64 or x86_64.
There is an Xcode directory in the base of the OSG software
distribution, but its future is limited, and will be discontinued once
the CMake project generator completely implements its functionality.
APPLICATION BUNDLES (.app bundles)
The example programs when built as application bundles only contain the
executable file. They do not contain the dependent libraries as would a
normal bundle, so they are not generally portable to other machines.
They also do not know where to find plugins. An environmental variable
OSG_LIBRARY_PATH may be set to point to the location where the plugin
.so files are located. OSG_FILE_PATH may be set to point to the location
where data files are located. Setting OSG_FILE_PATH to the
OpenSceneGraph-Data directory is very useful when testing OSG by running
the example programs.
Many of the example programs use command-line arguments. When
double-clicking on an application (or using the equivalent "open"
command on the command line) only those examples and applications that
do not require command-line arguments will successfully run. The
executable file within the .app bundle can be run from the command-line
if command-line arguments are needed.
64-BIT APPLICATION SUPPORT
OpenSceneGraph will not compile successfully when OSG_WINDOWING_SYSTEM is
Carbon and either x86_64 or ppc64 is selected under CMAKE_OSX_ARCHITECTURES,
as Carbon is a 32bit only API. A version of the osgviewer library written in
Cocoa is needed. However, OSG may be compiled under 64-bits if the X11
windowing system is selected. However, Two parts of the OSG default
distribution will not work with 64-bit X11: the osgviewerWX example
program and the osgdb_qt (Quicktime) plugin. These must be removed from
the Xcode project after Cmake generates it in order to compile with
64-bit architectures. The lack of the latter means that images such as
jpeg, tiff, png, and gif will not work, nor will animations dependent on
Quicktime. A new ImageIO-based plugin is being developed to handle the
still images, and a QTKit plugin will need to be developed to handle
animations.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,10 @@
#ifndef _OPENTHREADS_CONFIG
#define _OPENTHREADS_CONFIG
/* #undef _OPENTHREADS_ATOMIC_USE_GCC_BUILTINS */
/* #undef _OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS */
/* #undef _OPENTHREADS_ATOMIC_USE_SUN */
/* #undef _OPENTHREADS_ATOMIC_USE_WIN32_INTERLOCKED */
/* #undef _OPENTHREADS_ATOMIC_USE_MUTEX */
#endif

View File

@@ -0,0 +1,10 @@
#ifndef OSG_CONFIG
#define OSG_CONFIG 1
/* #undef OSG_USE_FLOAT_MATRIX */
/* #undef OSG_USE_FLOAT_PLANE */
#define OSG_USE_FLOAT_BOUNDINGSPHERE
#define OSG_USE_FLOAT_BOUNDINGBOX
/* #undef OSG_ENFORCE_THREADSAFE */
#endif

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>osgWidget</string>
<key>CFBundleGetInfoString</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>org.OpenSceneGraph.osgWidget</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string></string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>2.2.0</string>
</dict>
</plist>

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>osgimagesequence</string>
<key>CFBundleGetInfoString</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>org.OpenSceneGraph.osgimagesequence</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleShortVersionString</key>
<string></string>
</dict>
</plist>

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>osgwidgetmenu</string>
<key>CFBundleGetInfoString</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>org.OpenSceneGraph.osgwidgetmenu</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleShortVersionString</key>
<string></string>
</dict>
</plist>

View File

@@ -30,6 +30,7 @@ ADD_SUBDIRECTORY(osgviewer)
ADD_SUBDIRECTORY(osgarchive)
ADD_SUBDIRECTORY(osgconv)
ADD_SUBDIRECTORY(osgversion)
ADD_SUBDIRECTORY(osgfilecache)
#REWRITE_CMAKELIST(ADD_OSG_EXAMPLE)

View File

@@ -1,7 +1,13 @@
#this file is automatically generated
SET(TARGET_SRC OrientationConverter.cpp osgconv.cpp )
SET(TARGET_H OrientationConverter.h )
SET(TARGET_SRC
OrientationConverter.cpp
osgconv.cpp
)
SET(TARGET_H
OrientationConverter.h
)
#### end var setup ###
SETUP_APPLICATION(osgconv)

View File

@@ -17,6 +17,7 @@
#include <osgDB/WriteFile>
#include <osgDB/FileNameUtils>
#include <osgDB/ReaderWriter>
#include <osgDB/PluginQuery>
#include <osgUtil/Optimizer>
#include <osgUtil/Simplifier>
@@ -506,6 +507,8 @@ int main( int argc, char **argv )
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display command line parameters");
arguments.getApplicationUsage()->addCommandLineOption("--help-env","Display environmental variables available");
arguments.getApplicationUsage()->addCommandLineOption("--formats","List supported file formats");
arguments.getApplicationUsage()->addCommandLineOption("--plugins","List database olugins");
// if user request help write it out to cout.
@@ -522,6 +525,45 @@ int main( int argc, char **argv )
return 1;
}
if (arguments.read("--plugins"))
{
osgDB::FileNameList plugins = osgDB::listAllAvailablePlugins();
for(osgDB::FileNameList::iterator itr = plugins.begin();
itr != plugins.end();
++itr)
{
std::cout<<"Plugin "<<*itr<<std::endl;
}
return 0;
}
std::string plugin;
if (arguments.read("--plugin", plugin))
{
osgDB::outputPluginDetails(std::cout, plugin);
return 0;
}
std::string ext;
if (arguments.read("--format", ext))
{
plugin = osgDB::Registry::instance()->createLibraryNameForExtension(ext);
osgDB::outputPluginDetails(std::cout, plugin);
return 0;
}
if (arguments.read("--formats"))
{
osgDB::FileNameList plugins = osgDB::listAllAvailablePlugins();
for(osgDB::FileNameList::iterator itr = plugins.begin();
itr != plugins.end();
++itr)
{
osgDB::outputPluginDetails(std::cout,*itr);
}
return 0;
}
if (arguments.argc()<=1)
{
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
@@ -540,7 +582,6 @@ int main( int argc, char **argv )
osgDB::Registry::instance()->setOptions(options);
}
std::string ext;
while (arguments.read("-e",ext))
{
std::string libName = osgDB::Registry::instance()->createLibraryNameForExtension(ext);

View File

@@ -0,0 +1,7 @@
SET(TARGET_SRC osgfilecache.cpp )
SET(TARGET_ADDED_LIBRARIES osgTerrain )
#### end var setup ###
SETUP_APPLICATION(osgfilecache)

View File

@@ -0,0 +1,427 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This application is open source and may be redistributed and/or modified
* freely and without restriction, both in commericial and non commericial applications,
* as long as this copyright notice is maintained.
*
* This application 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.
*/
#include <osg/Timer>
#include <osg/ArgumentParser>
#include <osg/ApplicationUsage>
#include <osg/CoordinateSystemNode>
#include <osg/Geometry>
#include <osg/io_utils>
#include <osgTerrain/TerrainTile>
#include <osgDB/Archive>
#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
#include <osgDB/FileUtils>
#include <iostream>
#include <algorithm>
#include <signal.h>
static bool s_ExitApplication = false;
struct Extents
{
Extents():
_maxLevel(0),
_min(DBL_MAX,DBL_MAX),
_max(-DBL_MAX,-DBL_MAX) {}
Extents(unsigned int maxLevel, double minX, double minY, double maxX, double maxY):
_maxLevel(maxLevel),
_min(minX, minY),
_max(maxX, maxY) {}
Extents(const Extents& extents):
_maxLevel(extents._maxLevel),
_min(extents._min),
_max(extents._max) {}
Extents& operator = (const Extents& rhs)
{
if (&rhs == this) return *this;
_maxLevel = rhs._maxLevel;
_min = rhs._min;
_max = rhs._max;
return *this;
}
bool intersects(unsigned level, osg::Vec2d& in_min, osg::Vec2d& in_max)
{
osg::notify(osg::INFO)<<"intersects("<<level<<", min="<<in_min<<" max="<<in_max<<")"<<std::endl;
osg::notify(osg::INFO)<<" _maxLevel="<<_maxLevel<<", _min="<<_min<<" _max="<<_max<<std::endl;
if (level>_maxLevel) return false;
osg::Vec2d union_min, union_max;
// handle mins
if (_min.x()!=DBL_MAX && in_min.x()!=DBL_MAX)
{
// both _min.x() and in_min.x() are defined so use max of two
union_min.x() = _min.x()>in_min.x() ? _min.x() : in_min.x();
}
else
{
// one or both _min.x() and in_min.x() aren't defined so use min of two
union_min.x() = _min.x()<in_min.x() ? _min.x() : in_min.x();
}
if (_min.y()!=DBL_MAX && in_min.y()!=DBL_MAX)
{
// both _min.y() and in_min.y() are defined so use max of two
union_min.y() = _min.y()>in_min.y() ? _min.y() : in_min.y();
}
else
{
// one or both _min.y() and in_min.y() aren't defined so use min of two
union_min.y() = _min.y()<in_min.y() ? _min.y() : in_min.y();
}
// handle maxs
if (_max.x()!=-DBL_MAX && in_max.x()!=-DBL_MAX)
{
// both _max.x() and in_max.x() are defined so use max of two
union_max.x() = _max.x()<in_max.x() ? _max.x() : in_max.x();
}
else
{
// one or both _max.x() and in_max.x() aren't defined so use max of two
union_max.x() = _max.x()>in_max.x() ? _max.x() : in_max.x();
}
if (_max.y()!=-DBL_MAX && in_max.y()!=-DBL_MAX)
{
// both _max.y() and in_max.y() are defined so use max of two
union_max.y() = _max.y()<in_max.y() ? _max.y() : in_max.y();
}
else
{
// one or both _max.y() and in_max.y() aren't defined so use max of two
union_max.y() = _max.y()>in_max.y() ? _max.y() : in_max.y();
}
bool result = union_min.x()<union_max.x() && union_min.y()<union_max.y() ;
osg::notify(osg::INFO)<<" union_min="<<union_min<<" union_max="<<union_max<<" result = "<<result<<std::endl;
return result;
}
unsigned int _maxLevel;
osg::Vec2d _min;
osg::Vec2d _max;
};
class LoadDataVisitor : public osg::NodeVisitor
{
public:
LoadDataVisitor():
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
_currentLevel(0) {}
void addExtents(unsigned int maxLevel, double minX, double minY, double maxX, double maxY)
{
_extentsList.push_back(Extents(maxLevel, minX, minY, maxX, maxY));
}
void addExtents(unsigned int maxLevel)
{
_extentsList.push_back(Extents(maxLevel, DBL_MAX, DBL_MAX, -DBL_MAX, -DBL_MAX));
}
void apply(osg::CoordinateSystemNode& cs)
{
_csnStack.push_back(&cs);
if (!s_ExitApplication) traverse(cs);
_csnStack.pop_back();
}
void apply(osg::Group& group)
{
if (s_ExitApplication) return;
osgTerrain::TerrainTile* terrainTile = dynamic_cast<osgTerrain::TerrainTile*>(&group);
osgTerrain::Locator* locator = terrainTile ? terrainTile->getLocator() : 0;
if (locator)
{
osg::Vec3d l00(0.0,0.0,0.0);
osg::Vec3d l10(1.0,0.0,0.0);
osg::Vec3d l11(1.0,1.0,0.0);
osg::Vec3d l01(0.0,1.0,0.0);
osg::Vec3d w00, w10, w11, w01;
locator->convertLocalToModel(l00, w00);
locator->convertLocalToModel(l10, w10);
locator->convertLocalToModel(l11, w11);
locator->convertLocalToModel(l01, w01);
if (locator->getEllipsoidModel() &&
locator->getCoordinateSystemType()==osgTerrain::Locator::GEOCENTRIC)
{
convertXYZToLatLongHeight(locator->getEllipsoidModel(), w00);
convertXYZToLatLongHeight(locator->getEllipsoidModel(), w10);
convertXYZToLatLongHeight(locator->getEllipsoidModel(), w11);
convertXYZToLatLongHeight(locator->getEllipsoidModel(), w01);
}
updateBound(w00);
updateBound(w10);
updateBound(w11);
updateBound(w01);
return;
}
traverse(group);
}
void apply(osg::Transform& transform)
{
osg::Matrix matrix;
if (!_matrixStack.empty()) matrix = _matrixStack.back();
transform.computeLocalToWorldMatrix(matrix,this);
pushMatrix(matrix);
traverse(transform);
popMatrix();
}
void apply(osg::PagedLOD& plod)
{
if (s_ExitApplication) return;
++_currentLevel;
initBound();
// first compute the bounds of this subgraph
for(unsigned int i=0; i<plod.getNumFileNames(); ++i)
{
if (plod.getFileName(i).empty())
{
traverse(plod);
}
}
if (intersects())
{
for(unsigned int i=0; i<plod.getNumFileNames(); ++i)
{
osg::notify(osg::INFO)<<" filename["<<i<<"] "<<plod.getFileName(i)<<std::endl;
if (!plod.getFileName(i).empty())
{
std::string filename;
if (!plod.getDatabasePath().empty())
{
filename = plod.getDatabasePath() + plod.getFileName(i);
}
else
{
filename = plod.getFileName(i);
}
osg::notify(osg::NOTICE)<<"reading "<<filename<<std::endl;
osg::ref_ptr<osg::Node> node = osgDB::readNodeFile(filename);
if (!s_ExitApplication && node.valid()) node->accept(*this);
}
}
}
--_currentLevel;
}
void apply(osg::Geode& geode)
{
for(unsigned int i=0; i<geode.getNumDrawables(); ++i)
{
osg::Geometry* geom = geode.getDrawable(i)->asGeometry();
if (geom)
{
osg::Vec3Array* vertices = dynamic_cast<osg::Vec3Array*>(geom->getVertexArray());
if (vertices) updateBound(*vertices);
}
}
}
protected:
inline void pushMatrix(osg::Matrix& matrix) { _matrixStack.push_back(matrix); }
inline void popMatrix() { _matrixStack.pop_back(); }
void convertXYZToLatLongHeight(osg::EllipsoidModel* em, osg::Vec3d& v)
{
em->convertXYZToLatLongHeight(v.x(), v.y(), v.z(),
v.y(), v.x(), v.z());
v.x() = osg::RadiansToDegrees(v.x());
v.y() = osg::RadiansToDegrees(v.y());
}
void initBound()
{
_min.set(DBL_MAX, DBL_MAX);
_max.set(-DBL_MAX, -DBL_MAX);
}
void updateBound(osg::Vec3d& v)
{
if (v.x() < _min.x()) _min.x() = v.x();
if (v.y() < _min.y()) _min.y() = v.y();
if (v.x() > _max.x()) _max.x() = v.x();
if (v.y() > _max.y()) _max.y() = v.y();
}
void updateBound(osg::Vec3Array& vertices)
{
// set up matrix
osg::Matrix matrix;
if (!_matrixStack.empty()) matrix = _matrixStack.back();
// set up ellipsoid model
osg::EllipsoidModel* em = !_csnStack.empty() ? _csnStack.back()->getEllipsoidModel() : 0;
for(osg::Vec3Array::iterator itr = vertices.begin();
itr != vertices.end();
++itr)
{
osg::Vec3d v = osg::Vec3d(*itr) * matrix;
if (em) convertXYZToLatLongHeight(em, v);
updateBound(v);
}
}
bool intersects()
{
osg::notify(osg::INFO)<<"intersects() _min = "<<_min<<" _max = "<<_max<<std::endl;
for(ExtentsList::iterator itr = _extentsList.begin();
itr != _extentsList.end();
++itr)
{
if (itr->intersects(_currentLevel, _min, _max)) return true;
}
return false;
}
typedef std::vector<Extents> ExtentsList;
typedef std::vector<osg::Matrix> MatrixStack;
typedef std::vector<osg::CoordinateSystemNode*> CSNStack;
ExtentsList _extentsList;
unsigned int _currentLevel;
MatrixStack _matrixStack;
CSNStack _csnStack;
osg::Vec2d _min;
osg::Vec2d _max;
};
static void signalHandler(int sig)
{
printf("\nCaught signal %d, requesting exit...\n\n",sig);
s_ExitApplication = true;
}
int main( int argc, char **argv )
{
#ifndef _WIN32
signal(SIGHUP, signalHandler);
signal(SIGQUIT, signalHandler);
signal(SIGKILL, signalHandler);
signal(SIGUSR1, signalHandler);
signal(SIGUSR2, signalHandler);
#endif
signal(SIGABRT, signalHandler);
signal(SIGINT, signalHandler);
signal(SIGTERM, signalHandler);
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
// set up the usage document, in case we need to print out how to use this program.
arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName());
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is an application for collecting a set of seperate files into a single archive file that can be later read in OSG applications..");
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-l level","Read down to level across the whole database.");
arguments.getApplicationUsage()->addCommandLineOption("-e level minX minY maxX maxY","Read down to <level> across the extents minX, minY to maxY, maxY. Note, for geocentric datase X and Y are longitude and latitude respectively.");
arguments.getApplicationUsage()->addCommandLineOption("-c directory","Shorthand for --file-cache directory.");
arguments.getApplicationUsage()->addCommandLineOption("--file-cache directory","Set directory as to place cache download files.");
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
LoadDataVisitor ldv;
unsigned int maxLevels = 0;
while(arguments.read("-l",maxLevels))
{
ldv.addExtents(maxLevels);
}
double minX, maxX, minY, maxY;
while(arguments.read("-e",maxLevels, minX, minY, maxX, maxY))
{
ldv.addExtents(maxLevels, minX, minY, maxX, maxY);
}
std::string fileCache;
while(arguments.read("--file-cache",fileCache) || arguments.read("-c",fileCache)) {}
if (!fileCache.empty())
{
std::string str("OSG_FILE_CACHE=");
str += fileCache;
putenv(strdup((char*)str.c_str()));
}
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
if (!loadedModel)
{
std::cout<<"No data loaded, please specify a database to load"<<std::endl;
return 1;
}
loadedModel->accept(ldv);
if (s_ExitApplication)
{
std::cout<<"osgfilecache cleanly exited in response to signal."<<std::endl;
}
return 0;
}

View File

@@ -219,6 +219,8 @@ bool validName(const std::string& first)
if (first=="LightPointNode") return false;
if (first=="GeometryTechnique") return false;
if (first=="GeoemtryTechnique") return false;
if (first=="KdTree") return false;
if (first=="LineSegment") return false;
return true;
}
@@ -230,6 +232,7 @@ std::string typoCorrection(const std::string& name)
if (name=="") return "";
if (name=="") return "";
#endif
if (name=="Weidemann") return "Wiedemann";
if (name=="Martsz") return "Martz";
if (name=="Matz") return "Martz";
if (name=="Froenlich") return "Fr<EFBFBD>hlich";
@@ -238,6 +241,7 @@ std::string typoCorrection(const std::string& name)
if (name=="Fruciel") return "Frauciel";
if (name=="Hebelin") return "Herbelin";
if (name=="Jea-Sebastien") return "Jean-Sebastien";
if (name=="Jean-Sebastian") return "Jean-Sebastien";
if (name=="Robet") return "Robert";
if (name=="Morné") return "Morn<EFBFBD>";
if (name=="Adndre") return "Andre";
@@ -256,7 +260,7 @@ std::string typoCorrection(const std::string& name)
if (name=="Drederic") return "Frederic";
if (name=="Fredrick") return "Frederic";
if (name=="Fredric") return "Frederic";
if (name=="Garrat") return "Garret";
if (name=="Garrat") return "Garrett";
if (name=="Geof") return "Geoff";
if (name=="Gronenger") return "Gronager";
if (name=="Gronger") return "Gronager";
@@ -342,16 +346,33 @@ std::string typoCorrection(const std::string& name)
if (name=="Giatan") return "Gaitan";
if (name=="Melchoir") return "Melchior";
if (name=="Simmonsson") return "Simonsson";
if (name=="Simmonson") return "Simonsson";
if (name=="Sokolwsky") return "Sokolowsky";
if (name=="Cullu") return "Callu";
if (name=="Comporesi") return "Camporesi";
if (name=="Machler") return "M<EFBFBD>chler";
if (name=="Maechler") return "M<EFBFBD>chler";
if (name=="Messerschimdt") return "Messerschmidt";
if (name=="Garret") return "Garrett";
if (name=="Adrain") return "Adrian";
if (name=="Elgi") return "Egli";
return name;
}
void nameCorrection(NamePair& name)
{
if (name.first=="John" && name.second=="Vidar")
{
name.first = "John";
name.second = "Vidar Larring";
}
if (name.first=="Sebastien" && name.second=="Messerschmidt")
{
name.first = "Sebastian";
name.second = "Messerschmidt";
}
if ((name.first=="Jose" || name.first=="Jos<EFBFBD>") && name.second=="Delport")
{
name.first = "J.P.";
@@ -412,6 +433,11 @@ void nameCorrection(NamePair& name)
name.first = "Paul";
name.second = "de Repentigny";
}
if (name.first=="Raymond" && name.second=="de")
{
name.first = "Raymond";
name.second = "de Vries";
}
if (name.first=="Nick" && name.second=="")
{
name.first = "Trajce";

View File

@@ -39,27 +39,16 @@ int main(int argc, char** argv)
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("--image <filename>","Load an image and render it on a quad");
arguments.getApplicationUsage()->addCommandLineOption("--dem <filename>","Load an image/DEM and render it on a HeightField");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display command line parameters");
arguments.getApplicationUsage()->addCommandLineOption("--help-env","Display environmental variables available");
arguments.getApplicationUsage()->addCommandLineOption("--help-keys","Display keyboard & mouse bindings available");
arguments.getApplicationUsage()->addCommandLineOption("--help-all","Display all command line, env vars and keyboard & mouse bindings.");
arguments.getApplicationUsage()->addCommandLineOption("--SingleThreaded","Select SingleThreaded threading model for viewer.");
arguments.getApplicationUsage()->addCommandLineOption("--CullDrawThreadPerContext","Select CullDrawThreadPerContext threading model for viewer.");
arguments.getApplicationUsage()->addCommandLineOption("--DrawThreadPerContext","Select DrawThreadPerContext threading model for viewer.");
arguments.getApplicationUsage()->addCommandLineOption("--CullThreadPerCameraDrawThreadPerContext","Select CullThreadPerCameraDrawThreadPerContext threading model for viewer.");
arguments.getApplicationUsage()->addCommandLineOption("--login <url> <username> <password>","Provide authentication information for http file access.");
// if user request help write it out to cout.
bool helpAll = arguments.read("--help-all");
unsigned int helpType = ((helpAll || arguments.read("-h") || arguments.read("--help"))? osg::ApplicationUsage::COMMAND_LINE_OPTION : 0 ) |
((helpAll || arguments.read("--help-env"))? osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE : 0 ) |
((helpAll || arguments.read("--help-keys"))? osg::ApplicationUsage::KEYBOARD_MOUSE_BINDING : 0 );
if (helpType)
osgViewer::Viewer viewer(arguments);
unsigned int helpType = 0;
if ((helpType = arguments.readHelpType()))
{
arguments.getApplicationUsage()->write(std::cout, helpType);
return 1;
}
osgViewer::Viewer viewer(arguments);
// report any errors if they have occurred when parsing the program arguments.
if (arguments.errors())
@@ -74,6 +63,19 @@ int main(int argc, char** argv)
return 1;
}
std::string url, username, password;
while(arguments.read("--login",url, username, password))
{
if (!osgDB::Registry::instance()->getAuthenticationMap())
{
osgDB::Registry::instance()->setAuthenticationMap(new osgDB::AuthenticationMap);
osgDB::Registry::instance()->getAuthenticationMap()->addAuthenticationDetails(
url,
new osgDB::AuthenticationDetails(username, password)
);
}
}
// set up the camera manipulators.
{
osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator;
@@ -121,6 +123,9 @@ int main(int argc, char** argv)
// add the LOD Scale handler
viewer.addEventHandler(new osgViewer::LODScaleHandler);
// add the screen capture handler
viewer.addEventHandler(new osgViewer::ScreenCaptureHandler);
// load the data
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
if (!loadedModel)

View File

@@ -323,6 +323,7 @@ INPUT = $(OSGHOME)/include/osg \
$(OSGHOME)/include/osgIntrospection \
$(OSGHOME)/include/osgParticle \
$(OSGHOME)/include/osgViewer \
$(OSGHOME)/include/osgWidget \
$(OSGHOME)/include/osgShadow \
$(OSGHOME)/include/osgManipulator \
$(OSGHOME)/include/osgSim \

View File

@@ -398,6 +398,7 @@ INPUT = $(OSGHOME)/include/osg \
$(OSGHOME)/include/osgIntrospection \
$(OSGHOME)/include/osgParticle \
$(OSGHOME)/include/osgViewer \
$(OSGHOME)/include/osgWidget \
$(OSGHOME)/include/osgManipulator \
$(OSGHOME)/include/osgShadow \
$(OSGHOME)/include/osgSim \

View File

@@ -398,6 +398,7 @@ INPUT = ${OpenSceneGraph_SOURCE_DIR}/include/osg \
${OpenSceneGraph_SOURCE_DIR}/include/osgIntrospection \
${OpenSceneGraph_SOURCE_DIR}/include/osgParticle \
${OpenSceneGraph_SOURCE_DIR}/include/osgViewer \
${OpenSceneGraph_SOURCE_DIR}/include/osgWidget \
${OpenSceneGraph_SOURCE_DIR}/include/osgManipulator \
${OpenSceneGraph_SOURCE_DIR}/include/osgShadow \
${OpenSceneGraph_SOURCE_DIR}/include/osgSim \

View File

@@ -5,13 +5,13 @@ SET(TARGET_DEFAULT_PREFIX "example_")
SET(TARGET_DEFAULT_LABEL_PREFIX "Examples")
SET(TARGET_COMMON_LIBRARIES
OpenThreads
osg
osgDB
osgUtil
osgGA
osgViewer
osgText
OpenThreads
osg
osgDB
osgUtil
osgGA
osgViewer
osgText
)
IF(DYNAMIC_OPENSCENEGRAPH)
@@ -32,6 +32,7 @@ IF(DYNAMIC_OPENSCENEGRAPH)
ADD_SUBDIRECTORY(osgdepthpeeling)
ADD_SUBDIRECTORY(osgdistortion)
ADD_SUBDIRECTORY(osgfadetext)
ADD_SUBDIRECTORY(osgfont)
ADD_SUBDIRECTORY(osgforest)
ADD_SUBDIRECTORY(osgfxbrowser)
ADD_SUBDIRECTORY(osggeodemo)
@@ -39,9 +40,10 @@ IF(DYNAMIC_OPENSCENEGRAPH)
ADD_SUBDIRECTORY(osggeometryshaders)
ADD_SUBDIRECTORY(osghangglide)
ADD_SUBDIRECTORY(osghud)
ADD_SUBDIRECTORY(osgimagesequence)
ADD_SUBDIRECTORY(osgimpostor)
ADD_SUBDIRECTORY(osgintersection)
ADD_SUBDIRECTORY(osgmultiplerendertargets)
ADD_SUBDIRECTORY(osgkdtree)
ADD_SUBDIRECTORY(osgkeyboard)
ADD_SUBDIRECTORY(osgkeyboardmouse)
ADD_SUBDIRECTORY(osglauncher)
@@ -52,6 +54,7 @@ IF(DYNAMIC_OPENSCENEGRAPH)
ADD_SUBDIRECTORY(osgmanipulator)
ADD_SUBDIRECTORY(osgmotionblur)
ADD_SUBDIRECTORY(osgmovie)
ADD_SUBDIRECTORY(osgmultiplerendertargets)
ADD_SUBDIRECTORY(osgmultitexture)
ADD_SUBDIRECTORY(osgmultitexturecontrol)
ADD_SUBDIRECTORY(osgoccluder)
@@ -70,6 +73,7 @@ IF(DYNAMIC_OPENSCENEGRAPH)
ADD_SUBDIRECTORY(osgprerendercubemap)
ADD_SUBDIRECTORY(osgreflect)
ADD_SUBDIRECTORY(osgscalarbar)
ADD_SUBDIRECTORY(osgscreencapture)
ADD_SUBDIRECTORY(osgscribe)
ADD_SUBDIRECTORY(osgsequence)
ADD_SUBDIRECTORY(osgshaders)
@@ -87,7 +91,7 @@ IF(DYNAMIC_OPENSCENEGRAPH)
ADD_SUBDIRECTORY(osgstereomatch)
ADD_SUBDIRECTORY(osgteapot)
ADD_SUBDIRECTORY(osgterrain)
ADD_SUBDIRECTORY(osgtessellate)#)
ADD_SUBDIRECTORY(osgtessellate)
ADD_SUBDIRECTORY(osgtext)
ADD_SUBDIRECTORY(osgtext3D)
ADD_SUBDIRECTORY(osgtexture1D)
@@ -112,6 +116,10 @@ IF(DYNAMIC_OPENSCENEGRAPH)
ADD_SUBDIRECTORY(osgviewerSDL)
ENDIF(SDL_FOUND)
IF (GTKGL_FOUND)
ADD_SUBDIRECTORY(osgviewerGTK)
ENDIF(GTKGL_FOUND)
IF (FOX_FOUND)
ADD_SUBDIRECTORY(osgviewerFOX)
ENDIF(FOX_FOUND)
@@ -138,6 +146,27 @@ IF(DYNAMIC_OPENSCENEGRAPH)
ENDIF(WIN32)
IF (APPLE)
ADD_SUBDIRECTORY(osgviewerCocoa)
ENDIF(APPLE)
IF (BUILD_OSGWIDGET)
ADD_SUBDIRECTORY(osgwidgetaddremove)
ADD_SUBDIRECTORY(osgwidgetbox)
ADD_SUBDIRECTORY(osgwidgetcanvas)
ADD_SUBDIRECTORY(osgwidgetframe)
ADD_SUBDIRECTORY(osgwidgetinput)
ADD_SUBDIRECTORY(osgwidgetlabel)
ADD_SUBDIRECTORY(osgwidgetmenu)
ADD_SUBDIRECTORY(osgwidgetnotebook)
ADD_SUBDIRECTORY(osgwidgetscrolled)
ADD_SUBDIRECTORY(osgwidgetshader)
ADD_SUBDIRECTORY(osgwidgetstyled)
ADD_SUBDIRECTORY(osgwidgettable)
ADD_SUBDIRECTORY(osgwidgetwindow)
ENDIF(BUILD_OSGWIDGET)
#ADD_SUBDIRECTORY(osgcegui)
#to add subject to find socket#ADD_SUBDIRECTORY(osgcluster)

View File

@@ -0,0 +1,4 @@
SET(TARGET_SRC osgfont.cpp)
SET(TARGET_ADDED_LIBRARIES osgText)
SETUP_EXAMPLE(osgfont)

View File

@@ -0,0 +1,140 @@
#include <cstdlib>
#include <sstream>
#include <osg/io_utils>
#include <osg/ArgumentParser>
#include <osg/Geode>
#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
void textInfo(osgText::Text* text)
{
const osgText::Text::TextureGlyphQuadMap& tgqm = text->getTextureGlyphQuadMap();
const osgText::Text::TextureGlyphQuadMap::const_iterator tgqmi = tgqm.begin();
const osgText::Text::GlyphQuads& gq = tgqmi->second;
osgText::String& s = text->getText();
for(unsigned int i = 0; i < s.size(); i++)
{
osg::Vec2 ul = gq.getCoords()[0 + (i * 4)]; // upperLeft
osg::Vec2 ll = gq.getCoords()[1 + (i * 4)]; // lowerLeft
osg::Vec2 lr = gq.getCoords()[2 + (i * 4)]; // lowerRight
osg::Vec2 ur = gq.getCoords()[3 + (i * 4)]; // upperRight
/*
osg::Vec3 ul = gq.getTransformedCoords(0)[0 + (i * 4)];
osg::Vec3 ll = gq.getTransformedCoords(0)[1 + (i * 4)];
osg::Vec3 lr = gq.getTransformedCoords(0)[2 + (i * 4)];
osg::Vec3 ur = gq.getTransformedCoords(0)[3 + (i * 4)];
*/
osg::notify(osg::NOTICE)
<< "'" << static_cast<char>(s[i]) << "':"
<< " width(" << lr.x() - ll.x() << ")"
<< " height(" << ul.y() - ll.y() << ")" << std::endl << "\t"
<< "ul(" << ul << "), "
<< "ll(" << ll << "), "
<< "lr(" << lr << "), "
<< "ur(" << ur << ")"
<< std::endl
;
}
}
osg::Camera* createOrthoCamera(double width, double height)
{
osg::Camera* camera = new osg::Camera();
camera->getOrCreateStateSet()->setMode(
GL_LIGHTING,
osg::StateAttribute::PROTECTED | osg::StateAttribute::OFF
);
osg::Matrix m = osg::Matrix::ortho2D(0.0f, width, 0.0f, height);
camera->setProjectionMatrix(m);
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
camera->setViewMatrix(osg::Matrix::identity());
camera->setClearMask(GL_DEPTH_BUFFER_BIT);
camera->setRenderOrder(osg::Camera::POST_RENDER);
return camera;
}
osgText::Text* createLabel(const std::string& l, const char* f, unsigned int size)
{
static osg::Vec3 pos(10.0f, 10.0f, 0.0f);
osgText::Text* label = new osgText::Text();
osgText::Font* font = osgText::readFontFile(f);
label->setFont(font);
label->setCharacterSize(size);
label->setFontResolution(size, size);
label->setColor(osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f));
label->setPosition(pos);
label->setAlignment(osgText::Text::LEFT_BOTTOM);
// It seems to be important we do this last to get best results?
label->setText(l);
textInfo(label);
pos.y() += size + 10.0f;
return label;
}
typedef std::list<unsigned int> Sizes;
int main(int argc, char** argv)
{
osgViewer::Viewer viewer;
osg::ArgumentParser args(&argc, argv);
// Make sure we have the minimum args...
if(argc <= 2)
{
osg::notify(osg::FATAL) << "usage: " << args[0] << " FONTFILE [sizes...]" << std::endl;
return 1;
}
viewer.addEventHandler(new osgViewer::StatsHandler());
viewer.addEventHandler(new osgViewer::WindowSizeHandler());
osg::Group* group = new osg::Group();
osg::Camera* camera = createOrthoCamera(1280.0f, 1024.0f);
// Create the list of desired sizes.
Sizes sizes;
for(int i = 2; i < argc; i++)
{
if(!args.isNumber(i)) continue;
sizes.push_back(std::atoi(args[i]));
}
osg::Geode* geode = new osg::Geode();
// Add all of our osgText drawables.
for(Sizes::const_iterator i = sizes.begin(); i != sizes.end(); i++)
{
std::stringstream ss;
ss << *i << " 1234567890 abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ";
geode->addDrawable(createLabel(ss.str(), args[1], *i));
}
camera->addChild(geode);
group->addChild(camera);
viewer.setSceneData(group);
return viewer.run();
}

View File

@@ -0,0 +1,4 @@
SET(TARGET_SRC osgimagesequence.cpp )
#### end var setup ###
SETUP_EXAMPLE(osgimagesequence)

View File

@@ -0,0 +1,114 @@
/* OpenSceneGraph example, osgtexture3D.
*
* 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 <osg/Node>
#include <osg/Geometry>
#include <osg/Notify>
#include <osg/Texture1D>
#include <osg/Texture2D>
#include <osg/Texture3D>
#include <osg/TextureRectangle>
#include <osg/ImageSequence>
#include <osg/Geode>
#include <osgDB/Registry>
#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
#include <osgViewer/Viewer>
#include <iostream>
//
// A simple demo demonstrating how to set on an animated texture using an osg::ImageSequence
//
osg::StateSet* createState()
{
osg::ref_ptr<osg::ImageSequence> imageSequence = new osg::ImageSequence;
imageSequence->setDuration(2.0);
imageSequence->addImage(osgDB::readImageFile("Cubemap_axis/posx.png"));
imageSequence->addImage(osgDB::readImageFile("Cubemap_axis/negx.png"));
imageSequence->addImage(osgDB::readImageFile("Cubemap_axis/posy.png"));
imageSequence->addImage(osgDB::readImageFile("Cubemap_axis/negy.png"));
imageSequence->addImage(osgDB::readImageFile("Cubemap_axis/posz.png"));
imageSequence->addImage(osgDB::readImageFile("Cubemap_axis/negz.png"));
#if 1
osg::Texture2D* texture = new osg::Texture2D;
texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR);
texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR);
texture->setWrap(osg::Texture::WRAP_R,osg::Texture::REPEAT);
texture->setResizeNonPowerOfTwoHint(false);
texture->setImage(imageSequence.get());
//texture->setTextureSize(512,512);
//texture->setUpdateCallback(new osg::ImageSequence::UpdateCallback);
#else
osg::TextureRectangle* texture = new osg::TextureRectangle;
texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR);
texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR);
texture->setWrap(osg::Texture::WRAP_R,osg::Texture::REPEAT);
// texture->setResizeNonPowerOfTwoHint(false);
texture->setImage(imageSequence.get());
//texture->setTextureSize(512,512);
//texture->setUpdateCallback(new osg::ImageSequence::UpdateCallback);
#endif
// create the StateSet to store the texture data
osg::StateSet* stateset = new osg::StateSet;
stateset->setTextureAttributeAndModes(0,texture,osg::StateAttribute::ON);
return stateset;
}
osg::Node* createModel()
{
// create the geometry of the model, just a simple 2d quad right now.
osg::Geode* geode = new osg::Geode;
geode->addDrawable(osg::createTexturedQuadGeometry(osg::Vec3(0.0f,0.0f,0.0), osg::Vec3(1.0f,0.0f,0.0), osg::Vec3(0.0f,0.0f,1.0f)));
geode->setStateSet(createState());
return geode;
}
int main(int argc, char **argv)
{
osg::ArgumentParser arguments(&argc,argv);
// construct the viewer.
osgViewer::Viewer viewer(arguments);
// create a model from the images and pass it to the viewer.
viewer.setSceneData(createModel());
std::string filename;
if (arguments.read("-o",filename))
{
osgDB::writeNodeFile(*viewer.getSceneData(),filename);
}
return viewer.run();
}

View File

@@ -0,0 +1,9 @@
SET(TARGET_SRC
osgkdtree.cpp
)
SET(TARGET_ADDED_LIBRARIES osgSim )
#### end var setup ###
SETUP_EXAMPLE(osgkdtree)

View File

@@ -0,0 +1,70 @@
/* OpenSceneGraph example, osgintersection.
*
* 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 <osgDB/ReadFile>
#include <osg/ArgumentParser>
#include <osg/ApplicationUsage>
#include <osg/Timer>
#include <osg/CoordinateSystemNode>
#include <osg/Notify>
#include <osg/io_utils>
#include <osg/Geometry>
#include <osg/TriangleIndexFunctor>
#include <osgUtil/IntersectionVisitor>
#include <osgUtil/LineSegmentIntersector>
#include <osgUtil/UpdateVisitor>
#include <osgSim/LineOfSight>
#include <osgSim/HeightAboveTerrain>
#include <osgSim/ElevationSlice>
#include <osgViewer/Viewer>
#include <osg/KdTree>
#include <iostream>
int main(int argc, char **argv)
{
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
int maxNumLevels = 16;
int targetNumIndicesPerLeaf = 16;
while (arguments.read("--max", maxNumLevels)) {}
while (arguments.read("--leaf", targetNumIndicesPerLeaf)) {}
osgDB::Registry::instance()->setBuildKdTreesHint(osgDB::ReaderWriter::Options::BUILD_KDTREES);
osg::ref_ptr<osg::Node> scene = osgDB::readNodeFiles(arguments);
if (!scene)
{
std::cout<<"No model loaded, please specify a valid model on the command line."<<std::endl;
return 0;
}
osgViewer::Viewer viewer;
viewer.setSceneData(scene.get());
return viewer.run();
}

View File

@@ -31,6 +31,11 @@
#include <osgManipulator/Translate2DDragger>
#include <osgManipulator/TranslateAxisDragger>
#include <osg/ShapeDrawable>
#include <osg/MatrixTransform>
#include <osg/Geometry>
#include <osg/Material>
#include <iostream>
osgManipulator::Dragger* createDragger(const std::string& name)
@@ -78,10 +83,13 @@ osgManipulator::Dragger* createDragger(const std::string& name)
d->setupDefaultGeometry();
dragger = d;
}
return dragger;
}
osg::Node* createHUD()
{
osg::Geode* geode = new osg::Geode();
@@ -141,6 +149,104 @@ osg::Node* addDraggerToScene(osg::Node* scene, osgManipulator::CommandManager* c
return root;
}
osg::Node* createDemoScene(osgManipulator::CommandManager* cmdMgr) {
osg::Group* root = new osg::Group;
osg::ref_ptr<osg::Geode> geode_1 = new osg::Geode;
osg::ref_ptr<osg::MatrixTransform> transform_1 = new osg::MatrixTransform;
osg::ref_ptr<osg::Geode> geode_2 = new osg::Geode;
osg::ref_ptr<osg::MatrixTransform> transform_2 = new osg::MatrixTransform;
osg::ref_ptr<osg::Geode> geode_3 = new osg::Geode;
osg::ref_ptr<osg::MatrixTransform> transform_3 = new osg::MatrixTransform;
osg::ref_ptr<osg::Geode> geode_4 = new osg::Geode;
osg::ref_ptr<osg::MatrixTransform> transform_4 = new osg::MatrixTransform;
osg::ref_ptr<osg::Geode> geode_5 = new osg::Geode;
osg::ref_ptr<osg::MatrixTransform> transform_5 = new osg::MatrixTransform;
osg::ref_ptr<osg::Geode> geode_6 = new osg::Geode;
osg::ref_ptr<osg::MatrixTransform> transform_6 = new osg::MatrixTransform;
osg::ref_ptr<osg::Geode> geode_7 = new osg::Geode;
osg::ref_ptr<osg::MatrixTransform> transform_7 = new osg::MatrixTransform;
const float radius = 0.8f;
const float height = 1.0f;
osg::ref_ptr<osg::TessellationHints> hints = new osg::TessellationHints;
hints->setDetailRatio(2.0f);
osg::ref_ptr<osg::ShapeDrawable> shape;
shape = new osg::ShapeDrawable(new osg::Box(osg::Vec3(0.0f, 0.0f, -2.0f), 10, 10.0f, 0.1f), hints.get());
shape->setColor(osg::Vec4(0.5f, 0.5f, 0.7f, 1.0f));
geode_1->addDrawable(shape.get());
shape = new osg::ShapeDrawable(new osg::Cylinder(osg::Vec3(0.0f, 0.0f, 0.0f), radius * 2,radius), hints.get());
shape->setColor(osg::Vec4(0.8f, 0.8f, 0.8f, 1.0f));
geode_2->addDrawable(shape.get());
shape = new osg::ShapeDrawable(new osg::Cylinder(osg::Vec3(-3.0f, 0.0f, 0.0f), radius,radius), hints.get());
shape->setColor(osg::Vec4(0.6f, 0.8f, 0.8f, 1.0f));
geode_3->addDrawable(shape.get());
shape = new osg::ShapeDrawable(new osg::Cone(osg::Vec3(3.0f, 0.0f, 0.0f), 2 * radius,radius), hints.get());
shape->setColor(osg::Vec4(0.4f, 0.9f, 0.3f, 1.0f));
geode_4->addDrawable(shape.get());
shape = new osg::ShapeDrawable(new osg::Cone(osg::Vec3(0.0f, -3.0f, 0.0f), radius, height), hints.get());
shape->setColor(osg::Vec4(0.2f, 0.5f, 0.7f, 1.0f));
geode_5->addDrawable(shape.get());
shape = new osg::ShapeDrawable(new osg::Cylinder(osg::Vec3(0.0f, 3.0f, 0.0f), radius, height), hints.get());
shape->setColor(osg::Vec4(1.0f, 0.3f, 0.3f, 1.0f));
geode_6->addDrawable(shape.get());
shape = new osg::ShapeDrawable(new osg::Cone(osg::Vec3(0.0f, 0.0f, 3.0f), 2.0f, 2.0f), hints.get());
shape->setColor(osg::Vec4(0.8f, 0.8f, 0.4f, 1.0f));
geode_7->addDrawable(shape.get());
// material
osg::ref_ptr<osg::Material> matirial = new osg::Material;
matirial->setColorMode(osg::Material::DIFFUSE);
matirial->setAmbient(osg::Material::FRONT_AND_BACK, osg::Vec4(0, 0, 0, 1));
matirial->setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4(1, 1, 1, 1));
matirial->setShininess(osg::Material::FRONT_AND_BACK, 64.0f);
root->getOrCreateStateSet()->setAttributeAndModes(matirial.get(), osg::StateAttribute::ON);
transform_1.get()->addChild(addDraggerToScene(geode_1.get(),cmdMgr,"TabBoxDragger"));
transform_2.get()->addChild(addDraggerToScene(geode_2.get(),cmdMgr,"TabPlaneDragger"));
transform_3.get()->addChild(addDraggerToScene(geode_3.get(),cmdMgr,"TabPlaneTrackballDragger"));
transform_4.get()->addChild(addDraggerToScene(geode_4.get(),cmdMgr,"TrackballDragger"));
transform_5.get()->addChild(addDraggerToScene(geode_5.get(),cmdMgr,"Translate1DDragger"));
transform_6.get()->addChild(addDraggerToScene(geode_6.get(),cmdMgr,"Translate2DDragger"));
transform_7.get()->addChild(addDraggerToScene(geode_7.get(),cmdMgr,"TranslateAxisDragger"));
root->addChild(transform_1.get());
root->addChild(transform_2.get());
root->addChild(transform_3.get());
root->addChild(transform_4.get());
root->addChild(transform_5.get());
root->addChild(transform_6.get());
root->addChild(transform_7.get());
return root;
}
class PickModeHandler : public osgGA::GUIEventHandler
{
public:
@@ -254,7 +360,7 @@ int main( int argc, char **argv )
arguments.getApplicationUsage()->addCommandLineOption("--help-keys","Display keyboard & mouse bindings available");
arguments.getApplicationUsage()->addCommandLineOption("--help-all","Display all command line, env vars and keyboard & mouse bindings.");
arguments.getApplicationUsage()->addCommandLineOption("--dragger <draggername>","Use the specified dragger for manipulation");
arguments.getApplicationUsage()->addCommandLineOption("--dragger <draggername>","Use the specified dragger for manipulation [TabPlaneDragger,TabPlaneTrackballDragger,TrackballDragger,Translate1DDragger,Translate2DDragger,TranslateAxisDragger,TabBoxDragger]");
// construct the viewer.
@@ -280,12 +386,6 @@ int main( int argc, char **argv )
arguments.writeErrorMessages(std::cout);
return 1;
}
if (arguments.argc()<=1)
{
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
return 1;
}
std::string dragger_name = "TabBoxDragger";
arguments.read("--dragger", dragger_name);
@@ -295,11 +395,17 @@ int main( int argc, char **argv )
// read the scene from the list of file specified command line args.
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
// create a command manager
osg::ref_ptr<osgManipulator::CommandManager> cmdMgr = new osgManipulator::CommandManager;
// if no model has been successfully loaded report failure.
bool tragger2Scene(true);
if (!loadedModel)
{
std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
return 1;
//std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
//return 1;
loadedModel = createDemoScene(cmdMgr.get());
tragger2Scene=false;
}
// any option left unread are converted into errors to write out later.
@@ -320,11 +426,13 @@ int main( int argc, char **argv )
osgUtil::Optimizer optimizer;
optimizer.optimize(loadedModel.get());
osg::ref_ptr<osgManipulator::CommandManager> cmdMgr = new osgManipulator::CommandManager;
// pass the loaded scene graph to the viewer.
viewer.setSceneData(addDraggerToScene(loadedModel.get(), cmdMgr.get(), dragger_name));
if ( tragger2Scene ) {
viewer.setSceneData(addDraggerToScene(loadedModel.get(), cmdMgr.get(), dragger_name));
} else {
viewer.setSceneData(loadedModel.get());
}
viewer.addEventHandler(new PickModeHandler());
return viewer.run();

View File

@@ -428,11 +428,14 @@ int main(int argc, char** argv)
if (image)
{
osg::notify(osg::NOTICE)<<"image->s()"<<image->s()<<" image-t()="<<image->t()<<std::endl;
geode->addDrawable(myCreateTexturedQuadGeometry(pos,image->s(),image->t(),image, useTextureRectangle, xyPlane, flip));
bottomright = pos + osg::Vec3(static_cast<float>(image->s()),static_cast<float>(image->t()),0.0f);
pos.y() += image->t()*1.5f;
if (xyPlane) pos.y() += image->t()*1.05f;
else pos.z() += image->t()*1.05f;
}
else
{

View File

@@ -92,103 +92,175 @@ class ElevationLayerBlendingCallback : public osg::NodeCallback
ElevationLayerBlendingCallback(osgFX::MultiTextureControl* mtc, const Elevations& elevations, float animationTime=4.0f):
_previousFrame(-1),
_previousTime(0.0),
_currentElevation(0.0),
_mtc(mtc),
_elevations(elevations),
_animationTime(animationTime) {}
/** Callback method called by the NodeVisitor when visiting a node.*/
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
{
if (!nv->getFrameStamp() || _previousFrame==nv->getFrameStamp()->getFrameNumber())
{
if (nv->getVisitorType()==osg::NodeVisitor::UPDATE_VISITOR)
{
// we've already updated for this frame so no need to do it again, just traverse children.
traverse(node,nv);
return;
}
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
float deltaTime = 0.01f;
if (_previousFrame!=-1)
{
deltaTime = float(nv->getFrameStamp()->getReferenceTime() - _previousTime);
}
_previousTime = nv->getFrameStamp()->getReferenceTime();
_previousFrame = nv->getFrameStamp()->getFrameNumber();
double elevation = nv->getViewPoint().z();
osg::CoordinateSystemNode* csn = dynamic_cast<osg::CoordinateSystemNode*>(node);
if (csn)
{
osg::EllipsoidModel* em = csn->getEllipsoidModel();
if (em)
float deltaTime = 0.01f;
if (_previousFrame!=-1)
{
double X = nv->getViewPoint().x();
double Y = nv->getViewPoint().y();
double Z = nv->getViewPoint().z();
double latitude, longitude;
em->convertXYZToLatLongHeight(X,Y,Z,latitude, longitude, elevation);
deltaTime = float(nv->getFrameStamp()->getReferenceTime() - _previousTime);
}
_previousTime = nv->getFrameStamp()->getReferenceTime();
_previousFrame = nv->getFrameStamp()->getFrameNumber();
if (_mtc.valid() && !_elevations.empty())
{
unsigned int index = _mtc->getNumTextureWeights()-1;
for(unsigned int i=0; i<_elevations.size(); ++i)
{
if (_currentElevation>_elevations[i])
{
index = i;
break;
}
}
float delta = std::min(deltaTime/_animationTime, 1.0f);
for(unsigned int i=0; i<_mtc->getNumTextureWeights(); ++i)
{
float currentValue = _mtc->getTextureWeight(i);
float desiredValue = (i==index) ? 1.0f : 0.0f;
if (desiredValue != currentValue)
{
if (currentValue<desiredValue)
{
desiredValue = std::min(currentValue + delta, desiredValue);
}
else
{
desiredValue = std::max(currentValue - delta, desiredValue);
}
_mtc->setTextureWeight(i, desiredValue);
}
}
}
}
if (_mtc.valid() && !_elevations.empty())
else if (nv->getVisitorType()==osg::NodeVisitor::CULL_VISITOR)
{
unsigned int index = _mtc->getNumTextureWeights()-1;
for(unsigned int i=0; i<_elevations.size(); ++i)
_currentElevation = nv->getViewPoint().z();
osg::CoordinateSystemNode* csn = dynamic_cast<osg::CoordinateSystemNode*>(node);
if (csn)
{
if (elevation>_elevations[i])
osg::EllipsoidModel* em = csn->getEllipsoidModel();
if (em)
{
index = i;
break;
double X = nv->getViewPoint().x();
double Y = nv->getViewPoint().y();
double Z = nv->getViewPoint().z();
double latitude, longitude;
em->convertXYZToLatLongHeight(X,Y,Z,latitude, longitude, _currentElevation);
}
}
float delta = std::min(deltaTime/_animationTime, 1.0f);
for(unsigned int i=0; i<_mtc->getNumTextureWeights(); ++i)
{
float currentValue = _mtc->getTextureWeight(i);
float desiredValue = (i==index) ? 1.0f : 0.0f;
if (desiredValue != currentValue)
{
if (currentValue<desiredValue)
{
desiredValue = std::min(currentValue + delta, desiredValue);
}
else
{
desiredValue = std::max(currentValue - delta, desiredValue);
}
_mtc->setTextureWeight(i, desiredValue);
}
}
}
traverse(node,nv);
}
int _previousFrame;
double _previousTime;
float _animationTime;
double _currentElevation;
osg::observer_ptr<osgFX::MultiTextureControl> _mtc;
Elevations _elevations;
OpenThreads::Mutex _mutex;
};
// class to handle events with a pick
class TerrainHandler : public osgGA::GUIEventHandler {
public:
TerrainHandler(osgTerrain::Terrain* terrain):
_terrain(terrain) {}
bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa)
{
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::KEYDOWN):
{
if (ea.getKey()=='r')
{
_terrain->setSampleRatio(_terrain->getSampleRatio()*0.5);
osg::notify(osg::NOTICE)<<"Sample ratio "<<_terrain->getSampleRatio()<<std::endl;
return true;
}
else if (ea.getKey()=='R')
{
_terrain->setSampleRatio(_terrain->getSampleRatio()/0.5);
osg::notify(osg::NOTICE)<<"Sample ratio "<<_terrain->getSampleRatio()<<std::endl;
return true;
}
else if (ea.getKey()=='v')
{
_terrain->setVerticalScale(_terrain->getVerticalScale()*1.25);
osg::notify(osg::NOTICE)<<"Vertical scale "<<_terrain->getVerticalScale()<<std::endl;
return true;
}
else if (ea.getKey()=='V')
{
_terrain->setVerticalScale(_terrain->getVerticalScale()/1.25);
osg::notify(osg::NOTICE)<<"Vertical scale "<<_terrain->getVerticalScale()<<std::endl;
return true;
}
return false;
}
default:
return false;
}
}
protected:
~TerrainHandler() {}
osg::ref_ptr<osgTerrain::Terrain> _terrain;
};
int main( int argc, char **argv )
{
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
arguments.getApplicationUsage()->addCommandLineOption("-v","Set the terrain vertical scale.");
arguments.getApplicationUsage()->addCommandLineOption("-r","Set the terrain sample ratio.");
arguments.getApplicationUsage()->addCommandLineOption("--login <url> <username> <password>","Provide authentication information for http file access.");
// construct the viewer.
osgViewer::Viewer viewer(arguments);
float verticalScale = 1.0f;
while(arguments.read("-v",verticalScale)) {}
float sampleRatio = 1.0f;
while(arguments.read("-r",sampleRatio)) {}
std::string url, username, password;
while(arguments.read("--login",url, username, password))
{
if (!osgDB::Registry::instance()->getAuthenticationMap())
{
osgDB::Registry::instance()->setAuthenticationMap(new osgDB::AuthenticationMap);
osgDB::Registry::instance()->getAuthenticationMap()->addAuthenticationDetails(
url,
new osgDB::AuthenticationDetails(username, password)
);
}
}
// add all the event handlers to the viewer
{
@@ -259,11 +331,16 @@ int main( int argc, char **argv )
{
terrain = new osgTerrain::Terrain;
terrain->addChild(rootnode);
terrain->setSampleRatio(0.25f);
rootnode = terrain;
}
terrain->setSampleRatio(sampleRatio);
terrain->setVerticalScale(verticalScale);
// register our custom handler for adjust Terrain settings
viewer.addEventHandler(new TerrainHandler(terrain));
osg::CoordinateSystemNode* csn = findTopMostNodeOfType<osg::CoordinateSystemNode>(rootnode);
unsigned int numLayers = 1;
@@ -290,14 +367,19 @@ int main( int argc, char **argv )
ElevationLayerBlendingCallback* elbc = new ElevationLayerBlendingCallback(mtc, elevations);
// assign to the most appropriate node (the CoordinateSystemNode is best as it provides the elevation on the globe.)
if (csn) csn->setCullCallback(elbc);
else if (mtc) mtc->setCullCallback(elbc);
else rootnode->setCullCallback(elbc);
// note we must assign callback as both an update and cull callback, as update callback to do the update of
// the the osgFX::MultiTextureControl node a thread safe way, and as a cull callback to gather the camera
// position information.
osg::Node* nodeToAssignCallbackTo = csn ? csn : (mtc ? mtc : rootnode);
nodeToAssignCallbackTo->setUpdateCallback(elbc);
nodeToAssignCallbackTo->setCullCallback(elbc);
// add a viewport to the viewer and attach the scene graph.
viewer.setSceneData( rootnode );
}
// create the windows and run the threads.
viewer.realize();

View File

@@ -26,6 +26,17 @@
#include <osgViewer/Viewer>
#include <osgViewer/CompositeViewer>
#include <osgGA/TerrainManipulator>
#include <osgGA/StateSetManipulator>
#include <osgGA/AnimationPathManipulator>
#include <osgGA/TrackballManipulator>
#include <osgGA/FlightManipulator>
#include <osgGA/DriveManipulator>
#include <osgGA/KeySwitchMatrixManipulator>
#include <osgGA/StateSetManipulator>
#include <osgGA/AnimationPathManipulator>
#include <osgGA/TerrainManipulator>
#include <osg/Material>
#include <osg/Geode>
#include <osg/BlendFunc>
@@ -72,6 +83,18 @@ bool PickHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapte
if (view) pick(view,ea);
return false;
}
case(osgGA::GUIEventAdapter::KEYDOWN):
{
if (ea.getKey()=='c')
{
osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa);
osg::ref_ptr<osgGA::GUIEventAdapter> event = new osgGA::GUIEventAdapter(ea);
event->setX((ea.getXmin()+ea.getXmax())*0.5);
event->setY((ea.getYmin()+ea.getYmax())*0.5);
if (view) pick(view,*event);
}
return false;
}
default:
return false;
}
@@ -255,6 +278,36 @@ int main( int argc, char **argv )
{
osgViewer::Viewer viewer;
// add all the camera manipulators
{
osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator;
keyswitchManipulator->addMatrixManipulator( '1', "Trackball", new osgGA::TrackballManipulator() );
keyswitchManipulator->addMatrixManipulator( '2', "Flight", new osgGA::FlightManipulator() );
keyswitchManipulator->addMatrixManipulator( '3', "Drive", new osgGA::DriveManipulator() );
unsigned int num = keyswitchManipulator->getNumMatrixManipulators();
keyswitchManipulator->addMatrixManipulator( '4', "Terrain", new osgGA::TerrainManipulator() );
std::string pathfile;
char keyForAnimationPath = '5';
while (arguments.read("-p",pathfile))
{
osgGA::AnimationPathManipulator* apm = new osgGA::AnimationPathManipulator(pathfile);
if (apm || !apm->valid())
{
num = keyswitchManipulator->getNumMatrixManipulators();
keyswitchManipulator->addMatrixManipulator( keyForAnimationPath, "Path", apm );
++keyForAnimationPath;
}
}
keyswitchManipulator->selectMatrixManipulator(num);
viewer.setCameraManipulator( keyswitchManipulator.get() );
}
// add the handler for doing the picking
viewer.addEventHandler(new PickHandler(updateText.get()));

View File

@@ -200,7 +200,11 @@ struct MyCameraPostDrawCallback : public osg::Camera::DrawCallback
};
osg::Node* createPreRenderSubGraph(osg::Node* subgraph, unsigned tex_width, unsigned tex_height, osg::Camera::RenderTargetImplementation renderImplementation, bool useImage, bool useTextureRectangle, bool useHDR)
osg::Node* createPreRenderSubGraph(osg::Node* subgraph,
unsigned tex_width, unsigned tex_height,
osg::Camera::RenderTargetImplementation renderImplementation,
bool useImage, bool useTextureRectangle, bool useHDR,
unsigned int samples, unsigned int colorSamples)
{
if (!subgraph) return 0;
@@ -359,7 +363,8 @@ osg::Node* createPreRenderSubGraph(osg::Node* subgraph, unsigned tex_width, unsi
image->allocateImage(tex_width, tex_height, 1, GL_RGBA, GL_FLOAT);
// attach the image so its copied on each frame.
camera->attach(osg::Camera::COLOR_BUFFER, image);
camera->attach(osg::Camera::COLOR_BUFFER, image,
samples, colorSamples);
camera->setPostDrawCallback(new MyCameraPostDrawCallback(image));
@@ -376,7 +381,9 @@ osg::Node* createPreRenderSubGraph(osg::Node* subgraph, unsigned tex_width, unsi
else
{
// attach the texture and use it as the color buffer.
camera->attach(osg::Camera::COLOR_BUFFER, texture);
camera->attach(osg::Camera::COLOR_BUFFER, texture,
0, 0, false,
samples, colorSamples);
}
@@ -427,8 +434,11 @@ int main( int argc, char **argv )
return 1;
}
unsigned tex_width = 1024;
unsigned tex_height = 512;
unsigned int tex_width = 1024;
unsigned int tex_height = 512;
unsigned int samples = 0;
unsigned int colorSamples = 0;
while (arguments.read("--width", tex_width)) {}
while (arguments.read("--height", tex_height)) {}
@@ -439,6 +449,8 @@ int main( int argc, char **argv )
while (arguments.read("--pbuffer-rtt")) { renderImplementation = osg::Camera::PIXEL_BUFFER_RTT; }
while (arguments.read("--fb")) { renderImplementation = osg::Camera::FRAME_BUFFER; }
while (arguments.read("--window")) { renderImplementation = osg::Camera::SEPERATE_WINDOW; }
while (arguments.read("--fbo-samples", samples)) {}
while (arguments.read("--color-samples", colorSamples)) {}
bool useImage = false;
while (arguments.read("--image")) { useImage = true; }
@@ -469,7 +481,7 @@ int main( int argc, char **argv )
loadedModelTransform->setUpdateCallback(nc);
osg::Group* rootNode = new osg::Group();
rootNode->addChild(createPreRenderSubGraph(loadedModelTransform,tex_width,tex_height, renderImplementation, useImage, useTextureRectangle, useHDR));
rootNode->addChild(createPreRenderSubGraph(loadedModelTransform,tex_width,tex_height, renderImplementation, useImage, useTextureRectangle, useHDR, samples, colorSamples));
// add model to the viewer.
viewer.setSceneData( rootNode );

View File

@@ -0,0 +1,4 @@
SET(TARGET_SRC osgscreencapture.cpp )
#### end var setup ###
SETUP_EXAMPLE(osgscreencapture)

View File

@@ -0,0 +1,791 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This application is open source and may be redistributed and/or modified
* freely and without restriction, both in commericial and non commericial applications,
* as long as this copyright notice is maintained.
*
* This application 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.
*/
#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
#include <osgUtil/Optimizer>
#include <osg/CoordinateSystemNode>
#include <osg/Switch>
#include <osgText/Text>
#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
#include <osgGA/TrackballManipulator>
#include <osgGA/FlightManipulator>
#include <osgGA/DriveManipulator>
#include <osgGA/KeySwitchMatrixManipulator>
#include <osgGA/StateSetManipulator>
#include <osgGA/AnimationPathManipulator>
#include <osgGA/TerrainManipulator>
#include <iostream>
#include <sstream>
class WindowCaptureCallback : public osg::Camera::DrawCallback
{
public:
enum Mode
{
READ_PIXELS,
SINGLE_PBO,
DOUBLE_PBO,
TRIPLE_PBO
};
enum FramePosition
{
START_FRAME,
END_FRAME
};
struct ContextData : public osg::Referenced
{
ContextData(osg::GraphicsContext* gc, Mode mode, GLenum readBuffer, const std::string& name):
_gc(gc),
_mode(mode),
_readBuffer(readBuffer),
_fileName(name),
_pixelFormat(GL_BGRA),
_type(GL_UNSIGNED_BYTE),
_width(0),
_height(0),
_currentImageIndex(0),
_currentPboIndex(0),
_reportTimingFrequency(100),
_numTimeValuesRecorded(0),
_timeForReadPixels(0.0),
_timeForFullCopy(0.0),
_timeForMemCpy(0.0)
{
_previousFrameTick = osg::Timer::instance()->tick();
if (gc->getTraits())
{
if (gc->getTraits()->alpha)
{
osg::notify(osg::NOTICE)<<"Select GL_BGRA read back format"<<std::endl;
_pixelFormat = GL_BGRA;
}
else
{
osg::notify(osg::NOTICE)<<"Select GL_BGR read back format"<<std::endl;
_pixelFormat = GL_BGR;
}
}
getSize(gc, _width, _height);
std::cout<<"Window size "<<_width<<", "<<_height<<std::endl;
// single buffered image
_imageBuffer.push_back(new osg::Image);
// double buffer PBO.
switch(_mode)
{
case(READ_PIXELS):
osg::notify(osg::NOTICE)<<"Reading window usig glReadPixels, with out PixelBufferObject."<<std::endl;
break;
case(SINGLE_PBO):
osg::notify(osg::NOTICE)<<"Reading window usig glReadPixels, with a single PixelBufferObject."<<std::endl;
_pboBuffer.push_back(0);
break;
case(DOUBLE_PBO):
osg::notify(osg::NOTICE)<<"Reading window usig glReadPixels, with a double buffer PixelBufferObject."<<std::endl;
_pboBuffer.push_back(0);
_pboBuffer.push_back(0);
break;
case(TRIPLE_PBO):
osg::notify(osg::NOTICE)<<"Reading window usig glReadPixels, with a triple buffer PixelBufferObject."<<std::endl;
_pboBuffer.push_back(0);
_pboBuffer.push_back(0);
_pboBuffer.push_back(0);
break;
default:
break;
}
}
void getSize(osg::GraphicsContext* gc, int& width, int& height)
{
if (gc->getTraits())
{
width = gc->getTraits()->width;
height = gc->getTraits()->height;
}
}
void updateTimings(osg::Timer_t tick_start,
osg::Timer_t tick_afterReadPixels,
osg::Timer_t tick_afterMemCpy,
unsigned int dataSize);
void read()
{
osg::BufferObject::Extensions* ext = osg::BufferObject::getExtensions(_gc->getState()->getContextID(),true);
if (ext->isPBOSupported() && !_pboBuffer.empty())
{
if (_pboBuffer.size()==1)
{
singlePBO(ext);
}
else
{
multiPBO(ext);
}
}
else
{
readPixels();
}
}
void readPixels();
void singlePBO(osg::BufferObject::Extensions* ext);
void multiPBO(osg::BufferObject::Extensions* ext);
typedef std::vector< osg::ref_ptr<osg::Image> > ImageBuffer;
typedef std::vector< GLuint > PBOBuffer;
osg::GraphicsContext* _gc;
Mode _mode;
GLenum _readBuffer;
std::string _fileName;
GLenum _pixelFormat;
GLenum _type;
int _width;
int _height;
unsigned int _currentImageIndex;
ImageBuffer _imageBuffer;
unsigned int _currentPboIndex;
PBOBuffer _pboBuffer;
unsigned int _reportTimingFrequency;
unsigned int _numTimeValuesRecorded;
double _timeForReadPixels;
double _timeForFullCopy;
double _timeForMemCpy;
osg::Timer_t _previousFrameTick;
};
WindowCaptureCallback(Mode mode, FramePosition position, GLenum readBuffer):
_mode(mode),
_position(position),
_readBuffer(readBuffer)
{
}
FramePosition getFramePosition() const { return _position; }
ContextData* createContextData(osg::GraphicsContext* gc) const
{
std::stringstream filename;
filename << "test_"<<_contextDataMap.size()<<".jpg";
return new ContextData(gc, _mode, _readBuffer, filename.str());
}
ContextData* getContextData(osg::GraphicsContext* gc) const
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
osg::ref_ptr<ContextData>& data = _contextDataMap[gc];
if (!data) data = createContextData(gc);
return data.get();
}
virtual void operator () (osg::RenderInfo& renderInfo) const
{
glReadBuffer(_readBuffer);
osg::GraphicsContext* gc = renderInfo.getState()->getGraphicsContext();
osg::ref_ptr<ContextData> cd = getContextData(gc);
cd->read();
}
typedef std::map<osg::GraphicsContext*, osg::ref_ptr<ContextData> > ContextDataMap;
Mode _mode;
FramePosition _position;
GLenum _readBuffer;
mutable OpenThreads::Mutex _mutex;
mutable ContextDataMap _contextDataMap;
};
void WindowCaptureCallback::ContextData::updateTimings(osg::Timer_t tick_start,
osg::Timer_t tick_afterReadPixels,
osg::Timer_t tick_afterMemCpy,
unsigned int dataSize)
{
if (!_reportTimingFrequency) return;
double timeForReadPixels = osg::Timer::instance()->delta_s(tick_start, tick_afterReadPixels);
double timeForFullCopy = osg::Timer::instance()->delta_s(tick_start, tick_afterMemCpy);
double timeForMemCpy = osg::Timer::instance()->delta_s(tick_afterReadPixels, tick_afterMemCpy);
_timeForReadPixels += timeForReadPixels;
_timeForFullCopy += timeForFullCopy;
_timeForMemCpy += timeForMemCpy;
++_numTimeValuesRecorded;
if (_numTimeValuesRecorded==_reportTimingFrequency)
{
timeForReadPixels = _timeForReadPixels/double(_numTimeValuesRecorded);
timeForFullCopy = _timeForFullCopy/double(_numTimeValuesRecorded);
timeForMemCpy = _timeForMemCpy/double(_numTimeValuesRecorded);
double averageFrameTime = osg::Timer::instance()->delta_s(_previousFrameTick, tick_afterMemCpy)/double(_numTimeValuesRecorded);
double fps = 1.0/averageFrameTime;
_previousFrameTick = tick_afterMemCpy;
_timeForReadPixels = 0.0;
_timeForFullCopy = 0.0;
_timeForMemCpy = 0.0;
_numTimeValuesRecorded = 0;
double numMPixels = double(_width * _height) / 1000000.0;
double numMb = double(dataSize) / (1024*1024);
int prec = osg::notify(osg::NOTICE).precision(5);
if (timeForMemCpy==0.0)
{
osg::notify(osg::NOTICE)<<"fps = "<<fps<<", full frame copy = "<<timeForFullCopy*1000.0f<<"ms rate = "<<numMPixels / timeForFullCopy<<" Mpixel/sec, copy speed = "<<numMb / timeForFullCopy<<" Mb/sec"<<std::endl;
}
else
{
osg::notify(osg::NOTICE)<<"fps = "<<fps<<", full frame copy = "<<timeForFullCopy*1000.0f<<"ms rate = "<<numMPixels / timeForFullCopy<<" Mpixel/sec, "<<numMb / timeForFullCopy<< " Mb/sec "<<
"time for memcpy = "<<timeForMemCpy*1000.0<<"ms memcpy speed = "<<numMb / timeForMemCpy<<" Mb/sec"<<std::endl;
}
osg::notify(osg::NOTICE).precision(prec);
}
}
void WindowCaptureCallback::ContextData::readPixels()
{
// std::cout<<"readPixels("<<_fileName<<" image "<<_currentImageIndex<<" "<<_currentPboIndex<<std::endl;
unsigned int nextImageIndex = (_currentImageIndex+1)%_imageBuffer.size();
unsigned int nextPboIndex = _pboBuffer.empty() ? 0 : (_currentPboIndex+1)%_pboBuffer.size();
int width=0, height=0;
getSize(_gc, width, height);
if (width!=_width || _height!=height)
{
std::cout<<" Window resized "<<width<<", "<<height<<std::endl;
_width = width;
_height = height;
}
osg::Image* image = _imageBuffer[_currentImageIndex].get();
osg::Timer_t tick_start = osg::Timer::instance()->tick();
#if 1
image->readPixels(0,0,_width,_height,
_pixelFormat,_type);
#endif
osg::Timer_t tick_afterReadPixels = osg::Timer::instance()->tick();
updateTimings(tick_start, tick_afterReadPixels, tick_afterReadPixels, image->getTotalSizeInBytes());
if (!_fileName.empty())
{
// osgDB::writeImageFile(*image, _fileName);
}
_currentImageIndex = nextImageIndex;
_currentPboIndex = nextPboIndex;
}
void WindowCaptureCallback::ContextData::singlePBO(osg::BufferObject::Extensions* ext)
{
// std::cout<<"singelPBO( "<<_fileName<<" image "<<_currentImageIndex<<" "<<_currentPboIndex<<std::endl;
unsigned int nextImageIndex = (_currentImageIndex+1)%_imageBuffer.size();
int width=0, height=0;
getSize(_gc, width, height);
if (width!=_width || _height!=height)
{
std::cout<<" Window resized "<<width<<", "<<height<<std::endl;
_width = width;
_height = height;
}
GLuint& pbo = _pboBuffer[0];
osg::Image* image = _imageBuffer[_currentImageIndex].get();
if (image->s() != _width ||
image->t() != _height)
{
osg::notify(osg::NOTICE)<<"Allocating image "<<std::endl;
image->allocateImage(_width, _height, 1, _pixelFormat, _type);
if (pbo!=0)
{
osg::notify(osg::NOTICE)<<"deleting pbo "<<pbo<<std::endl;
ext->glDeleteBuffers (1, &pbo);
pbo = 0;
}
}
if (pbo==0)
{
ext->glGenBuffers(1, &pbo);
ext->glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, pbo);
ext->glBufferData(GL_PIXEL_PACK_BUFFER_ARB, image->getTotalSizeInBytes(), 0, GL_STREAM_READ);
osg::notify(osg::NOTICE)<<"Generating pbo "<<pbo<<std::endl;
}
else
{
ext->glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, pbo);
}
osg::Timer_t tick_start = osg::Timer::instance()->tick();
#if 1
glReadPixels(0, 0, _width, _height, _pixelFormat, _type, 0);
#endif
osg::Timer_t tick_afterReadPixels = osg::Timer::instance()->tick();
GLubyte* src = (GLubyte*)ext->glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB,
GL_READ_ONLY_ARB);
if(src)
{
memcpy(image->data(), src, image->getTotalSizeInBytes());
ext->glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB);
}
ext->glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0);
osg::Timer_t tick_afterMemCpy = osg::Timer::instance()->tick();
updateTimings(tick_start, tick_afterReadPixels, tick_afterMemCpy, image->getTotalSizeInBytes());
if (!_fileName.empty())
{
// osgDB::writeImageFile(*image, _fileName);
}
_currentImageIndex = nextImageIndex;
}
void WindowCaptureCallback::ContextData::multiPBO(osg::BufferObject::Extensions* ext)
{
// std::cout<<"multiPBO( "<<_fileName<<" image "<<_currentImageIndex<<" "<<_currentPboIndex<<std::endl;
unsigned int nextImageIndex = (_currentImageIndex+1)%_imageBuffer.size();
unsigned int nextPboIndex = (_currentPboIndex+1)%_pboBuffer.size();
int width=0, height=0;
getSize(_gc, width, height);
if (width!=_width || _height!=height)
{
std::cout<<" Window resized "<<width<<", "<<height<<std::endl;
_width = width;
_height = height;
}
GLuint& copy_pbo = _pboBuffer[_currentPboIndex];
GLuint& read_pbo = _pboBuffer[nextPboIndex];
osg::Image* image = _imageBuffer[_currentImageIndex].get();
if (image->s() != _width ||
image->t() != _height)
{
osg::notify(osg::NOTICE)<<"Allocating image "<<std::endl;
image->allocateImage(_width, _height, 1, _pixelFormat, _type);
if (read_pbo!=0)
{
osg::notify(osg::NOTICE)<<"deleting pbo "<<read_pbo<<std::endl;
ext->glDeleteBuffers (1, &read_pbo);
read_pbo = 0;
}
if (copy_pbo!=0)
{
osg::notify(osg::NOTICE)<<"deleting pbo "<<copy_pbo<<std::endl;
ext->glDeleteBuffers (1, &copy_pbo);
copy_pbo = 0;
}
}
bool doCopy = copy_pbo!=0;
if (copy_pbo==0)
{
ext->glGenBuffers(1, &copy_pbo);
ext->glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, copy_pbo);
ext->glBufferData(GL_PIXEL_PACK_BUFFER_ARB, image->getTotalSizeInBytes(), 0, GL_STREAM_READ);
osg::notify(osg::NOTICE)<<"Generating pbo "<<read_pbo<<std::endl;
}
if (read_pbo==0)
{
ext->glGenBuffers(1, &read_pbo);
ext->glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, read_pbo);
ext->glBufferData(GL_PIXEL_PACK_BUFFER_ARB, image->getTotalSizeInBytes(), 0, GL_STREAM_READ);
osg::notify(osg::NOTICE)<<"Generating pbo "<<read_pbo<<std::endl;
}
else
{
ext->glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, read_pbo);
}
osg::Timer_t tick_start = osg::Timer::instance()->tick();
#if 1
glReadPixels(0, 0, _width, _height, _pixelFormat, _type, 0);
#endif
osg::Timer_t tick_afterReadPixels = osg::Timer::instance()->tick();
if (doCopy)
{
ext->glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, copy_pbo);
GLubyte* src = (GLubyte*)ext->glMapBuffer(GL_PIXEL_PACK_BUFFER_ARB,
GL_READ_ONLY_ARB);
if(src)
{
memcpy(image->data(), src, image->getTotalSizeInBytes());
ext->glUnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB);
}
if (!_fileName.empty())
{
// osgDB::writeImageFile(*image, _fileName);
}
}
ext->glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0);
osg::Timer_t tick_afterMemCpy = osg::Timer::instance()->tick();
updateTimings(tick_start, tick_afterReadPixels, tick_afterMemCpy, image->getTotalSizeInBytes());
_currentImageIndex = nextImageIndex;
_currentPboIndex = nextPboIndex;
}
void addCallbackToViewer(osgViewer::ViewerBase& viewer, WindowCaptureCallback* callback)
{
if (callback->getFramePosition()==WindowCaptureCallback::START_FRAME)
{
osgViewer::ViewerBase::Windows windows;
viewer.getWindows(windows);
for(osgViewer::ViewerBase::Windows::iterator itr = windows.begin();
itr != windows.end();
++itr)
{
osgViewer::GraphicsWindow* window = *itr;
osg::GraphicsContext::Cameras& cameras = window->getCameras();
osg::Camera* firstCamera = 0;
for(osg::GraphicsContext::Cameras::iterator cam_itr = cameras.begin();
cam_itr != cameras.end();
++cam_itr)
{
if (firstCamera)
{
if ((*cam_itr)->getRenderOrder() < firstCamera->getRenderOrder())
{
firstCamera = (*cam_itr);
}
if ((*cam_itr)->getRenderOrder() == firstCamera->getRenderOrder() &&
(*cam_itr)->getRenderOrderNum() < firstCamera->getRenderOrderNum())
{
firstCamera = (*cam_itr);
}
}
else
{
firstCamera = *cam_itr;
}
}
if (firstCamera)
{
osg::notify(osg::NOTICE)<<"First camera "<<firstCamera<<std::endl;
firstCamera->setInitialDrawCallback(callback);
}
else
{
osg::notify(osg::NOTICE)<<"No camera found"<<std::endl;
}
}
}
else
{
osgViewer::ViewerBase::Windows windows;
viewer.getWindows(windows);
for(osgViewer::ViewerBase::Windows::iterator itr = windows.begin();
itr != windows.end();
++itr)
{
osgViewer::GraphicsWindow* window = *itr;
osg::GraphicsContext::Cameras& cameras = window->getCameras();
osg::Camera* lastCamera = 0;
for(osg::GraphicsContext::Cameras::iterator cam_itr = cameras.begin();
cam_itr != cameras.end();
++cam_itr)
{
if (lastCamera)
{
if ((*cam_itr)->getRenderOrder() > lastCamera->getRenderOrder())
{
lastCamera = (*cam_itr);
}
if ((*cam_itr)->getRenderOrder() == lastCamera->getRenderOrder() &&
(*cam_itr)->getRenderOrderNum() >= lastCamera->getRenderOrderNum())
{
lastCamera = (*cam_itr);
}
}
else
{
lastCamera = *cam_itr;
}
}
if (lastCamera)
{
osg::notify(osg::NOTICE)<<"Last camera "<<lastCamera<<std::endl;
lastCamera->setFinalDrawCallback(callback);
}
else
{
osg::notify(osg::NOTICE)<<"No camera found"<<std::endl;
}
}
}
}
int main(int argc, char** argv)
{
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName());
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the standard OpenSceneGraph example which loads and visualises 3d models.");
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
osgViewer::Viewer viewer(arguments);
unsigned int helpType = 0;
if ((helpType = arguments.readHelpType()))
{
arguments.getApplicationUsage()->write(std::cout, helpType);
return 1;
}
// report any errors if they have occurred when parsing the program arguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
if (arguments.argc()<=1)
{
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
return 1;
}
// set up the camera manipulators.
{
osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator;
keyswitchManipulator->addMatrixManipulator( '1', "Trackball", new osgGA::TrackballManipulator() );
keyswitchManipulator->addMatrixManipulator( '2', "Flight", new osgGA::FlightManipulator() );
keyswitchManipulator->addMatrixManipulator( '3', "Drive", new osgGA::DriveManipulator() );
keyswitchManipulator->addMatrixManipulator( '4', "Terrain", new osgGA::TerrainManipulator() );
std::string pathfile;
char keyForAnimationPath = '5';
while (arguments.read("-p",pathfile))
{
osgGA::AnimationPathManipulator* apm = new osgGA::AnimationPathManipulator(pathfile);
if (apm || !apm->valid())
{
unsigned int num = keyswitchManipulator->getNumMatrixManipulators();
keyswitchManipulator->addMatrixManipulator( keyForAnimationPath, "Path", apm );
keyswitchManipulator->selectMatrixManipulator(num);
++keyForAnimationPath;
}
}
viewer.setCameraManipulator( keyswitchManipulator.get() );
}
// add the state manipulator
viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) );
// add the thread model handler
viewer.addEventHandler(new osgViewer::ThreadingHandler);
// add the window size toggle handler
viewer.addEventHandler(new osgViewer::WindowSizeHandler);
// add the stats handler
viewer.addEventHandler(new osgViewer::StatsHandler);
// add the help handler
viewer.addEventHandler(new osgViewer::HelpHandler(arguments.getApplicationUsage()));
// add the record camera path handler
viewer.addEventHandler(new osgViewer::RecordCameraPathHandler);
// add the LOD Scale handler
viewer.addEventHandler(new osgViewer::LODScaleHandler);
GLenum readBuffer = GL_BACK;
WindowCaptureCallback::FramePosition position = WindowCaptureCallback::END_FRAME;
WindowCaptureCallback::Mode mode = WindowCaptureCallback::DOUBLE_PBO;
while (arguments.read("--start-frame")) { position = WindowCaptureCallback::START_FRAME; readBuffer = GL_FRONT; }
while (arguments.read("--end-frame")) position = WindowCaptureCallback::END_FRAME;
while (arguments.read("--front")) readBuffer = GL_FRONT;
while (arguments.read("--back")) readBuffer = GL_BACK;
while (arguments.read("--no-pbo")) mode = WindowCaptureCallback::READ_PIXELS;
while (arguments.read("--single-pbo")) mode = WindowCaptureCallback::SINGLE_PBO;
while (arguments.read("--double-pbo")) mode = WindowCaptureCallback::DOUBLE_PBO;
while (arguments.read("--triple-pbo")) mode = WindowCaptureCallback::TRIPLE_PBO;
unsigned int width=1280;
unsigned int height=1024;
bool pbufferOnly = false;
osg::ref_ptr<osg::GraphicsContext> pbuffer;
if (arguments.read("--pbuffer",width,height) ||
(pbufferOnly = arguments.read("--pbuffer-only",width,height)))
{
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
traits->x = 0;
traits->y = 0;
traits->width = width;
traits->height = height;
traits->red = 8;
traits->green = 8;
traits->blue = 8;
traits->alpha = 8;
traits->windowDecoration = false;
traits->pbuffer = true;
traits->doubleBuffer = true;
traits->sharedContext = 0;
pbuffer = osg::GraphicsContext::createGraphicsContext(traits.get());
if (pbuffer.valid())
{
osg::notify(osg::NOTICE)<<"Pixel buffer has been created successfully."<<std::endl;
}
else
{
osg::notify(osg::NOTICE)<<"Pixel buffer has not been created successfully."<<std::endl;
}
}
// load the data
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments);
if (!loadedModel)
{
std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
return 1;
}
// any option left unread are converted into errors to write out later.
arguments.reportRemainingOptionsAsUnrecognized();
// report any errors if they have occurred when parsing the program arguments.
if (arguments.errors())
{
arguments.writeErrorMessages(std::cout);
return 1;
}
// optimize the scene graph, remove redundant nodes and state etc.
osgUtil::Optimizer optimizer;
optimizer.optimize(loadedModel.get());
viewer.setSceneData( loadedModel.get() );
if (pbuffer.valid())
{
osg::ref_ptr<osg::Camera> camera = new osg::Camera;
camera->setGraphicsContext(pbuffer.get());
camera->setViewport(new osg::Viewport(0,0,width,height));
GLenum buffer = pbuffer->getTraits()->doubleBuffer ? GL_BACK : GL_FRONT;
camera->setDrawBuffer(buffer);
camera->setReadBuffer(buffer);
camera->setFinalDrawCallback(new WindowCaptureCallback(mode, position, readBuffer));
if (pbufferOnly)
{
viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd());
viewer.realize();
}
else
{
viewer.realize();
viewer.stopThreading();
pbuffer->realize();
viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd());
viewer.startThreading();
}
}
else
{
viewer.realize();
addCallbackToViewer(viewer, new WindowCaptureCallback(mode, position, readBuffer));
}
return viewer.run();
}

View File

@@ -502,10 +502,8 @@ int main(int argc, char** argv)
arguments.getApplicationUsage()->addCommandLineOption("--minNearSplit", "ParallelSplitShadowMap shadow map near offset.");//ADEGLI
arguments.getApplicationUsage()->addCommandLineOption("--maxFarDist", "ParallelSplitShadowMap max far distance to shadow.");//ADEGLI
arguments.getApplicationUsage()->addCommandLineOption("--moveVCamFactor", "ParallelSplitShadowMap move the virtual frustum behind the real camera, (also back ground object can cast shadow).");//ADEGLI
arguments.getApplicationUsage()->addCommandLineOption("--NVidia", "ParallelSplitShadowMap set default PolygonOffset for NVidia.");//ADEGLI
arguments.getApplicationUsage()->addCommandLineOption("--PolyOffset-Factor", "ParallelSplitShadowMap set PolygonOffset factor.");//ADEGLI
arguments.getApplicationUsage()->addCommandLineOption("--PolyOffset-Unit", "ParallelSplitShadowMap set PolygonOffset unit.");//ADEGLI
arguments.getApplicationUsage()->addCommandLineOption("--CullFaceFront", "ParallelSplitShadowMap add a cull face: front.");//ADEGLI
arguments.getApplicationUsage()->addCommandLineOption("-1", "Use test model one.");
@@ -626,20 +624,12 @@ int main(int argc, char** argv)
}
double polyoffsetfactor = -0.02;
double polyoffsetunit = 1.0;
double polyoffsetfactor = pssm->getPolygonOffset().x();
double polyoffsetunit = pssm->getPolygonOffset().y();
while (arguments.read("--PolyOffset-Factor", polyoffsetfactor));
while (arguments.read("--PolyOffset-Unit", polyoffsetunit));
pssm->setPolygonOffset(osg::Vec2(polyoffsetfactor,polyoffsetunit)); //ATI Radeon
if (arguments.read("--NVidia")){
//pssm->setPolygonOffset(osg::Vec2(-0.02,1.0)); //ATI Radeon
pssm->setPolygonOffset(osg::Vec2(10.0f,20.0f)); //NVidia
}
if ( arguments.read("--CullFaceFront") ) {
pssm->forceFrontCullFace();
}
pssm->setPolygonOffset(osg::Vec2(polyoffsetfactor,polyoffsetunit));
shadowedScene->setShadowTechnique(pssm.get());
}
@@ -761,7 +751,7 @@ int main(int argc, char** argv)
// osgDB::writeNodeFile(*group,"test.osg");
while (!viewer.done())
{
if (updateLightPosition)

View File

@@ -412,7 +412,49 @@ void testQuat(const osg::Vec3d& quat_scale)
class MyThread : public OpenThreads::Thread {
public:
void run(void) { }
void run(void) { }
};
class NotifyThread : public OpenThreads::Thread {
public:
NotifyThread(osg::NotifySeverity level, const std::string& message):
_done(false),
_level(level),
_message(message) {}
~NotifyThread()
{
_done = true;
while(isRunning())
{
OpenThreads::Thread::YieldCurrentThread();
}
}
void run(void)
{
std::cout << "Entering thread ..." <<_message<< std::endl;
unsigned int count=0;
while(!_done)
{
++count;
#if 1
osg::notify(_level)<<_message<<this<<"\n";
#else
osg::notify(_level)<<_message<<this<<std::endl;
#endif
}
std::cout << "Leaving thread ..." <<_message<< " count="<<count<<std::endl;
}
bool _done;
osg::NotifySeverity _level;
std::string _message;
};
void testThreadInitAndExit()
@@ -428,6 +470,25 @@ void testThreadInitAndExit()
OpenThreads::Thread::microSleep(500000);
std::cout<<"pass thread start and delete test"<<std::endl<<std::endl;
std::cout<<"****** Running notify thread test ****** "<<std::endl;
{
NotifyThread thread1(osg::INFO,"thread one:");
NotifyThread thread2(osg::INFO,"thread two:");
NotifyThread thread3(osg::INFO,"thread three:");
NotifyThread thread4(osg::INFO,"thread four:");
thread1.startThread();
thread2.startThread();
thread3.startThread();
thread4.startThread();
// add a sleep to allow the thread start to fall over it its going to.
OpenThreads::Thread::microSleep(5000000);
}
std::cout<<"pass noitfy thread test."<<std::endl<<std::endl;
}
void testPolytope()

View File

@@ -0,0 +1,10 @@
FILE(GLOB ui_files_1 "English.lproj/*.strings")
FILE(GLOB ui_files_2 "English.lproj/MainMenu.nib/*.nib")
SET(TARGET_SRC ViewerCocoa.mm main.m Info.plist ${ui_files_1} ${ui_files_2})
SET(TARGET_EXTERNAL_LIBRARIES osg ${COCOA_LIBRARY})
SET_SOURCE_FILES_PROPERTIES(Info.plist PROPERTIES MACOSX_PACKAGE_LOCATION .)
SET_SOURCE_FILES_PROPERTIES(${ui_files_1} PROPERTIES MACOSX_PACKAGE_LOCATION Resources/English.lproj)
SET_SOURCE_FILES_PROPERTIES(${ui_files_2} PROPERTIES MACOSX_PACKAGE_LOCATION Resources/English.lproj/MainMenu.nib)
SETUP_EXAMPLE(osgviewerCocoa)

View File

@@ -2,27 +2,27 @@
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>org.openscenegraph.osgsimpleviewerCocoa</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>osgviewerCocoa</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>org.openscenegraph.osgviewerCocoa</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>osgviewerCocoa</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>

View File

@@ -53,37 +53,37 @@
namespace osgViewer
{
// Just a forward declaration so I don't need the #include in the header.
class Viewer;
class GraphicsWindowEmbedded;
// Just a forward declaration so I don't need the #include in the header.
class Viewer;
class GraphicsWindowEmbedded;
}
// Subclass NSOpenGLView. We could subclass NSView instead, but NSOpenGLView is easy.
@interface ViewerCocoa : NSOpenGLView
{
// Note: In Objective-C++, if you use objects instead of pointers as
// member instance variables, you MUST turn on "Call C++ Default Ctors/Dtors in Objective-C".
// -fobjc-call-cxx-cdtors
// This option makes sure constructors and destructors are run.
// This option is only available for gcc 4.0+ (Mac OS X 10.4+)
// Note: In Objective-C++, if you use objects instead of pointers as
// member instance variables, you MUST turn on "Call C++ Default Ctors/Dtors in Objective-C".
// -fobjc-call-cxx-cdtors
// This option makes sure constructors and destructors are run.
// This option is only available for gcc 4.0+ (Mac OS X 10.4+)
// Is SimpleViewer supposed use ref_ptr? (Doesn't look like it to me.)
// If so, remember ref_ptr is an object on the stack and the cdtors option must be activated.
// We could also make simpleViewer an object instead of a pointer, but again, turn on the option.
osgViewer::Viewer* theViewer;
osgViewer::GraphicsWindowEmbedded* graphicsWindow;
// Is SimpleViewer supposed use ref_ptr? (Doesn't look like it to me.)
// If so, remember ref_ptr is an object on the stack and the cdtors option must be activated.
// We could also make simpleViewer an object instead of a pointer, but again, turn on the option.
osgViewer::Viewer* theViewer;
osgViewer::GraphicsWindowEmbedded* graphicsWindow;
// This timer is used to trigger animation callbacks since everything is event driven.
NSTimer* animationTimer;
// This timer is used to trigger animation callbacks since everything is event driven.
NSTimer* animationTimer;
// Flags to help track whether ctrl-clicking or option-clicking is being used
BOOL isUsingCtrlClick;
BOOL isUsingOptionClick;
// Flag to track whether the OpenGL multithreading engine is enabled or not
BOOL isUsingMultithreadedOpenGLEngine;
// Flags to help track whether ctrl-clicking or option-clicking is being used
BOOL isUsingCtrlClick;
BOOL isUsingOptionClick;
// Flag to track whether the OpenGL multithreading engine is enabled or not
BOOL isUsingMultithreadedOpenGLEngine;
}
// My custom static method to create a basic pixel format

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,8 @@
SET(TARGET_SRC osggtkdrawingarea.cpp osgviewerGTK.cpp)
SET(TARGET_H osggtkdrawingarea.h)
INCLUDE_DIRECTORIES(${GTK_INCLUDE_DIRS} ${GTKGL_INCLUDE_DIRS})
LINK_DIRECTORIES(${GTK_LIBRARY_DIRS} ${GTKGL_LIBRARY_DIRS})
LINK_LIBRARIES(osgViewer ${GTK_LIBRARIES} ${GTKGL_LIBRARIES})
SETUP_EXAMPLE(osgviewerGTK)

View File

@@ -0,0 +1,148 @@
#include "osggtkdrawingarea.h"
OSGGTKDrawingArea::OSGGTKDrawingArea():
_widget (gtk_drawing_area_new()),
_glconfig (0),
_context (0),
_drawable (0),
_state (0),
_queue (*getEventQueue()) {
setCameraManipulator(new osgGA::TrackballManipulator());
}
OSGGTKDrawingArea::~OSGGTKDrawingArea() {
}
bool OSGGTKDrawingArea::createWidget(int width, int height) {
_glconfig = gdk_gl_config_new_by_mode(static_cast<GdkGLConfigMode>(
GDK_GL_MODE_RGBA |
GDK_GL_MODE_DEPTH |
GDK_GL_MODE_DOUBLE
));
if(not _glconfig) {
osg::notify(osg::FATAL) << "Fail!" << std::endl;
return false;
}
gtk_widget_set_size_request(_widget, width, height);
gtk_widget_set_gl_capability(
_widget,
_glconfig,
0,
true,
GDK_GL_RGBA_TYPE
);
gtk_widget_add_events(
_widget,
GDK_BUTTON1_MOTION_MASK |
GDK_BUTTON2_MOTION_MASK |
GDK_BUTTON3_MOTION_MASK |
GDK_POINTER_MOTION_MASK |
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_KEY_PRESS_MASK |
GDK_KEY_RELEASE_MASK |
GDK_VISIBILITY_NOTIFY_MASK
);
// We do this so that we don't have to suck up ALL the input to the
// window, but instead just when the drawing area is focused.
g_object_set(_widget, "can-focus", true, NULL);
_connect("realize", G_CALLBACK(&OSGGTKDrawingArea::_srealize));
_connect("unrealize", G_CALLBACK(&OSGGTKDrawingArea::_sunrealize));
_connect("expose_event", G_CALLBACK(&OSGGTKDrawingArea::_sexpose_event));
_connect("configure_event", G_CALLBACK(&OSGGTKDrawingArea::_sconfigure_event));
_connect("motion_notify_event", G_CALLBACK(&OSGGTKDrawingArea::_smotion_notify_event));
_connect("button_press_event", G_CALLBACK(&OSGGTKDrawingArea::_sbutton_press_event));
_connect("button_release_event", G_CALLBACK(&OSGGTKDrawingArea::_sbutton_press_event));
_connect("key_press_event", G_CALLBACK(&OSGGTKDrawingArea::_skey_press_event));
_gw = setUpViewerAsEmbeddedInWindow(0, 0, width, height);
return true;
}
void OSGGTKDrawingArea::_realize(GtkWidget* widget) {
_context = gtk_widget_get_gl_context(widget);
_drawable = gtk_widget_get_gl_drawable(widget);
gtkRealize();
}
void OSGGTKDrawingArea::_unrealize(GtkWidget* widget) {
gtkUnrealize();
}
bool OSGGTKDrawingArea::_expose_event(GtkWidget* widget, GdkEventExpose* event) {
if(not gtkGLBegin()) return false;
frame();
gtkGLSwap();
gtkGLEnd();
return gtkExpose();
}
bool OSGGTKDrawingArea::_configure_event(GtkWidget* widget, GdkEventConfigure* event) {
gtkGLBegin();
_queue.windowResize(0, 0, event->width, event->height);
_gw->resized(0, 0, event->width, event->height);
gtkGLEnd();
return gtkConfigure(event->width, event->height);
}
bool OSGGTKDrawingArea::_motion_notify_event(GtkWidget* widget, GdkEventMotion* event) {
_state = event->state;
_queue.mouseMotion(event->x, event->y);
return gtkMotionNotify(event->x, event->y);
}
bool OSGGTKDrawingArea::_button_press_event(GtkWidget* widget, GdkEventButton* event) {
_state = event->state;
if(event->type == GDK_BUTTON_PRESS) {
if(event->button == 1) gtk_widget_grab_focus(_widget);
_queue.mouseButtonPress(event->x, event->y, event->button);
return gtkButtonPress(event->x, event->y, event->button);
}
else if(event->type == GDK_BUTTON_RELEASE) {
_queue.mouseButtonRelease(event->x, event->y, event->button);
return gtkButtonRelease(event->x, event->y, event->button);
}
else return false;
}
bool OSGGTKDrawingArea::_key_press_event(GtkWidget* widget, GdkEventKey* event) {
_state = event->state;
if(event->type == GDK_KEY_PRESS) {
_queue.keyPress(event->keyval);
return gtkKeyPress(event->keyval);
}
else if(event->type == GDK_KEY_RELEASE) {
_queue.keyRelease(event->keyval);
return gtkKeyRelease(event->keyval);
}
else return false;
}

View File

@@ -0,0 +1,207 @@
#include <gtk/gtk.h>
#include <gtk/gtkgl.h>
#include <osgViewer/Viewer>
#include <osgGA/TrackballManipulator>
// This is an implementation of SimpleViewer that is designed to be subclassed
// and used as a GtkDrawingArea in a GTK application. Because of the implemention
// of GTK, I was unable to derive from GtkWidget and instead had to "wrap" it.
// Conceptually, however, you can think of an OSGGTKDrawingArea as both an OSG
// Viewer AND GtkDrawingArea.
//
// While it is possible to use this class directly, it won't end up doing anything
// interesting without calls to queueDraw, which ideally are done in the user's
// subclass implementation (see: osgviewerGTK).
class OSGGTKDrawingArea : public osgViewer::Viewer {
GtkWidget* _widget;
GdkGLConfig* _glconfig;
GdkGLContext* _context;
GdkGLDrawable* _drawable;
osg::ref_ptr<osgViewer::GraphicsWindowEmbedded> _gw;
unsigned int _state;
osgGA::EventQueue& _queue;
static OSGGTKDrawingArea* _self(gpointer self) {
return static_cast<OSGGTKDrawingArea*>(self);
}
// A simple helper function to connect us to the various GTK signals.
void _connect(const char* name, GCallback callback) {
g_signal_connect(G_OBJECT(_widget), name, callback, this);
}
void _realize (GtkWidget*);
void _unrealize (GtkWidget*);
bool _expose_event (GtkWidget*, GdkEventExpose*);
bool _configure_event (GtkWidget*, GdkEventConfigure*);
bool _motion_notify_event (GtkWidget*, GdkEventMotion*);
bool _button_press_event (GtkWidget*, GdkEventButton*);
bool _key_press_event (GtkWidget*, GdkEventKey*);
// The following functions are static "wrappers" so that we can invoke the
// bound methods of a class instance by passing the "this" pointer as the
// self argument and invoking it explicitly.
static void _srealize(GtkWidget* widget, gpointer self) {
_self(self)->_realize(widget);
}
static void _sunrealize(GtkWidget* widget, gpointer self) {
_self(self)->_unrealize(widget);
}
static bool _sexpose_event(GtkWidget* widget, GdkEventExpose* expose, gpointer self) {
return _self(self)->_expose_event(widget, expose);
}
static bool _sconfigure_event(
GtkWidget* widget,
GdkEventConfigure* event,
gpointer self
) {
return _self(self)->_configure_event(widget, event);
}
static bool _smotion_notify_event(
GtkWidget* widget,
GdkEventMotion* event,
gpointer self
) {
return _self(self)->_motion_notify_event(widget, event);
}
static bool _sbutton_press_event(
GtkWidget* widget,
GdkEventButton* event,
gpointer self
) {
return _self(self)->_button_press_event(widget, event);
}
static bool _skey_press_event(
GtkWidget* widget,
GdkEventKey* event,
gpointer self
) {
return _self(self)->_key_press_event(widget, event);
}
protected:
// You can override these in your subclass if you'd like. :)
// Right now they're fairly uninformative, but they could be easily extended.
// Note that the "state" information isn't passed around to each function
// but is instead stored and abstracted internally. See below.
virtual void gtkRealize () {};
virtual void gtkUnrealize () {};
virtual bool gtkExpose () {
return true;
};
// The new width and height.
virtual bool gtkConfigure(int, int) {
return true;
};
// The "normalized" coordinates of the mouse.
virtual bool gtkMotionNotify(double, double) {
return true;
};
// The "normalized" coordinates of the mouse and the mouse button code on down.
virtual bool gtkButtonPress(double, double, unsigned int) {
return true;
};
// The "normalized" coordinates of the mouse and mouse button code on release.
virtual bool gtkButtonRelease(double, double, unsigned int) {
return true;
}
// The X key value on down.
virtual bool gtkKeyPress(unsigned int) {
return true;
};
// The X key value on release.
virtual bool gtkKeyRelease(unsigned int) {
return true;
};
// These functions wrap state tests of the most recent state in the
// GtkDrawingArea.
inline bool stateShift() {
return _state & GDK_SHIFT_MASK;
}
inline bool stateLock() {
return _state & GDK_LOCK_MASK;
}
inline bool stateControl() {
return _state & GDK_CONTROL_MASK;
}
inline bool stateMod() {
return _state & (
GDK_MOD1_MASK |
GDK_MOD2_MASK |
GDK_MOD3_MASK |
GDK_MOD4_MASK |
GDK_MOD5_MASK
);
}
inline bool stateButton() {
return _state & (
GDK_BUTTON1_MASK |
GDK_BUTTON2_MASK |
GDK_BUTTON3_MASK |
GDK_BUTTON4_MASK |
GDK_BUTTON5_MASK
);
}
public:
OSGGTKDrawingArea ();
~OSGGTKDrawingArea ();
bool createWidget(int, int);
GtkWidget* getWidget() {
return _widget;
}
bool gtkGLBegin() {
if(_drawable and _context) return gdk_gl_drawable_gl_begin(_drawable, _context);
else return false;
}
void gtkGLEnd() {
if(_drawable) gdk_gl_drawable_gl_end(_drawable);
}
// Because of GTK's internal double buffering, I'm not sure if we're really
// taking advantage of OpenGL's internal swapping.
bool gtkGLSwap() {
if(_drawable and gdk_gl_drawable_is_double_buffered(_drawable)) {
gdk_gl_drawable_swap_buffers(_drawable);
return true;
}
else {
glFlush();
return false;
}
}
void queueDraw() {
gtk_widget_queue_draw(_widget);
}
};

View File

@@ -0,0 +1,232 @@
#include <iostream>
#include <string>
#include <osg/Stats>
#include <osgDB/ReadFile>
#include "osggtkdrawingarea.h"
const char* HELP_TEXT =
"Use CTRL or SHIFT plus right-click to pull up a fake menu.\n"
"Use the standard TrackballManipulator keys to rotate the loaded\n"
"model (with caveats; the model won't keep rotating).\n"
"\n"
"<b>OpenSceneGraph Project, 2008</b>"
;
// If you want to see how to connect class method to callbacks, take a look at the
// implementation of OSGGTKDrawingArea. It's dirty, but it's the only way I could
// come up with.
bool activate(GtkWidget* widget, gpointer) {
GtkWidget* label = gtk_bin_get_child(GTK_BIN(widget));
std::cout << "MENU: " << gtk_label_get_label(GTK_LABEL(label)) << std::endl;
return true;
}
// Our derived OSGGTKDrawingArea "widget." Redraws occur while the mouse buttons
// are held down and mouse motion is detected.
//
// This is the easiest way to demonstrate the use of OSGGTKDrawingArea. We override
// a few of the event methods to setup our menu and to issue redraws. Note that an
// unmodified OSGGTKDrawingArea never calls queueDraw, so OSG is never asked to render
// itself.
class ExampleOSGGTKDrawingArea : public OSGGTKDrawingArea {
GtkWidget* _menu;
unsigned int _tid;
// A helper function to easily setup our menu entries.
void _menuAdd(const std::string& title) {
GtkWidget* item = gtk_menu_item_new_with_label(title.c_str());
gtk_menu_shell_append(GTK_MENU_SHELL(_menu), item);
g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(activate), 0);
}
bool _clicked(GtkWidget* widget) {
const char* text = gtk_label_get_label(
GTK_LABEL(gtk_bin_get_child(GTK_BIN(widget)))
);
if(not std::strncmp(text, "Close", 5)) gtk_main_quit();
else if(not std::strncmp(text, "Open File", 9)) {
GtkWidget* of = gtk_file_chooser_dialog_new(
"Please select an OSG file...",
GTK_WINDOW(gtk_widget_get_toplevel(getWidget())),
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN,
GTK_RESPONSE_ACCEPT,
NULL
);
if(gtk_dialog_run(GTK_DIALOG(of)) == GTK_RESPONSE_ACCEPT) {
char* file = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(of));
osg::ref_ptr<osg::Node> model = osgDB::readNodeFile(file);
if(model.valid()) {
setSceneData(model.get());
queueDraw();
}
g_free(file);
}
gtk_widget_destroy(of);
}
// Assume we're wanting FPS toggling.
else {
if(not _tid) {
_tid = g_timeout_add(
15,
(GSourceFunc)(ExampleOSGGTKDrawingArea::timeout),
this
);
gtk_button_set_label(GTK_BUTTON(widget), "Toggle 60 FPS (off)");
}
else {
g_source_remove(_tid);
gtk_button_set_label(GTK_BUTTON(widget), "Toggle 60 FPS (on)");
_tid = 0;
}
}
return true;
}
protected:
// Check right-click release to see if we need to popup our menu.
bool gtkButtonRelease(double, double, unsigned int button) {
if(button == 3 and (stateControl() or stateShift())) gtk_menu_popup(
GTK_MENU(_menu),
0,
0,
0,
0,
button,
0
);
return true;
}
// Our "main" drawing pump. Since our app is just a model viewer, we use
// click+motion as our criteria for issuing OpenGL refreshes.
bool gtkMotionNotify(double, double) {
if(stateButton()) queueDraw();
return true;
}
public:
ExampleOSGGTKDrawingArea():
OSGGTKDrawingArea (),
_menu (gtk_menu_new()),
_tid (0) {
_menuAdd("Option");
_menuAdd("Another Option");
_menuAdd("Still More Options");
gtk_widget_show_all(_menu);
getCamera()->setStats(new osg::Stats("omg"));
}
~ExampleOSGGTKDrawingArea() {}
// Public so that we can use this as a callback in main().
static bool clicked(GtkWidget* widget, gpointer self) {
return static_cast<ExampleOSGGTKDrawingArea*>(self)->_clicked(widget);
}
//static gboolean timeout(GtkWidget* widget) {
static bool timeout(void* self) {
static_cast<ExampleOSGGTKDrawingArea*>(self)->queueDraw();
return true;
}
};
// Our main() function! FINALLY! Most of this code is GTK stuff, so it's mostly boilerplate.
// If we wanted to get real jiggy with it we could use Glade and cut down about 20 lines of
// code or so.
int main(int argc, char** argv) {
gtk_init(&argc, &argv);
gtk_gl_init(&argc, &argv);
ExampleOSGGTKDrawingArea da;
if(da.createWidget(640, 480)) {
if(argc >= 2) {
osg::ref_ptr<osg::Node> model = osgDB::readNodeFile(argv[1]);
if(model.valid()) da.setSceneData(model.get());
}
GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
GtkWidget* vbox1 = gtk_vbox_new(false, 3);
GtkWidget* vbox2 = gtk_vbox_new(false, 3);
GtkWidget* hbox = gtk_hbox_new(false, 3);
GtkWidget* label = gtk_label_new("");
GtkWidget* buttons[] = {
gtk_button_new_with_label("Open File"),
gtk_button_new_with_label("Toggle 60 FPS (on)"),
gtk_button_new_with_label("Close")
};
gtk_label_set_use_markup(GTK_LABEL(label), true);
gtk_label_set_label(GTK_LABEL(label), HELP_TEXT);
for(unsigned int i = 0; i < sizeof(buttons) / sizeof(GtkWidget*); i++) {
gtk_box_pack_start(
GTK_BOX(vbox2),
buttons[i],
false,
false,
0
);
g_signal_connect(
G_OBJECT(buttons[i]),
"clicked",
G_CALLBACK(ExampleOSGGTKDrawingArea::clicked),
&da
);
}
gtk_window_set_title(GTK_WINDOW(window), "osgviewerGTK");
gtk_box_pack_start(GTK_BOX(hbox), vbox2, true, true, 2);
gtk_box_pack_start(GTK_BOX(hbox), label, true, true, 2);
gtk_box_pack_start(GTK_BOX(vbox1), da.getWidget(), true, true, 2);
gtk_box_pack_start(GTK_BOX(vbox1), hbox, false, false, 2);
gtk_container_set_reallocate_redraws(GTK_CONTAINER(window), true);
gtk_container_add(GTK_CONTAINER(window), vbox1);
g_signal_connect(
G_OBJECT(window),
"delete_event",
G_CALLBACK(gtk_main_quit),
0
);
gtk_widget_show_all(window);
gtk_main();
}
else return 1;
return 0;
}

View File

@@ -9,6 +9,11 @@
#include "wx/wx.h"
#endif
// For wxCURSOR_BLANK below, but isn't used a.t.m.
//#ifdef WIN32
//#include "wx/msw/wx.rc"
//#endif
#include "osgviewerWX.h"
@@ -40,16 +45,21 @@ bool wxOsgApp::OnInit()
// create osg canvas
// - initialize
int *attributes = new int[6];
int *attributes = new int[7];
attributes[0] = int(WX_GL_DOUBLEBUFFER);
attributes[1] = WX_GL_RGBA;
attributes[2] = WX_GL_DEPTH_SIZE;
attributes[3] = 8;
attributes[4] = WX_GL_STENCIL_SIZE;
attributes[5] = 8;
attributes[6] = 0;
GraphicsWindowWX* gw = new GraphicsWindowWX(frame, wxID_ANY, wxDefaultPosition,
wxSize(width, height), wxSUNKEN_BORDER, wxT("osgviewerWX"), attributes);
OSGCanvas *canvas = new OSGCanvas(frame, wxID_ANY, wxDefaultPosition,
wxSize(width, height), wxSUNKEN_BORDER, wxT("osgviewerWX"), attributes);
GraphicsWindowWX* gw = new GraphicsWindowWX(canvas);
canvas->SetGraphicsWindow(gw);
osgViewer::Viewer *viewer = new osgViewer::Viewer;
viewer->getCamera()->setGraphicsContext(gw);
@@ -68,7 +78,6 @@ bool wxOsgApp::OnInit()
viewer->setSceneData(loadedModel.get());
viewer->setCameraManipulator(new osgGA::TrackballManipulator);
frame->SetViewer(viewer);
/* Show the frame */
@@ -102,30 +111,169 @@ void MainFrame::OnIdle(wxIdleEvent &event)
event.RequestMore();
}
BEGIN_EVENT_TABLE(GraphicsWindowWX, wxGLCanvas)
EVT_SIZE (GraphicsWindowWX::OnSize )
EVT_PAINT (GraphicsWindowWX::OnPaint )
EVT_ERASE_BACKGROUND(GraphicsWindowWX::OnEraseBackground)
EVT_KEY_DOWN (GraphicsWindowWX::OnKeyDown )
EVT_KEY_UP (GraphicsWindowWX::OnKeyUp )
EVT_MOUSE_EVENTS (GraphicsWindowWX::OnMouse )
BEGIN_EVENT_TABLE(OSGCanvas, wxGLCanvas)
EVT_SIZE (OSGCanvas::OnSize)
EVT_PAINT (OSGCanvas::OnPaint)
EVT_ERASE_BACKGROUND (OSGCanvas::OnEraseBackground)
EVT_CHAR (OSGCanvas::OnChar)
EVT_KEY_UP (OSGCanvas::OnKeyUp)
EVT_ENTER_WINDOW (OSGCanvas::OnMouseEnter)
EVT_LEFT_DOWN (OSGCanvas::OnMouseDown)
EVT_MIDDLE_DOWN (OSGCanvas::OnMouseDown)
EVT_RIGHT_DOWN (OSGCanvas::OnMouseDown)
EVT_LEFT_UP (OSGCanvas::OnMouseUp)
EVT_MIDDLE_UP (OSGCanvas::OnMouseUp)
EVT_RIGHT_UP (OSGCanvas::OnMouseUp)
EVT_MOTION (OSGCanvas::OnMouseMotion)
END_EVENT_TABLE()
GraphicsWindowWX::GraphicsWindowWX(wxWindow *parent, wxWindowID id,
OSGCanvas::OSGCanvas(wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size, long style, const wxString& name, int *attributes)
: wxGLCanvas(parent, id, pos, size, style|wxFULL_REPAINT_ON_RESIZE, name, attributes)
{
// default cursor to standard
_oldCursor = *wxSTANDARD_CURSOR;
}
OSGCanvas::~OSGCanvas()
{
}
void OSGCanvas::OnPaint( wxPaintEvent& WXUNUSED(event) )
{
/* must always be here */
wxPaintDC dc(this);
}
void OSGCanvas::OnSize(wxSizeEvent& event)
{
// this is also necessary to update the context on some platforms
wxGLCanvas::OnSize(event);
// set GL viewport (not called by wxGLCanvas::OnSize on all platforms...)
int width, height;
GetClientSize(&width, &height);
if (_graphics_window.valid())
{
// update the window dimensions, in case the window has been resized.
_graphics_window->getEventQueue()->windowResize(0, 0, width, height);
_graphics_window->resized(0,0,width,height);
}
}
void OSGCanvas::OnEraseBackground(wxEraseEvent& WXUNUSED(event))
{
/* Do nothing, to avoid flashing on MSW */
}
void OSGCanvas::OnChar(wxKeyEvent &event)
{
#if wxUSE_UNICODE
int key = event.GetUnicodeKey();
#else
int key = event.GetKeyCode();
#endif
if (_graphics_window.valid())
_graphics_window->getEventQueue()->keyPress(key);
// If this key event is not processed here, we should call
// event.Skip() to allow processing to continue.
}
void OSGCanvas::OnKeyUp(wxKeyEvent &event)
{
#if wxUSE_UNICODE
int key = event.GetUnicodeKey();
#else
int key = event.GetKeyCode();
#endif
if (_graphics_window.valid())
_graphics_window->getEventQueue()->keyRelease(key);
// If this key event is not processed here, we should call
// event.Skip() to allow processing to continue.
}
void OSGCanvas::OnMouseEnter(wxMouseEvent &event)
{
// Set focus to ourselves, so keyboard events get directed to us
SetFocus();
}
void OSGCanvas::OnMouseDown(wxMouseEvent &event)
{
if (_graphics_window.valid())
{
_graphics_window->getEventQueue()->mouseButtonPress(event.GetX(), event.GetY(),
event.GetButton());
}
}
void OSGCanvas::OnMouseUp(wxMouseEvent &event)
{
if (_graphics_window.valid())
{
_graphics_window->getEventQueue()->mouseButtonRelease(event.GetX(), event.GetY(),
event.GetButton());
}
}
void OSGCanvas::OnMouseMotion(wxMouseEvent &event)
{
if (_graphics_window.valid())
_graphics_window->getEventQueue()->mouseMotion(event.GetX(), event.GetY());
}
void OSGCanvas::UseCursor(bool value)
{
if (value)
{
// show the old cursor
SetCursor(_oldCursor);
}
else
{
// remember the old cursor
_oldCursor = GetCursor();
// hide the cursor
// - can't find a way to do this neatly, so create a 1x1, transparent image
wxImage image(1,1);
image.SetMask(true);
image.SetMaskColour(0, 0, 0);
wxCursor cursor(image);
SetCursor(cursor);
// On wxGTK, only works as of version 2.7.0
// (http://trac.wxwidgets.org/ticket/2946)
// SetCursor( wxStockCursor( wxCURSOR_BLANK ) );
}
}
GraphicsWindowWX::GraphicsWindowWX(OSGCanvas *canvas)
{
_canvas = canvas;
_traits = new GraphicsContext::Traits;
wxPoint pos = _canvas->GetPosition();
wxSize size = _canvas->GetSize();
_traits->x = pos.x;
_traits->y = pos.y;
_traits->width = size.x;
_traits->height = size.y;
init();
}
GraphicsWindowWX::~GraphicsWindowWX()
{
}
void GraphicsWindowWX::init()
@@ -147,120 +295,32 @@ void GraphicsWindowWX::init()
}
}
GraphicsWindowWX::~GraphicsWindowWX()
{
}
void GraphicsWindowWX::OnPaint( wxPaintEvent& WXUNUSED(event) )
{
/* must always be here */
wxPaintDC dc(this);
}
void GraphicsWindowWX::OnSize(wxSizeEvent& event)
{
// this is also necessary to update the context on some platforms
wxGLCanvas::OnSize(event);
// set GL viewport (not called by wxGLCanvas::OnSize on all platforms...)
int width, height;
GetClientSize(&width, &height);
// update the window dimensions, in case the window has been resized.
getEventQueue()->windowResize(0, 0, width, height);
resized(0,0,width,height);
}
void GraphicsWindowWX::OnEraseBackground(wxEraseEvent& WXUNUSED(event))
{
/* Do nothing, to avoid flashing on MSW */
}
void GraphicsWindowWX::OnKeyDown(wxKeyEvent &event)
{
#if wxUSE_UNICODE
int key = event.GetUnicodeKey();
#else
int key = event.GetKeyCode();
#endif
getEventQueue()->keyPress(key);
// propagate event
event.Skip();
}
void GraphicsWindowWX::OnKeyUp(wxKeyEvent &event)
{
#if wxUSE_UNICODE
int key = event.GetUnicodeKey();
#else
int key = event.GetKeyCode();
#endif
getEventQueue()->keyRelease(key);
// propagate event
event.Skip();
}
void GraphicsWindowWX::OnMouse(wxMouseEvent& event)
{
if (event.ButtonDown()) {
int button = event.GetButton();
getEventQueue()->mouseButtonPress(event.GetX(), event.GetY(), button);
}
else if (event.ButtonUp()) {
int button = event.GetButton();
getEventQueue()->mouseButtonRelease(event.GetX(), event.GetY(), button);
}
else if (event.Dragging()) {
getEventQueue()->mouseMotion(event.GetX(), event.GetY());
}
}
void GraphicsWindowWX::grabFocus()
{
// focus this window
SetFocus();
// focus the canvas
_canvas->SetFocus();
}
void GraphicsWindowWX::grabFocusIfPointerInWindow()
{
// focus this window, if the pointer is in the window
wxPoint pos = wxGetMousePosition();
if (this == wxFindWindowAtPoint(pos)) {
SetFocus();
}
if (wxFindWindowAtPoint(pos) == _canvas)
_canvas->SetFocus();
}
void GraphicsWindowWX::useCursor(bool cursorOn)
{
if (cursorOn) {
// show the old cursor
SetCursor(_oldCursor);
}
else {
// remember the old cursor
_oldCursor = GetCursor();
// hide the cursor
// - can't find a way to do this neatly, so create a 1x1, transparent image
wxImage image(1,1);
image.SetMask(true);
image.SetMaskColour(0, 0, 0);
wxCursor cursor(image);
SetCursor(cursor);
}
_canvas->UseCursor(cursorOn);
}
bool GraphicsWindowWX::makeCurrentImplementation()
{
SetCurrent();
_canvas->SetCurrent();
return true;
}
void GraphicsWindowWX::swapBuffersImplementation()
{
SwapBuffers();
_canvas->SwapBuffers();
}

View File

@@ -8,25 +8,50 @@
#include <osgViewer/Viewer>
#include <string>
class GraphicsWindowWX : public wxGLCanvas, public osgViewer::GraphicsWindow
class GraphicsWindowWX;
class OSGCanvas : public wxGLCanvas
{
public:
GraphicsWindowWX(wxWindow *parent, wxWindowID id = wxID_ANY,
OSGCanvas(wxWindow *parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxString& name = wxT("TestGLCanvas"),
int *attributes = 0);
~GraphicsWindowWX();
void init();
virtual ~OSGCanvas();
void SetGraphicsWindow(osgViewer::GraphicsWindow *gw) { _graphics_window = gw; }
void OnPaint(wxPaintEvent& event);
void OnSize(wxSizeEvent& event);
void OnEraseBackground(wxEraseEvent& event);
void OnKeyDown(wxKeyEvent &event);
void OnChar(wxKeyEvent &event);
void OnKeyUp(wxKeyEvent &event);
void OnMouse(wxMouseEvent &event);
void OnMouseEnter(wxMouseEvent &event);
void OnMouseDown(wxMouseEvent &event);
void OnMouseUp(wxMouseEvent &event);
void OnMouseMotion(wxMouseEvent &event);
void UseCursor(bool value);
private:
DECLARE_EVENT_TABLE()
osg::ref_ptr<osgViewer::GraphicsWindow> _graphics_window;
wxCursor _oldCursor;
};
class GraphicsWindowWX : public osgViewer::GraphicsWindow
{
public:
GraphicsWindowWX(OSGCanvas *canvas);
~GraphicsWindowWX();
void init();
//
// GraphicsWindow interface
@@ -38,7 +63,7 @@ public:
bool makeCurrentImplementation();
void swapBuffersImplementation();
// note implemented yet...just use dummy implementation to get working.
// not implemented yet...just use dummy implementation to get working.
virtual bool valid() const { return true; }
virtual bool realizeImplementation() { return true; }
virtual bool isRealizedImplementation() const { return true; }
@@ -46,15 +71,15 @@ public:
virtual bool releaseContextImplementation() { return true; }
private:
wxCursor _oldCursor;
DECLARE_EVENT_TABLE()
// XXX need to set _canvas to NULL when the canvas is deleted by
// its parent. for this, need to add event handler in OSGCanvas
OSGCanvas* _canvas;
};
class MainFrame : public wxFrame
{
public:
MainFrame(wxFrame *frame, const wxString& title, const wxPoint& pos,
MainFrame(wxFrame *frame, const wxString& title, const wxPoint& pos,
const wxSize& size, long style = wxDEFAULT_FRAME_STYLE);
void SetViewer(osgViewer::Viewer *viewer);

View File

@@ -0,0 +1,7 @@
#this file is automatically generated
SET(TARGET_SRC osgwidgetaddremove.cpp )
SET(TARGET_ADDED_LIBRARIES osgWidget )
#### end var setup ###
SETUP_EXAMPLE(osgwidgetaddremove)

View File

@@ -0,0 +1,134 @@
// -*-c++-*- osgWidget - Code by: Jeremy Moles (cubicool) 2007-2008
// $Id: osgwidgetaddremove.cpp 45 2008-04-23 16:46:11Z cubicool $
#include <osgWidget/Util>
#include <osgWidget/WindowManager>
#include <osgWidget/Table>
#include <osgWidget/Box>
#include <osgWidget/Label>
const unsigned int MASK_2D = 0xF0000000;
class ABCWidget: public osgWidget::Label {
public:
ABCWidget(const std::string& label):
osgWidget::Label("", label) {
setFont("fonts/Vera.ttf");
setFontSize(20);
setCanFill(true);
setShadow(0.08f);
addSize(10.0f, 10.0f);
}
};
class Button: public osgWidget::Label {
public:
Button(const std::string& label):
osgWidget::Label("", label) {
setFont("fonts/Vera.ttf");
setFontSize(30);
setColor(0.8f, 0.2f, 0.2f, 0.8f);
setCanFill(true);
setShadow(0.1f);
setEventMask(osgWidget::EVENT_MASK_MOUSE_CLICK);
addSize(20.0f, 20.0f);
}
// NOTE! I need to make it clearer than Push/Release can happen so fast that
// the changes you make aren't visible with your refresh rate. Throttling state
// changes and what-have-you on mousePush/mouseRelease/etc. is going to be
// annoying...
virtual bool mousePush(double, double, osgWidget::WindowManager*) {
addColor(0.2f, 0.2f, 0.2f, 0.0f);
return true;
}
virtual bool mouseRelease(double, double, osgWidget::WindowManager*) {
addColor(-0.2f, -0.2f, -0.2f, 0.0f);
return true;
}
};
class AddRemove: public osgWidget::Box {
osg::ref_ptr<osgWidget::Window> _win1;
public:
AddRemove():
osgWidget::Box ("buttons", osgWidget::Box::VERTICAL),
_win1 (new osgWidget::Box("win1", osgWidget::Box::VERTICAL)) {
addWidget(new Button("Add Widget"));
addWidget(new Button("Remove Widget"));
// Take special note here! Not only do the Button objects have their
// own overridden methods for changing the color, but they have attached
// callbacks for doing the work with local data.
getByName("Widget_1")->addCallback(osgWidget::Callback(
&AddRemove::handlePressAdd,
this,
osgWidget::EVENT_MOUSE_PUSH
));
getByName("Widget_2")->addCallback(osgWidget::Callback(
&AddRemove::handlePressRemove,
this,
osgWidget::EVENT_MOUSE_PUSH
));
}
virtual void managed(osgWidget::WindowManager* wm) {
osgWidget::Box::managed(wm);
_win1->setOrigin(250.0f, 0.0f);
wm->addChild(_win1.get());
}
bool handlePressAdd(osgWidget::Event& ev) {
static unsigned int num = 0;
std::stringstream ss;
ss << "a random widget " << num;
_win1->addWidget(new ABCWidget(ss.str()));
_win1->resize();
num++;
return true;
}
bool handlePressRemove(osgWidget::Event& ev) {
// TODO: Temporary hack!
const osgWidget::Box::Vector& v = _win1->getObjects();
if(!v.size()) return false;
osgWidget::Widget* w = _win1->getObjects()[v.size() - 1].get();
_win1->removeWidget(w);
_win1->resize();
return true;
}
};
int main(int argc, char** argv) {
osgViewer::Viewer viewer;
osgWidget::WindowManager* wm = new osgWidget::WindowManager(
&viewer,
1280.0f,
1024.0f,
MASK_2D
);
osgWidget::Box* buttons = new AddRemove();
wm->addChild(buttons);
return createExample(viewer, wm);
}

View File

@@ -0,0 +1,7 @@
#this file is automatically generated
SET(TARGET_SRC osgwidgetbox.cpp )
SET(TARGET_ADDED_LIBRARIES osgWidget )
#### end var setup ###
SETUP_EXAMPLE(osgwidgetbox)

View File

@@ -0,0 +1,122 @@
// -*-c++-*- osgWidget - Code by: Jeremy Moles (cubicool) 2007-2008
// $Id: osgwidgetbox.cpp 59 2008-05-15 20:55:31Z cubicool $
// NOTE: You'll find this example very similar to osgwidgetwindow. However, here we
// demonstrate a bit of subclassing of Widget so that we can respond to events
// such as mouseEnter and mouseLeave. We also demonstrate the use of padding, though
// fill and alignment should be working too.
#include <osg/io_utils>
#include <osgDB/ReadFile>
#include <osgWidget/Util>
#include <osgWidget/WindowManager>
#include <osgWidget/Box>
const unsigned int MASK_2D = 0xF0000000;
const unsigned int MASK_3D = 0x0F000000;
struct ColorWidget: public osgWidget::Widget {
ColorWidget():
osgWidget::Widget("", 256.0f, 256.0f) {
}
bool mouseEnter(double, double, osgWidget::WindowManager*) {
addColor(-osgWidget::Color(0.4f, 0.4f, 0.4f, 0.0f));
// osgWidget::warn() << "enter: " << getColor() << std::endl;
return true;
}
bool mouseLeave(double, double, osgWidget::WindowManager*) {
addColor(osgWidget::Color(0.4f, 0.4f, 0.4f, 0.0f));
// osgWidget::warn() << "leave: " << getColor() << std::endl;
return true;
}
bool mouseOver(double x, double y, osgWidget::WindowManager*) {
osgWidget::Color c = getImageColorAtPointerXY(x, y);
if(c.a() < 0.001f) {
// osgWidget::warn() << "Transparent Pixel: " << x << " " << y << std::endl;
return false;
}
return true;
}
bool keyUp(int key, int keyMask, osgWidget::WindowManager*) {
// osgWidget::warn() << "..." << key << " - " << keyMask << std::endl;
return true;
}
};
osgWidget::Box* createBox(const std::string& name, osgWidget::Box::BOX_TYPE bt) {
osgWidget::Box* box = new osgWidget::Box(name, bt, true);
osgWidget::Widget* widget1 = new osgWidget::Widget(name + "_widget1", 100.0f, 100.0f);
osgWidget::Widget* widget2 = new osgWidget::Widget(name + "_widget2", 100.0f, 100.0f);
osgWidget::Widget* widget3 = new ColorWidget();
widget1->setColor(0.3f, 0.3f, 0.3f, 1.0f);
widget2->setColor(0.6f, 0.6f, 0.6f, 1.0f);
widget3->setImage("osgWidget/natascha.png");
widget3->setTexCoord(0.0f, 0.0f, osgWidget::Widget::LOWER_LEFT);
widget3->setTexCoord(1.0f, 0.0f, osgWidget::Widget::LOWER_RIGHT);
widget3->setTexCoord(1.0f, 1.0f, osgWidget::Widget::UPPER_RIGHT);
widget3->setTexCoord(0.0f, 1.0f, osgWidget::Widget::UPPER_LEFT);
box->addWidget(widget1);
box->addWidget(widget2);
box->addWidget(widget3);
return box;
}
int main(int argc, char** argv) {
osgViewer::CompositeViewer viewer;
osgViewer::View* view = new osgViewer::View();
osgWidget::WindowManager* wm = new osgWidget::WindowManager(
view,
1280.0f,
1024.0f,
MASK_2D,
osgWidget::WindowManager::WM_PICK_DEBUG |
osgWidget::WindowManager::WM_NO_INVERT_Y
);
wm->setPointerFocusMode(osgWidget::WindowManager::PFM_SLOPPY);
osgWidget::Window* box1 = createBox("HBOX", osgWidget::Box::HORIZONTAL);
osgWidget::Window* box2 = createBox("VBOX", osgWidget::Box::VERTICAL);
osgWidget::Window* box3 = createBox("HBOX2", osgWidget::Box::HORIZONTAL);
osgWidget::Window* box4 = createBox("VBOX2", osgWidget::Box::VERTICAL);
box1->getBackground()->setColor(1.0f, 0.0f, 0.0f, 0.8f);
box1->attachMoveCallback();
box2->getBackground()->setColor(0.0f, 1.0f, 0.0f, 0.8f);
box2->attachMoveCallback();
box3->getBackground()->setColor(0.0f, 0.0f, 1.0f, 0.8f);
box3->attachMoveCallback();
wm->addChild(box1);
wm->addChild(box2);
wm->addChild(box3);
wm->addChild(box4);
box4->hide();
osg::Node* model = osgDB::readNodeFile("spaceship.osg");
model->setNodeMask(MASK_3D);
return osgWidget::createCompositeExample(viewer, view, wm, model);
}

View File

@@ -0,0 +1,7 @@
#this file is automatically generated
SET(TARGET_SRC osgwidgetcanvas.cpp )
SET(TARGET_ADDED_LIBRARIES osgWidget )
#### end var setup ###
SETUP_EXAMPLE(osgwidgetcanvas)

View File

@@ -0,0 +1,118 @@
// -*-c++-*- osgWidget - Code by: Jeremy Moles (cubicool) 2007-2008
// $Id: osgwidgetcanvas.cpp 33 2008-04-04 19:03:12Z cubicool $
#include <osgWidget/Util>
#include <osgWidget/WindowManager>
#include <osgWidget/Canvas>
const unsigned int MASK_2D = 0xF0000000;
bool colorWidgetEnter(osgWidget::Event& event) {
event.getWidget()->addColor(0.5f, 0.2f, 0.3f, 0.0f);
// osgWidget::warn() << "WIDGET mouseEnter " << event.getWidget()->getName() << std::endl;
return true;
}
bool colorWidgetLeave(osgWidget::Event& event) {
event.getWidget()->addColor(-0.5f, -0.2f, -0.3f, 0.0f);
// osgWidget::warn() << "WIDGET mouseLeave" << std::endl;
return true;
}
bool windowMouseOver(osgWidget::Event& event) {
osgWidget::XYCoord xy = event.getWindow()->localXY(event.x, event.y);
// osgWidget::warn() << "WINDOW " << xy.x() << " - " << xy.y() << std::endl;
return true;
}
bool widgetMouseOver(osgWidget::Event& event) {
osgWidget::XYCoord xy = event.getWidget()->localXY(event.x, event.y);
// osgWidget::warn() << "WIDGET mouseOver " << xy.x() << " - " << xy.y() << std::endl;
return true;
}
osgWidget::Widget* createWidget(
const std::string& name,
osgWidget::color_type col,
osgWidget::Widget::Layer layer
) {
osgWidget::Widget* widget = new osgWidget::Widget(name, 200.0f, 200.0f);
widget->setEventMask(osgWidget::EVENT_ALL);
widget->addCallback(osgWidget::Callback(&colorWidgetEnter, osgWidget::EVENT_MOUSE_PUSH));
widget->addCallback(osgWidget::Callback(&colorWidgetLeave, osgWidget::EVENT_MOUSE_RELEASE));
widget->addCallback(osgWidget::Callback(&colorWidgetEnter, osgWidget::EVENT_MOUSE_ENTER));
widget->addCallback(osgWidget::Callback(&colorWidgetLeave, osgWidget::EVENT_MOUSE_LEAVE));
widget->addCallback(osgWidget::Callback(&widgetMouseOver, osgWidget::EVENT_MOUSE_OVER));
widget->setColor(col, col, col, 0.5f);
widget->setLayer(layer);
return widget;
}
int main(int argc, char** argv) {
osgViewer::Viewer viewer;
osgWidget::WindowManager* wm = new osgWidget::WindowManager(
&viewer,
1280.0f,
1024.0f,
MASK_2D,
osgWidget::WindowManager::WM_PICK_DEBUG
);
osgWidget::Canvas* canvas = new osgWidget::Canvas("canvas");
canvas->addCallback(osgWidget::Callback(&windowMouseOver, osgWidget::EVENT_MOUSE_OVER));
canvas->attachMoveCallback();
canvas->attachRotateCallback();
canvas->attachScaleCallback();
canvas->addWidget(
createWidget("w1", 0.2f, osgWidget::Widget::LAYER_LOW),
0.0f,
0.0f
);
canvas->addWidget(
createWidget("w2", 0.4f, osgWidget::Widget::LAYER_MIDDLE),
200.0f,
0.0f
);
canvas->addWidget(
createWidget("w3", 0.6f, osgWidget::Widget::LAYER_HIGH),
400.0f,
0.0f
);
// Add a child and then resize it relatively to the size of the parent Window.
osgWidget::Widget* relWidget = new osgWidget::Widget("relative");
relWidget->setLayer(osgWidget::Widget::LAYER_LOW, 1);
relWidget->setCoordinateMode(osgWidget::Widget::CM_RELATIVE);
relWidget->setSize(0.2f, 0.2f);
relWidget->setColor(0.5f, 0.5f, 0.1f, 0.9f);
osgWidget::warn() << canvas->getWidth() << std::endl;
canvas->addWidget(relWidget, 0.4f, 0.4f);
relWidget->addOrigin(0.1f, 0.1f);
relWidget->addSize(0.2f, 0.2f);
canvas->resize();
// Finally, add the whole thing to the WindowManager.
wm->addChild(canvas);
return osgWidget::createExample(viewer, wm);
}

View File

@@ -0,0 +1,7 @@
#this file is automatically generated
SET(TARGET_SRC osgwidgetframe.cpp )
SET(TARGET_ADDED_LIBRARIES osgWidget )
#### end var setup ###
SETUP_EXAMPLE(osgwidgetframe)

View File

@@ -0,0 +1,89 @@
// -*-c++-*- osgWidget - Code by: Jeremy Moles (cubicool) 2007-2008
// $Id: osgwidgetframe.cpp 40 2008-04-11 14:05:11Z cubicool $
#include <osgWidget/Util>
#include <osgWidget/WindowManager>
#include <osgWidget/Frame>
#include <osgWidget/Box>
const unsigned int MASK_2D = 0xF0000000;
int main(int argc, char** argv) {
osgViewer::Viewer viewer;
osgWidget::WindowManager* wm = new osgWidget::WindowManager(
&viewer,
1280.0f,
1024.0f,
MASK_2D,
osgWidget::WindowManager::WM_PICK_DEBUG
);
osgWidget::Frame* frame = osgWidget::Frame::createSimpleFrame(
"frame",
32.0f,
32.0f,
300.0f,
300.0f
);
osgWidget::Table* table = new osgWidget::Table("table", 2, 2);
osgWidget::Box* bottom = new osgWidget::Box("panel", osgWidget::Box::HORIZONTAL);
table->addWidget(new osgWidget::Widget("red", 300.0f, 300.0f), 0, 0);
table->addWidget(new osgWidget::Widget("white", 300.0f, 300.0f), 0, 1);
table->addWidget(new osgWidget::Widget("yellow", 300.0f, 300.0f), 1, 0);
table->addWidget(new osgWidget::Widget("purple", 300.0f, 300.0f), 1, 1);
table->getByRowCol(0, 0)->setColor(1.0f, 0.0f, 0.0f, 1.0f);
table->getByRowCol(0, 1)->setColor(1.0f, 1.0f, 1.0f, 1.0f);
table->getByRowCol(1, 0)->setColor(1.0f, 1.0f, 0.0f, 1.0f);
table->getByRowCol(1, 1)->setColor(1.0f, 0.0f, 1.0f, 1.0f);
table->getByRowCol(0, 0)->setMinimumSize(100.0f, 100.0f);
table->getByRowCol(0, 1)->setMinimumSize(100.0f, 100.0f);
table->getByRowCol(1, 0)->setMinimumSize(100.0f, 100.0f);
table->getByRowCol(1, 1)->setMinimumSize(100.0f, 100.0f);
frame->setWindow(table);
// Give frame some nice textures.
// TODO: This has to be done after setWindow(); wtf?
frame->getBackground()->setColor(0.0f, 0.0f, 0.0f, 0.0f);
osgWidget::Widget* l = frame->getBorder(osgWidget::Frame::BORDER_LEFT);
osgWidget::Widget* r = frame->getBorder(osgWidget::Frame::BORDER_RIGHT);
osgWidget::Widget* t = frame->getBorder(osgWidget::Frame::BORDER_TOP);
osgWidget::Widget* b = frame->getBorder(osgWidget::Frame::BORDER_BOTTOM);
l->setImage("osgWidget/border-left.tga", true);
r->setImage("osgWidget/border-right.tga", true);
t->setImage("osgWidget/border-top.tga", true);
b->setImage("osgWidget/border-bottom.tga", true);
l->setTexCoordWrapVertical();
r->setTexCoordWrapVertical();
t->setTexCoordWrapHorizontal();
b->setTexCoordWrapHorizontal();
// Create the bottom, XArt panel.
osgWidget::Widget* left = new osgWidget::Widget("left", 512.0f, 256.0f);
osgWidget::Widget* center = new osgWidget::Widget("center", 256.0f, 256.0f);
osgWidget::Widget* right = new osgWidget::Widget("right", 512.0f, 256.0f);
left->setImage ("osgWidget/panel-left.tga", true);
center->setImage("osgWidget/panel-center.tga", true);
right->setImage ("osgWidget/panel-right.tga", true);
center->setTexCoordWrapHorizontal();
bottom->addWidget(left);
bottom->addWidget(center);
bottom->addWidget(right);
bottom->getBackground()->setColor(0.0f, 0.0f, 0.0f, 0.0f);
bottom->setOrigin(0.0f, 1024.0f - 256.0f);
// Add everything to the WindowManager.
wm->addChild(frame);
wm->addChild(bottom);
return osgWidget::createExample(viewer, wm);
}

View File

@@ -0,0 +1,7 @@
#this file is automatically generated
SET(TARGET_SRC osgwidgetinput.cpp )
SET(TARGET_ADDED_LIBRARIES osgWidget )
#### end var setup ###
SETUP_EXAMPLE(osgwidgetinput)

View File

@@ -0,0 +1,185 @@
// -*-c++-*- osgWidget - Code by: Jeremy Moles (cubicool) 2007-2008
// $Id: osgwidgetinput.cpp 50 2008-05-06 05:06:36Z cubicool $
#include <osgDB/WriteFile>
#include <osgWidget/Util>
#include <osgWidget/WindowManager>
#include <osgWidget/Box>
#include <osgWidget/Table>
#include <osgWidget/Frame>
#include <osgWidget/Label>
#include <osgWidget/Input>
const unsigned int MASK_2D = 0xF0000000;
const char* INFO =
"Use the Input Wigets below to enter the X, Y, and Z position of a\n"
"sphere to be inserted into the scene. Once you've done this, use\n"
"the button below to add it!"
;
void setupLabel(osgWidget::Label* label) {
label->setFontSize(16);
label->setFontColor(1.0f, 1.0f, 1.0f, 1.0f);
label->setFont("fonts/Vera.ttf");
label->setPadding(2.0f);
label->setHeight(18.0f);
label->setCanFill(true);
}
osgWidget::Input* createTableRow(
osgWidget::Table* table,
unsigned int rowNum,
const std::string& valName
) {
std::stringstream ssLabel;
std::stringstream ssInput;
ssLabel << "Label_Row" << rowNum;
ssInput << "Input_Row" << rowNum;
osgWidget::Label* label = new osgWidget::Label(ssLabel.str(), valName);
osgWidget::Input* input = new osgWidget::Input(ssInput.str(), "", 20);
setupLabel(label);
setupLabel(input);
label->setWidth(50.0f);
label->setColor(0.1f, 0.1f, 0.1f, 1.0f);
input->setWidth(150.0f);
input->setColor(0.4f, 0.4f, 0.4f, 1.0f);
table->addWidget(label, rowNum, 0);
table->addWidget(input, rowNum, 1);
return input;
}
osgWidget::Label* createLabel(const std::string& text) {
osgWidget::Label* label = new osgWidget::Label("", text);
setupLabel(label);
return label;
}
class Button: public osgWidget::Label {
public:
typedef std::vector<osgWidget::Input*> Inputs;
private:
Inputs _xyz;
public:
Button(const std::string& text, const Inputs& inputs):
osgWidget::Label("", text),
_xyz(inputs) {
setupLabel(this);
setEventMask(osgWidget::EVENT_MASK_MOUSE_CLICK);
setShadow(0.1f);
addHeight(4.0f);
}
bool mousePush(double, double, osgWidget::WindowManager*) {
osgWidget::warn()
<< "x: " << _xyz[0]->getLabel() << std::endl
<< "y: " << _xyz[1]->getLabel() << std::endl
<< "z: " << _xyz[2]->getLabel() << std::endl
;
return false;
}
};
// TODO: Testing our _parent/EmbeddedWindow stuff.
bool info(osgWidget::Event& ev) {
osgWidget::warn() << "MousePush @ Window: " << ev.getWindow()->getName() << std::endl;
return true;
}
int main(int argc, char** argv) {
osgViewer::Viewer viewer;
osgWidget::WindowManager* wm = new osgWidget::WindowManager(
&viewer,
1280.0f,
1024.0f,
MASK_2D,
osgWidget::WindowManager::WM_PICK_DEBUG
);
osgWidget::Box* box = new osgWidget::Box("vbox", osgWidget::Box::VERTICAL);
osgWidget::Table* table = new osgWidget::Table("table", 3, 2);
osgWidget::Box* lbox1 = new osgWidget::Box("lbox1", osgWidget::Box::HORIZONTAL);
osgWidget::Box* lbox2 = new osgWidget::Box("lbox2", osgWidget::Box::HORIZONTAL);
osgWidget::Frame* frame = osgWidget::Frame::createSimpleFrameWithSingleTexture(
"frame",
"osgWidget/theme.png",
64.0f,
64.0f,
16.0f,
16.0f,
100.0f,
100.0f
);
osgWidget::Input* x = createTableRow(table, 0, "X Position");
osgWidget::Input* y = createTableRow(table, 1, "Y Position");
osgWidget::Input* z = createTableRow(table, 2, "Z Position");
Button::Inputs inputs;
inputs.push_back(x);
inputs.push_back(y);
inputs.push_back(z);
table->addCallback(osgWidget::Callback(&info, osgWidget::EVENT_MOUSE_PUSH));
lbox1->addWidget(createLabel(INFO));
lbox2->addWidget(new Button("Add To Scene...", inputs));
box->addWidget(lbox1->embed());
box->addWidget(table->embed());
box->addWidget(lbox2->embed());
box->addCallback(osgWidget::Callback(&info, osgWidget::EVENT_MOUSE_PUSH));
frame->setWindow(box);
frame->getEmbeddedWindow()->setSize(box->getWidth(), box->getHeight());
frame->getBackground()->setColor(0.0f, 0.0f, 0.0f, 0.0f);
frame->attachTabFocusCallback();
for(osgWidget::Frame::Iterator i = frame->begin(); i != frame->end(); i++) {
if(i->valid()) i->get()->setColor(0.5f, 0.7f, 1.0f, 1.0f);
}
wm->addChild(frame);
/*
// Print out our focus list, it should just have 3 widgets.
osgWidget::WidgetList wl;
box->getFocusList(wl);
for(osgWidget::WidgetList::iterator i = wl.begin(); i != wl.end(); i++) {
osgWidget::warn() << i->get()->getName() << std::endl;
}
*/
lbox1->getBackground()->setColor(1.0f, 0.0f, 0.0f, 1.0f, osgWidget::Widget::UPPER_LEFT);
lbox1->getBackground()->setColor(0.0f, 1.0f, 0.0f, 1.0f, osgWidget::Widget::LOWER_LEFT);
lbox1->getBackground()->setColor(0.0f, 0.0f, 1.0f, 1.0f, osgWidget::Widget::LOWER_RIGHT);
lbox1->getBackground()->setColor(1.0f, 1.0f, 1.0f, 1.0f, osgWidget::Widget::UPPER_RIGHT);
lbox1->setVisibilityMode(osgWidget::Window::VM_ENTIRE);
lbox1->update();
int r = osgWidget::createExample(viewer, wm);
// osgWidget::writeWindowManagerNode(wm);
// osgDB::writeNodeFile(*box, "osgWidget.osg");
return r;
}

View File

@@ -0,0 +1,7 @@
#this file is automatically generated
SET(TARGET_SRC osgwidgetlabel.cpp )
SET(TARGET_ADDED_LIBRARIES osgWidget )
#### end var setup ###
SETUP_EXAMPLE(osgwidgetlabel)

View File

@@ -0,0 +1,120 @@
// -*-c++-*- osgWidget - Code by: Jeremy Moles (cubicool) 2007-2008
// $Id: osgwidgetlabel.cpp 66 2008-07-14 21:54:09Z cubicool $
#include <osg/io_utils>
#include <osgWidget/Util>
#include <osgWidget/WindowManager>
#include <osgWidget/Box>
#include <osgWidget/Label>
const unsigned int MASK_2D = 0xF0000000;
const char* LABEL1 =
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed\n"
"do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n"
"Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris\n"
"nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in..."
;
const char* LABEL2 =
"...reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla\n"
"pariatur. Excepteur sint occaecat cupidatat non proident, sunt in \n"
"culpa qui officia deserunt mollit anim id est laborum. BBBBB"
;
osgWidget::Label* createLabel(const std::string& l, unsigned int size=13) {
osgWidget::Label* label = new osgWidget::Label("", "");
label->setFont("fonts/Vera.ttf");
label->setFontSize(size);
label->setFontColor(1.0f, 1.0f, 1.0f, 1.0f);
label->setLabel(l);
/*
text->setBackdropType(osgText::Text::DROP_SHADOW_BOTTOM_RIGHT);
text->setBackdropImplementation(osgText::Text::NO_DEPTH_BUFFER);
text->setBackdropOffset(0.2f);
*/
return label;
}
int main(int argc, char** argv) {
osgViewer::Viewer viewer;
osgWidget::WindowManager* wm = new osgWidget::WindowManager(
&viewer,
1280.0f,
1024.0f,
MASK_2D,
osgWidget::WindowManager::WM_PICK_DEBUG |
osgWidget::WindowManager::WM_NO_INVERT_Y
);
osgWidget::Box* box = new osgWidget::Box("HBOX", osgWidget::Box::HORIZONTAL);
osgWidget::Box* vbox = new osgWidget::Box("vbox", osgWidget::Box::VERTICAL);
osgWidget::Label* label1 = createLabel(LABEL1);
osgWidget::Label* label2 = createLabel(LABEL2);
// Setup the labels for horizontal box.
label1->setPadding(10.0f);
label2->setPadding(10.0f);
label1->addSize(21.0f, 22.0f);
label2->addSize(21.0f, 22.0f);
label1->setColor(1.0f, 0.5f, 0.0f, 0.0f);
label2->setColor(1.0f, 0.5f, 0.0f, 0.0f);
box->addWidget(label1);
box->addWidget(label2);
box->attachMoveCallback();
box->attachScaleCallback();
box->attachRotateCallback();
// Setup the labels for the vertical box.
osgWidget::Label* label3 = createLabel("Label 3", 80);
osgWidget::Label* label4 = createLabel("Label 4", 60);
osgWidget::Label* label5 = createLabel("ABCDEFGHIJK", 93);
label3->setPadding(3.0f);
label4->setPadding(3.0f);
label5->setPadding(3.0f);
label3->setColor(0.0f, 0.0f, 0.5f, 0.5f);
label4->setColor(0.0f, 0.0f, 0.5f, 0.5f);
label5->setColor(0.0f, 0.0f, 0.5f, 0.5f);
label5->setAlignHorizontal(osgWidget::Widget::HA_LEFT);
label5->setAlignVertical(osgWidget::Widget::VA_BOTTOM);
// Test our label copy construction...
osgWidget::Label* label6 = label5->cloneAs("label6");
label6->setLabel("abcdefghijklmnopqrs");
vbox->addWidget(label3);
vbox->addWidget(label4);
vbox->addWidget(label5);
vbox->addWidget(label6);
vbox->attachMoveCallback();
vbox->attachScaleCallback();
vbox->resize();
// vbox->setVisibilityMode(osgWidget::Window::VM_ENTIRE);
// vbox->setVisibleArea(50, 50, 500, 200);
// vbox->setAnchorVertical(osgWidget::Window::VA_TOP);
// vbox->setAnchorHorizontal(osgWidget::Window::HA_RIGHT);
// Test our label-in-window copy construction...
osgWidget::Box* clonedBox = box->cloneAs("HBOX-new");
clonedBox->getBackground()->setColor(0.0f, 1.0f, 0.0f, 0.5f);
wm->addChild(box);
wm->addChild(vbox);
wm->addChild(clonedBox);
return osgWidget::createExample(viewer, wm);
}

View File

@@ -0,0 +1,7 @@
#this file is automatically generated
SET(TARGET_SRC osgwidgetmenu.cpp )
SET(TARGET_ADDED_LIBRARIES osgWidget )
#### end var setup ###
SETUP_EXAMPLE(osgwidgetmenu)

View File

@@ -0,0 +1,129 @@
// -*-c++-*- osgWidget - Code by: Jeremy Moles (cubicool) 2007-2008
// $Id: osgwidgetmenu.cpp 66 2008-07-14 21:54:09Z cubicool $
#include <iostream>
#include <osgDB/ReadFile>
#include <osgWidget/Util>
#include <osgWidget/WindowManager>
#include <osgWidget/Box>
#include <osgWidget/Label>
// For now this is just an example, but osgWidget::Menu will later be it's own Window.
// I just wanted to get this out there so that people could see it was possible.
const unsigned int MASK_2D = 0xF0000000;
const unsigned int MASK_3D = 0x0F000000;
struct ColorLabel: public osgWidget::Label {
ColorLabel(const char* label):
osgWidget::Label("", "") {
setFont("fonts/Vera.ttf");
setFontSize(14);
setFontColor(1.0f, 1.0f, 1.0f, 1.0f);
setColor(0.3f, 0.3f, 0.3f, 1.0f);
addHeight(18.0f);
setCanFill(true);
setLabel(label);
setEventMask(osgWidget::EVENT_MOUSE_PUSH | osgWidget::EVENT_MASK_MOUSE_MOVE);
}
bool mousePush(double, double, osgWidget::WindowManager*) {
return true;
}
bool mouseEnter(double, double, osgWidget::WindowManager*) {
setColor(0.6f, 0.6f, 0.6f, 1.0f);
return true;
}
bool mouseLeave(double, double, osgWidget::WindowManager*) {
setColor(0.3f, 0.3f, 0.3f, 1.0f);
return true;
}
};
class ColorLabelMenu: public ColorLabel {
osg::ref_ptr<osgWidget::Window> _window;
public:
ColorLabelMenu(const char* label):
ColorLabel(label) {
_window = new osgWidget::Box(
std::string("Menu_") + label,
osgWidget::Box::VERTICAL,
true
);
_window->addWidget(new ColorLabel("Open Some Stuff"));
_window->addWidget(new ColorLabel("Do It Now"));
_window->addWidget(new ColorLabel("Hello, How Are U?"));
_window->addWidget(new ColorLabel("Hmmm..."));
_window->addWidget(new ColorLabel("Option 5"));
_window->resize();
setColor(0.8f, 0.8f, 0.8f, 0.8f);
}
void managed(osgWidget::WindowManager* wm) {
osgWidget::Label::managed(wm);
wm->addChild(_window.get());
_window->hide();
}
void positioned() {
osgWidget::Label::positioned();
_window->setOrigin(getX(), getHeight());
_window->resize(getWidth());
}
bool mousePush(double, double, osgWidget::WindowManager*) {
if(!_window->isVisible()) _window->show();
else _window->hide();
return true;
}
bool mouseLeave(double, double, osgWidget::WindowManager*) {
if(!_window->isVisible()) setColor(0.8f, 0.8f, 0.8f, 0.8f);
return true;
}
};
int main(int argc, char** argv) {
osgViewer::Viewer viewer;
osgWidget::WindowManager* wm = new osgWidget::WindowManager(
&viewer,
1280.0f,
1024.0f,
MASK_2D,
osgWidget::WindowManager::WM_PICK_DEBUG |
osgWidget::WindowManager::WM_NO_BETA_WARN
);
osgWidget::Window* menu = new osgWidget::Box("menu", osgWidget::Box::HORIZONTAL);
menu->addWidget(new ColorLabelMenu("Pick me!"));
menu->addWidget(new ColorLabelMenu("No, wait, pick me!"));
menu->addWidget(new ColorLabelMenu("Dont pick them..."));
menu->addWidget(new ColorLabelMenu("Grarar!?!"));
wm->addChild(menu);
menu->getBackground()->setColor(1.0f, 1.0f, 1.0f, 0.0f);
menu->resizePercent(100.0f);
osg::Node* model = osgDB::readNodeFile("osgcool.osg");
model->setNodeMask(MASK_3D);
return osgWidget::createExample(viewer, wm, model);
}

View File

@@ -0,0 +1,7 @@
#this file is automatically generated
SET(TARGET_SRC osgwidgetnotebook.cpp )
SET(TARGET_ADDED_LIBRARIES osgWidget )
#### end var setup ###
SETUP_EXAMPLE(osgwidgetnotebook)

View File

@@ -0,0 +1,134 @@
// -*-c++-*- osgWidget - Code by: Jeremy Moles (cubicool) 2007-2008
// $Id: osgwidgetnotebook.cpp 45 2008-04-23 16:46:11Z cubicool $
#include <osg/io_utils>
#include <osgWidget/Util>
#include <osgWidget/WindowManager>
#include <osgWidget/Box>
#include <osgWidget/Canvas>
#include <osgWidget/Label>
const unsigned int MASK_2D = 0xF0000000;
const unsigned int MASK_3D = 0x0F000000;
class Notebook: public osgWidget::Box {
osg::ref_ptr<osgWidget::Box> _tabs;
osg::ref_ptr<osgWidget::Canvas> _windows;
public:
// NOTE: This whole thing is just a hack to demonstrate a concept. The real
// implementation would need to be much cleaner.
bool callbackTabPressed(osgWidget::Event& ev) {
osgWidget::Canvas::Vector& objs = _windows->getObjects();
for(unsigned int i = 0; i < objs.size(); i++) objs[i]->setLayer(
osgWidget::Widget::LAYER_MIDDLE,
i
);
_windows->getByName(ev.getWidget()->getName())->setLayer(
osgWidget::Widget::LAYER_MIDDLE,
objs.size()
);
_windows->resize();
return true;
}
Notebook(const std::string& name):
osgWidget::Box(name, osgWidget::Box::VERTICAL) {
_tabs = new osgWidget::Box("tabs", osgWidget::Box::HORIZONTAL);
_windows = new osgWidget::Canvas("canvas");
for(unsigned int i = 0; i < 4; i++) {
std::stringstream ss;
// Setup everything for our Tab...
ss << "Tab_" << i;
osgWidget::Label* label1 = new osgWidget::Label(ss.str());
label1->setFont("fonts/VeraMono.ttf");
label1->setFontSize(20);
label1->setFontColor(1.0f, 1.0f, 1.0f, 1.0f);
label1->setColor(0.0f, i / 4.0f, 0.3f, 1.0f);
label1->setLabel(ss.str());
label1->addSize(20.0f, 20.0f);
label1->setShadow(0.1f);
label1->setCanFill(true);
_tabs->addWidget(label1);
// Setup everything for the Window corresponding to the Tab
// in the Canvas down below.
std::stringstream descr;
descr
<< "This is some text" << std::endl
<< "for the Tab_" << i << " tab." << std::endl
<< "Press the button up top" << std::endl
<< "And this should go to the next Window!" << std::endl
;
osgWidget::Label* label2 = new osgWidget::Label(ss.str());
label2->setFont("fonts/Vera.ttf");
label2->setFontSize(15);
label2->setFontColor(1.0f, 1.0f, 1.0f, 1.0f);
label2->setColor(0.0f, i / 4.0f, 0.3f, 1.0f);
label2->setLabel(descr.str());
label2->setLayer(osgWidget::Widget::LAYER_MIDDLE, i);
label2->addSize(50.0f, 50.0f);
_windows->addWidget(label2, 0.0f, 0.0f);
label1->setEventMask(osgWidget::EVENT_MOUSE_PUSH);
label1->addCallback(osgWidget::Callback(
&Notebook::callbackTabPressed,
this,
osgWidget::EVENT_MOUSE_PUSH
));
}
osgWidget::Label* label = new osgWidget::Label("label");
label->setFont("fonts/arial.ttf");
label->setFontSize(15);
label->setFontColor(1.0f, 1.0f, 1.0f, 1.0f);
label->setLabel("Drag the window here...");
label->addSize(20.0f, 20.0f);
label->setShadow(0.08f);
label->setCanFill(true);
addWidget(label);
addWidget(_tabs->embed());
addWidget(_windows->embed());
}
};
int main(int argc, char** argv) {
osgViewer::Viewer viewer;
osgWidget::WindowManager* wm = new osgWidget::WindowManager(
&viewer,
1280.0f,
720.0f,
MASK_2D,
osgWidget::WindowManager::WM_PICK_DEBUG
);
Notebook* notebook = new Notebook("notebook");
osgWidget::warn()
<< "Sizes are..." << std::endl
<< "Cur: " << notebook->getSize() << std::endl
<< "Min: " << notebook->getMinSize() << std::endl
;
notebook->attachMoveCallback();
wm->addChild(notebook);
return osgWidget::createExample(viewer, wm);
}

View File

@@ -0,0 +1,7 @@
#this file is automatically generated
SET(TARGET_SRC osgwidgetscrolled.cpp )
SET(TARGET_ADDED_LIBRARIES osgWidget )
#### end var setup ###
SETUP_EXAMPLE(osgwidgetscrolled)

View File

@@ -0,0 +1,134 @@
// -*-c++-*- osgWidget - Code by: Jeremy Moles (cubicool) 2007-2008
// $Id: osgwidgetframe.cpp 34 2008-04-07 03:12:41Z cubicool $
#include <osgWidget/Util>
#include <osgWidget/WindowManager>
#include <osgWidget/Frame>
#include <osgWidget/Box>
const unsigned int MASK_2D = 0xF0000000;
// NOTE: THIS IS JUST A TEMPORARY HACK! :) This functionality will all eventually be
// encapsulate into another class in osgWidget proper.
bool scrollWindow(osgWidget::Event& ev) {
// The first thing we need to do is make sure we have a Frame object...
osgWidget::Frame* frame = dynamic_cast<osgWidget::Frame*>(ev.getWindow());
if(!frame) return false;
// And now we need to make sure our Frame has a valid internal EmbeddedWindow widget.
osgWidget::Window::EmbeddedWindow* ew =
dynamic_cast<osgWidget::Window::EmbeddedWindow*>(frame->getEmbeddedWindow())
;
if(!ew) return false;
// Lets get the visible area so that we can use it to make sure our scrolling action
// is necessary in the first place.
const osgWidget::Quad& va = ew->getWindow()->getVisibleArea();
// The user wants to scroll up; make sure that the visible area's Y origin isn't already
// at 0.0f, 0.0f.
if(ev.getWindowManager()->isMouseScrollingUp() && va[1] != 0.0f)
ew->getWindow()->addVisibleArea(0, -20)
;
else if(va[1] <= (ew->getWindow()->getHeight() - ew->getHeight()))
ew->getWindow()->addVisibleArea(0, 20)
;
// We need to manually call update to make sure the visible area scissoring is done
// properly.
frame->update();
return true;
}
bool changeTheme(osgWidget::Event& ev) {
std::string theme;
if(ev.key == osgGA::GUIEventAdapter::KEY_Right)
theme = "osgWidget/theme-1.png"
;
else if(ev.key == osgGA::GUIEventAdapter::KEY_Left)
theme = "osgWidget/theme-2.png"
;
else return false;
osgWidget::Frame* frame = dynamic_cast<osgWidget::Frame*>(ev.getWindow());
if(!frame) return false;
// This is just one way to access all our Widgets; we could just as well have used:
//
// for(osgWidget::Frame::Iterator i = frame.begin(); i != frame.end() i++) {}
//
// ...and it have worked, too.
for(unsigned int row = 0; row < 3; row++) {
for(unsigned int col = 0; col < 3; col++) {
frame->getByRowCol(row, col)->setImage(theme);
}
}
return true;
}
int main(int argc, char** argv) {
osgViewer::Viewer viewer;
osgWidget::WindowManager* wm = new osgWidget::WindowManager(
&viewer,
1280.0f,
1024.0f,
MASK_2D,
osgWidget::WindowManager::WM_PICK_DEBUG
);
osgWidget::Frame* frame = osgWidget::Frame::createSimpleFrameWithSingleTexture(
"frame",
"osgWidget/theme-2.png",
64.0f,
64.0f,
16.0f,
16.0f,
100.0f,
100.0f
);
frame->getBackground()->setColor(0.0f, 0.0f, 0.0f, 0.0f);
// This is our Transformers box. :)
osgWidget::Box* box = new osgWidget::Box("images", osgWidget::Box::VERTICAL);
osgWidget::Widget* img1 = new osgWidget::Widget("im1", 512.0f, 512.0f);
osgWidget::Widget* img2 = new osgWidget::Widget("im2", 512.0f, 512.0f);
osgWidget::Widget* img3 = new osgWidget::Widget("im3", 512.0f, 512.0f);
osgWidget::Widget* img4 = new osgWidget::Widget("im4", 512.0f, 512.0f);
img1->setImage("osgWidget/scrolled1.jpg", true);
img2->setImage("osgWidget/scrolled2.jpg", true);
img3->setImage("osgWidget/scrolled3.jpg", true);
img4->setImage("osgWidget/scrolled4.jpg", true);
img1->setMinimumSize(10.0f, 10.0f);
img2->setMinimumSize(10.0f, 10.0f);
img3->setMinimumSize(10.0f, 10.0f);
img4->setMinimumSize(10.0f, 10.0f);
box->addWidget(img1);
box->addWidget(img2);
box->addWidget(img3);
box->addWidget(img4);
box->setEventMask(osgWidget::EVENT_NONE);
frame->getEmbeddedWindow()->setWindow(box);
frame->getEmbeddedWindow()->setColor(1.0f, 1.0f, 1.0f, 1.0f);
frame->resize(300.0f, 300.0f);
frame->addCallback(osgWidget::Callback(&scrollWindow, osgWidget::EVENT_MOUSE_SCROLL));
frame->addCallback(osgWidget::Callback(&changeTheme, osgWidget::EVENT_KEY_DOWN));
wm->addChild(frame);
return osgWidget::createExample(viewer, wm);
}

View File

@@ -0,0 +1,7 @@
#this file is automatically generated
SET(TARGET_SRC osgwidgetshader.cpp )
SET(TARGET_ADDED_LIBRARIES osgWidget )
#### end var setup ###
SETUP_EXAMPLE(osgwidgetshader)

View File

@@ -0,0 +1,75 @@
// -*-c++-*- osgWidget - Code by: Jeremy Moles (cubicool) 2007-2008
// $Id: osgwidgetshader.cpp 28 2008-03-26 15:26:48Z cubicool $
#include <osgDB/FileUtils>
#include <osgWidget/Util>
#include <osgWidget/WindowManager>
#include <osgWidget/Canvas>
const unsigned int MASK_2D = 0xF0000000;
osgWidget::Widget* createWidget(
const std::string& name,
osgWidget::color_type col,
osgWidget::Widget::Layer layer
) {
osgWidget::Widget* widget = new osgWidget::Widget(name, 200.0f, 200.0f);
widget->setColor(col, col, col, 0.2f);
widget->setLayer(layer);
return widget;
}
int main(int argc, char** argv) {
osgViewer::Viewer viewer;
osgWidget::WindowManager* wm = new osgWidget::WindowManager(
&viewer,
1280.0f,
1024.0f,
MASK_2D
);
osgWidget::Canvas* canvas = new osgWidget::Canvas("canvas");
canvas->attachMoveCallback();
canvas->attachScaleCallback();
canvas->addWidget(
createWidget("w1", 0.2f, osgWidget::Widget::LAYER_LOW),
0.0f,
0.0f
);
canvas->addWidget(
createWidget("w2", 0.4f, osgWidget::Widget::LAYER_MIDDLE),
200.0f,
0.0f
);
canvas->addWidget(
createWidget("w3", 0.6f, osgWidget::Widget::LAYER_HIGH),
400.0f,
0.0f
);
wm->addChild(canvas);
osg::Program* program = new osg::Program();
program->addShader(osg::Shader::readShaderFile(
osg::Shader::VERTEX,
osgDB::findDataFile("osgWidget/osgwidgetshader-vert.glsl")
));
program->addShader(osg::Shader::readShaderFile(
osg::Shader::FRAGMENT,
osgDB::findDataFile("osgWidget/osgwidgetshader-frag.glsl")
));
canvas->getGeode()->getOrCreateStateSet()->setAttribute(program);
return osgWidget::createExample(viewer, wm);
}

View File

@@ -0,0 +1,7 @@
#this file is automatically generated
SET(TARGET_SRC osgwidgetstyled.cpp )
SET(TARGET_ADDED_LIBRARIES osgWidget )
#### end var setup ###
SETUP_EXAMPLE(osgwidgetstyled)

View File

@@ -0,0 +1,83 @@
// -*-c++-*- osgWidget - Code by: Jeremy Moles (cubicool) 2007-2008
// $Id: osgwidgetshader.cpp 28 2008-03-26 15:26:48Z cubicool $
#include <osgWidget/Util>
#include <osgWidget/WindowManager>
#include <osgWidget/StyleManager>
#include <osgWidget/Box>
const unsigned int MASK_2D = 0xF0000000;
const std::string& STYLE1 =
"color 0 0 0 128\n"
"padding 5\n"
;
const std::string& STYLE2 =
"color 1.0 0.5 0.0\n"
;
const std::string& STYLE3 =
"fill true\n"
;
const std::string& STYLE4 =
"pos 100.0 100.0\n"
"size 600 600\n"
;
class CustomStyled: public osgWidget::Widget {
};
class CustomStyle: public osgWidget::Style {
virtual bool applyStyle(osgWidget::Widget* w, osgWidget::Reader r) {
CustomStyled* cs = dynamic_cast<CustomStyled*>(w);
if(!cs) return false;
osgWidget::warn() << "Here, okay." << std::endl;
return true;
}
};
int main(int argc, char** argv) {
osgViewer::Viewer viewer;
osgWidget::WindowManager* wm = new osgWidget::WindowManager(
&viewer,
1280.0f,
1024.0f,
MASK_2D
);
osgWidget::Box* box = new osgWidget::Box("box", osgWidget::Box::VERTICAL);
osgWidget::Widget* widget1 = new osgWidget::Widget("w1", 200.0f, 200.0f);
osgWidget::Widget* widget2 = new osgWidget::Widget("w2", 100.0f, 100.0f);
osgWidget::Widget* widget3 = new osgWidget::Widget("w3", 0.0f, 0.0f);
CustomStyled* cs = new CustomStyled();
// Yep.
wm->getStyleManager()->addStyle(new osgWidget::Style("widget.style1", STYLE1));
wm->getStyleManager()->addStyle(new osgWidget::Style("widget.style2", STYLE2));
wm->getStyleManager()->addStyle(new osgWidget::Style("spacer", STYLE3));
wm->getStyleManager()->addStyle(new osgWidget::Style("window", STYLE4));
// wm->getStyleManager()->addStyle(new CustomStyle("widget", ""));
widget1->setStyle("widget.style1");
widget2->setStyle("widget.style2");
widget3->setStyle("spacer");
box->setStyle("window");
box->addWidget(widget1);
box->addWidget(widget2);
box->addWidget(widget3);
wm->addChild(box);
// box->resizePercent(0.0f, 100.0f);
return osgWidget::createExample(viewer, wm);
}

View File

@@ -0,0 +1,7 @@
#this file is automatically generated
SET(TARGET_SRC osgwidgettable.cpp )
SET(TARGET_ADDED_LIBRARIES osgWidget )
#### end var setup ###
SETUP_EXAMPLE(osgwidgettable)

View File

@@ -0,0 +1,69 @@
// -*-c++-*- osgWidget - Code by: Jeremy Moles (cubicool) 2007-2008
// $Id: osgwidgettable.cpp 43 2008-04-17 03:40:05Z cubicool $
#include <osgWidget/Util>
#include <osgWidget/WindowManager>
#include <osgWidget/Table>
const unsigned int MASK_2D = 0xF0000000;
// This examples demonstrates the use of an osgWidget::Table, which differs from a Box in
// many ways. First and foremost, a Table's size is intially known, whereas a Box can be
// dynamically added to. Secondly, a table is matrix Layout, with both vertical and
// horizontal placement cells. A Box, on the other hand, can only be vertical or horizontal.
int main(int argc, char** argv) {
osgViewer::Viewer viewer;
osgWidget::WindowManager* wm = new osgWidget::WindowManager(
&viewer,
1280.0f,
1024.0f,
MASK_2D,
osgWidget::WindowManager::WM_PICK_DEBUG
);
osgWidget::Table* table = new osgWidget::Table("table", 3, 3);
// Here we create our "cells" manually, though it will often be convenient to
// do so algorithmically. Also, notice how we set the text name of each widget to
// correspond with it's "index" in the table. This is merely a convenience, which
// we use later...
table->addWidget(new osgWidget::Widget("0, 0", 100.0f, 25.0f), 0, 0);
table->addWidget(new osgWidget::Widget("0, 1", 100.0f, 25.0f), 0, 1);
table->addWidget(new osgWidget::Widget("0, 2", 100.0f, 75.0f), 0, 2);
table->addWidget(new osgWidget::Widget("1, 0", 200.0f, 45.0f), 1, 0);
table->addWidget(new osgWidget::Widget("1, 1", 200.0f, 45.0f), 1, 1);
table->addWidget(new osgWidget::Widget("1, 2", 200.0f, 45.0f), 1, 2);
table->addWidget(new osgWidget::Widget("2, 0", 300.0f, 65.0f), 2, 0);
table->addWidget(new osgWidget::Widget("2, 1", 300.0f, 65.0f), 2, 1);
table->addWidget(new osgWidget::Widget("2, 2", 300.0f, 65.0f), 2, 2);
table->getBackground()->setColor(0.0f, 0.0f, 0.5f, 1.0f);
table->attachMoveCallback();
// Use a hackish method of setting the spacing for all Widgets.
for(osgWidget::Table::Iterator i = table->begin(); i != table->end(); i++)
i->get()->setPadding(1.0f)
;
// Now we fetch the very first 0, 0 Widget in the table using an awkward method.
// This is merely one way to fetch a Widget from a Window, there are many others.
// The osgWidget::Window::getByName interface will be very handy in scripting languages
// where users will want to retrieve handles to existing Windows using a useful
// textual name, such as "MainGUIParent" or something.
table->getByName("0, 0")->setAlignHorizontal(osgWidget::Widget::HA_LEFT);
table->getByName("0, 0")->setAlignVertical(osgWidget::Widget::VA_BOTTOM);
table->getByName("0, 0")->setPadding(10.0f);
// Change the colors a bit to differentiate this row from the others.
table->getByName("2, 0")->setColor(1.0f, 0.0f, 0.0f, 1.0f, osgWidget::Widget::LOWER_LEFT);
table->getByName("2, 1")->setColor(1.0f, 0.0f, 0.0f, 0.5f);
table->getByName("2, 2")->setColor(1.0f, 0.0f, 0.0f, 0.5f);
wm->addChild(table);
return createExample(viewer, wm);
}

View File

@@ -0,0 +1,7 @@
#this file is automatically generated
SET(TARGET_SRC osgwidgetwindow.cpp )
SET(TARGET_ADDED_LIBRARIES osgWidget )
#### end var setup ###
SETUP_EXAMPLE(osgwidgetwindow)

View File

@@ -0,0 +1,204 @@
// -*-c++-*- osgWidget - Code by: Jeremy Moles (cubicool) 2007-2008
// $Id: osgwidgetwindow.cpp 66 2008-07-14 21:54:09Z cubicool $
#include <iostream>
#include <osgDB/ReadFile>
#include <osgGA/StateSetManipulator>
#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
#include <osgWidget/WindowManager>
#include <osgWidget/ViewerEventHandlers>
#include <osgWidget/Box>
const unsigned int MASK_2D = 0xF0000000;
const unsigned int MASK_3D = 0x0F000000;
// Here we create (and later demonstrate) the use of a simple function callback.
bool windowClicked(osgWidget::Event& ev) {
std::cout << "windowClicked: " << ev.getWindow()->getName() << std::endl;
if(ev.getData()) {
std::string* s = static_cast<std::string*>(ev.getData());
std::cout << "This is data attached to the event: " << *s << std::endl;
}
return true;
}
bool windowScrolled(osgWidget::Event& ev) {
osgWidget::warn()
<< "scrolling up? " << ev.getWindowManager()->isMouseScrollingUp()
<< std::endl
;
return true;
}
// Here we dcreate a new class and show how to use a method callback (which differs from
// a function callback in that we are required to also pass the "this" argument).
struct Object {
bool windowClicked(osgWidget::Event& ev) {
std::cout << "Object::windowClicked " << ev.getWindow()->getName() << std::endl;
return true;
}
};
int main(int argc, char** argv) {
osgViewer::Viewer viewer;
// Let's get busy! The WindowManager class is actually an osg::Switch,
// so you can add it to (ideally) an orthographic camera and have it behave as
// expected. Note that you create a WindowManager with a NodeMask--it is very important
// that this be unique for picking to work properly. This also makes it possible to have
// multiple WindowManagers each operating on their own, unique set of Window objects.
// The final bool argument is a group of flags that introduce optional functionality
// for the WindowManager. In our case we include the flags USE_PYTHON and USE_LUA,
// to demonstrate (and test) their usage. Finally, we pass the temporary WM_NO_BETA_WARN
// argument, which prevents creating the orange warning window. :) It will be shown
// in other examples...
osgWidget::WindowManager* wm = new osgWidget::WindowManager(
&viewer,
1280.0f,
1024.0f,
MASK_2D,
osgWidget::WindowManager::WM_USE_LUA |
osgWidget::WindowManager::WM_USE_PYTHON |
osgWidget::WindowManager::WM_PICK_DEBUG |
osgWidget::WindowManager::WM_NO_BETA_WARN
);
// An actual osgWidget::Window is pure virtual, so we've got to use the osgWidget::Box
// implementation for now. At a later time, support for Tables and other kinds of
// advanced layout Window types will be added.
osgWidget::Window* box = new osgWidget::Box("box", osgWidget::Box::HORIZONTAL);
// Now we actually attach our two types of callbacks to the box instance. The first
// uses the simple function signature, the second uses a bound method, passing "this"
// as the second argument to the Callback constructor.
Object obj;
static std::string data = "lol ur face!";
box->addCallback(osgWidget::Callback(&windowClicked, osgWidget::EVENT_MOUSE_PUSH, &data));
box->addCallback(osgWidget::Callback(&windowScrolled, osgWidget::EVENT_MOUSE_SCROLL));
box->addCallback(osgWidget::Callback(
&Object::windowClicked,
&obj,
osgWidget::EVENT_MOUSE_PUSH
));
// Create some of our "testing" Widgets; included are two Widget subclasses I made
// during testing which I've kept around for testing purposes. You'll notice
// that you cannot move the box using the NullWidget, and that the NotifyWidget
// is a bit verbose. :)
osgWidget::Widget* widget1 = new osgWidget::NotifyWidget("widget1", 300.0f, 100.0f);
osgWidget::Widget* widget2 = new osgWidget::NullWidget("widget2", 400.0f, 75.0f);
osgWidget::Widget* widget3 = new osgWidget::Widget("widget3", 100.0f, 100.0f);
// Set the colors of widget1 and widget3 to green.
widget1->setColor(0.0f, 1.0f, 0.0f, 1.0f);
widget1->setCanFill(true);
widget3->setColor(0.0f, 1.0f, 0.0f, 1.0f);
widget1->setImage(osgDB::readImageFile("Images/Saturn.TGA"), true);
// Set the color of widget2, to differentiate it and make it sassy. This is
// like a poor man's gradient!
widget2->setColor(0.9f, 0.0f, 0.0f, 0.9f, osgWidget::Widget::LOWER_LEFT);
widget2->setColor(0.9f, 0.0f, 0.0f, 0.9f, osgWidget::Widget::LOWER_RIGHT);
widget2->setColor(0.0f, 0.0f, 0.9f, 0.9f, osgWidget::Widget::UPPER_RIGHT);
widget2->setColor(0.0f, 0.0f, 0.9f, 0.9f, osgWidget::Widget::UPPER_LEFT);
// Now add our newly created widgets to our box.
box->addWidget(widget1);
box->addWidget(widget2);
box->addWidget(widget3);
// For maximum efficiency, Windows don't automatically reallocate their geometry
// and internal positioning every time a widget is added. Thus, we either have to
// call the WindowManger::resizeAllWindows method or manually call
// Window::resize when we're ready.
box->resize();
// Now, lets clone our existing box and create a new copy of of it, also adding that
// to the WindowManager. This demonstrates the usages of OSG's ->clone() support,
// though that is abstracted by our META_UIObject macro.
osgWidget::Window* boxCopy = box->cloneAs("newBox");
// Move our copy to make it visible.
boxCopy->setOrigin(0.0f, 125.0f);
boxCopy->getByName("widget1")->setColor(0.5f, 0.0f, 1.0f, 1.0f);
boxCopy->getByName("widget3")->setColor(0.5f, 0.0f, 1.0f, 1.0f);
// Add the successfully created Box (if we get this far) into the WindowManager, so
// that they can receive events.
wm->addChild(box);
wm->addChild(boxCopy);
// Now, ask our new box to be 100% the width of the WindowManager.
boxCopy->resizePercent(100.0f, 0.0f);
// Here we demonstrate the use of osgWidget/io_utils. This is really only useful for
// debugging at the moment, but later I'll make it more generic for .osg and .ive
// creation.
// std::cout << *box << std::endl << *boxCopy << std::endl;
// Add our event handler; is this better as a MatrixManipulator? Add a few other
// helpful ViewerEventHandlers.
viewer.addEventHandler(new osgWidget::MouseHandler(wm));
viewer.addEventHandler(new osgWidget::KeyboardHandler(wm));
viewer.addEventHandler(new osgViewer::StatsHandler());
viewer.addEventHandler(new osgViewer::WindowSizeHandler());
viewer.addEventHandler(new osgGA::StateSetManipulator(
viewer.getCamera()->getOrCreateStateSet()
));
// Setup our OSG objects for our scene; note the use of the utility function
// createOrthoCamera, which is just a helper for setting up a proper viewing area.
// An alternative (and a MUCH easier alternative at that!) is to
// simply use the createParentOrthoCamera method of the WindowManager class,
// which will wrap the calls to createOrthoCamera and addChild for us! Check out
// some of the other examples to see this in action...
osg::Group* group = new osg::Group();
osg::Camera* camera = osgWidget::createInvertedYOrthoCamera(1280.0f, 1024.0f);
osg::Node* model = osgDB::readNodeFile("cow.osg");
// Set our first non-UI node to be something other than the mask we created our
// WindowManager with to avoid picking.
// TODO: Do I need to create a mechanism for doing this automatically, or should
// that be the responsibility of the users of osgWidget?
model->setNodeMask(MASK_3D);
// Add the WindowManager instance to the 2D camera. This isn't strictly necessary,
// and you can get some cool results putting the WindowManager directly into a
// 3D scene. This is not necessary if you use WindowManager::createParentOrthoCamera.
camera->addChild(wm);
// Add our camera and a testing 3D model to the scene.
group->addChild(camera);
group->addChild(model);
// Here we show how to both run simple strings of code AND run entire files. These
// assume that you're running the osgwidgetwindow example from the build directory,
// otherwise you'll need to adjust the file path below in the call to runFile().
wm->getLuaEngine()->eval("window = osgwidget.newWindow()");
wm->getLuaEngine()->runFile("osgWidget/osgwidgetwindow.lua");
wm->getPythonEngine()->eval("import osgwidget");
wm->getPythonEngine()->runFile("osgWidget/osgwidgetwindow.py");
viewer.setUpViewInWindow(0, 0, 1280, 1024);
viewer.setSceneData(group);
/*
osgViewer::Viewer::Cameras cameras;
viewer.getCameras(cameras);
osg::Camera* c = cameras[0];
osg::Matrix s = osg::Matrix::scale(1.0f, -1.0f, 1.0f);
c->setProjectionMatrix(s * c->getProjectionMatrix());
*/
return viewer.run();
}

View File

@@ -90,22 +90,6 @@ end
# Doxygen fails to detect that std::vector<T> is a base class for
# osg::Vector*, so we need to specify that manually
configure reflector "osg::VectorGLsizei"
add base "std::vector<GLsizei>"
end
configure reflector "osg::VectorGLubyte"
add base "std::vector<GLubyte>"
end
configure reflector "osg::VectorGLushort"
add base "std::vector<GLushort>"
end
configure reflector "osg::VectorGLuint"
add base "std::vector<GLuint>"
end
configure reflector "osgText::VectorUInt"
add base "std::vector<unsigned int>"
end
@@ -113,99 +97,49 @@ end
#############################################################################
# Doxygen fails to detect that std::vector<T> is a base class for
# TemplateArray<> and TemplateIndexArray<> templates, so we need
# to specify that manually
# Doxygen/genwrapper is not coping with the new MixinVector so disable associated wrappers
configure reflector /osg::TemplateIndexArray< GLbyte.*/
add base "std::vector<GLbyte>"
end
configure reflector /osg::TemplateIndexArray< GLubyte.*/
add base "std::vector<GLubyte>"
end
configure reflector /osg::TemplateIndexArray< GLshort.*/
add base "std::vector<GLshort>"
end
configure reflector /osg::TemplateIndexArray< GLushort.*/
add base "std::vector<GLushort>"
end
configure reflector /osg::TemplateIndexArray< GLint.*/
add base "std::vector<GLint>"
end
configure reflector /osg::TemplateIndexArray< GLuint.*/
add base "std::vector<GLuint>"
end
configure reflector /osg::TemplateArray< GLfloat.*/
add base "std::vector<GLfloat>"
end
suppress reflector /osg::TemplateIndexArray< GLbyte.*/
suppress reflector /osg::TemplateIndexArray< GLubyte.*/
suppress reflector /osg::TemplateIndexArray< GLshort.*/
suppress reflector /osg::TemplateIndexArray< GLushort.*/
suppress reflector /osg::TemplateIndexArray< GLint.*/
suppress reflector /osg::TemplateIndexArray< GLuint.*/
suppress reflector /osg::TemplateArray< GLfloat.*/
suppress reflector /osg::TemplateArray< GLdouble.*/
suppress reflector /osg::TemplateArray< osg::Vec2\s*\,.*/
suppress reflector /osg::TemplateArray< osg::Vec3\s*\,.*/
suppress reflector /osg::TemplateArray< osg::Vec4\s*\,.*/
suppress reflector /osg::TemplateArray< osg::Vec2d\s*\,.*/
suppress reflector /osg::TemplateArray< osg::Vec3d\s*\,.*/
suppress reflector /osg::TemplateArray< osg::Vec4d\s*\,.*/
suppress reflector /osg::TemplateArray< osg::Vec2b\s*\,.*/
suppress reflector /osg::TemplateArray< osg::Vec3b\s*\,.*/
suppress reflector /osg::TemplateArray< osg::Vec4b\s*\,.*/
suppress reflector /osg::TemplateArray< osg::Vec2s\s*\,.*/
suppress reflector /osg::TemplateArray< osg::Vec3s\s*\,.*/
suppress reflector /osg::TemplateArray< osg::Vec4s\s*\,.*/
suppress reflector /osg::TemplateArray< osg::Vec4ub\s*\,.*/
configure reflector /osg::TemplateArray< osg::Vec2\s*\,.*/
add base "std::vector<osg::Vec2>"
end
suppress reflector "osg::DrawArrayLengths"
suppress reflector "osg::DrawElementsUByte"
suppress reflector "osg::DrawElementsUShort"
suppress reflector "osg::DrawElementsUInt"
configure reflector /osg::TemplateArray< osg::Vec3\s*\,.*/
add base "std::vector<osg::Vec3>"
end
suppress reflector "osg::VectorGLsizei"
suppress reflector "osg::VectorGLubyte"
suppress reflector "osg::VectorGLushort"
suppress reflector "osg::VectorGLuint"
configure reflector /osg::TemplateArray< osg::Vec4\s*\,.*/
add base "std::vector<osg::Vec4>"
end
suppress reflector "osg::MixinVector< GLsizei >"
suppress reflector "osg::MixinVector< GLubyte >"
suppress reflector "osg::MixinVector< GLushort >"
suppress reflector "osg::MixinVector< GLuint >"
configure reflector /osg::TemplateArray< osg::Vec2b\s*\,.*/
add base "std::vector<osg::Vec2b>"
end
suppress reflector "OpenThreads::Atomic"
suppress reflector "OpenThreads::AtomicPtr"
configure reflector /osg::TemplateArray< osg::Vec3b\s*\,.*/
add base "std::vector<osg::Vec3b>"
end
configure reflector /osg::TemplateArray< osg::Vec4b\s*\,.*/
add base "std::vector<osg::Vec4b>"
end
configure reflector /osg::TemplateArray< osg::Vec2s\s*\,.*/
add base "std::vector<osg::Vec2s>"
end
configure reflector /osg::TemplateArray< osg::Vec3s\s*\,.*/
add base "std::vector<osg::Vec3s>"
end
configure reflector /osg::TemplateArray< osg::Vec4s\s*\,.*/
add base "std::vector<osg::Vec4s>"
end
configure reflector /osg::TemplateArray< osg::Vec4ub\s*\,.*/
add base "std::vector<osg::Vec4ub>"
end
configure file "osg/Array"
emit after "
STD_VECTOR_REFLECTOR(std::vector<osg::Vec2>)
STD_VECTOR_REFLECTOR(std::vector<osg::Vec3>)
STD_VECTOR_REFLECTOR(std::vector<osg::Vec4>)
STD_VECTOR_REFLECTOR(std::vector<osg::Vec2b>)
STD_VECTOR_REFLECTOR(std::vector<osg::Vec3b>)
STD_VECTOR_REFLECTOR(std::vector<osg::Vec4b>)
STD_VECTOR_REFLECTOR(std::vector<osg::Vec2s>)
STD_VECTOR_REFLECTOR(std::vector<osg::Vec3s>)
STD_VECTOR_REFLECTOR(std::vector<osg::Vec4s>)
STD_VECTOR_REFLECTOR(std::vector<osg::Vec4ub>)
STD_VECTOR_REFLECTOR(std::vector<GLubyte>)
STD_VECTOR_REFLECTOR(std::vector<GLbyte>)
STD_VECTOR_REFLECTOR(std::vector<GLushort>)
STD_VECTOR_REFLECTOR(std::vector<GLshort>)
STD_VECTOR_REFLECTOR(std::vector<GLuint>)
STD_VECTOR_REFLECTOR(std::vector<GLint>)
"
end
#############################################################################
@@ -464,6 +398,12 @@ end
# avoid functions that use protected types, since those are not handled
# currently
configure reflector "osgSim::OverlayNode"
configure method /.*getOverlayData.*/
replace with ""
end
end
configure reflector "osg::Shader"
configure method /.*_PerContextShader_.*/
replace with ""

195
include/OpenThreads/Atomic Normal file
View File

@@ -0,0 +1,195 @@
/* -*-c++-*- OpenThreads library, Copyright (C) 2008 The Open Thread Group
*
* 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.
*/
#ifndef _OPENTHREADS_ATOMIC_
#define _OPENTHREADS_ATOMIC_
#include <OpenThreads/Config>
#include <OpenThreads/Exports>
#if defined(_OPENTHREADS_ATOMIC_USE_GCC_BUILTINS) && defined(__i386__)
#define _OPENTHREADS_ATOMIC_USE_LIBRARY_ROUTINES
#elif defined(_OPENTHREADS_ATOMIC_USE_WIN32_INTERLOCKED)
#define _OPENTHREADS_ATOMIC_USE_LIBRARY_ROUTINES
#elif defined(_OPENTHREADS_ATOMIC_USE_SUN)
# include <atomic.h>
#elif defined(_OPENTHREADS_ATOMIC_USE_MUTEX)
# include "Mutex"
# include "ScopedLock"
#endif
#if defined(_OPENTHREADS_ATOMIC_USE_LIBRARY_ROUTINES)
#define _OPENTHREADS_ATOMIC_INLINE
#else
#define _OPENTHREADS_ATOMIC_INLINE inline
#endif
namespace OpenThreads {
/**
* @class Atomic
* @brief This class provides an atomic increment and decrement operation.
*/
class OPENTHREAD_EXPORT_DIRECTIVE Atomic {
public:
Atomic(unsigned value = 0) : _value(value)
{ }
_OPENTHREADS_ATOMIC_INLINE unsigned operator++();
_OPENTHREADS_ATOMIC_INLINE unsigned operator--();
_OPENTHREADS_ATOMIC_INLINE operator unsigned() const;
private:
Atomic(const Atomic&);
Atomic& operator=(const Atomic&);
#if defined(_OPENTHREADS_ATOMIC_USE_MUTEX)
mutable Mutex _mutex;
#endif
#if defined(_OPENTHREADS_ATOMIC_USE_WIN32_INTERLOCKED)
volatile long _value;
#elif defined(_OPENTHREADS_ATOMIC_USE_SUN)
volatile uint_t _value;
#else
volatile unsigned _value;
#endif
};
/**
* @class AtomicPtr
* @brief This class provides an atomic pointer assignment using cas operations.
*/
class OPENTHREAD_EXPORT_DIRECTIVE AtomicPtr {
public:
AtomicPtr(void* ptr = 0) : _ptr(ptr)
{ }
~AtomicPtr()
{ _ptr = 0; }
// assigns a new pointer
_OPENTHREADS_ATOMIC_INLINE bool assign(void* ptrNew, const void* const ptrOld);
_OPENTHREADS_ATOMIC_INLINE void* get() const;
private:
AtomicPtr(const AtomicPtr&);
AtomicPtr& operator=(const AtomicPtr&);
#if defined(_OPENTHREADS_ATOMIC_USE_MUTEX)
mutable Mutex _mutex;
#endif
void* volatile _ptr;
};
#if !defined(_OPENTHREADS_ATOMIC_USE_LIBRARY_ROUTINES)
_OPENTHREADS_ATOMIC_INLINE unsigned
Atomic::operator++()
{
#if defined(_OPENTHREADS_ATOMIC_USE_GCC_BUILTINS)
return __sync_add_and_fetch(&_value, 1);
#elif defined(_OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS)
return __add_and_fetch(&_value, 1);
#elif defined(_OPENTHREADS_ATOMIC_USE_SUN)
return atomic_inc_uint_nv(&_value);
#elif defined(_OPENTHREADS_ATOMIC_USE_MUTEX)
ScopedLock<Mutex> lock(_mutex);
return ++_value;
#else
return ++_value;
#endif
}
_OPENTHREADS_ATOMIC_INLINE unsigned
Atomic::operator--()
{
#if defined(_OPENTHREADS_ATOMIC_USE_GCC_BUILTINS)
return __sync_sub_and_fetch(&_value, 1);
#elif defined(_OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS)
return __sub_and_fetch(&_value, 1);
#elif defined(_OPENTHREADS_ATOMIC_USE_SUN)
return atomic_dec_uint_nv(&_value);
#elif defined(_OPENTHREADS_ATOMIC_USE_MUTEX)
ScopedLock<Mutex> lock(_mutex);
return --_value;
#else
return --_value;
#endif
}
_OPENTHREADS_ATOMIC_INLINE
Atomic::operator unsigned() const
{
#if defined(_OPENTHREADS_ATOMIC_USE_GCC_BUILTINS)
__sync_synchronize();
return _value;
#elif defined(_OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS)
__synchronize();
return _value;
#elif defined(_OPENTHREADS_ATOMIC_USE_SUN)
membar_consumer(); // Hmm, do we need???
return _value;
#elif defined(_OPENTHREADS_ATOMIC_USE_MUTEX)
ScopedLock<Mutex> lock(_mutex);
return _value;
#else
return _value;
#endif
}
_OPENTHREADS_ATOMIC_INLINE bool
AtomicPtr::assign(void* ptrNew, const void* const ptrOld)
{
#if defined(_OPENTHREADS_ATOMIC_USE_GCC_BUILTINS)
return __sync_bool_compare_and_swap(&_ptr, ptrOld, ptrNew);
#elif defined(_OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS)
return __compare_and_swap((unsigned long*)&_ptr, (unsigned long)ptrOld, (unsigned long)ptrNew);
#elif defined(_OPENTHREADS_ATOMIC_USE_SUN)
return ptrOld == atomic_cas_ptr(&_ptr, ptrOld, ptrNew);
#elif defined(_OPENTHREADS_ATOMIC_USE_MUTEX)
ScopedLock<Mutex> lock(_mutex);
if (_ptr != ptrOld)
return false;
_ptr = ptrNew;
return true;
#else
if (_ptr != ptrOld)
return false;
_ptr = ptrNew;
return true;
#endif
}
_OPENTHREADS_ATOMIC_INLINE void*
AtomicPtr::get() const
{
#if defined(_OPENTHREADS_ATOMIC_USE_GCC_BUILTINS)
__sync_synchronize();
return _ptr;
#elif defined(_OPENTHREADS_ATOMIC_USE_MIPOSPRO_BUILTINS)
__synchronize();
return _ptr;
#elif defined(_OPENTHREADS_ATOMIC_USE_SUN)
membar_consumer(); // Hmm, do we need???
return _ptr;
#elif defined(_OPENTHREADS_ATOMIC_USE_MUTEX)
ScopedLock<Mutex> lock(_mutex);
return _ptr;
#else
return _ptr;
#endif
}
#endif // !defined(_OPENTHREADS_ATOMIC_USE_LIBRARY_ROUTINES)
}
#endif // _OPENTHREADS_ATOMIC_

View File

@@ -19,9 +19,9 @@
extern "C" {
#define OPENTHREADS_MAJOR_VERSION 2
#define OPENTHREADS_MINOR_VERSION 2
#define OPENTHREADS_PATCH_VERSION 1
#define OPENTHREADS_SOVERSION 10
#define OPENTHREADS_MINOR_VERSION 3
#define OPENTHREADS_PATCH_VERSION 0
#define OPENTHREADS_SOVERSION 11
/** OpenThreadsGetVersion() returns the library version number.
* Numbering convention : OpenThreads-1.0 will return 1.0 from OpenThreadsGetVersion. */

View File

@@ -116,7 +116,7 @@ class OSG_EXPORT AnimationPath : public virtual osg::Object
matrix.preMult(osg::Matrixd::rotate(_rotation.inverse()));
matrix.preMult(osg::Matrixd::translate(-_position));
}
protected:
osg::Vec3d _position;
@@ -164,6 +164,7 @@ class OSG_EXPORT AnimationPath : public virtual osg::Object
/** Given a specific time, return the local ControlPoint frame for a point. */
virtual bool getInterpolatedControlPoint(double time,ControlPoint& controlPoint) const;
/** Insert a control point into the AnimationPath.*/
void insert(double time,const ControlPoint& controlPoint);
double getFirstTime() const { if (!_timeControlPointMap.empty()) return _timeControlPointMap.begin()->first; else return 0.0;}
@@ -200,6 +201,9 @@ class OSG_EXPORT AnimationPath : public virtual osg::Object
/** Write the animation path to a flat ASCII file stream. */
void write(std::ostream& out) const;
/** Write the control point to a flat ASCII file stream. */
void write(TimeControlPointMap::const_iterator itr, std::ostream& out) const;
protected:
virtual ~AnimationPath() {}

View File

@@ -43,9 +43,11 @@ class OSG_EXPORT ApplicationUsage : public osg::Referenced
enum Type
{
NO_HELP = 0x0,
COMMAND_LINE_OPTION = 0x1,
ENVIRONMENTAL_VARIABLE = 0x2,
KEYBOARD_MOUSE_BINDING = 0x4
KEYBOARD_MOUSE_BINDING = 0x4,
HELP_ALL = KEYBOARD_MOUSE_BINDING|ENVIRONMENTAL_VARIABLE|COMMAND_LINE_OPTION
};
void addUsageExplanation(Type type,const std::string& option,const std::string& explanation);

View File

@@ -190,6 +190,14 @@ class OSG_EXPORT ArgumentParser
/** Write error messages to the given ostream, if at or above the given severity. */
void writeErrorMessages(std::ostream& output,ErrorSeverity sevrity=BENIGN);
/** This convinience method handles help requests on the command line.
* Return the type(s) of help requested. The return value of this
* function is suitable for passing into getApplicationUsage()->write().
* If ApplicationUsage::NO_HELP is returned then no help commandline option
* was found on the command line. */
ApplicationUsage::Type readHelpType();
protected:

View File

@@ -14,7 +14,7 @@
#ifndef OSG_ARRAY
#define OSG_ARRAY 1
#include <vector>
#include <osg/MixinVector>
#include <osg/Vec2>
#include <osg/Vec3>
@@ -171,7 +171,7 @@ class OSG_EXPORT Array : public Object
};
template<typename T, Array::Type ARRAYTYPE, int DataSize, int DataType>
class TemplateArray : public Array, public std::vector<T>
class TemplateArray : public Array, public MixinVector<T>
{
public:
@@ -179,20 +179,20 @@ class TemplateArray : public Array, public std::vector<T>
TemplateArray(const TemplateArray& ta,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
Array(ta,copyop),
std::vector<T>(ta) {}
MixinVector<T>(ta) {}
TemplateArray(unsigned int no) :
Array(ARRAYTYPE,DataSize,DataType),
std::vector<T>(no) {}
MixinVector<T>(no) {}
TemplateArray(unsigned int no,T* ptr) :
Array(ARRAYTYPE,DataSize,DataType),
std::vector<T>(ptr,ptr+no) {}
MixinVector<T>(ptr,ptr+no) {}
template <class InputIterator>
TemplateArray(InputIterator first,InputIterator last) :
Array(ARRAYTYPE,DataSize,DataType),
std::vector<T>(first,last) {}
MixinVector<T>(first,last) {}
TemplateArray& operator = (const TemplateArray& array)
{
@@ -222,7 +222,7 @@ class TemplateArray : public Array, public std::vector<T>
/** Frees unused space on this vector - i.e. the difference between size() and max_size() of the underlying vector.*/
virtual void trim()
{
std::vector<T>( *this ).swap( *this );
MixinVector<T>( *this ).swap( *this );
}
virtual const GLvoid* getDataPointer() const { if (!this->empty()) return &this->front(); else return 0; }
@@ -257,7 +257,7 @@ class OSG_EXPORT IndexArray : public Array
};
template<typename T, Array::Type ARRAYTYPE, int DataSize, int DataType>
class TemplateIndexArray : public IndexArray, public std::vector<T>
class TemplateIndexArray : public IndexArray, public MixinVector<T>
{
public:
@@ -265,20 +265,20 @@ class TemplateIndexArray : public IndexArray, public std::vector<T>
TemplateIndexArray(const TemplateIndexArray& ta,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
IndexArray(ta,copyop),
std::vector<T>(ta) {}
MixinVector<T>(ta) {}
TemplateIndexArray(unsigned int no) :
IndexArray(ARRAYTYPE,DataSize,DataType),
std::vector<T>(no) {}
MixinVector<T>(no) {}
TemplateIndexArray(unsigned int no,T* ptr) :
IndexArray(ARRAYTYPE,DataSize,DataType),
std::vector<T>(ptr,ptr+no) {}
MixinVector<T>(ptr,ptr+no) {}
template <class InputIterator>
TemplateIndexArray(InputIterator first,InputIterator last) :
IndexArray(ARRAYTYPE,DataSize,DataType),
std::vector<T>(first,last) {}
MixinVector<T>(first,last) {}
TemplateIndexArray& operator = (const TemplateIndexArray& array)
{
@@ -308,7 +308,7 @@ class TemplateIndexArray : public IndexArray, public std::vector<T>
/** Frees unused space on this vector - i.e. the difference between size() and max_size() of the underlying vector.*/
virtual void trim()
{
std::vector<T>( *this ).swap( *this );
MixinVector<T>( *this ).swap( *this );
}
virtual const GLvoid* getDataPointer() const { if (!this->empty()) return &this->front(); else return 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.
*/
@@ -29,7 +29,7 @@ class OSG_EXPORT AutoTransform : public Transform
public :
AutoTransform();
AutoTransform(const AutoTransform& pat,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
AutoTransform(const AutoTransform& pat,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
virtual osg::Object* cloneType() const { return new AutoTransform (); }
virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new AutoTransform (*this,copyop); }
@@ -48,12 +48,12 @@ class OSG_EXPORT AutoTransform : public Transform
inline void setRotation(const Quat& quat) { _rotation = quat; _matrixDirty=true; dirtyBound(); }
inline const Quat& getRotation() const { return _rotation; }
inline void setScale(float scale) { setScale(osg::Vec3(scale,scale,scale)); }
void setScale(const Vec3& scale);
inline const Vec3& getScale() const { return _scale; }
void setMinimumScale(float minimumScale) { _minimumScale = minimumScale; }
float getMinimumScale() const { return _minimumScale; }
@@ -62,7 +62,7 @@ class OSG_EXPORT AutoTransform : public Transform
inline void setPivotPoint(const Vec3& pivot) { _pivotPoint = pivot; _matrixDirty=true; dirtyBound(); }
inline const Vec3& getPivotPoint() const { return _pivotPoint; }
void setAutoUpdateEyeMovementTolerance(float tolerance) { _autoUpdateEyeMovementTolerance = tolerance; }
float getAutoUpdateEyeMovementTolerance() const { return _autoUpdateEyeMovementTolerance; }
@@ -74,7 +74,7 @@ class OSG_EXPORT AutoTransform : public Transform
ROTATE_TO_SCREEN,
ROTATE_TO_CAMERA
};
void setAutoRotateMode(AutoRotateMode mode) { _autoRotateMode = mode; _firstTimeToInitEyePoint = true; }
AutoRotateMode getAutoRotateMode() const { return _autoRotateMode; }
@@ -83,8 +83,8 @@ class OSG_EXPORT AutoTransform : public Transform
bool getAutoScaleToScreen() const { return _autoScaleToScreen; }
void setAutoScaleTransistionWidthRatio(float ratio) { _autoScaleTransitionWidthRatio = ratio; }
float getAutoScaleTransistionWidthRatio() const { return _autoScaleTransitionWidthRatio; }
void setAutoScaleTransitionWidthRatio(float ratio) { _autoScaleTransitionWidthRatio = ratio; }
float getAutoScaleTransitionWidthRatio() const { return _autoScaleTransitionWidthRatio; }
virtual bool computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor* nv) const;
@@ -95,7 +95,7 @@ class OSG_EXPORT AutoTransform : public Transform
protected :
virtual ~AutoTransform() {}
Vec3 _position;
@@ -105,17 +105,17 @@ class OSG_EXPORT AutoTransform : public Transform
AutoRotateMode _autoRotateMode;
bool _autoScaleToScreen;
mutable Quat _rotation;
mutable Vec3 _scale;
mutable bool _firstTimeToInitEyePoint;
mutable osg::Vec3 _previousEyePoint;
mutable osg::Vec3 _previousLocalUp;
mutable Viewport::value_type _previousWidth;
mutable Viewport::value_type _previousHeight;
mutable Viewport::value_type _previousHeight;
mutable osg::Matrix _previousProjection;
mutable osg::Vec3 _previousPosition;
float _minimumScale;
float _maximumScale;
float _autoScaleTransitionWidthRatio;

View File

@@ -14,6 +14,7 @@
#ifndef OSG_BOUNDINGBOX
#define OSG_BOUNDINGBOX 1
#include <osg/Config>
#include <osg/Export>
#include <osg/Vec3>
#include <osg/Vec3d>
@@ -31,12 +32,12 @@ class OSG_EXPORT BoundingBox
{
public:
#ifdef OSG_USE_DOUBLE_BOUNDINGBOX
typedef Vec3d vec_type;
typedef double value_type;
#else
#ifdef OSG_USE_FLOAT_BOUNDINGBOX
typedef Vec3f vec_type;
typedef float value_type;
#else
typedef Vec3d vec_type;
typedef double value_type;
#endif

View File

@@ -14,6 +14,7 @@
#ifndef OSG_BOUNDINGSPHERE
#define OSG_BOUNDINGSPHERE 1
#include <osg/Config>
#include <osg/Export>
#include <osg/Vec3f>
#include <osg/Vec3d>
@@ -32,12 +33,12 @@ class OSG_EXPORT BoundingSphere
{
public:
#ifdef OSG_USE_DOUBLE_BOUNDINGSPHERE
typedef Vec3d vec_type;
typedef double value_type;
#else
#ifdef OSG_USE_FLOAT_BOUNDINGSPHERE
typedef Vec3f vec_type;
typedef float value_type;
#else
typedef Vec3d vec_type;
typedef double value_type;
#endif
vec_type _center;

View File

@@ -68,9 +68,29 @@
#endif
#ifndef GL_VERSION_1_5
#define GL_STREAM_DRAW 0x88E0
#define GL_STREAM_READ 0x88E1
#define GL_STREAM_COPY 0x88E2
#define GL_STATIC_DRAW 0x88E4
#define GL_STATIC_READ 0x88E5
#define GL_STATIC_COPY 0x88E6
#define GL_DYNAMIC_DRAW 0x88E8
#define GL_DYNAMIC_READ 0x88E9
#define GL_DYNAMIC_COPY 0x88EA
#endif
#ifndef GL_VERSION_2_1
#define GL_PIXEL_PACK_BUFFER 0x88EB
#define GL_PIXEL_UNPACK_BUFFER 0x88EC
#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED
#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF
#endif
#ifndef GL_ARB_pixel_buffer_object
#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB
#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC
#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB
#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC
#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED
#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF
#endif

View File

@@ -91,7 +91,7 @@ class OSG_EXPORT Camera : public Transform, public CullSettings
/** Set the clear color used in glClearColor(..).
* glClearColor is only called if mask & GL_COLOR_BUFFER_BIT is true*/
void setClearColor(const osg::Vec4& color) { _clearColor=color; }
void setClearColor(const osg::Vec4& color) { _clearColor=color; applyMaskAction(CLEAR_COLOR); }
/** Get the clear color.*/
const osg::Vec4& getClearColor() const { return _clearColor; }
@@ -329,12 +329,23 @@ class OSG_EXPORT Camera : public Transform, public CullSettings
COLOR_BUFFER15 = COLOR_BUFFER0+15
};
/** Attach a buffer with specified OpenGL internal format.*/
void attach(BufferComponent buffer, GLenum internalFormat);
void attach(BufferComponent buffer, osg::Texture* texture, unsigned int level = 0, unsigned int face=0, bool mipMapGeneration=false);
/** Attach a Texture to specified buffer component.
* The level parameter controls the mip map level of the texture that is attached.
* The face parameter controls the face of texture cube map or z level of 3d texture.
* The mipMapGeneration flag controls whether mipmap generation should be done for texture.*/
void attach(BufferComponent buffer, osg::Texture* texture, unsigned int level = 0, unsigned int face=0, bool mipMapGeneration=false,
unsigned int multisampleSamples = 0,
unsigned int multisampleColorSamples = 0);
void attach(BufferComponent buffer, osg::Image* image);
/** Attach a Image to specified buffer component.*/
void attach(BufferComponent buffer, osg::Image* image,
unsigned int multisampleSamples = 0,
unsigned int multisampleColorSamples = 0);
/** Detach specified buffer component.*/
void detach(BufferComponent buffer);
struct Attachment
@@ -343,7 +354,9 @@ class OSG_EXPORT Camera : public Transform, public CullSettings
_internalFormat(GL_NONE),
_level(0),
_face(0),
_mipMapGeneration(false) {}
_mipMapGeneration(false),
_multisampleSamples(0),
_multisampleColorSamples(0) {}
int width() const
{
@@ -372,6 +385,8 @@ class OSG_EXPORT Camera : public Transform, public CullSettings
unsigned int _level;
unsigned int _face;
bool _mipMapGeneration;
unsigned int _multisampleSamples;
unsigned int _multisampleColorSamples;
};
typedef std::map< BufferComponent, Attachment> BufferAttachmentMap;
@@ -381,8 +396,8 @@ class OSG_EXPORT Camera : public Transform, public CullSettings
/** Get the const BufferAttachmentMap, used to configure frame buffer objects, pbuffers and texture reads.*/
const BufferAttachmentMap& getBufferAttachmentMap() const { return _bufferAttachmentMap; }
/** Create a operation thread for this camera.*/
void createCameraThread();
@@ -435,14 +450,16 @@ class OSG_EXPORT Camera : public Transform, public CullSettings
DrawCallback(const DrawCallback&,const CopyOp&) {}
META_Object(osg,DrawCallback)
/** Functor method called by rendering thread. Users will typically override this method to carry tasks such as screen capture.*/
virtual void operator () (osg::RenderInfo& renderInfo) const;
/** Functor method, provided for backwards compatibility, called by operator() (osg::RenderInfo& renderInfo) method.*/
virtual void operator () (const osg::Camera& /*camera*/) const {}
};
/** Set the initial draw callback for custom operations to be done before the drawing of the camera's subgraph and pre render stages.*/
void setIntialDrawCallback(DrawCallback* cb) { _preDrawCallback = cb; }
void setInitialDrawCallback(DrawCallback* cb) { _initialDrawCallback = cb; }
/** Get the initial draw callback.*/
DrawCallback* getInitialDrawCallback() { return _initialDrawCallback.get(); }
@@ -499,6 +516,9 @@ class OSG_EXPORT Camera : public Transform, public CullSettings
/** Transform method that must be defined to provide generic interface for scene graph traversals.*/
virtual bool computeWorldToLocalMatrix(Matrix& matrix,NodeVisitor*) const;
/** Inherit the local cull settings variable from specified CullSettings object, according to the inheritance mask.*/
virtual void inheritCullSettings(const CullSettings& settings, unsigned int inheritanceMask);
protected :
virtual ~Camera();

View File

@@ -1,4 +1,4 @@
/* -*-c++-*- OpenSceneGraph - setCullSettingsright (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
@@ -14,6 +14,7 @@
#ifndef OSG_CULLSETTINGS
#define OSG_CULLSETTINGS 1
#include <iosfwd>
#include <osg/Matrix>
#include <osg/ClearNode>

View File

@@ -79,6 +79,35 @@
#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506
#endif
#ifndef GL_EXT_framebuffer_blit
#define GL_EXT_framebuffer_blit 1
#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6
#define GL_READ_FRAMEBUFFER_EXT 0x8CA8
#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9
#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA
#endif
#ifndef GL_EXT_framebuffer_multisample
#define GL_EXT_framebuffer_multisample 1
#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB
#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56
#define GL_MAX_SAMPLES_EXT 0x8D57
#endif
#ifndef GL_MAX_SAMPLES_EXT
// Workaround for Centos 5 and other distros that define
// GL_EXT_framebuffer_multisample but not GL_MAX_SAMPLES_EXT
#define GL_MAX_SAMPLES_EXT 0x8D57
#endif
#ifndef GL_NV_framebuffer_multisample_coverage
#define GL_NV_framebuffer_multisample_coverage 1
#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB
#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10
#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11
#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12
#endif
#ifndef GL_VERSION_1_4
#define GL_DEPTH_COMPONENT16 0x81A5
#define GL_DEPTH_COMPONENT24 0x81A6
@@ -99,6 +128,8 @@ namespace osg
typedef void APIENTRY TglDeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers);
typedef void APIENTRY TglGenRenderbuffersEXT(GLsizei, GLuint *);
typedef void APIENTRY TglRenderbufferStorageEXT(GLenum, GLenum, GLsizei, GLsizei);
typedef void APIENTRY TglRenderbufferStorageMultisampleEXT(GLenum, GLsizei, GLenum, GLsizei, GLsizei);
typedef void APIENTRY TglRenderbufferStorageMultisampleCoverageNV(GLenum, GLsizei, GLsizei, GLenum, GLsizei, GLsizei);
typedef void APIENTRY TglBindFramebufferEXT(GLenum, GLuint);
typedef void APIENTRY TglDeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers);
typedef void APIENTRY TglGenFramebuffersEXT(GLsizei, GLuint *);
@@ -109,12 +140,13 @@ namespace osg
typedef void APIENTRY TglFramebufferTextureLayerEXT(GLenum, GLenum, GLuint, GLint, GLint);
typedef void APIENTRY TglFramebufferRenderbufferEXT(GLenum, GLenum, GLenum, GLuint);
typedef void APIENTRY TglGenerateMipmapEXT(GLenum);
typedef void APIENTRY TglRenderbufferStorageMultisampleCoverageNV(GLenum, GLuint, GLuint, GLenum, GLuint, GLuint);
typedef void APIENTRY TglBlitFramebufferEXT(GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum);
TglBindRenderbufferEXT* glBindRenderbufferEXT;
TglGenRenderbuffersEXT* glGenRenderbuffersEXT;
TglDeleteRenderbuffersEXT* glDeleteRenderbuffersEXT;
TglRenderbufferStorageEXT* glRenderbufferStorageEXT;
TglRenderbufferStorageMultisampleEXT* glRenderbufferStorageMultisampleEXT;
TglRenderbufferStorageMultisampleCoverageNV* glRenderbufferStorageMultisampleCoverageNV;
TglBindFramebufferEXT* glBindFramebufferEXT;
TglDeleteFramebuffersEXT* glDeleteFramebuffersEXT;
@@ -126,10 +158,13 @@ namespace osg
TglFramebufferTextureLayerEXT* glFramebufferTextureLayerEXT;
TglFramebufferRenderbufferEXT* glFramebufferRenderbufferEXT;
TglGenerateMipmapEXT* glGenerateMipmapEXT;
TglBlitFramebufferEXT* glBlitFramebufferEXT;
static FBOExtensions* instance(unsigned contextID, bool createIfNotInitalized);
bool isSupported() const { return _supported; }
bool isMultisampleSupported() const { return glRenderbufferStorageMultisampleEXT != 0; }
bool isMultisampleCoverageSupported() const { return glRenderbufferStorageMultisampleCoverageNV != 0; }
protected:
FBOExtensions(unsigned int contextID);
@@ -146,7 +181,7 @@ namespace osg
{
public:
RenderBuffer();
RenderBuffer(int width, int height, GLenum internalFormat);
RenderBuffer(int width, int height, GLenum internalFormat, int samples=0, int colorSamples=0);
RenderBuffer(const RenderBuffer& copy, const CopyOp& copyop = CopyOp::SHALLOW_COPY);
META_Object(osg, RenderBuffer);
@@ -158,6 +193,10 @@ namespace osg
inline void setSize(int w, int h);
inline GLenum getInternalFormat() const;
inline void setInternalFormat(GLenum format);
inline int getSamples() const;
inline int getColorSamples() const;
inline void setSamples(int samples);
inline void setColorSamples(int colorSamples);
GLuint getObjectID(unsigned int contextID, const FBOExtensions *ext) const;
inline int compare(const RenderBuffer &rb) const;
@@ -176,6 +215,8 @@ namespace osg
* this call is useful for when an OpenGL context has been destroyed. */
static void discardDeletedRenderBuffers(unsigned int contextID);
static int getMaxSamples(unsigned int contextID, const FBOExtensions *ext);
protected:
virtual ~RenderBuffer();
RenderBuffer &operator=(const RenderBuffer &) { return *this; }
@@ -185,9 +226,14 @@ namespace osg
private:
mutable buffered_value<GLuint> _objectID;
mutable buffered_value<int> _dirty;
GLenum _internalFormat;
int _width;
int _height;
// "samples" in the framebuffer_multisample extension is equivalent to
// "coverageSamples" in the framebuffer_multisample_coverage extension.
int _samples;
int _colorSamples;
};
// INLINE METHODS
@@ -232,6 +278,28 @@ namespace osg
dirtyAll();
}
inline int RenderBuffer::getSamples() const
{
return _samples;
}
inline int RenderBuffer::getColorSamples() const
{
return _colorSamples;
}
inline void RenderBuffer::setSamples(int samples)
{
_samples = samples;
dirtyAll();
}
inline void RenderBuffer::setColorSamples(int colorSamples)
{
_colorSamples = colorSamples;
dirtyAll();
}
inline void RenderBuffer::dirtyAll() const
{
_dirty.setAllElementsTo(1);
@@ -278,8 +346,9 @@ namespace osg
FrameBufferAttachment&operator = (const FrameBufferAttachment& copy);
bool isMultisample() const;
void createRequiredTexturesAndApplyGenerateMipMap(State& state, const FBOExtensions* ext) const;
void attach(State &state, GLenum attachment_point, const FBOExtensions* ext) const;
void attach(State &state, GLenum target, GLenum attachment_point, const FBOExtensions* ext) const;
int compare(const FrameBufferAttachment &fa) const;
private:
@@ -308,25 +377,29 @@ namespace osg
inline const AttachmentMap& getAttachmentMap() const;
void setAttachment(GLenum attachment_point, const FrameBufferAttachment &attachment);
inline const FrameBufferAttachment& getAttachment(GLenum attachment_point) const;
inline bool hasAttachment(GLenum attachment_point) const;
void setAttachment(BufferComponent attachment_point, const FrameBufferAttachment &attachment);
inline const FrameBufferAttachment& getAttachment(BufferComponent attachment_point) const;
inline bool hasAttachment(BufferComponent attachment_point) const;
GLenum convertBufferComponentToGLenum(BufferComponent attachment_point) const;
BufferComponent convertGLenumToBufferComponent(GLenum attachment_point) const;
inline bool hasMultipleRenderingTargets() const { return !_drawBuffers.empty(); }
inline const MultipleRenderingTargets& getMultipleRenderingTargets() const { return _drawBuffers; }
bool isMultisample() const;
int compare(const StateAttribute &sa) const;
void apply(State &state) const;
enum BindTarget
{
READ_FRAMEBUFFER = GL_READ_FRAMEBUFFER_EXT,
DRAW_FRAMEBUFFER = GL_DRAW_FRAMEBUFFER_EXT,
READ_DRAW_FRAMEBUFFER = GL_FRAMEBUFFER_EXT
};
/** Bind the FBO as either the read or draw target, or both. */
void apply(State &state, BindTarget target) const;
/** Mark internal FBO for deletion.
* Deletion requests are queued until they can be executed
* in the proper GL context. */
@@ -348,6 +421,8 @@ namespace osg
inline void dirtyAll();
GLenum convertBufferComponentToGLenum(BufferComponent attachment_point) const;
private:
AttachmentMap _attachments;
@@ -367,21 +442,11 @@ namespace osg
return _attachments;
}
inline bool FrameBufferObject::hasAttachment(GLenum attachment_point) const
{
return hasAttachment(convertGLenumToBufferComponent(attachment_point));
}
inline bool FrameBufferObject::hasAttachment(FrameBufferObject::BufferComponent attachment_point) const
{
return _attachments.find(attachment_point) != _attachments.end();
}
inline const FrameBufferAttachment &FrameBufferObject::getAttachment(GLenum attachment_point) const
{
return getAttachment(convertGLenumToBufferComponent(attachment_point));
}
inline const FrameBufferAttachment &FrameBufferObject::getAttachment(FrameBufferObject::BufferComponent attachment_point) const
{
return _attachments.find(attachment_point)->second;

View File

@@ -80,7 +80,7 @@ bool setGLExtensionFuncPtr(T& t, const char* str1)
if (data)
{
memcpy(&t, &data, sizeof(T));
return false;
return true;
}
else
{
@@ -96,7 +96,7 @@ bool setGLExtensionFuncPtr(T& t, const char* str1, const char* str2)
if (data)
{
memcpy(&t, &data, sizeof(T));
return false;
return true;
}
else
{

View File

@@ -139,10 +139,6 @@ class OSG_EXPORT Geometry : public Drawable
Array* getVertexArray() { return _vertexData.array.get(); }
const Array* getVertexArray() const { return _vertexData.array.get(); }
void setVertexIndices(IndexArray* array);
IndexArray* getVertexIndices() { return _vertexData.indices.get(); }
const IndexArray* getVertexIndices() const { return _vertexData.indices.get(); }
void setVertexData(const ArrayData& arrayData);
ArrayData& getVertexData() { return _vertexData; }
const ArrayData& getVertexData() const { return _vertexData; }
@@ -154,10 +150,6 @@ class OSG_EXPORT Geometry : public Drawable
void setNormalArray(Array* array);
Array* getNormalArray() { return _normalData.array.get(); }
const Array* getNormalArray() const { return _normalData.array.get(); }
void setNormalIndices(IndexArray* array);
IndexArray* getNormalIndices() { return _normalData.indices.get(); }
const IndexArray* getNormalIndices() const { return _normalData.indices.get(); }
void setNormalData(const ArrayData& arrayData);
ArrayData& getNormalData() { return _normalData; }
@@ -170,10 +162,6 @@ class OSG_EXPORT Geometry : public Drawable
Array* getColorArray() { return _colorData.array.get(); }
const Array* getColorArray() const { return _colorData.array.get(); }
void setColorIndices(IndexArray* array);
IndexArray* getColorIndices() { return _colorData.indices.get(); }
const IndexArray* getColorIndices() const { return _colorData.indices.get(); }
void setColorData(const ArrayData& arrayData);
ArrayData& getColorData() { return _colorData; }
const ArrayData& getColorData() const { return _colorData; }
@@ -186,10 +174,6 @@ class OSG_EXPORT Geometry : public Drawable
Array* getSecondaryColorArray() { return _secondaryColorData.array.get(); }
const Array* getSecondaryColorArray() const { return _secondaryColorData.array.get(); }
void setSecondaryColorIndices(IndexArray* array);
IndexArray* getSecondaryColorIndices() { return _secondaryColorData.indices.get(); }
const IndexArray* getSecondaryColorIndices() const { return _secondaryColorData.indices.get(); }
void setSecondaryColorData(const ArrayData& arrayData);
ArrayData& getSecondaryColorData() { return _secondaryColorData; }
const ArrayData& getSecondaryColorData() const { return _secondaryColorData; }
@@ -202,10 +186,6 @@ class OSG_EXPORT Geometry : public Drawable
Array* getFogCoordArray() { return _fogCoordData.array.get(); }
const Array* getFogCoordArray() const { return _fogCoordData.array.get(); }
void setFogCoordIndices(IndexArray* array);
IndexArray* getFogCoordIndices() { return _fogCoordData.indices.get(); }
const IndexArray* getFogCoordIndices() const { return _fogCoordData.indices.get(); }
void setFogCoordData(const ArrayData& arrayData);
ArrayData& getFogCoordData() { return _fogCoordData; }
const ArrayData& getFogCoordData() const { return _fogCoordData; }
@@ -214,10 +194,6 @@ class OSG_EXPORT Geometry : public Drawable
void setTexCoordArray(unsigned int unit,Array*);
Array* getTexCoordArray(unsigned int unit);
const Array* getTexCoordArray(unsigned int unit) const;
void setTexCoordIndices(unsigned int unit,IndexArray*);
IndexArray* getTexCoordIndices(unsigned int unit);
const IndexArray* getTexCoordIndices(unsigned int unit) const;
void setTexCoordData(unsigned int index,const ArrayData& arrayData);
ArrayData& getTexCoordData(unsigned int index);
@@ -233,10 +209,6 @@ class OSG_EXPORT Geometry : public Drawable
Array *getVertexAttribArray(unsigned int index);
const Array *getVertexAttribArray(unsigned int index) const;
void setVertexAttribIndices(unsigned int index,IndexArray* array);
IndexArray* getVertexAttribIndices(unsigned int index);
const IndexArray* getVertexAttribIndices(unsigned int index) const;
void setVertexAttribBinding(unsigned int index,AttributeBinding ab);
AttributeBinding getVertexAttribBinding(unsigned int index) const;
@@ -282,6 +254,45 @@ class OSG_EXPORT Geometry : public Drawable
unsigned int getPrimitiveSetIndex(const PrimitiveSet* primitiveset) const;
/** deprecated - forces OpenGL slow path, just kept for backwards compatibility.*/
void setVertexIndices(IndexArray* array);
IndexArray* getVertexIndices() { return _vertexData.indices.get(); }
const IndexArray* getVertexIndices() const { return _vertexData.indices.get(); }
/** deprecated - forces OpenGL slow path, just kept for backwards compatibility.*/
void setNormalIndices(IndexArray* array);
IndexArray* getNormalIndices() { return _normalData.indices.get(); }
const IndexArray* getNormalIndices() const { return _normalData.indices.get(); }
/** deprecated - forces OpenGL slow path, just kept for backwards compatibility.*/
void setColorIndices(IndexArray* array);
IndexArray* getColorIndices() { return _colorData.indices.get(); }
const IndexArray* getColorIndices() const { return _colorData.indices.get(); }
/** deprecated - forces OpenGL slow path, just kept for backwards compatibility.*/
void setSecondaryColorIndices(IndexArray* array);
IndexArray* getSecondaryColorIndices() { return _secondaryColorData.indices.get(); }
const IndexArray* getSecondaryColorIndices() const { return _secondaryColorData.indices.get(); }
/** deprecated - forces OpenGL slow path, just kept for backwards compatibility.*/
void setFogCoordIndices(IndexArray* array);
IndexArray* getFogCoordIndices() { return _fogCoordData.indices.get(); }
const IndexArray* getFogCoordIndices() const { return _fogCoordData.indices.get(); }
/** deprecated - forces OpenGL slow path, just kept for backwards compatibility.*/
void setTexCoordIndices(unsigned int unit,IndexArray*);
IndexArray* getTexCoordIndices(unsigned int unit);
const IndexArray* getTexCoordIndices(unsigned int unit) const;
/** deprecated - forces OpenGL slow path, just kept for backwards compatibility.*/
void setVertexAttribIndices(unsigned int index,IndexArray* array);
IndexArray* getVertexAttribIndices(unsigned int index);
const IndexArray* getVertexAttribIndices(unsigned int index) const;
/** When set to true, ignore the setUseDisplayList() settings, and hints to the drawImplementation
method to use OpenGL vertex buffer objects for rendering.*/
virtual void setUseVertexBufferObjects(bool flag);

View File

@@ -92,7 +92,8 @@ class OSG_EXPORT GraphicsContext : public Object
useMultiThreadedOpenGLEngine(false),
useCursor(true),
sharedContext(0),
setInheritedWindowPixelFormat(false) {}
setInheritedWindowPixelFormat(false),
overrideRedirect(false) {}
// graphics context original and size
int x;
@@ -145,6 +146,9 @@ class OSG_EXPORT GraphicsContext : public Object
// ask the GraphicsWindow implementation to set the pixel format of an inherited window
bool setInheritedWindowPixelFormat;
// X11 hint whether to override the window managers window size/position redirection
bool overrideRedirect;
};

View File

@@ -41,7 +41,7 @@ public:
virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new Hint(*this,copyop); }
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const Hint *>(obj)!=NULL; }
virtual const char* libraryName() const { return "osg"; }
virtual const char* className() const { return "Light"; }
virtual const char* className() const { return "Hint"; }
virtual Type getType() const { return HINT; }
virtual int compare(const StateAttribute& sa) const

View File

@@ -18,6 +18,7 @@
#include <osg/Vec2>
#include <osg/Vec3>
#include <osg/Vec4>
#include <osg/FrameStamp>
#include <string>
#include <vector>
@@ -52,6 +53,9 @@
namespace osg {
// forward declare
class NodeVisitor;
/** Image class for encapsulating the storage texture image data. */
class OSG_EXPORT Image : public Object
{
@@ -293,6 +297,8 @@ class OSG_EXPORT Image : public Object
/** Get the const PixelBufferObject.*/
const PixelBufferObject* getPixelBufferObject() const { return _bufferObject.get(); }
virtual void update(NodeVisitor* nv) {}
protected :

120
include/osg/ImageSequence Normal file
View File

@@ -0,0 +1,120 @@
/* -*-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.
*/
#ifndef OSG_IMAGESEQUENCE
#define OSG_IMAGESEQUENCE 1
#include <OpenThreads/Mutex>
#include <osg/ImageStream>
#include <osg/StateAttribute>
#include <list>
namespace osg {
/**
* Image Buffer class.
*/
class OSG_EXPORT ImageSequence : public ImageStream
{
public:
ImageSequence();
/** Copy constructor using CopyOp to manage deep vs shallow copy. */
ImageSequence(const ImageSequence& ImageSequence, const CopyOp& copyop=CopyOp::SHALLOW_COPY);
virtual Object* cloneType() const { return new ImageSequence(); }
virtual Object* clone(const CopyOp& copyop) const { return new ImageSequence(*this,copyop); }
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const ImageSequence*>(obj)!=0; }
virtual const char* libraryName() const { return "osg"; }
virtual const char* className() const { return "ImageSequence"; }
/** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */
virtual int compare(const Image& rhs) const;
virtual void setReferenceTime(double t) { _referenceTime = t; }
virtual double getReferenceTime() const { return _referenceTime; }
virtual void setTimeMultiplier(double tm) { _timeMultiplier = tm; }
virtual double getTimeMultiplier() const { return _timeMultiplier; }
typedef std::list< osg::ref_ptr<osg::Image> > Images;
typedef std::list< std::string > FileNames;
enum Mode
{
PRE_LOAD_ALL_IMAGES,
PAGE_AND_RETAIN_IMAGES,
PAGE_AND_DISCARD_USED_IMAGES
};
void setMode(Mode mode);
Mode getMode() const { return _mode; }
void setDuration(double duration);
double getDuration() const { return _duration; }
void addImageFile(const std::string& fileName);
FileNames& getFileNames() { return _fileNames; }
const FileNames& getFileNames() const { return _fileNames; }
void addImage(osg::Image* image);
Images& getImages() { return _images; }
const Images& getImages() const { return _images; }
virtual void update(NodeVisitor* nv);
struct OSG_EXPORT UpdateCallback : public osg::StateAttribute::Callback
{
virtual void operator () (osg::StateAttribute* attr, osg::NodeVisitor* nv);
};
protected:
virtual ~ImageSequence() {}
void setImageToChild(const osg::Image* image);
void computeTimePerImage();
double _referenceTime;
double _timeMultiplier;
Mode _mode;
double _duration;
double _timePerImage;
OpenThreads::Mutex _mutex;
FileNames _fileNames;
FileNames::iterator _fileNamesIterator;
double _fileNamesIteratorTime;
double _imageHeadTime;
Images _images;
Images::iterator _imageIterator;
double _imageIteratorTime;
typedef std::pair< std::string, osg::ref_ptr<osg::Image> > FileNameImagePair;
typedef std::list< FileNameImagePair > FileNameImageList;
FileNameImageList _filesRequested;
};
} // namespace
#endif

View File

@@ -78,7 +78,6 @@ class OSG_EXPORT ImageStream : public Image
virtual void setVolume(float) {}
virtual float getVolume() const { return 0.0f; }
virtual void update() {}
protected:
virtual void applyLoopingMode() {}

196
include/osg/KdTree Normal file
View File

@@ -0,0 +1,196 @@
/* -*-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.
*/
#ifndef OSG_KDTREE
#define OSG_KDTREE 1
#include <osg/Shape>
#include <osg/Geometry>
#include <map>
namespace osg
{
/** Implementation of a kdtree for Geometry leaves, to enable fast intersection tests.*/
class OSG_EXPORT KdTree : public osg::Shape
{
public:
KdTree();
KdTree(const KdTree& rhs, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
META_Shape(osg, KdTree)
struct OSG_EXPORT BuildOptions
{
BuildOptions();
unsigned int _numVerticesProcessed;
unsigned int _targetNumTrianglesPerLeaf;
unsigned int _maxNumLevels;
};
/** Build the kdtree from the specified source geometry object.
* retun true on success. */
virtual bool build(BuildOptions& buildOptions, osg::Geometry* geometry);
struct LineSegmentIntersection
{
LineSegmentIntersection():
ratio(-1.0),
p0(0),
p1(0),
p2(0),
r0(0.0f),
r1(0.0f),
r2(0.0f),
primitiveIndex(0) {}
bool operator < (const LineSegmentIntersection& rhs) const { return ratio < rhs.ratio; }
typedef std::vector<unsigned int> IndexList;
typedef std::vector<double> RatioList;
double ratio;
osg::Vec3d intersectionPoint;
osg::Vec3 intersectionNormal;
unsigned int p0;
unsigned int p1;
unsigned int p2;
float r0;
float r1;
float r2;
unsigned int primitiveIndex;
};
typedef std::vector<LineSegmentIntersection> LineSegmentIntersections;
/** compute the intersection of a line segment and the kdtree, return true if an intersection has been found.*/
virtual bool intersect(const osg::Vec3& start, const osg::Vec3& end, LineSegmentIntersections& intersections) const;
typedef int value_type;
struct KdNode
{
KdNode():
first(0),
second(0) {}
KdNode(value_type f, value_type s):
first(f),
second(s) {}
osg::BoundingBox bb;
value_type first;
value_type second;
};
struct Triangle
{
Triangle():
p0(0),p1(0),p2(0) {}
Triangle(unsigned int ip0, unsigned int ip1, unsigned int ip2):
p0(ip0), p1(ip1), p2(ip2) {}
bool operator < (const Triangle& rhs) const
{
if (p0<rhs.p0) return true;
if (p0>rhs.p0) return false;
if (p1<rhs.p1) return true;
if (p1>rhs.p1) return false;
return p2<rhs.p2;
}
unsigned int p0;
unsigned int p1;
unsigned int p2;
};
typedef std::vector< KdNode > KdNodeList;
typedef std::vector< Triangle > TriangleList;
int addNode(const KdNode& node)
{
int num = _kdNodes.size();
_kdNodes.push_back(node);
return num;
}
KdNode& getNode(int nodeNum) { return _kdNodes[nodeNum]; }
const KdNode& getNode(int nodeNum) const { return _kdNodes[nodeNum]; }
KdNodeList& getNodes() { return _kdNodes; }
const KdNodeList& getNodes() const { return _kdNodes; }
void setVertices(osg::Vec3Array* vertices) { _vertices = vertices; }
const osg::Vec3Array* getVertices() const { return _vertices.get(); }
unsigned int addTriangle(const Triangle& tri)
{
unsigned int num = _triangles.size();
_triangles.push_back(tri);
return num;
}
Triangle& getTriangle(unsigned int i) { return _triangles[i]; }
const Triangle& getTriangle(unsigned int i) const { return _triangles[i]; }
TriangleList& getTriangles() { return _triangles; }
const TriangleList& getTriangles() const { return _triangles; }
protected:
osg::ref_ptr<osg::Vec3Array> _vertices;
KdNodeList _kdNodes;
TriangleList _triangles;
};
class OSG_EXPORT KdTreeBuilder : public osg::NodeVisitor
{
public:
KdTreeBuilder();
KdTreeBuilder(const KdTreeBuilder& rhs);
virtual KdTreeBuilder* clone() { return new KdTreeBuilder(*this); }
void apply(osg::Geode& geode);
KdTree::BuildOptions _buildOptions;
osg::ref_ptr<osg::KdTree> _kdTreePrototype;
protected:
virtual ~KdTreeBuilder() {}
};
}
#endif

View File

@@ -14,6 +14,7 @@
#ifndef OSG_MATRIX
#define OSG_MATRIX 1
#include <osg/Config>
#include <osg/Matrixd>
#include <osg/Matrixf>

Some files were not shown because too many files have changed in this diff Show More