Compare commits

..

289 Commits

Author SHA1 Message Date
Robert Osfield
9c384664af Updated ChangeLog
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@15107 16af8721-9629-0410-8352-f15c8da7e697
2015-08-12 10:04:33 +00:00
Robert Osfield
c1f083a67e Revised shaders to catch NVidia length bug that generates NAN's
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@15105 16af8721-9629-0410-8352-f15c8da7e697
2015-08-12 08:34:57 +00:00
Robert Osfield
23d582fef5 Updated version and ChangeLog for release
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@15104 16af8721-9629-0410-8352-f15c8da7e697
2015-08-12 07:41:40 +00:00
Robert Osfield
074d470fa5 Updated version number for 3.2.3 release
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@15103 16af8721-9629-0410-8352-f15c8da7e697
2015-08-12 07:38:17 +00:00
Robert Osfield
ee71c5a63f Updated AUTHORS, ChangeLog and README for 3.2.3 release
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@15102 16af8721-9629-0410-8352-f15c8da7e697
2015-08-12 07:37:39 +00:00
Robert Osfield
fc77489239 Merged Contributors list from svn/trunk.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@15101 16af8721-9629-0410-8352-f15c8da7e697
2015-08-12 06:50:35 +00:00
Robert Osfield
6fa7dd27f3 From Glenn Waldron, fix error in ZIP plugin handling of memory buffer
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@15066 16af8721-9629-0410-8352-f15c8da7e697
2015-08-08 08:49:33 +00:00
Robert Osfield
32366f0489 Updated RayTracedTechnique shaders from svn/trunk.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@15058 16af8721-9629-0410-8352-f15c8da7e697
2015-08-06 10:09:18 +00:00
Robert Osfield
30fff3106d Updated version and NEWS for 3.2.2 stable release
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@15051 16af8721-9629-0410-8352-f15c8da7e697
2015-08-04 15:52:28 +00:00
Robert Osfield
23458666b8 Update NEWS to online Contributors list.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@15050 16af8721-9629-0410-8352-f15c8da7e697
2015-08-04 10:37:50 +00:00
Robert Osfield
c91bfcee21 Updated AUTHORS
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@15049 16af8721-9629-0410-8352-f15c8da7e697
2015-08-04 10:26:26 +00:00
Robert Osfield
d763feddda Updated ChangeLog and NEWS for 3.2.2 release
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@15048 16af8721-9629-0410-8352-f15c8da7e697
2015-08-04 10:25:40 +00:00
Robert Osfield
3b789fc6b0 Upated rc number to 4
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@15047 16af8721-9629-0410-8352-f15c8da7e697
2015-08-04 10:11:39 +00:00
Robert Osfield
110cf64c3b Build fix for Mingw
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@15045 16af8721-9629-0410-8352-f15c8da7e697
2015-08-04 09:35:00 +00:00
Robert Osfield
9d326917f0 From Pjotr Svetachov, buid fixes for VS2015.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@15023 16af8721-9629-0410-8352-f15c8da7e697
2015-07-23 14:42:39 +00:00
Robert Osfield
5ead09215e Added check for validity of OpenFlight shininess value.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@15000 16af8721-9629-0410-8352-f15c8da7e697
2015-07-21 14:22:12 +00:00
Robert Osfield
60838d0c42 Fixed typo
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14995 16af8721-9629-0410-8352-f15c8da7e697
2015-07-21 13:42:07 +00:00
Robert Osfield
bddbdfdefe Reinstated the TIFFSetField(image, TIFFTAG_ROWSPERSTRIP, rowsperstrip);
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14987 16af8721-9629-0410-8352-f15c8da7e697
2015-07-19 09:51:27 +00:00
Robert Osfield
0744b6881f Updated release candidate nubmer
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14979 16af8721-9629-0410-8352-f15c8da7e697
2015-07-17 09:15:40 +00:00
Robert Osfield
3371ce640a Updated ChangeLog and AURHORS
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14976 16af8721-9629-0410-8352-f15c8da7e697
2015-07-17 09:03:49 +00:00
Robert Osfield
dff397f647 Updated ChangeLog and AUTHORS file
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14975 16af8721-9629-0410-8352-f15c8da7e697
2015-07-17 08:35:23 +00:00
Robert Osfield
1c833e2e4d Added cmake_policy setting for cmake-3.x to avoid warning with Qt usage.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14972 16af8721-9629-0410-8352-f15c8da7e697
2015-07-17 08:17:34 +00:00
Robert Osfield
cf268b4cfd From Patrick Neary, "To the tiff plugin, add the capability to write tiff images with unsigned short data"
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14971 16af8721-9629-0410-8352-f15c8da7e697
2015-07-17 08:13:01 +00:00
Robert Osfield
1d628eebfb From Patrick Neary, "Added some lesser used tokens that we use from GL_ARB_texture_rg to computeFormatDataType(), and computeNumComponents() in src/osg/Image.cpp"
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14968 16af8721-9629-0410-8352-f15c8da7e697
2015-07-16 19:19:29 +00:00
Robert Osfield
20401947bf Build fix for GLDAL>=2.0
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14926 16af8721-9629-0410-8352-f15c8da7e697
2015-06-30 08:38:53 +00:00
Robert Osfield
16ac602824 From Jannik Heller, fix to clearReferencesToDependentCameras().
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14923 16af8721-9629-0410-8352-f15c8da7e697
2015-06-19 09:54:05 +00:00
Robert Osfield
4f830fb0e2 From Farshid Lashkari, "I've modified some setter methods of TextBase to avoid unnecessary calls to computeGlyphRepresentation() if the value has not changed."
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14911 16af8721-9629-0410-8352-f15c8da7e697
2015-06-12 08:04:38 +00:00
Robert Osfield
d4fc0ceba3 Philippe Renon, "Fixed potential divide by zero in NodeTrackerManipulator : The divide by zero happens when throwing a NodeTrackerManipulator.
The infinite result trickles down and later causes NaN in culling.

The fix was to use getThrowScale() as done everywhere else."


git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14906 16af8721-9629-0410-8352-f15c8da7e697
2015-06-10 10:02:22 +00:00
Robert Osfield
825882be19 Fixed setReferenceTime() bug where a * eather than the correct / was being used. Bug and fix suggested Benjamin Richter.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14897 16af8721-9629-0410-8352-f15c8da7e697
2015-06-07 11:13:08 +00:00
Robert Osfield
bc473c4e0e Fixed memory error associated with reading over the end of container due to an unbounded while loop.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14867 16af8721-9629-0410-8352-f15c8da7e697
2015-05-21 14:11:54 +00:00
Robert Osfield
a430566596 Changed the CMP0020 check to > 2.8.10
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14863 16af8721-9629-0410-8352-f15c8da7e697
2015-05-05 11:04:05 +00:00
Robert Osfield
3d77abc06d Merged correction to coordinates from svn/trunk
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14853 16af8721-9629-0410-8352-f15c8da7e697
2015-04-20 10:43:00 +00:00
Robert Osfield
033e52b8ef Updated contributor fixes
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14852 16af8721-9629-0410-8352-f15c8da7e697
2015-04-20 10:42:28 +00:00
Robert Osfield
785ce9f679 Moved uniform substitution to infront of vertex attribute substituion to make sure gl_Vertex usage is replaced when required.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14847 16af8721-9629-0410-8352-f15c8da7e697
2015-04-20 09:38:49 +00:00
Robert Osfield
f26be0155c From Lionel Largarde, "fix for the Image::computeNumberOfMipmapLevels method. The method did use the float version of the log function and the / operator.
It works for most of the input sizes, but fails for 8192, 32768...
For 8192, the method returns 13 instead of 14."



git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14815 16af8721-9629-0410-8352-f15c8da7e697
2015-04-01 09:37:53 +00:00
Robert Osfield
9eb02084a6 Removed unimplemented ComputeBoundingBoxCallback and ComputeBoundingSphereCallback
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14799 16af8721-9629-0410-8352-f15c8da7e697
2015-03-17 09:10:59 +00:00
Robert Osfield
bd82047acb Added missing references for static build
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14797 16af8721-9629-0410-8352-f15c8da7e697
2015-03-17 08:26:13 +00:00
Robert Osfield
f9a20d017a From Konstantin Matveyev, "Last update in the osgAnimation::Animation ONCE mode bug fix"
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14790 16af8721-9629-0410-8352-f15c8da7e697
2015-03-16 10:30:51 +00:00
Robert Osfield
5878a70ede Reverted merged from svn/trunk.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14787 16af8721-9629-0410-8352-f15c8da7e697
2015-03-13 08:13:59 +00:00
Robert Osfield
57d04290ab From Konstantin Matveyev, "Small fix for OSG 3.3.6.119 in the attachment.
One line added in osg/LibraryWrapper.cpp

USE_SERIALIZER_WRAPPER(Callback)
"



git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14785 16af8721-9629-0410-8352-f15c8da7e697
2015-03-13 08:12:19 +00:00
Robert Osfield
ceda86b31b From Laurens Voerman, "attached is a zip with a modified version of:
OpenSceneGraph\CMakeModules\FindFBX.cmake

This version can find fbx sdk 2015.1 and will prefer it over older versions.

Tested with Visual Studio Express 2013 on 64bit windows 7"


git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14783 16af8721-9629-0410-8352-f15c8da7e697
2015-03-12 15:12:57 +00:00
Robert Osfield
499e38ff98 Warning fixes
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14779 16af8721-9629-0410-8352-f15c8da7e697
2015-03-11 17:47:30 +00:00
Robert Osfield
3461d9e8b5 From Laurens Voerman, "The current version will not compile with SDL version 2, error
OpenSceneGraph\src\osgPlugins\sdl\JoystickDevice.cpp(42): error C2664: 'const char *SDL_JoystickName(SDL_Joystick *)' : cannot convert argument 1 from 'int' to 'SDL_Joystick *'
due to changes in the SDL api.

Tested with Visual Studio Express 2013; SDL 2.0.1"


git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14777 16af8721-9629-0410-8352-f15c8da7e697
2015-03-11 17:37:33 +00:00
Robert Osfield
4a535fe426 Updated RC to 2.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14763 16af8721-9629-0410-8352-f15c8da7e697
2015-03-05 18:00:54 +00:00
Robert Osfield
fc7302ccba Updated AUTHORS file for next release candidate
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14762 16af8721-9629-0410-8352-f15c8da7e697
2015-03-05 18:00:16 +00:00
Robert Osfield
7f4d116391 Restructed the checks in the CollectLowestTransformsVisitor::removeTransforms() to avoid benign case being flagged as warning.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14754 16af8721-9629-0410-8352-f15c8da7e697
2015-03-03 12:56:10 +00:00
Robert Osfield
edf27e36ed Re-organized the #ifdef's to avoid usage of glPolyginMode under GLES
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14750 16af8721-9629-0410-8352-f15c8da7e697
2015-03-03 12:00:22 +00:00
Robert Osfield
c8d8a051ad From Michael McDonnell, Merged enchancements to osgtesselationshader example from OSG-svn/trunk to OSG-3.2 branch.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14746 16af8721-9629-0410-8352-f15c8da7e697
2015-03-02 11:08:59 +00:00
Robert Osfield
4c9e17fcc7 From Jannik Heller, "I noticed the rotation in the OrbitManipulator depends on the framerate. To reproduce this issue, start the osganimate example, rotate the model with the left mouse button, then let go of the mouse button while still moving. You will notice that with V-Sync enabled, the model rotates slower.
The OrbitManipulator calculates a scale to counteract the framerate dependency, but it turns out this scale wasn't used for the rotation yet."


git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14743 16af8721-9629-0410-8352-f15c8da7e697
2015-03-01 11:08:51 +00:00
Robert Osfield
95853370e1 Updated AUTHROS, Controbitors and rc number in prep for the 3.2.2-rc1
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14741 16af8721-9629-0410-8352-f15c8da7e697
2015-02-27 10:15:45 +00:00
Robert Osfield
c90cc658a0 Updated AUTHORS
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14734 16af8721-9629-0410-8352-f15c8da7e697
2015-02-26 20:06:11 +00:00
Robert Osfield
7c8ab128a6 From Bradley Baker Searles, "We had someone replace a DDS texture with a GL_RGB/GL_UNSIGNED_SHORT_5_6_6 image, which would trigger a crash in Image.cpp while flipping the mipmap chain. The code was trying to flip the mipmaps using the rowStep for the full-size image (we have "dds_flip" set in the osgDB::ReaderWriter::Options in the osgDB::Registry)."
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14731 16af8721-9629-0410-8352-f15c8da7e697
2015-02-26 19:13:46 +00:00
Robert Osfield
1185fbda34 From Bradley Baker Searles, "Small patch attached to handle DDS flip when s=4. Currently it will omit flipping and generate a warning: "Vertical flip was skipped. Image dimensions have to be multiple of 4."."
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14730 16af8721-9629-0410-8352-f15c8da7e697
2015-02-26 18:07:25 +00:00
Robert Osfield
005e52144d Fixed typo
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14726 16af8721-9629-0410-8352-f15c8da7e697
2015-02-26 14:16:36 +00:00
Robert Osfield
b6f05114dc Fixed image allocation operations.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14713 16af8721-9629-0410-8352-f15c8da7e697
2015-02-23 20:28:37 +00:00
Robert Osfield
8bb91a5265 From Arjun Ramamurthy, fix for StatsHandler when being used in multiple view/windows
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14710 16af8721-9629-0410-8352-f15c8da7e697
2015-02-23 11:07:35 +00:00
Robert Osfield
13f2cb3f47 From Sebastian Messerschmidt,"Attached you find a version of the ReaderWriterDDS with info outputs set to OSG_INFO instead of OSG_NOTICE. The old version spams the console for each loaded DDS file."
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14702 16af8721-9629-0410-8352-f15c8da7e697
2015-02-18 10:23:43 +00:00
Robert Osfield
dab3efadce Updated ChangeLog
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14649 16af8721-9629-0410-8352-f15c8da7e697
2015-01-06 15:10:48 +00:00
Robert Osfield
6f004ef7db From Julien Valentin, added missing initializer
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14648 16af8721-9629-0410-8352-f15c8da7e697
2015-01-06 14:55:10 +00:00
Robert Osfield
6895e29417 From Julien Valentin, typo fix
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14645 16af8721-9629-0410-8352-f15c8da7e697
2015-01-06 14:41:18 +00:00
Robert Osfield
6cf1db199c Added comment about using -DCMAKE_DISABLE_FINDPACKAGE_* command line.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14631 16af8721-9629-0410-8352-f15c8da7e697
2014-12-22 10:35:30 +00:00
Robert Osfield
d4e5c72ebc Added doxygen comment for ref_ptr<>::release().
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14629 16af8721-9629-0410-8352-f15c8da7e697
2014-12-22 09:50:08 +00:00
Robert Osfield
3dd2816414 From Mattias Helsing, "CMake have release 3.0 and 3.1 and we have some bad checks for cmake
major version when settings cmake policies in CMakeLists.txt. This fixes it"


git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14619 16af8721-9629-0410-8352-f15c8da7e697
2014-12-18 15:59:06 +00:00
Robert Osfield
eeadbae72d Updated AUTHORS
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14618 16af8721-9629-0410-8352-f15c8da7e697
2014-12-18 11:37:54 +00:00
Robert Osfield
b203faaa22 From Adrian Clark, "Recently I tried compiling version 3.x of OpenSceneGraph for Android, using a recent Android NDK, only to run into problems with missing dependencies when trying to link my android project against the generated libraries.
After some exploration, I found the problem is because the APP_PLATFORM variable in Application.mk is set to a platform number which is no longer compatible with the Android NDK by the OSG CMake toolchain. This causes the Android to compile it using the most recent Android platform libraries which (for reasons I don't know) no longer provide functions which OSG relies (in particular rand and stat64).



This bug affects the current SVN repos for OSG 3.3.1, OSG 3.3.0, OSG 3.2.1 and OSG 3.2.0 (and possibly earlier).



I posted a longer discussion of what the problem is in this forum thread:

http://forum.openscenegraph.org/viewtopic.php?p=62012#62012





But essentially the fix is to change one line in OSG/PlatformSpecifics/Android/Application.mk.master.in from:



APP_PLATFORM := ${ANDROID_PLATFORM}



To



APP_PLATFORM := android-${ANDROID_PLATFORM}





The attached file will fix the bug in the 3.2.0 - 3.3.1 SVN repos for OSG.

"


git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14612 16af8721-9629-0410-8352-f15c8da7e697
2014-12-18 09:20:40 +00:00
Robert Osfield
324dc573a0 From Farshid Lashkari, "The Collada loader would crash while processing textures on certain files. I've attached the fix."
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14596 16af8721-9629-0410-8352-f15c8da7e697
2014-12-10 11:30:02 +00:00
Robert Osfield
750cd78178 Fixed memory leak in RenderStageCache.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14579 16af8721-9629-0410-8352-f15c8da7e697
2014-12-08 11:08:48 +00:00
Robert Osfield
b5179e247f Fixed warnigns
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14548 16af8721-9629-0410-8352-f15c8da7e697
2014-11-26 17:07:51 +00:00
Robert Osfield
84ec88cc25 Removed redundent line endings
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14547 16af8721-9629-0410-8352-f15c8da7e697
2014-11-26 17:07:07 +00:00
Robert Osfield
7a9e97877c Fixed deprecated warnings
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14544 16af8721-9629-0410-8352-f15c8da7e697
2014-11-26 16:29:43 +00:00
Robert Osfield
0bedd4c43a Fixed warning
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14543 16af8721-9629-0410-8352-f15c8da7e697
2014-11-26 16:15:50 +00:00
Robert Osfield
d1b9bdbbbe Fixed warnings
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14541 16af8721-9629-0410-8352-f15c8da7e697
2014-11-26 16:07:46 +00:00
Robert Osfield
c923584158 Removed redudent spaces
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14540 16af8721-9629-0410-8352-f15c8da7e697
2014-11-26 16:06:55 +00:00
Robert Osfield
c789f7bced Fixed warning
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14538 16af8721-9629-0410-8352-f15c8da7e697
2014-11-26 16:02:06 +00:00
Robert Osfield
18810de975 From Jan Klimke, "i noticed, that there are a couple of additional flaws when building osg for Mac OS X 10.10 Yosemite.
The mac os sdk version is recognized by the current CMAKE script as 10.1 instead of 10.10 since it cuts the version string from the 4th place. I introduced a more reliable version checking based on splitting the returned version code into MAJOR MINOR and PATCH parts and reassemble the OSG sdk version afterwards.

I replaced the existing CMake code against the following (returning now version 10.10 as expected):

 # Determine the canonical name of the selected Platform SDK
   EXECUTE_PROCESS(COMMAND "/usr/bin/sw_vers" "-productVersion"
                   OUTPUT_VARIABLE OSG_OSX_SDK_NAME
                   OUTPUT_STRIP_TRAILING_WHITESPACE)
   STRING(REPLACE "." ";" MACOS_VERSION_LIST ${OSG_OSX_SDK_NAME})
   LIST(GET MACOS_VERSION_LIST 0 MACOS_VERSION_MAJOR)
   LIST(GET MACOS_VERSION_LIST 1 MACOS_VERSION_MINOR)
   LIST(GET MACOS_VERSION_LIST 2 MACOS_VERSION_PATCH)

   SET(OSG_OSX_SDK_NAME "macosx${MACOS_VERSION_MAJOR}.${MACOS_VERSION_MINOR}")

Also i added the check for the new Version to some more find scripts.

Additionally the nil object in Objective C now seems to be equivalent with a null_ptr that cannot be passed as GLInt anymore. So i switched this in the PixelBufferCocoa.mm to pass a zero instead of nil.
"


git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14528 16af8721-9629-0410-8352-f15c8da7e697
2014-11-24 15:24:31 +00:00
Robert Osfield
e3ba4c82e4 Fixed handling of viewer's Camera
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14525 16af8721-9629-0410-8352-f15c8da7e697
2014-11-24 14:10:40 +00:00
Robert Osfield
ce82cfd25f From Alberto Luaces,"the current code uses the preprocessor for generating the plugin path in
a way that when CMAKE_INSTALL_PREFIX contains something along the lines
of

/usr/x86_64-linux-gnu/

it gets substituted as

/usr/x86_64-1-gnu/

that is, the string is preprocessed again, thereby making changes to
anything that matches any defined symbol, as "linux" in this example
(https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=763816).

Quoting that path directly in CMake scripts solves that problem.
"



git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14521 16af8721-9629-0410-8352-f15c8da7e697
2014-11-21 20:16:13 +00:00
Robert Osfield
9c42d8f0da From Björn Blissing, fix for ambiguous defines in Atomic.cpp when compiling with MinGW and GCC
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14512 16af8721-9629-0410-8352-f15c8da7e697
2014-11-21 10:21:44 +00:00
Robert Osfield
2b4221c211 Copied Contributors file from svn/trunk.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14511 16af8721-9629-0410-8352-f15c8da7e697
2014-11-21 09:28:20 +00:00
Robert Osfield
7d04c3457a From Claus Steuer, "XCode 6, IOs 8.1 SDK Compile fix : There are some undefined texture formats when compiling osg for IOs 8.1 with XCode 6 and OpenGLES2 enabled."
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14509 16af8721-9629-0410-8352-f15c8da7e697
2014-11-20 17:37:50 +00:00
Robert Osfield
166a8b6ccf From Farshid Lashkari, "The obj loader was overriding the existing database path list with the file path of the model, instead of prepending the file path to the path list. The latter seems to be more common behavior for most of the existing loader plugins. Also, the local options weren't actually being used when processing the scene graph for textures. I've attached the fix for both issues."
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14506 16af8721-9629-0410-8352-f15c8da7e697
2014-11-20 16:38:17 +00:00
Robert Osfield
5cc425cf99 From Marc Helbling, "here is a trivial fix in the Inventor plugin. In one code path, the pointer validity is checked after dereferencing a pointer that can be null (image->valid()) instead of calling ref_ptr::valid (image.valid())."
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14504 16af8721-9629-0410-8352-f15c8da7e697
2014-11-20 10:52:20 +00:00
Robert Osfield
f19a63e50d From Marc Helbling, "I've come across scenes that contains geometries with initialized but empty vertex arrays and primitives and that would make some optimizers crash.
The submission therefore only contains a test on the size of the vertex array for the VertexCacheMissVisitor and the VertexAccessOrderVisitor visitors."



git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14502 16af8721-9629-0410-8352-f15c8da7e697
2014-11-20 10:45:03 +00:00
Robert Osfield
506f26d292 From Sukender, "Fix for 3DS reader, which may read wrong triangles. Actually, indices may suffer a 'short int' overflow, in two places."
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14499 16af8721-9629-0410-8352-f15c8da7e697
2014-11-20 09:55:48 +00:00
Robert Osfield
c8d3571efd Fixed segfalt in Texture2DArray copy constructor where it would apply images to an uninitialzed vector.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14497 16af8721-9629-0410-8352-f15c8da7e697
2014-11-20 09:41:22 +00:00
Robert Osfield
1fa34dbbcc From Marc Helbling, "patch adding support for ambient material in the FBX plugin. It's a straightfoward adaptation of the emissive support and has been tested on a proprietary model."
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14496 16af8721-9629-0410-8352-f15c8da7e697
2014-11-20 09:32:40 +00:00
Robert Osfield
3cabbb5a5a Added default setting of build type to Release
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14494 16af8721-9629-0410-8352-f15c8da7e697
2014-11-20 09:31:47 +00:00
Robert Osfield
0c052ce2ed From Pjotr Svetachov, fix for build breakage with giflib 5.0.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14492 16af8721-9629-0410-8352-f15c8da7e697
2014-11-20 09:21:48 +00:00
Robert Osfield
60bafc2050 Fixed contributors names
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14488 16af8721-9629-0410-8352-f15c8da7e697
2014-11-19 17:31:45 +00:00
Robert Osfield
0dd978df7a From Clement Boesch, "Fix remaining bit of Giflib5 usage"
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14487 16af8721-9629-0410-8352-f15c8da7e697
2014-11-19 17:31:00 +00:00
Robert Osfield
0ec0b79d6c From Laurens Voerman, "I found a new way to crach the osgviewer:
osgviewer "ProxyNode { FileNameList { cow.osgt } num_children 1 }".osgs

The proxy node reader wrongly assumes options to be non NULL.

fixed in attached zip:
src\osgWrappers\deprecated-dotosg\osg\ProxyNode.cpp

applies to both the 3.2 branch and svn trunk"


git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14483 16af8721-9629-0410-8352-f15c8da7e697
2014-11-19 11:37:33 +00:00
Robert Osfield
9f0f107c66 Build fixes for ffmpeg LIBAVCODEC_VERSION_MAJOR >= 56
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14463 16af8721-9629-0410-8352-f15c8da7e697
2014-11-04 16:29:37 +00:00
Robert Osfield
cceb63ed12 Fixed MD2 danglng pointer crash.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14412 16af8721-9629-0410-8352-f15c8da7e697
2014-08-19 09:27:44 +00:00
Robert Osfield
e5185937c8 From Ryan Kawicki, "There is an issue where the model insets of a terrex terrain are being removed during the loading process. The issue is described below.
- the issue here is that the plugin is removing group nodes if
      that group node only has one child.  becuase transforms are also
      group nodes, there were cases when the transform would have only
      one child under it and would cause it to remove the translation
      portion.  this would cause all the vertex data to be loaded around
      the last matrix operation, which in our case was the origin (0,0,0).

We work off of OSG 2.8.1 but see that this has not been addressed on latest yet.  I’ve tested this against 2.8.1 and have cleanly applied it to my local repository off of latest."



git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14406 16af8721-9629-0410-8352-f15c8da7e697
2014-08-08 16:42:31 +00:00
Robert Osfield
9221cab9c5 From Tim George, "Currently there is a problem with using a camera with a viewport with a non 0 offset and also using an FBO. The problem is that only area made up of the viewports width and height is drawn based on an offset of 0,0 instead of using the viewports offset.
It is caused by line 991 in RenderStage.cpp:


Code:
fbo_ext->glBlitFramebuffer(
0, 0, static_cast<GLint>(_viewport->width()), static_cast<GLint>(_viewport->height()),
0, 0, static_cast<GLint>(_viewport->width()), static_cast<GLint>(_viewport->height()),
blitMask, GL_NEAREST);



which is not taking into account the viewport x and y when performing the blit. It probably should be:


Code:
fbo_ext->glBlitFramebuffer(
static_cast<GLint>(_viewport->x()), static_cast<GLint>(_viewport->y()),
static_cast<GLint>(_viewport->width()) + static_cast<GLint>(_viewport->x()), static_cast<GLint>(_viewport->height()) + static_cast<GLint>(_viewport->y()),
static_cast<GLint>(_viewport->x()), static_cast<GLint>(_viewport->y()),
static_cast<GLint>(_viewport->width()) + static_cast<GLint>(_viewport->x()), static_cast<GLint>(_viewport->height()) + static_cast<GLint>(_viewport->y()),
blitMask, GL_NEAREST);
"

Note from Robert Osfield, made small tweak to above on merge, changing the width+x to x+width to make it read more naturally.



git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14404 16af8721-9629-0410-8352-f15c8da7e697
2014-08-08 16:34:09 +00:00
Robert Osfield
4b687b7a86 From Marc Helbling, "please find a fix for the vertex pretransform visitor (VertexAccessOrderVisitor).
The issue with current code is that arrays are collected *before* duplicating shared arrays which leads to arrays that are correctly duplicated but that are not reordered.

Also the submitted patch contains a small cleaning in GeometryArrayGathrer as the _useDrawElements variable is not used; it is only set in the GeometryArrayGathrer constructor and VertexAccessOrderVisitor already checks that primitives have indexed type."


git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14402 16af8721-9629-0410-8352-f15c8da7e697
2014-08-08 16:09:38 +00:00
Robert Osfield
f32d30d033 Applied fix to Node::remove*Callback(NodeCallback*) inspired by fix from Glen Waldron that was applied to svn/trunk.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14400 16af8721-9629-0410-8352-f15c8da7e697
2014-08-08 15:45:48 +00:00
Robert Osfield
c931140eaf Added catch for NULL Transform pointers getting into the _transformMap.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14387 16af8721-9629-0410-8352-f15c8da7e697
2014-07-29 15:47:51 +00:00
Robert Osfield
21a2cf6ff1 Removed usage of _appliedProgramObjectSet as it's no longer used by OSG applications and was causing a threading crash.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14379 16af8721-9629-0410-8352-f15c8da7e697
2014-07-22 16:35:28 +00:00
Robert Osfield
3416f91704 Updated version to 3.2.2
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14378 16af8721-9629-0410-8352-f15c8da7e697
2014-07-22 16:34:44 +00:00
Robert Osfield
7126619e40 Added setting of glPixelStore before glTexSubImage2D call.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14373 16af8721-9629-0410-8352-f15c8da7e697
2014-07-21 13:45:57 +00:00
Robert Osfield
12cf202cfc I want to submit a bugfix for a crash occurring in osgText/Glyph.cpp if
the scene tree contains (large) 2D textures from images with STRIDE.

============================================================================
#0  0x00007fffe8ea4350 in __memmove_ssse3 () from /lib64/libc.so.6
#1  0x00007fffe52ced76 in ?? () from /usr/lib64/libnvidia-glcore.so.310.44
#2  0x00007fffe52d8e86 in ?? () from /usr/lib64/libnvidia-glcore.so.310.44
#3  0x00007fffe53dd8be in ?? () from /usr/lib64/libnvidia-glcore.so.310.44
#4  0x00007fffe53c2643 in ?? () from /usr/lib64/libnvidia-glcore.so.310.44
#5  0x00007fffe53c7fdd in ?? () from /usr/lib64/libnvidia-glcore.so.310.44
#6  0x00007fffe53cbabf in ?? () from /usr/lib64/libnvidia-glcore.so.310.44
#7  0x00007fffe53cc1fa in ?? () from /usr/lib64/libnvidia-glcore.so.310.44
#8  0x00007ffff30092fd in osgText::GlyphTexture::apply (this=0x1bb8cf0, state=
    ...)
    at /d43/jaap/dev/jaapOSG/build/OpenSceneGraph3.3.1/src/osgText/Glyph.cpp:234
#9  0x00007ffff56c30b6 in osg::State::applyAttributeOnTexUnit (this=0x125f180,
    unit=0, attribute=0x1bb8cf0, as=...)
    at /d43/jaap/dev/jaapOSG/build/OpenSceneGraph3.3.1/include/osg/State:1713
#10 0x00007ffff56c2f3f in osg::State::applyTextureAttribute (this=0x125f180,
    unit=0, attribute=0x1bb8cf0)
    at /d43/jaap/dev/jaapOSG/build/OpenSceneGraph3.3.1/include/osg/State:411
#11 0x00007ffff30204da in osgText::Text::drawTextWithBackdrop (this=0x1baed70,
    state=..., colorMultiplier=...)
==============================================================================

The crash disappears if I either (1) disable the use of images with stride
in the (public) osgGeo-library, or (2) add the following bugfix to Glyph.cpp.
This combination gives me the confidence that I understand where this problem
originates from, without trying to understand the full OpenGL details.

===============================================================================
@@ -221,7 +223,12 @@
             imageData[i] = 0;
         }

+        glPixelStorei(GL_UNPACK_ALIGNMENT,1);

+        #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
+        glPixelStorei(GL_UNPACK_ROW_LENGTH,getTextureWidth());
+        #endif
+
         // allocate the texture memory.
         glTexImage2D( GL_TEXTURE_2D, 0, GL_ALPHA,
                 getTextureWidth(), getTextureHeight(), 0,
================================================================================

I have copied (and adapted) the added lines above from the same source file,
where they were used in front of a similar call to glTexSubImage2D(.) around
line 515."



git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14371 16af8721-9629-0410-8352-f15c8da7e697
2014-07-21 13:43:10 +00:00
Robert Osfield
ae81ca6b6e Updated ChangeLog and README for release
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14362 16af8721-9629-0410-8352-f15c8da7e697
2014-07-04 11:34:44 +00:00
Robert Osfield
27bfc09c7a Updated version number to 3.2.1 for release
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14361 16af8721-9629-0410-8352-f15c8da7e697
2014-07-04 11:29:02 +00:00
Robert Osfield
ea5857c8d5 Updated RC number
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14359 16af8721-9629-0410-8352-f15c8da7e697
2014-07-04 08:52:29 +00:00
Robert Osfield
fb7f800ba7 Updated release candidate number and ChangeLog for 3.2.1-rc6
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14354 16af8721-9629-0410-8352-f15c8da7e697
2014-07-03 14:20:46 +00:00
Robert Osfield
0ecaf90a7c Updated NEWS in prep for 3.2.1 release
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14353 16af8721-9629-0410-8352-f15c8da7e697
2014-07-03 14:13:01 +00:00
Robert Osfield
32fe2f09d4 Added vertical destructors
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14352 16af8721-9629-0410-8352-f15c8da7e697
2014-07-03 13:06:56 +00:00
Robert Osfield
46c52f2a97 Merged fix from svn/trunk to handlng of file type of nested files within a .osgx, .osgt and .osgb file.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14345 16af8721-9629-0410-8352-f15c8da7e697
2014-07-02 14:14:57 +00:00
Robert Osfield
dfd59cbfe1 Added #include <stdint.h> to address compile issue on some Linux distro's.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14342 16af8721-9629-0410-8352-f15c8da7e697
2014-07-01 07:31:48 +00:00
Robert Osfield
81b32a3d89 Add dds no flip on write option to prevent output of .dds volume from being flipped by the dds plugin.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14340 16af8721-9629-0410-8352-f15c8da7e697
2014-06-30 15:31:39 +00:00
Robert Osfield
98889b7331 Updated ChangeLog and AUTHORS file
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14336 16af8721-9629-0410-8352-f15c8da7e697
2014-06-30 10:22:37 +00:00
Robert Osfield
4fefd87b80 From Mikhail Izmestev, "Attached fix to avoid vector reallocs on push_back in StateGraph::moveStateGraph."
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14335 16af8721-9629-0410-8352-f15c8da7e697
2014-06-30 10:13:22 +00:00
Robert Osfield
586c177db9 Updated ChangeLog and AUTHORS file
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14333 16af8721-9629-0410-8352-f15c8da7e697
2014-06-30 09:13:04 +00:00
Robert Osfield
b138fa8ab7 Updated RC number
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14330 16af8721-9629-0410-8352-f15c8da7e697
2014-06-30 08:55:36 +00:00
Robert Osfield
5aa7acd92b From Pjotr Svetachov, "Here is a small fix for a overflow when editing large 3d volume data."
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14328 16af8721-9629-0410-8352-f15c8da7e697
2014-06-30 08:46:53 +00:00
Robert Osfield
a4a684cb07 Removed space from #include.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14327 16af8721-9629-0410-8352-f15c8da7e697
2014-06-30 08:20:31 +00:00
Robert Osfield
d009dec52f Merged librsvg-2.0>=2.35 version check from svn/trunk.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14325 16af8721-9629-0410-8352-f15c8da7e697
2014-06-30 07:39:16 +00:00
Robert Osfield
9d14c9908e From Alexander Sinditskiy, build fix to allow building against versions older than librsvg-2.36.2
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14324 16af8721-9629-0410-8352-f15c8da7e697
2014-06-30 07:37:09 +00:00
Robert Osfield
cd5e4a999b Removed unused method.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14317 16af8721-9629-0410-8352-f15c8da7e697
2014-06-27 15:55:02 +00:00
Robert Osfield
46e53047bc From Laurens Voerman, "attached is a modified version of src/osgUtil/Tessellator.cpp
current code checks for a Nullpointer and on notify level info or above will inform you with a crash, by dereferencing it."



git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14316 16af8721-9629-0410-8352-f15c8da7e697
2014-06-27 15:48:41 +00:00
Robert Osfield
1d120f7814 Updated AUTHORS file
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14314 16af8721-9629-0410-8352-f15c8da7e697
2014-06-27 15:39:56 +00:00
Robert Osfield
2c25825800 Added a render order sort to the list of Cameras being tested by the *Viewer::generatePointerData(..) method to ensure that the highest Camera gets focus.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14311 16af8721-9629-0410-8352-f15c8da7e697
2014-06-27 15:38:48 +00:00
Robert Osfield
2f83db9442 Added a render order sort to the list of Cameras being tested by the *Viewer::generatePointerData(..) method to ensure that the highest Camera gets focus.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14308 16af8721-9629-0410-8352-f15c8da7e697
2014-06-27 15:30:50 +00:00
Robert Osfield
78a59c33bd Updated AUTHORS file
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14307 16af8721-9629-0410-8352-f15c8da7e697
2014-06-27 15:26:03 +00:00
Robert Osfield
ec8a784d90 Updated ChangeLog for 3.2.1-rc4
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14305 16af8721-9629-0410-8352-f15c8da7e697
2014-06-26 15:54:37 +00:00
Robert Osfield
949d6f20e5 Updated RC number to 4.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14304 16af8721-9629-0410-8352-f15c8da7e697
2014-06-26 15:18:56 +00:00
Robert Osfield
ce51923f87 From Sebastian Messerschmidt, "I've applied a simple fix for the backward animation support in osg::Sequence.
It will simply use the sign of the speed set in the getNextValue. Attached file is against trunk."


git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14301 16af8721-9629-0410-8352-f15c8da7e697
2014-06-26 11:49:58 +00:00
Robert Osfield
1571ac72b7 From Laurens Voerman, "In order to speed up loading large scenes (especially from network disk) I added code to our viewer to setup multiple database-pagers and request the files trough a database-request:
databasePager->setUpThreads(16, 1);

We experienced problems with multiple databasepagers loading files in parallel, when two threads start to load the same file (usually a texture referenced by multiple models). The second thread to add the file to the cache (sometimes) manages to do so while the refcount from the cached object still is zero, causing the object loaded to be destroyed.
Sometimes the second thread manages to ref() the object before Referenced::signalObserversAndDelete does the final recount check, causing a warning:
    "Warning Referenced::signalObserversAndDelete(,,) doing delete with _refCount=1"

With a deleted object added to the scenegraph we get some undesired results, I think the program only crashes if the object was a Node, and just has some untextured surfaces if it was a texture, but I'm not completely sure.

Attached is a modified version of the Registry.cpp, returning the object in cache and let the duplicate loaded object to be destroyed.

A more efficient option would be to add some sort of blocking entry to the objectcache to stop the second thread from reading the file, and just wait until the first thread added it to the cache. If you think that's worthwile we would be happy to implement that version. A bit tricky to implement and test, that's why I submit a simple version that stops my program from crashing.
"


git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14299 16af8721-9629-0410-8352-f15c8da7e697
2014-06-26 11:11:38 +00:00
Robert Osfield
64bef29848 Removed erroneous character
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14297 16af8721-9629-0410-8352-f15c8da7e697
2014-06-26 11:09:21 +00:00
Robert Osfield
fc0c2a76c1 From Farshid Lashkari,
"I noticed that Text3D objects would change there z alignment depending on the alignment mode. I'm not sure if this was intentional or just a simple mistake. My expectation was that the front of the object would always stay aligned to the 0 z-plane, regardless of the alignment mode. I've attached an updated version that retains a consistent z-alignment."
"I just now noticed another issue with Text3D objects. It was not properly computing the bounding box when non-axis aligned rotations were being applied. In this case all corners of the bounding box need to be transformed in order to get the correct containing box. I've attached the updated file."
"The incorrect bounding box problem also applies to regular Text objects. I've attached the fix for that as well as the original Text3D fix."



git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14295 16af8721-9629-0410-8352-f15c8da7e697
2014-06-26 10:53:16 +00:00
Robert Osfield
fb09bd6c12 From Laurens Voerman, "while debugging ImageSequence I had a crash, due to the very large frametimes caused by halting the program. The problem is that when the frame time exceeds the length of the entire image sequence, a looping sequence will try to read it's _imageDataList beyond its size.
fix attached for  src/osg/ImageSequence.cpp"



git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14292 16af8721-9629-0410-8352-f15c8da7e697
2014-06-26 10:24:39 +00:00
Robert Osfield
94e7f4e860 From Laurens Voerman, "while testing databasepager stuff I noticed that the various loaders (osg/ive/osgx) do not pass the current options to the imagePager, therefore the images cannot be found if not in the global OSG_FILE_PATH. Attached is a fix, containing modified versions of
From Robert Osfield, add check to only apply Options object when a valid Option object is assigned.

src\osgPlugins\ive\ImageSequence.cpp
src\osgWrappers\deprecated-dotosg\osg\ImageSequence.cpp
src\osgWrappers\serializers\osg\ImageSequence.cpp"


git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14291 16af8721-9629-0410-8352-f15c8da7e697
2014-06-26 10:05:55 +00:00
Robert Osfield
1ca2ed9729 From Farshid Lashkari, "I've attached a small fix for the ply loader to support Windows style line endings when reading the header."
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14289 16af8721-9629-0410-8352-f15c8da7e697
2014-06-26 09:39:16 +00:00
Robert Osfield
f86acab9b2 From Aurelien Albert, "This submission fix all my problems with reading / writing "osgb" files inside "osga" archive with final archive size > 2 Go, with Windows OS (didn't tested with Linux)"
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14286 16af8721-9629-0410-8352-f15c8da7e697
2014-06-26 09:33:54 +00:00
Robert Osfield
5461ca4b6f From Riccardo Corsi, "there's an inconsistency between the behavior of the method and the
debug message it prints out on the console.

Around line 1040 of Registry.cpp (see code below) the method returns
"simpleFileName" but prints about returning "filename".

In attachment the modified file, based on osg 3.2.0
ricky


<code>
if(fileExists(simpleFileName))
{
    OSG_DEBUG << "FindFileInPath(" << filename << "): returning " <<
filename << std::endl;
    return simpleFileName;
}
</code>
"



git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14284 16af8721-9629-0410-8352-f15c8da7e697
2014-06-25 16:05:53 +00:00
Robert Osfield
0f797078f0 Refactored the way that hole are pruned from the occluder hole list.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14281 16af8721-9629-0410-8352-f15c8da7e697
2014-06-25 15:47:54 +00:00
Robert Osfield
14332e5ca1 From Laurens Voerman, "a minor patch for osgconv to make sure the helptext is printed if you run "osgconv -h" with OSG_NOTIFY_LEVEL set too low.
applys to both trunk and stable branch."


git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14279 16af8721-9629-0410-8352-f15c8da7e697
2014-06-25 11:07:57 +00:00
Robert Osfield
2f8a4c654a From Mikhail Izmestev, "Attached fix to avoid vector usage in StateGraph::prune and reduce heap allocations."
Notes from Robert Osfield, ammended the erase so that it explictly increments the iterator before the erase call.



git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14278 16af8721-9629-0410-8352-f15c8da7e697
2014-06-25 10:45:35 +00:00
Robert Osfield
832fb9798e From Björn Blissing, "I found a minor error in documentation in include/osg/Math.
Function: absolute() had the same description as the function minimum()

I removed the erroneous text."


git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14274 16af8721-9629-0410-8352-f15c8da7e697
2014-06-25 08:21:40 +00:00
Robert Osfield
79b0f8c839 From Björn Blissing, "Fix to support correct shininess and transparency in FBX plugin
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14271 16af8721-9629-0410-8352-f15c8da7e697
2014-06-25 08:17:59 +00:00
Robert Osfield
8d41495014 From Pjotr Svetachov, "There were some modes missing when exporting to .ogst so I added them."
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14270 16af8721-9629-0410-8352-f15c8da7e697
2014-06-24 19:57:45 +00:00
Robert Osfield
fb28e0ffa1 "I've attached a small for the osg ReaderWriter. It was performing a case sensitive comparison to the file extension to determine whether to write the file in ascii or binary. This meant that if the filename was "model.OSGT" it would be treated as binary, instead of ascii. I've updated the plugin to ignore case."
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14268 16af8721-9629-0410-8352-f15c8da7e697
2014-06-24 14:59:04 +00:00
Robert Osfield
cb3ce747ca Fix to merge Geometries.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14266 16af8721-9629-0410-8352-f15c8da7e697
2014-06-24 11:24:48 +00:00
Robert Osfield
a6939bc46f Fixed check against number of vertices
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14263 16af8721-9629-0410-8352-f15c8da7e697
2014-06-16 16:18:02 +00:00
Robert Osfield
773d0a2ddf From Aurelien Albert, "I've got some issues using osgb files within an big osga archive (file size > 2Go).
Issue is described here : http://forum.openscenegraph.org/viewtopic.php?t=13914

Here is a fix, using "std::streampos" standard type for stream positions up to 64bits.
"



git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14260 16af8721-9629-0410-8352-f15c8da7e697
2014-06-16 08:54:51 +00:00
Robert Osfield
1b3dba7860 Removed generation of scroll event on the X11 button release event as X11 was generating both a pair of press/release events for a single scroll when movement.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14256 16af8721-9629-0410-8352-f15c8da7e697
2014-06-12 16:00:20 +00:00
Robert Osfield
f127220582 Added if () blocks to State::convertVertexShaderSourceToOsgBuiltIns() to ensure that only parts of the shader than need replacing are replaced.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.2@14254 16af8721-9629-0410-8352-f15c8da7e697
2014-06-12 15:24:31 +00:00
Robert Osfield
52abe9503f Updated release candidate for 3.2.1-rc3 2014-05-22 14:52:26 +00:00
Robert Osfield
95acbe55b5 Upated ChangeLog and AUTHORS in prep for release candidate 2014-05-22 14:43:30 +00:00
Robert Osfield
3a5d834643 From Sebastian Messershmidt, "There was some small error due to MS non-conformity handling comments correctly." 2014-05-15 14:58:43 +00:00
Robert Osfield
2ab66723d5 From Pjotr Svetachov, "Today I found a bug in the IutputStream class when saving array
attributes in vec3b format. It looks like my compiler takes the wrong
overload and outputs integers instead of characters. The problem is
that vec3b is of type signed char and that is not the same as char (
see http://stackoverflow.com/questions/436513/char-signed-char-char-unsigned-char
) and visual studio 2013 will promote it to integer when choosing an
overload.
It looks like that the InputStream class already takes care of this
issue (if it didn't it would have read everything ok and I would have
not even stumbled upon this bug. :) )"
2014-04-29 13:41:33 +00:00
Robert Osfield
044e20911b From Pjotr Svetachov, "I had the osgvolume example crash on me when loading large volume
datasets due to an overflow in image.cpp after a unneeded cast from
unsigned int to int. Here is a small fix."
2014-04-28 14:58:33 +00:00
Robert Osfield
a256eac9c5 From Jason Beverage, "Here is a fix for a small race condition in osgDB::makeDirectory. It attempts to create all the directories in the given path and stops attempting to make directories when one of them fails. I've added a check to see if the failure occurred b/c the directory was created by another thread or process.
We were running into issues occasionally in osgEarth where multiple threads were writing out files like /1/2/3.jpg and /1/3/4.jpg.  Both threads would try to create the /1 directory and only one of them would succeed.  So the first thread would write out the full /1/2/3.jpg while the second thread wouldn't create the /1/3 directory b/c /1 was already created and the writing of /1/3/4.jpg would fail.
"
2014-04-28 14:57:01 +00:00
Robert Osfield
14b978369e Fixed type error 2014-04-28 11:53:53 +00:00
Robert Osfield
25aeb1dadc From Farshid Lashkari, "I've attached a small fix to the Collada loader which prevents a null pointer access in some cases." 2014-04-24 17:26:44 +00:00
Robert Osfield
762f0819ff In the ::apply method, when the image data need to be re-uploaded, the Texture2DArray checks if the TextureObject can be re-used. The test was made using the constant 1 instead of the real texture depth, so the TextureObject was never re-used. 2014-04-24 17:23:15 +00:00
Robert Osfield
0d30acccf1 Fixed reference invalidation bug. 2014-04-24 10:39:03 +00:00
Robert Osfield
5c73224c36 Fixed comment 2014-04-14 16:16:22 +00:00
Robert Osfield
b65f0043ef Renamed FindFreeType.cmake to FindFreetype.cmake to enable CMake build to pick up on CMake's own FindFreetype.cmake when it's available. 2014-04-13 16:04:25 +00:00
Robert Osfield
283b9d4447 Merged changes from svn/trunk to add the REMOVE_CXX_FLAGS macro 2014-04-13 16:03:17 +00:00
Robert Osfield
2d8b521e33 Disabled warnings that FBX headers are generating that we can't fix 2014-04-09 17:21:26 +00:00
Robert Osfield
a6df790b64 Added extra search files for K/Ubuntu 14.04 new location for freetype headers 2014-04-08 19:44:29 +00:00
Robert Osfield
c0ef8b8264 From Remo Eichenberger, "I have extended the TIFF plugin that allows you to write LZW or JPEG compressed TIFF's. Options are:
tiff_compression = lzw | jpeg"
2014-04-08 12:00:59 +00:00
Robert Osfield
8c0413e293 From Pjotr Svetachov, "We had a small problem converting skeleton animations from fbx to osgt
format. Turned out that the serializer didn't handle bone names with
spaces very well (the 3ds studio max biped for instance has spaces by
default). Here is a small fix for the problem."
2014-04-08 11:17:55 +00:00
Robert Osfield
a3288ea19a From Pjotr Svetachov, previous obj "commit broke compilation under visual studio 2013. To use std::not1 you need to include the functional header. Here is a fix." 2014-04-08 11:07:57 +00:00
Robert Osfield
eeeb18926a Fixed build when using of double BoundingBox/BoundingSphere 2014-04-07 15:04:32 +00:00
Robert Osfield
dcb01cf3e5 From Jan Peciva, "I am sending four fixes to obj plugin:
- materialName used to be not stripped of whitespace, making number of models
fail to load materials; now fixed
- stripping was considering spaces only, thus models using tabs had problems
to load correctly; fixed
- fixed references to textures; they did not performed conversion to native
directory separators
- make d (dissolve) takes precedence over Tr (transparency); there seems to be
a confusion about the Tr item - some claiming 1 to be opaque and 0
transparent, while number of models uses exactly the opposite. d (dissolve),
if present in the model, does not suffer from this confusion, thus using it
instead fixes the problem for many many models.

I put many comments to the file concerning d and Tr item as others may further
investigate. Let me know in the case of any problems."
2014-04-07 14:18:17 +00:00
Robert Osfield
6077e19029 From Marcel Pursche, "The problem is that when OpenThreads is build with the Linux pthreads implementation all threads inherit the processor affinity from their parent thread.
This behavior is also described in the pthreads man page (http://man7.org/linux/man-pages/man3/pthread_create.3.html):

>
> Linux-specific details
> The new thread inherits copies of the calling thread's capability
> sets (see capabilities(7)) and CPU affinity mask (see
> sched_setaffinity(2)).
>

To prevent this behaviour I wrote a patch that explicitly sets the affinity mask to all cores of the system, if no specific affinity was defined with PThread::setProcessorAffinity(unsigned int) .

Thank you!
"
2014-04-07 14:11:11 +00:00
Robert Osfield
34911d071e From Bjorn Blessing, "I got bored of the constant reports of “missing chunk 0xA08A” when reading 3ds-files. After a bit of research I discovered that this property is related to the advanced transparency settings for the material in 3D studio. In this case the falloff parameter. These controls affect the opacity falloff of a transparent material. And the property chooses whether falloff is in or out. I have added the property to the file reader BUT no changes are made to make this property propagate into the osgMaterial. But at least we get rid of this annoying error message." 2014-04-07 14:03:54 +00:00
Robert Osfield
21acda6898 From Paul Martz, "We discussed the issue of GL_RED_SNORM and GL_RG_SNORM some time ago, but the issue was never completely resolved. Please see the attached submission to fix the issue.
osg/GL2Extensions was incorrectly defining GL_RED_SNORM and GL_RG_SNORM as part of the definitions for OpenGL v3.1. However, a quick review of the 3.1 spec indicates that these are not part of the 3.1 standard.

My attached change moves these definitions out of the #ifndef GL_VERSION_3_1 conditional block, and defines them conditionally if not already defined. This allows the DDS plugin to build for GL3.
"
2014-04-07 13:48:11 +00:00
Robert Osfield
cdf9886a9e Improved white space trimming 2014-02-05 11:06:39 +00:00
Robert Osfield
d91c8b81cd Replaced C cast to long with a static_cast<const void*>() to avoid a build error under Mingw 64. 2014-01-31 19:18:22 +00:00
Robert Osfield
5a8aee3ede Updated ChangeLog 2014-01-29 11:08:29 +00:00
Robert Osfield
abefc9d8a8 Fixed MingW build's handling of debug d postfix. 2014-01-28 16:48:27 +00:00
Robert Osfield
8cbee2664f Disabled the compiler invocation at runtime. 2014-01-28 16:47:53 +00:00
Robert Osfield
ebbf2d1653 From Laurens Voerman, "I experienced a crash in Geometry::fixDeprecatedData(), on certain files, and brought the problem down to a very simple test file, attached as test3.zip.
There are two problems:
1> for DrawElementsUShortPrimitiveType (and UInt) the source_pindex still equals -1 and causes a crash
     in DrawElementsUBytePrimitiveType source_pindex is incremented, and in DrawElementsU(Short/Int)PrimitiveType primitiveNum is incremented, but never used

2> The drawelements need to be rewritten as the vertices are reordered.

created a patch for osg stable branch(r14038): attached as Geometry-osg-3.2.zip
and for svn brach(r14044): attached as Geometry_osg_svn.zip"
2014-01-24 17:31:03 +00:00
Robert Osfield
aa81404a41 From Aurelien Albert, "In the "apply" method of osg::FrameBufferObject, the draw buffers are always enabled, even if the target is only "READ_FRAMEBUFFER".
This can lead to inconsistency if you bind a framebuffer with multiple attachments in DRAW mode and then a framebuffer with different attachment count in READ mode (for example to manually "blit" from a FBo to another).

On some ATI cards (at least RADEON HD) this also leads to an "incomplete " FBO status

I've added a test to enable drawbuffers only if target is "DRAW" or "READ_DRAW", this solves my problems on ATI cards."
2014-01-24 17:06:33 +00:00
Robert Osfield
a69d12af10 From Michael Schanne, "small fix for a duplicate OR operand in KdTree.cpp." 2014-01-24 16:45:46 +00:00
Robert Osfield
1102058f31 From Torben Dannahuer, "modified findcollada.cmake which can now detect Boost 1.55 libraries, which are used by Collada in my 3rdParty package" 2014-01-24 16:28:28 +00:00
Robert Osfield
684b4d8bf5 From Torben Dannhauer, VisualStudio 2013 build fixes 2014-01-24 16:24:59 +00:00
Robert Osfield
69fd9d7530 From Marc Helbling, "I am sending a small fix in the PLY pseudo-loader; the extension was checked in plyfile.cpp thus preventing the loading of any .PLY file (extension in uppercase). The extension filtering is already handled by ReaderWriter::acceptsExtension in a case unsensitive way." 2014-01-24 16:02:00 +00:00
Robert Osfield
6ffe11dda5 Fixed warnings 2014-01-23 19:55:35 +00:00
Robert Osfield
a8e7dbd9ce Cleaned up the Qt find package, and made changed the default threading model to SingleThreaded when using Qt5 to avoid crash due to regresssion since Qt4. 2014-01-23 10:09:57 +00:00
Robert Osfield
a2e1dc04bf Added clean up of osg::Program that are applied by the GLObjectsVisitor, which addresses a state leak that creates GL error once the main scene graph is rendered. 2014-01-23 09:41:16 +00:00
Robert Osfield
7b39cbddfd Added GL_TEXTURE_2D_MULTISAMPLE to texture mode list. 2014-01-23 07:59:53 +00:00
Robert Osfield
eaca0d3d3d From Stephan Huber, OSX build fix 2014-01-17 18:22:16 +00:00
Robert Osfield
2665191aed From Kristofer Tingdahl, "the patch I sent to src/osgQt/CMakeModules.txt did not do the work on windows. I have fixed that, and also made it more generic so there is no special handling of qt5.2, but all qt5 are the same.
I have tested this on:

mac/qt5.2
linux/qt5.2
windows/qt5.2, and
mac/qt5.1

All platforms perform as expected.

The previous fix removed the -f flag to the moc-pre-processor, but on windows, it turned out that -f "osgQt/QGraphicsViewer" was needed.

This becomes an include-statement in the file generated by moc which is needed for compiling it. I ask you consider this patch for the trunk and the 3.2 branch.


Secondly, I wonder if it would be possible to apply my patch for FindRSVG.cmake from 22nd November in the 3.2 branch.

In short, the version of librsvg must be equal or higher to 2.35:

PKG_CHECK_MODULES(RSVG librsvg-2.0>=2.35)
"
2014-01-17 14:02:46 +00:00
Robert Osfield
ed2b25e32c From Jordi Torres, "Fixed a typo in ReaderWriterCURL::ReaderWriterCURL() changed Psuedo for Pseudo." 2014-01-17 13:53:54 +00:00
Robert Osfield
acdebc99bc From Farshid Lashkari, "I've attached a fix for the Collada loader that prevents a crash with some files containing textures. I also converted an OSG_NOTICE to OSG_INFO to be consistent with other log messages within the loader." 2014-01-08 10:32:58 +00:00
Robert Osfield
574b3eb573 Removed more odd characters 2014-01-08 10:31:24 +00:00
Robert Osfield
d32d406019 Removed more odd characters 2014-01-08 10:28:11 +00:00
Robert Osfield
8b3a85e6bc Removed odd characters 2014-01-08 10:24:32 +00:00
Robert Osfield
91660974e2 Removed execute permissions using svn propdel svn:executable file 2014-01-07 16:43:49 +00:00
Robert Osfield
0f547585d3 From Farshid Lashkari, "I've attached a small change to the DAE writer to support writing out unknown transform types. It will essentially treat it as a matrix transform, using the the local to world matrix value." 2014-01-07 16:29:20 +00:00
Robert Osfield
3ba5f22604 From Sebastian Messerschmidt, "Original shader was not running on various NVidia cards due to old syntax in shader." 2014-01-07 16:16:25 +00:00
Robert Osfield
64707b12f2 Updated SO_VERSION of OpenThreads to avoid conflicts with Debian increments to the SO version they have bumped for OpenThreads 2014-01-07 11:02:39 +00:00
Robert Osfield
7da5ae26d0 Added State::getMaxTextureCoords() and State::getMaxTextureUnits() inline methods. 2014-01-07 11:01:27 +00:00
Robert Osfield
485776bf18 Renamed the OSGSIM cmake variable to OSGSIM_LIBRARY to be consistent with the rest of the variables. 2014-01-06 10:23:31 +00:00
Robert Osfield
3eddec871a From Kristofer Tingdahl, "the syntax of the moc executable has changed between 5.1.1 and 5.2.0 versions of qt (see below). The difference is that the <file> argument has become mandatory after the -f option.
Hence, moc will complain when osg throws in a -f without anything after it. Hence I propose removing the -f on Qt5 builds. I have tested building without -f on both qt520 and qt511, and that works well.

The attached src/osgQt/CMakeLists.txt that can be patched into 3.2 safely. For the trunk, I would consider dropping the check on the version, and simply remove the option on qt5. I have tested that on qt5.1.1, and that worked fine. Question is however if it works on qt5.0. Probably it does, so the question is simplicity of CMakeList.txt vs safety."
2013-12-19 17:13:23 +00:00
Robert Osfield
f8f04cb04c From Mike Krus, compile fix to enable compiling across a wider set of versions. 2013-12-06 09:36:02 +00:00
Robert Osfield
4f11db1653 From Stephan Huber, workaround for Clang bug under Apple 2013-11-22 10:33:57 +00:00
Robert Osfield
63bd3be9cd Warning fixes 2013-11-22 10:27:20 +00:00
Robert Osfield
4ca088dcf9 Clean up of line endings 2013-11-22 10:10:14 +00:00
Robert Osfield
3ef97ddeea From Stephan Huber, "attached you’ll find some minor ios-fixes/-enhancements
* force _OPENTHREADS_ATOMIC_USE_BSD_ATOMIC for IOS device + simulator as the test does not pick the right implementation
* fixed a small compile-bug for iphone-example
* added a check to prevent multiple realization of a GraphicsWindowIOS-object
"
2013-11-21 14:09:20 +00:00
Robert Osfield
31c54aa3e4 From Farshid Lashkari, "I recently encountered an issue attempting to load an IVE file generated by an older version of OSG. The file contained dxt1 compressed image data with mipmaps. The loaded model would cause crashes when passing the mipmap data to glCompressedTexImage2D. It seems that the size of the data array within the IVE file did not match the computed size from Image::getTotalSizeInBytesIncludingMipmaps(). This essentially made the mipmap offsets invalid within the Image object.
I'm not sure if the IVE was simply generated incorrectly, or if the Image::getTotalSizeInBytesIncludingMipmaps() was modified since the file was generated. Either way, I added a simple check in the IVE loader so that it clears the mipmap offsets if the actual data size does not match the computed data size. This seems like a safe fallback since the mipmap data can be automatically generated, and it fixes the problem in my case.

Also, while looking into this issue, I noticed that the osgDB::InputStream class applies the serialized image allocation mode. However, since the serializer is allocating the image data itself, it seems like it should force the allocation mode to USE_NEW_DELETE.
"
2013-11-21 13:58:36 +00:00
Robert Osfield
76c45c7731 Changed std::max to osg::minimum to addres build error under VS2013. 2013-11-21 11:00:50 +00:00
Robert Osfield
5efce09451 Removed -fpermissive flag from GCC build, and fixed warning 2013-10-25 15:48:15 +00:00
Robert Osfield
3f8e6d0a74 Added explict setting of the PolygonMode to over the distion mesh being toggled to wireframe. 2013-10-25 15:47:41 +00:00
Robert Osfield
9433947d2a Fixed warning 2013-10-24 20:22:05 +00:00
Robert Osfield
6f9b82142a Removed deprecated glib call 2013-10-24 19:56:14 +00:00
Robert Osfield
1dcc2555e7 Fixed FileInfo self initialization bug 2013-10-24 19:31:41 +00:00
Robert Osfield
27f9021df7 Fixed warnings 2013-10-22 16:28:03 +00:00
Robert Osfield
9af08d6715 From Colin McDonald, two submissions merged from svn/trunk:
"The osgb file reader uses seek to position within the file.
But the nested stream implementation for osga archive files doesn't
support seeking.  So osgb files can't currently be used in an osga
archive e.g. if osgdem is used to output a osgb format database it
can't be packaged in an archive file, in the same manner that ive
files could.

I've added seek support to the osga nested stream implementation."


"The osgt/osgb file formats output a scenegraph node with the type
set to "SCENE" in the file header.  But if the file is stored and
then extracted again from an osga archive this header info is lost,
and the resulting file is just an "OBJECT".  Possibly other plugin
operations would have the same effect.  The osgt/osgb plugin won't
then return the scenegraph contents.

I have updated the osgt/osgb plugin to return a node from an "OBJECT"
file."
2013-10-22 11:33:45 +00:00
Robert Osfield
5c4800c774 Fixed handling of in scene graph osg::Program being overriden by shader composition. 2013-10-22 11:17:29 +00:00
Robert Osfield
dfd8594042 From Robert Milharcic, workaround for ShaderComposer clean up bug. 2013-10-21 17:44:24 +00:00
Robert Osfield
be2d80abca Build fixes for clang 2013-10-21 09:56:57 +00:00
Robert Osfield
ca8f3d5f8a From Farshid Lashkari, "previously discussed change to the dae loader which applies the node ID as a "dae_node_id" user value." 2013-10-18 09:57:53 +00:00
Robert Osfield
790c0091e6 From Vladimir Chebeav, fix for removal of nested callbacks 2013-10-18 08:37:19 +00:00
Robert Osfield
ce58131cfc From Konstantin Matveyev, "Multiple light fix in FBX-importer" 2013-10-18 07:54:59 +00:00
Robert Osfield
309da2fe07 From Colin McDonald, "Added some missing updates to the serializer static build support." 2013-10-18 07:52:00 +00:00
Robert Osfield
97d706c640 Build fix 2013-10-17 18:34:16 +00:00
Robert Osfield
f14f58c486 Fix for error in getting the uniform block max name length, fix suggested by Christopher Fennell. 2013-10-17 18:29:38 +00:00
Robert Osfield
7c9cbc5ff9 From Pjotr Svetachov, "With the new osg::Geometry the binding for arrays now default to undefined. This breaks previously working code in osgAnimation::RigTransformHardware where the arrays got an undefined bounding and because of this the bone indices and weights were not loaded by the shader. Here is a little patch to fix this." 2013-10-10 20:42:21 +00:00
Robert Osfield
2a70ea9f64 Updated rc number 2013-10-07 10:40:10 +00:00
Robert Osfield
2f71509ebf From Stephan Huber, "attached you’ll find a bunch of fixes + enhancements for iOS and OS X based on current trunk. I incorporated + tested the submission from Colin Cochran, so his submission is not needed anymore.
* fixed a bug with multi-touch and touch-id-generation on iOS and OS X. (will fix a bug reported by Colin Cochran, without ditching the existing logic)
* removed unnecessary warning-flagss when generating xcode-projects via cmake, will enable the usage of OSG_AGGRESSIVE_WARNING_FLAGS
* added support for 10.9 (OS X)
* new cmake-variable: IPHONE_VERSION_MIN, this will set the deployment-target (previously hard-coded) If you set the IPHONE_VERSION_MIN to something like 7.0 osg gets compiled also for 64bit (amd64)
* cmake defaults now to the clang compiler if IPHONE_VERSION_MIN > 4.2
* cmake now sets some xcode-settings so the compiler uses the c++98-standard (clang defaults to c++11, w/o this I got a lot of linking errors)
* removed include-dir for avfoundation-plugin as not needed on OSX/IOS.
* enhanced the ios-example, will now show multitouch-information on a hud (similar to the  osgmultitouch-example), and more importantly, will compile + link out of the box
* small enhancements for the osc-device-plugin (send only one msg for MOVE/DRAG, even if multiple msgs/event is enabled)
* better memory-handling for the zeroconf-plugin
* fixed a possible bug in the rest-http-plugin when receiving mouse-events.
* incorporated a fix from Colin Cochran "forwarded touch events are not transformed into the GL UIView“
"
2013-10-07 10:38:58 +00:00
Robert Osfield
320c51aa96 Updated Controbutors to fix errors 2013-10-03 16:13:54 +00:00
Robert Osfield
8de7ad3fa3 Updated AUTHORS and ChangeLog for 3.2.1-rc1 2013-10-03 15:40:08 +00:00
Robert Osfield
316726445d Updated versions in prep for 3.2.1-rc1 2013-10-03 15:29:26 +00:00
Robert Osfield
eac772a841 Updated AUTHORS for for rc 2013-10-03 15:24:07 +00:00
Robert Osfield
f2428e961f From Dmitry Marakasov, "These are FreeBSD bits for src/osgPlugins/osc/osc/OscHostEndianness.h,
required to build newever OSG on this OS. Also corrects file name
in the error message - I was confused not to find OSCHostEndianness.h
after I've got this error.

Tested by successfully building OSG 3.2.0 with this patch on FreeBSD
9.1."
2013-10-02 11:29:56 +00:00
Robert Osfield
d636e89f9a From Björn Hein, "it seems that for generating "per vertex normals" as stated in the
comment, two of them are missing. This results in wrong display of
STL-files regarding normals. Following simple fix seems to work:

Index: ReaderWriterSTL.cpp
===================================================================
--- ReaderWriterSTL.cpp    (Revision 13797)
+++ ReaderWriterSTL.cpp    (Arbeitskopie)
@@ -108,6 +108,8 @@
                     ++itr)
                 {
                     perVertexNormals->push_back(*itr);
+                    perVertexNormals->push_back(*itr);
+                    perVertexNormals->push_back(*itr);
                 }

                 geom->setNormalArray(perVertexNormals.get(),
osg::Array::BIND_PER_VERTEX);
"
2013-10-02 11:09:22 +00:00
Robert Osfield
cb67c10b5f From Björn Blissing, "I propose making the following outputs a little bit more silent. In my mind it would suffice with OSG_DEBUG (compared to OSG_NOTICE) for these information messages." 2013-10-01 16:20:18 +00:00
Robert Osfield
7990effc06 From Christopher Baker, submitted by Alberto Luacas, "there is a bug report in the Ubuntu tracker that points to a bug when
loading multiple VRML files in parallel.  Christopher R. Baker has
detected this bug and crafted a patch.  In addition, libcoin has to be
also built with the "--enable-threadsafe" option.

I copy here his report, extracted from
(https://bugs.launchpad.net/ubuntu/+source/openscenegraph/+bug/1211993)
and attach his fix.  All credit is due to him:

«
There are three instances of a classical method-local-static
multithreaded initialization bug in the Inventor plugin for OSG that
trigger various memory faults when reading multiple VRML files in
parallel via osgDB::readNodeFile. These bugs are of the form:

static std::map<Stuff,OtherStuff> myHandyMap;
static bool once = true;
if(once) { ...fill myHandyMap; once = false }
... use myHandyMap;

To repeat: try loading multiple VRML files from multiple threads. The
liklihood of the bug depends on many factors, but my application, which
parallel-loads some dozens of small (<100K) VRML files on startup,
triggers this problem 25% of the time or more.

The attached patch (inventor-plugin-multithread.patch) rectifies this
problem by:

1 - Inheriting MyHandyMap from std::map, then
2 - Moving the map initialization into the derived constructor, which
3 - Is intrinsically protected from multithread issues by g++ (and is
part of the C++ standard), unless you pass -fno-threadsafe-statics,
which is strongly discouraged by the man page.
»
"
2013-10-01 09:37:54 +00:00
Robert Osfield
8d2c3db14c From Adrien Grandemange, "On Windows 7 and 8, mouse messages are generated in addition to touch messages, which leads to duplicate PUSH, DRAG and RELEASE events in OSG. Besides, the mouse and touch messages referring to the same user input are not necessarily sent at the same time, due to gesture translation done by Windows by default, such as double-tap => double-click and long-push => right-click.
The delay between the 2 types of messages is more noticeable on Windows 8 and leads to serious disruptions in our application.

Mouse messages generated by touch input are only present for legacy support. I think they should be filtered out by OSG (real click events originating from a physical mouse will of course still go through).

This is what this patch does, according to this suggestion: http://msdn.microsoft.com/en-us/library/dd693088%28v=VS.85%29.aspx (third issue in this page)."
2013-10-01 09:11:23 +00:00
Robert Osfield
04ea3aa6a2 From Thomas Hogarth, "Attached is a small build fix for PointSprite when compiling under GLES2 (r13788)
GL_POINT_SPRITE_OES does not exist in GLES2, instead you just draw using GL_POINTS then use gl_PointSize in a vertex shader to set the size."
2013-10-01 09:05:42 +00:00
Robert Osfield
d30a94bf4c 2013-09-30 18:32:44 +00:00
Robert Osfield
8ff77c10f9 From Farshid Lashkari, "I have a scene that makes heavy use of the StateSet::compare method and my profiler showed that a lot of time was being spent inside it. I made a small change to the method so that it performs a quick size comparison between the attribute/mode lists and bin mode before iterating through all the attributes. This made a noticeable improvement in my scene. I've attached the change." 2013-09-30 18:16:08 +00:00
Robert Osfield
76edd07195 Refactored the epsilon code to use the same one now used in svn/trunk. 2013-09-30 10:45:24 +00:00
Robert Osfield
0ab211cb7c Removed unnceccesary setNumChildrenRequiringUpdateTraversal from VolumeTile constructor. 2013-09-20 15:43:22 +00:00
Robert Osfield
0cd6a935e0 From Giuseppe Donvito, "I'm using OSG 320 and I need to flush a DDS 3D texture on disk.
I found a bug on DDS ReaderWriter that generates a false positive on a guard for the size check on writing operation. This is due to a wrong imageSize computation that uses img->getImageSizeInBytes() method instead of img->getTotalSizeInBytes(), that actually ignores the r() dimension, contrariwise taken into account by the function ComputeImageSizeInBytes() later.

The line 1062 on file ReaderWriterDDS.cpp should be fixed with:
[code]unsigned int imageSize = img->getTotalSizeInBytes();[/code]"
2013-09-10 15:18:34 +00:00
Robert Osfield
cab0f50371 From Giuseppe Donvito, Fixed typo of "CLEAR_GLOBAL_STATESET = 0x16," to indended "CLEAR_GLOBAL_STATESET = "0x10". 2013-09-10 13:29:28 +00:00
Robert Osfield
c62a57c006 From Colin Cochran, OES support for point sprites 2013-09-09 14:58:08 +00:00
Robert Osfield
fefe87ec13 osg uses osg::FBOExtensions to check if Frame Buffer Objects are
available.  But this just checks if the fbo functions can be called.
It doesn't check if the OpenGL renderer supports fbos.  For indirect
rendering on linux the client side capability may be different from
the display server, which can lead to mipmapped textures failing to
render.  I've added a fbo extension check.
2013-09-09 13:33:11 +00:00
Robert Osfield
8fd8036e33 From Ulrich Hertlein, "Patch for FindAVFoundation to work with OS X 10.9" 2013-09-09 12:44:32 +00:00
Robert Osfield
f653048d5f From Wang Rui, "Some developers report that the osgviewerMFC example is broken in 3.2, in which depth test is not enabled by default so all models loaded look awkward. I submit this patch to make it work again. I haven't gone deep to check why previous example goes wrong in newer version but I believe the problem was because the newly created camera object missed some important global statesets before set as the main camera." 2013-09-09 12:37:55 +00:00
Robert Osfield
caf56902c3 From Laurens Voerman, "two minor fixes, both in a CMakeList.txt file,
1> osgmultiplemovies example does not use SDL so needs no link to SDL

2> Added header files to "Plugins osg" project, so visual studio can find the source of
   OSG_WARN <<  "AsciiInputIterator::readProperty(): Unmatched property "
"
2013-09-09 12:33:20 +00:00
Robert Osfield
48498a1517 From Colin McDonald, "Attached are some fixes to build osg using the Solaris Studio compiler.
I've also checked the modified files still build ok with other
compilers (Linux gcc, Windows Visual Studio).

osgDB/OutputStream.cpp and osgPlugins/lws/SceneLoader.cpp require
stdlib.h for atoi use.

In osg/Uniform.cpp the compiler complains that base_class is unknown
unless I add a class name qualifier.

Not a build fix, but I spotted a typo in osgUtil/SceneView."
2013-09-05 10:23:24 +00:00
Robert Osfield
b86e644542 From Laurens Voerman, "like the "Bug in ProxyNode serializer" Farshid Lashkari found (svn submit 13754) the PagedLOD serializer attempts to read begin and and brackets.
Fix is identical (don't read brackets when num_chidren is zero) and applies both to trunk and 3.2 branch."
2013-09-05 10:08:06 +00:00
Robert Osfield
97091aa96c Fixed warnings 2013-09-05 10:05:05 +00:00
Robert Osfield
9574f4c087 From Alberto Luaces, "current versions of ffmpeg render «url_feof» macro as obsolete. The fix
is very simple and it is contained in the attached file."
2013-09-05 08:41:58 +00:00
Robert Osfield
a5002123a9 From Farshid Lashkari, "The ProxyNode serializer was not correctly reading the "Children" field. It conditionally writes the begin/end brackets, depending on whether it has children. However, during input it unconditionally attempts to read the begin/end brackets. I've modified the code to only read the brackets if it has children." 2013-09-02 10:57:50 +00:00
Robert Osfield
bddb6e8eaa Merged from svn/trunk, fixed double copy in StackedTransform constructor 2013-09-02 09:13:20 +00:00
Robert Osfield
41b1fcffe6 From Aurelien Albert, "I've go some problem with the method "State_Utils::replace" : if the original_phrase is empty, it leads to an infinite loop.
Here is a path to prevent this."
2013-08-05 12:00:59 +00:00
Robert Osfield
044f16b8b9 From Anish Thomas, added catch for to an empty DrawElementsUInt creation. 2013-08-01 11:25:07 +00:00
Robert Osfield
d581806619 From Ulrich Hertlein, "Based on the exchange on osg-users I went ahead and reworked shp/XBaseParser to avoid
weird behaviour (closing stdin) and leaking file descriptors, as well as some const-ness."
2013-08-01 10:28:15 +00:00
Robert Osfield
48364df671 From Sebastian Messerschmidt, "Seems like your re-factoring didn't really produces the correct results.
You can check with the tester2.flt provided earlier and check with the result image.
I double checked this with OpenFlight creator, and it seems the yaw is broken.

With my initial quaternion version is seems correct and if I change the


float cos_yaw = cosf(osg::inDegrees(yaw));
float sin_yaw = sinf(osg::inDegrees(yaw));

to be
float cos_yaw = cosf(osg::inDegrees(-yaw));
float sin_yaw = sinf(osg::inDegrees(-yaw));

it seems to work as well."
2013-08-01 10:04:07 +00:00
Robert Osfield
981ed52356 From Tom Jolley, "I found a couple more bugs after closely looking at the small piece of deprecated geometry in my model. There were problems with more than one primitive in a couple places. The first was the number of vertices were not being accumulated for DrawArraysPrimitiveType (caused another crash). The second is I had to move target_vindex and source_pindex before the PrimitiveSetList loop so they don't get reset on the next primitive (otherwise you end up with a lot of zeros in per vertex lists)." 2013-08-01 10:00:31 +00:00
Robert Osfield
9a90ddd2d9 From Aurelien Albert, "Here is the code to get access to OpenGL handle of an osg::FrameBufferObject" 2013-07-31 07:11:05 +00:00
Robert Osfield
123058965c From Tom Jolly, "I ran across this error reading one of our older files. An iterator was being changed inside a loop that caused a crash." 2013-07-31 06:56:28 +00:00
Robert Osfield
1364329fc8 From Sergey Kurdakov, merged from svn/trunk fix for GLES2 runtime invalid enumerant warning. 2013-07-31 06:43:46 +00:00
Robert Osfield
07550df2f2 From svn/trunk merged "Changed default cull mask to match the left cull mask so that mono rendering of presentations with left/right stereo images/movies works fine." 2013-07-30 06:39:36 +00:00
Robert Osfield
45f463ccd2 Removed trailing spaces 2013-07-30 06:39:01 +00:00
Robert Osfield
789d435abe Updated ChangeLog 2013-07-24 17:29:50 +00:00
Robert Osfield
6b8db67c91 Changed default of serialize draw to OFF 2013-07-24 17:27:14 +00:00
Robert Osfield
2975f9c20a Updated README for 3.2 release 2013-07-24 14:23:37 +00:00
Robert Osfield
ebc855cf50 Removed release candidate number in prep for 3.2.0 release 2013-07-24 14:11:55 +00:00
Robert Osfield
c9547497cc Fixed typo 2013-07-24 14:05:08 +00:00
Robert Osfield
75d32b3af6 Updated ChangeLog 2013-07-24 13:29:22 +00:00
Robert Osfield
a844a278ab Added GL2Extensions::isDrawBuffersSupported() and usage with FrameBufferObject.cpp to prevent invalid MRT usage causing crash under GLES2 2013-07-24 13:01:38 +00:00
Robert Osfield
94dcfb4ec2 Updated NEWS for 3.2 release 2013-07-24 12:50:34 +00:00
Robert Osfield
8528449dff Fixed warning 2013-07-24 12:49:11 +00:00
Robert Osfield
8d7fd88d5f Added getCallbacks() methods 2013-07-24 12:17:10 +00:00
Robert Osfield
28dd1cf8a8 Updated ChangeLog, AUTHORS file, Release Candidate Number and SO version number for 3.2-rc4 2013-07-23 18:34:01 +00:00
Robert Osfield
14de2266ba From Rocco Martino, build fix for compiling against ffmpeg/trunk 2013-07-23 18:11:31 +00:00
Robert Osfield
cc02695822 Disabled the check for Asio for Windows 2013-07-23 15:36:45 +00:00
Robert Osfield
2c442c9e9a Added NOT ANDROID to force use of posix API when building for Android under Windows 2013-07-23 15:28:34 +00:00
Robert Osfield
ca44b9cbce Added lazy setting of the UserDataContainer to avoid unncessarily create a UserDataContain when an empty description list is passed to Node::setDescriptions(..) 2013-07-23 10:24:27 +00:00
Robert Osfield
0483912e32 Fixed crash when open(..) returns an error. 2013-07-23 09:54:28 +00:00
Robert Osfield
21b5109089 Updated ChangeLog and AUTHORS file for rc3 2013-07-23 05:45:34 +00:00
Robert Osfield
549e20fbe7 Fixed svn source to that it's relase candidates and final release made from the OpenSceneGraph-3.2 branch 2013-07-23 05:41:40 +00:00
Robert Osfield
b4b7a13063 From Torben Dannhauer, "Please find attached further changes to make library auto detection
functional again for some libraries:

    Find3rdPa..: Fix to find libxml2
    FindCollada: Rearranged to handle different MSVC versions more effective.
    This file is already prepared for the upcoming VS 2013.
    FindNVTT: introduced management of debug libraries (also auto detected).
    "
2013-07-23 05:25:45 +00:00
Robert Osfield
8b58890975 Updatected rc number 2, ChangeLog and AUTHORS file for OSG-3.2-rc2 release 2013-07-22 13:40:53 +00:00
Robert Osfield
871521cfea From Andreas Ekstrand, "Attached is a small modification of the Collada writer that protects from crashes due to valArray being NULL in some situations." 2013-07-22 13:31:32 +00:00
Robert Osfield
f19018a03d Added FRAME_BUFFER_OBJECT enum 2013-07-22 10:07:21 +00:00
Robert Osfield
2709a5e946 From Christian Ruzicka, "with the current touch implementation on iOS the touches are not forwarded to parent views because the base implementation is not called. Also see the "Best Practices" in the iOS documentation for event handling:
http://developer.apple.com/library/ios/#documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/multitouch_background/multitouch_background.html

"If you handle events in a subclass of any other UIKit responder class:
- You do not have to implement all of the event handling methods.
- In the methods you do implement, be sure to call the superclass implementation. For example, [super touchesBegan:touches withEvent:event]."

I added the missing lines and tested it with OSG 3.1.9 and iOS SDK 6.1."
2013-07-19 21:03:28 +00:00
Robert Osfield
52d5d80508 Added default setting of BIND_PER_VERTEX when applying Geometry::setTexCoordArray() 2013-07-19 20:59:14 +00:00
Robert Osfield
86e465d5d8 Updated OpenThreads version to be in sync with OSG version. 2013-07-19 17:00:08 +00:00
Robert Osfield
50ed5ebd1c Branch OpenSceneGraph-3.2 2013-07-19 14:08:08 +00:00
1005 changed files with 19074 additions and 97261 deletions

View File

@@ -1,6 +1,6 @@
OpenSceneGraph Library 3.4.0
OpenSceneGraph Library 3.2.2
550 Contributors:
529 Contributors:
Firstname Surname
-----------------
@@ -8,8 +8,8 @@ Robert Osfield
Don Burns
Stephan Huber
Paul Martz
Farshid Lashkari
Mathias Fr<46>hlich
Farshid Lashkari
Marco Jez
Wang Rui
Jean-S<>bastien Guay
@@ -30,41 +30,40 @@ Colin McDonald
Trajce Nikolov
Tim Moore
Martin Lavery
Mattias Helsing
Tree
Jason Beverage
Pjotr Svetachov
Luigi Calori
Mike Wittman
Jan Peciva
Jason Beverage
Chris Hanson
Alberto Luaces
Roland Smeenk
Roger James
Mattias Helsing
Jeremy Moles
Jan Peciva
Alberto Luaces
J.P. Delport
Andy Skinner
Magnus Kessler
David Fries
Andy Skinner
Tom Jolley
Paul Melis
Luc Frauciel
Aurelien Albert
Pavel Moloshtan
Brad Christiansen
Terry Welsh
Olaf Flebbe
Mathieu Marache
Lionel Lagarde
Jason Daly
Aurelien Albert
Art Tevs
Philip Lowman
Per Fahlberg
Norman Vine
Jannik Heller
Chris Denham
Lionel Lagarde
Terry Welsh
Serge Lages
Romano Jos<6F> Magacho da Silva
Pjotr Svetachov
Chris Denham
Alberto Farre
Torben Dannhauer
Sherman Wilcox
@@ -76,8 +75,6 @@ Adrian Egli
Ruben Lopez
Randall Hopper
Jan Ciger
Sebastian Messerschmidt
Kristofer Tingdahl
Gideon May
Don Tidrow
Stephane Lamoliatte
@@ -87,18 +84,17 @@ Joakim Simonsson
David Spilling
Daniel Sj<53>lie
Bryan Thrall
Rafa Gaitan
Mike Connell
Fabien Lavignotte
Andreas Ekstrand
Thomas Hogarth
Riccardo Corsi
Mike Connell
Melchior Franz
Konstantin Matveyev
Johannes Baeuerle
Thomas Hogarth
Sebastian Messerschmidt
Rafa Gaitan
Neil Hughes
Martin Beckett
Marc Helbling
Joran Jessurun
Gino van den Bergen
Frederic Marmond
@@ -117,12 +113,10 @@ Martin Aumueller
Mario Valle
Lukasz Izdebski
Jorge Izquierdo Ciges
Jordi Torres
Gordon Tomlinson
Frederic Bouvier
Carlo Camporesi
Ben Discoe
Alexander Sinditskiy
Thibault Genessay
Sasa Bistrovic
Ravi Mathur
@@ -132,9 +126,11 @@ Mikhail Izmestev
Markus Trenkwalder
Loic Dachary
Joseph Steel
Jordi Torres
John Shue
Brad Colbert
Bj<EFBFBD>rn Blissing
Alexander Sinditskiy
Vivek Rajan
Uwe Woessner
Tony Horrobin
@@ -151,11 +147,11 @@ Neil Salter
Mihai Radu
Michael Hartman
Martins Innus
Marc Helbling
Maciej Krol
Lilin Xiong
Leandro Motta Barros
Johan Nouvel
Javier Taibo
Hartwig Wiesmann
Donn Mielcarek
Corbin Holtz
@@ -164,10 +160,12 @@ Alexander Irion
Toshiyuki Takahei
Sebastien Grignard
Rudolf Wiedemann
Robert Milharcic
Maria Ten
Liang Aibin
Kristofer Tingdahl
Konstantin Matveyev
Katharina Plugge
Julien Valentin
John Vidar Larring
John Kelso
John Ivar
@@ -181,25 +179,20 @@ Bruce Clay
Bradley Anderegg
Andreas Goebel
Alok Priyadarshi
Ali Botorabi
Alberto Barbati
Alan Dickinson
Vladimir Shabanov
Vladimir Chebaev
Tugkan Calapoglu
Tim Daoust
Sylvain Marie
Sohey Yamamoto
Sergey Leontyev
Santosh Gaikwad
Ryan Pavlik
Robert Milharcic
Rene Molenaar
Piotr Domagalski
Phil Atkin
Pawel Ksiezopolski
Nathan Monteleone
Miha Rav<61>elj
Miguel Escriva
Mattias Linde
Mark Sciabica
@@ -209,14 +202,11 @@ Lars Nilsson
Konstantin Sinitsyn
Ken Sewell
Julian Ortiz
Julen Garcia
John Kaniarz
Johannes Scholz
Jim Vaughan
Jeremy Bell
Jaromir Vitek
James French
Jaap Glas
Guillaume Millet
Gary Quinn
Garrett Potts
@@ -227,16 +217,13 @@ Donald Cipperly
Don Leich
Dietmar Funck
Colin Cochran
Christian Ruzicka
Christian Buchner
Charles Cole
Blake Williams
Bj<EFBFBD>rn Hein
Aur<EFBFBD>lien Chatelain
Antoine Hue
Andrew Bettison
Andreas Henne
Anders Backman
Ali Botorabi
Alexander Wiebel
Alessandro Terenzi
Zach Deedler
@@ -246,18 +233,18 @@ Warren Macchi
Vincent Bourdier
Terrex
Tassilo Glander
Sylvain Marie
Steve Lunsford
Stephane Simon
Stephan Eilemann
Stanislav Blinov
Sergey Polischuk
Roni Zanolli
Raymond de Vries
Ralf Kern
Piotr Gwiazdowski
Pierre Haritchabalet
Philippe Renon
Perry Miller
Pawel Ksiezopolski
Paul Palumbo
Paul Obermeier
Patrick Neary
@@ -265,7 +252,6 @@ Nguyen Van Truong
Nathan Cournia
Morten Haukness
Morn<EFBFBD> Pistorius
Michael Mc Donnell
Michael Henheffer
Michael Guerrero
Maya Leonard
@@ -282,13 +268,18 @@ Marcel Pursche
Lilith Bryant
Kevin Moiule
Keith Steffen
Julien Valentin
Julen Garcia
Joseph Winston
John Aughey
Johannes Scholz
Joachim Pouderoux
Jean-Christophe Lombardo
Javier Taibo
Jannik Heller
Jan Klimke
James Turner
James Moliere
Jaap Glas
Igor Kravtchenko
Himar Carmona
He Sicong
@@ -298,14 +289,12 @@ Guillaume Taze
Guillaume Chouvenc
Giuseppe Donvito
Gill Peacegood
Giampaolo Vigan<61>
Gerrick Bivins
George Tarantilis
Ferdi Smit
Eric Buehler
Eduardo Poyart
Edgar Ellis
Dmitry Marakasov
Dimi Christopoulos
Diane Delall<6C>e
David Longest
@@ -314,19 +303,18 @@ Daniel Trstenjak
Craig Bosma
Claus Scheiblauer
Christophe Loustaunau
Christian Kehl
Christian Ruzicka
Bradley Baker Searles
Brad Anderegg
Bj<EFBFBD>rn Hein
Aric Aumann
Andrew Sampson
Andrew Lorino
Alexandre Amalric
Aitor Moreno
Zbigniew Sroczynski
Yuri Vilmanis
Xin Li
Wang Lam
Wand Rui
Walter J. Altice
Volker Walkiewicz
Vladimir Vukicevic
@@ -352,7 +340,6 @@ Tan Dunning
Tamer Fahmy
Stewart Andreason
Steven Thomas
Stephan Wenglorz
Simon Hammett
Simon Carmody
Simon Buckley
@@ -388,11 +375,9 @@ Philip Lamb
Petr Salinger
Peter Bear
Peter Amstutz
Per Nordqvist
Paul Idstein
Paul Fredrikson
Paul Fotheringham
Paul Cheyrou-Lagreze
Pau Garcia
Patrick Hartling
Parag Chaudhur
@@ -409,10 +394,11 @@ Mirko Viviani
Mikkel Gj<47>l
Mike Krus
Mike Garrity
Michal Durkovic
Miha Rav<61>elj
Michael Schanne
Michael Polak
Michael Morrison
Michael Mc Donnell
Michael Logan
Michael Kapelko
Michael Bach Jensen
@@ -431,13 +417,11 @@ Martin Innus
Martin Beck
Marius Kintel
Mario Guimaraes
Marcus Hein
Marco Sciabica
Marco Lehmann
Maik Keller
Lukas Diduch
Louis Hamilton
Likasz Izebski
Lewis Harmon
Leigh Stivers
Laurence Muller
@@ -454,7 +438,6 @@ Juergen Rensen
Juan Manuel Alvarez
Juan Hernando
Josh Portway
Jonathan Greig
John Tan
John Grant
John Donovan
@@ -464,11 +447,10 @@ John Argentieri
Joan Abadie
Jim Brooks
Jeroen den Dekker
Jeffrey Kinross
Jay Zuckerman
Jason Howlett
Jason Ballenger
Jamie Robertson
James Turner
James Killian
James Athey
J.E. Hoffmann
@@ -502,7 +484,7 @@ Duvan Cope
Duncan Cavens
Drew Whitehouse
Douglas A. Pouk
Dmitriy Ogalcev
Dmitry Marakasov
Dean Iverson
David Jung
Danny Valente
@@ -510,7 +492,6 @@ Daniel Stien
Dan Minor
C<EFBFBD>sar L. B. Silveira
Cyril Brulebois
Cory Slep
Cl<EFBFBD>ment B<>sch
Clay Fowler
Claus Steuer
@@ -543,10 +524,8 @@ Andrew Reyonolds
Andreas Roth
Andreas Jochens
Andre Normann
Alois Wismer
Almalric Alexandre
Allen Bierbaum
Alexey Pavlov
Alberto Jaspe
Alan Purvis
Alan Ott

View File

@@ -52,9 +52,9 @@ endif()
PROJECT(OpenSceneGraph)
SET(OPENSCENEGRAPH_MAJOR_VERSION 3)
SET(OPENSCENEGRAPH_MINOR_VERSION 4)
SET(OPENSCENEGRAPH_PATCH_VERSION 0)
SET(OPENSCENEGRAPH_SOVERSION 130)
SET(OPENSCENEGRAPH_MINOR_VERSION 2)
SET(OPENSCENEGRAPH_PATCH_VERSION 3)
SET(OPENSCENEGRAPH_SOVERSION 100)
# set to 0 when not a release candidate, non zero means that any generated
# svn tags will be treated as release candidates of given number
@@ -85,16 +85,85 @@ SET(OpenThreads_SOURCE_DIR ${OpenSceneGraph_SOURCE_DIR})
# Maybe this can be used override existing behavior if needed?
SET(CMAKE_MODULE_PATH "${OpenSceneGraph_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}")
# Change the default build type to Release
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
ENDIF(NOT CMAKE_BUILD_TYPE)
IF(ANDROID)
## Option to enable Android build using AndroidNDK
OPTION(OSG_BUILD_PLATFORM_ANDROID OFF)
IF(OSG_BUILD_PLATFORM_ANDROID)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0 FATAL_ERROR)
INCLUDE(OsgAndroidMacroUtils)
SET(ANDROID TRUE)
IF(NOT ANDROID_PLATFORM)
MESSAGE("Warning Android Platform version NOT defined, Default selected version: 5")
SET(ANDROID_PLATFORM 5)
ENDIF()
IF(NOT ANDROID_ABI)
MESSAGE("Warning Android ABI version NOT defined, Default selection: armeabi armeabi-v7a")
SET(ANDROID_ABI "armeabi armeabi-v7a")
ENDIF()
IF(NOT ANDROID_STL)
MESSAGE("Warning Android STL NOT defined, Default selection: gnustl_static")
SET(ANDROID_STL "gnustl_static")
ENDIF()
IF(ANDROID_DEBUG)
MESSAGE("Warning Android Build is in debug mode")
SET(ANDROID_RELEASE_OPTIM "debug")
ELSE()
MESSAGE("Warning Android Build is in release mode")
SET(ANDROID_RELEASE_OPTIM "release")
ENDIF()
IF(ANDROID_NEON)
MESSAGE("Warning Android NEON optimizations enabled, this will not be available on all armeabi-v7a devices ie. Tegra2")
SET(ANDROID_OPTIM_NEON true)
ELSE()
SET(ANDROID_OPTIM_NEON false)
ENDIF()
IF(ANDROID_ARM32)
MESSAGE("Warning ARM 32bit instruction set will be used")
SET(ANDROID_OPTIM_ARM32 true)
ELSE()
SET(ANDROID_OPTIM_ARM32 false)
ENDIF()
FIND_PACKAGE(AndroidNDK REQUIRED)
SET(OSG_ANDROID_TEMPLATES "${CMAKE_SOURCE_DIR}/PlatformSpecifics/Android")
SET(J "4" CACHE STRING "how many processes for make -j <J>")
ADD_CUSTOM_COMMAND(
OUTPUT Android-OpenSceneGraph
DEPENDS ${CMAKE_BINARY_DIR}/Android.mk
COMMAND "${ANDROID_NDK}/ndk-build"
ARGS --directory=${CMAKE_BINARY_DIR} NDK_APPLICATION_MK=Application.mk -j${J} NDK_LOG=1
)
ADD_CUSTOM_TARGET(ndk ALL echo
DEPENDS Android-OpenSceneGraph
)
install(DIRECTORY include/ DESTINATION include/
PATTERN ".svn" EXCLUDE
)
install(DIRECTORY ${CMAKE_BINARY_DIR}/include/ DESTINATION include/
)
install(DIRECTORY ${CMAKE_BINARY_DIR}/obj/ DESTINATION obj/
PATTERN ".svn" EXCLUDE
PATTERN "objs" EXCLUDE
)
ADD_DEFINITIONS(-DANDROID)
ENDIF()
# Okay, here's the problem: On some platforms, linking against OpenThreads
# is not enough and explicit linking to the underlying thread library
# is also required (e.g. FreeBSD). But OpenThreads may be built with different
@@ -233,10 +302,6 @@ ELSE()
ENDIF()
ENDIF()
IF(UNIX AND NOT ANDROID)
# Not sure what this will do on Cygwin and Msys
# Also, remember OS X X11 is a user installed option so it may not exist.
@@ -401,224 +466,46 @@ MARK_AS_ADVANCED(OSG_DISABLE_MSVC_WARNINGS)
OPTION(OSG_USE_REF_PTR_IMPLICIT_OUTPUT_CONVERSION "Set to ON to use the ref_ptr<> T* operator() output conversion. " ON)
# Map the OPENGL_PROFILE to OSG_GL*_AVAILABLE settings
SET(OPENGL_PROFILE "GL2" CACHE STRING "OpenGL Profile to use, choose from GL1, GL2, GL3, GLES1, GLES2, GLES3")
IF ((OPENGL_PROFILE STREQUAL "GL1") OR (OPENGL_PROFILE STREQUAL "GL2"))
OPTION(OSG_GL1_AVAILABLE "Set to OFF to disable use of OpenGL 1.x functions library." ON )
ELSE()
OPTION(OSG_GL1_AVAILABLE "Set to OFF to disable use of OpenGL 1.x functions library." OFF )
ENDIF()
IF ((OPENGL_PROFILE STREQUAL "GL2"))
OPTION(OSG_GL2_AVAILABLE "Set to OFF to disable use of OpenGL 2.x functions library." ON )
ELSE()
OPTION(OSG_GL2_AVAILABLE "Set to OFF to disable use of OpenGL 2.x functions library." OFF )
ENDIF()
IF ((OPENGL_PROFILE STREQUAL "GL3") OR (OPENGL_PROFILE STREQUAL "GLCORE"))
OPTION(OSG_GL3_AVAILABLE "Set to OFF to disable use of OpenGL 3.x functions library." ON )
ELSE()
OPTION(OSG_GL3_AVAILABLE "Set to OFF to disable use of OpenGL 3.x functions library." OFF )
ENDIF()
IF ((OPENGL_PROFILE STREQUAL "GLES1"))
OPTION(OSG_GLES1_AVAILABLE "Set to OFF to disable use of OpenGL ES 1.x functions library." ON )
ELSE()
OPTION(OSG_GLES1_AVAILABLE "Set to OFF to disable use of OpenGL ES 1.x functions library." OFF )
ENDIF()
IF ((OPENGL_PROFILE STREQUAL "GLES2"))
OPTION(OSG_GLES2_AVAILABLE "Set to OFF to disable use of OpenGL ES 2.x functions library." ON )
ELSEIF ((OPENGL_PROFILE STREQUAL "GLES3"))
OPTION(OSG_GLES2_AVAILABLE "Set to OFF to disable use of OpenGL ES 2.x functions library." ON )
OPTION(OSG_GLES3_AVAILABLE "Set to OFF to disable use of OpenGL ES 3.x functions library." ON )
ELSE()
OPTION(OSG_GLES2_AVAILABLE "Set to OFF to disable use of OpenGL ES 2.x functions library." OFF )
OPTION(OSG_GLES3_AVAILABLE "Set to OFF to disable use of OpenGL ES 3.x functions library." OFF )
ENDIF()
OPTION(OSG_GL1_AVAILABLE "Set to OFF to disable use of OpenGL 1.x functions library." ON)
OPTION(OSG_GL2_AVAILABLE "Set to OFF to disable use of OpenGL 2.x functions library." ON)
OPTION(OSG_GL3_AVAILABLE "Set to OFF to disable use of OpenGL 3.x functions library." OFF)
OPTION(OSG_GLES1_AVAILABLE "Set to OFF to disable use of OpenGL ES 1.x functions library." OFF)
OPTION(OSG_GLES2_AVAILABLE "Set to OFF to disable use of OpenGL ES 2.x functions library." OFF)
OPTION(OSG_GL_LIBRARY_STATIC "Set to ON to statically link with OpenGL/GLES library." OFF)
SET(OPENGL_egl_LIBRARY CACHE STRING "Set the OpenGL egl library.")
# Map the OSG_GL*_AVAILABLE settings to OSG_GL_* settings
IF (OSG_GLES2_AVAILABLE OR OSG_GL3_AVAILABLE)
OPTION(OSG_GL_DISPLAYLISTS_AVAILABLE "Set to OFF to disable use of OpenGL display lists." OFF)
OPTION(OSG_GL_MATRICES_AVAILABLE "Set to OFF to disable use of OpenGL built-in matrices." OFF)
OPTION(OSG_GL_VERTEX_FUNCS_AVAILABLE "Set to OFF to disable use of OpenGL vertex functions such as glVertex/glColor etc." OFF)
OPTION(OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE "Set to OFF to disable use of OpenGL vertex functions such as glVertexPointer/glColorPointer etc." OFF)
OPTION(OSG_GL_FIXED_FUNCTION_AVAILABLE "Set to OFF to disable use of OpenGL fixed function pipeline." OFF)
ELSEIF (OSG_GLES1_AVAILABLE)
OPTION(OSG_GL_DISPLAYLISTS_AVAILABLE "Set to OFF to disable use of OpenGL display lists." OFF)
OPTION(OSG_GL_MATRICES_AVAILABLE "Set to OFF to disable use of OpenGL built-in matrices." ON)
OPTION(OSG_GL_VERTEX_FUNCS_AVAILABLE "Set to OFF to disable use of OpenGL vertex functions such as glVertex/glColor etc." ON)
OPTION(OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE "Set to OFF to disable use of OpenGL vertex functions such as glVertexPointer/glColorPointer etc." ON)
OPTION(OSG_GL_FIXED_FUNCTION_AVAILABLE "Set to OFF to disable use of OpenGL fixed function pipeline." ON)
ELSE()
OPTION(OSG_GL_DISPLAYLISTS_AVAILABLE "Set to OFF to disable use of OpenGL display lists." ON)
OPTION(OSG_GL_MATRICES_AVAILABLE "Set to OFF to disable use of OpenGL built-in matrices." ON)
OPTION(OSG_GL_VERTEX_FUNCS_AVAILABLE "Set to OFF to disable use of OpenGL vertex functions such as glVertex/glColor etc." ON)
OPTION(OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE "Set to OFF to disable use of OpenGL vertex functions such as glVertexPointer/glColorPointer etc." ON)
OPTION(OSG_GL_FIXED_FUNCTION_AVAILABLE "Set to OFF to disable use of OpenGL fixed function pipeline." ON)
ENDIF()
# SET(OSG_GL_DISPLAYLISTS_AVAILABLE ${OSG_GL1_AVAILABLE})
# SET(OSG_GL_MATRICES_AVAILABLE ${OSG_GL1_AVAILABLE})
# SET(OSG_GL_VERTEX_FUNCS_AVAILABLE ${OSG_GL1_AVAILABLE})
# SET(OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE ${OSG_GL1_AVAILABLE})
# SET(OSG_GL_FIXED_FUNCTION_AVAILABLE ${OSG_GL1_AVAILABLE})
IF (OSG_GLES1_AVAILABLE OR OSG_GLES2_AVAILABLE)
OPTION(OSG_CPP_EXCEPTIONS_AVAILABLE "Set to OFF to disable compile of OSG components that use C++ exceptions." OFF)
ELSE()
OPTION(OSG_CPP_EXCEPTIONS_AVAILABLE "Set to OFF to disable compile of OSG components that use C++ exceptions." ON)
ENDIF()
# Map the OSG_GL*_AVAILABLE settings to OpenGL header settings
IF (OSG_GL3_AVAILABLE)
IF (APPLE)
SET(OPENGL_HEADER1 "#include <OpenGL/gl.h>" CACHE STRING "#include<> line for OpenGL Header")
SET(OPENGL_HEADER2 "#include <OpenGL/gl3.h>" CACHE STRING "#include<> line for additional OpenGL Headers if required")
ELSE()
IF (OPENGL_PROFILE STREQUAL "GLCORE")
IF(WIN32)
FIND_PACKAGE(GLCORE REQUIRED)
ENDIF()
SET(OPENGL_HEADER1 "#include <GL/glcorearb.h>" CACHE STRING "#include<> line for OpenGL Header")
SET(OPENGL_HEADER2 "" CACHE STRING "#include<> line for additional OpenGL Headers if required")
ELSE()
SET(OPENGL_HEADER1 "#include <GL3/gl3.h>" CACHE STRING "#include<> line for OpenGL Header")
SET(OPENGL_HEADER2 "" CACHE STRING "#include<> line for additional OpenGL Headers if required")
ENDIF()
ENDIF()
ELSEIF(OSG_GLES1_AVAILABLE)
IF (APPLE AND NOT ANDROID)
SET(OPENGL_HEADER1 "#include \"TargetConditionals.h\"" CACHE STRING "#include<> line for OpenGL Header")
SET(OPENGL_HEADER2 "#include <OpenGLES/ES1/gl.h>" CACHE STRING "#include<> line for additional OpenGL Headers if required")
ELSE()
SET(OPENGL_HEADER1 "#include <GLES/gl.h>" CACHE STRING "#include<> line for OpenGL Header")
SET(OPENGL_HEADER2 "" CACHE STRING "#include<> line for additional OpenGL Headers if required")
ENDIF()
ELSEIF(OSG_GLES2_AVAILABLE)
IF (APPLE AND NOT ANDROID)
SET(OPENGL_HEADER1 "#include \"TargetConditionals.h\"" CACHE STRING "#include<> line for OpenGL Header")
SET(OPENGL_HEADER2 "#include <OpenGLES/ES2/gl.h>" CACHE STRING "#include<> line for additional OpenGL Headers if required")
# TODO: GLES3
ELSE()
SET(OPENGL_HEADER1 "#include <GLES2/gl2.h>" CACHE STRING "#include<> line for OpenGL Header")
SET(OPENGL_HEADER2 "" CACHE STRING "#include<> line for additional OpenGL Headers if required")
# TODO: GLES3
ENDIF()
ELSE()
IF (APPLE)
SET(OPENGL_HEADER1 "#include <OpenGL/gl.h>" CACHE STRING "#include<> line for OpenGL Header")
SET(OPENGL_HEADER2 "" CACHE STRING "#include<> line for additional OpenGL Headers if required")
ELSE()
SET(OPENGL_HEADER1 "#include <GL/gl.h>" CACHE STRING "#include<> line for OpenGL Header")
SET(OPENGL_HEADER2 "" CACHE STRING "#include<> line for additional OpenGL Headers if required")
ENDIF()
ENDIF()
IF (OSG_GL1_AVAILABLE)
SET(OSG_GL1_FEATURES "true")
ELSE()
SET(OSG_GL1_FEATURES "false")
ENDIF()
IF (OSG_GL2_AVAILABLE)
SET(OSG_GL2_FEATURES "true")
ELSE()
SET(OSG_GL2_FEATURES "false")
ENDIF()
IF (OSG_GL3_AVAILABLE)
SET(OSG_GL3_FEATURES "true")
ELSE()
SET(OSG_GL3_FEATURES "false")
ENDIF()
IF (OSG_GLES1_AVAILABLE)
SET(OSG_GLES1_FEATURES "true")
ELSE()
SET(OSG_GLES1_FEATURES "false")
ENDIF()
IF (OSG_GLES2_AVAILABLE)
SET(OSG_GLES2_FEATURES "true")
ELSE()
SET(OSG_GLES2_FEATURES "false")
ENDIF()
IF (OSG_GLES3_AVAILABLE)
SET(OSG_GLES3_FEATURES "true")
ELSE()
SET(OSG_GLES3_FEATURES "false")
ENDIF()
IF(ANDROID)
IF(OSG_GLES1_AVAILABLE)
FIND_PATH(OPENGL_INCLUDE_DIR GLES/gl.h
PATHS
${ANDROID_SYSROOT}/usr/include)
FIND_LIBRARY(OPENGL_gl_LIBRARY GLESv1_CM
PATHS
${ANDROID_SYSROOT}/usr/lib)
ELSEIF(OSG_GLES2_AVAILABLE)
FIND_PATH(OPENGL_INCLUDE_DIR GLES2/gl2.h
PATHS
${ANDROID_SYSROOT}/usr/include)
FIND_LIBRARY(OPENGL_gl_LIBRARY GLESv2
PATHS
${ANDROID_SYSROOT}/usr/lib)
ENDIF()
ENDIF()
OPTION(OSG_GL_DISPLAYLISTS_AVAILABLE "Set to OFF to disable use of OpenGL display lists." ${OSG_GL1_AVAILABLE})
OPTION(OSG_GL_MATRICES_AVAILABLE "Set to OFF to disable use of OpenGL built-in matrices." ${OSG_GL1_AVAILABLE})
OPTION(OSG_GL_VERTEX_FUNCS_AVAILABLE "Set to OFF to disable use of OpenGL vertex functions such as glVertex/glColor etc." ${OSG_GL1_AVAILABLE})
OPTION(OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE "Set to OFF to disable use of OpenGL vertex functions such as glVertexPointer/glColorPointer etc." ${OSG_GL1_AVAILABLE})
OPTION(OSG_GL_FIXED_FUNCTION_AVAILABLE "Set to OFF to disable use of OpenGL fixed function pipeline." ${OSG_GL1_AVAILABLE})
OPTION(OSG_CPP_EXCEPTIONS_AVAILABLE "Set to OFF to disable compile of OSG components that use C++ exceptions." ON)
################################################################################
# Set Config header file
# 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}")
################################################################################
# Set OpenGL header file
INCLUDE (CheckCXXSourceCompiles)
#SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${OPENGL_INCLUDE_DIR})
check_cxx_source_compiles(
"${OPENGL_HEADER1}
${OPENGL_HEADER2}
int main() { GLint64 test; return 0; }"
GL_HEADER_HAS_GLINT64
)
check_cxx_source_compiles(
"${OPENGL_HEADER1}
${OPENGL_HEADER2}
int main() { GLuint64 test; return 0; }"
GL_HEADER_HAS_GLUINT64
)
SET(OPENSCENEGRAPH_OPENGL_HEADER "${PROJECT_BINARY_DIR}/include/osg/GL")
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/src/osg/GL.in"
"${OPENSCENEGRAPH_OPENGL_HEADER}")
SET(OPENSCENEGRAPH_VERSION_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/include/osg/Version")
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/src/osg/Version.in"
"${OPENSCENEGRAPH_VERSION_HEADER}")
# INSTALL_FILES(/include/osg/ FILES "${OPENSCENEGRAPH_CONFIG_HEADER}")
################################################################################
# Set Version header file
SET(OPENSCENEGRAPH_VERSION_HEADER "${PROJECT_BINARY_DIR}/include/osg/Version")
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/src/osg/Version.in"
"${OPENSCENEGRAPH_VERSION_HEADER}")
################################################################################
# Set Version Info resource file
IF(MSVC)
SET(OPENSCENEGRAPH_VERSIONINFO_RC "${PROJECT_BINARY_DIR}/PlatformSpecifics/Windows/OpenSceneGraphVersionInfo.rc")
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/PlatformSpecifics/Windows/OpenSceneGraphVersionInfo.rc.in"
@@ -640,13 +527,12 @@ IF(WIN32 AND NOT ANDROID)
INCLUDE(Find3rdPartyDependencies)
ENDIF()
OPTION(OSG_USE_LOCAL_LUA_SOURCE "Enable to use local Lua source when building the lua plugin" ON)
#
# If you want to prevent CMake from picking up on any of the following optional 3rd Party dependencies in CMake 2.8 onwards
# you can use the following style of command line option when invoking Cmake (here illustrating ignoring PythonLibs) :
# cmake -DCMAKE_DISABLE_FIND_PACKAGE_PythonLibs=1 .
#
IF(ANDROID)
ANDROID_3RD_PARTY()
ELSE()
@@ -667,10 +553,7 @@ ELSE()
FIND_PACKAGE(LibVNCServer)
FIND_PACKAGE(OurDCMTK)
FIND_PACKAGE(FFmpeg)
FIND_PACKAGE(GStreamer COMPONENTS app pbutils)
FIND_PACKAGE(GLIB COMPONENTS gobject)
FIND_PACKAGE(DirectShow)
FIND_PACKAGE(SDL2)
FIND_PACKAGE(SDL)
FIND_PACKAGE(Poppler-glib)
FIND_PACKAGE(RSVG)
@@ -681,19 +564,6 @@ ELSE()
FIND_PACKAGE(Asio)
ENDIF()
FIND_PACKAGE(ZeroConf)
FIND_PACKAGE(LIBLAS)
IF (NOT(OSG_USE_LOCAL_LUA_SOURCE))
FIND_PACKAGE(Lua52)
IF (NOT (LUA_LIBRARIES AND LUA_INCLUDE_DIR))
FIND_PACKAGE(Lua51)
ENDIF()
ENDIF()
# V8 and Python plugins are tests for linking against these libraries but aren't functionality beyond this.
# FIND_PACKAGE(V8)
# FIND_PACKAGE(PythonLibs)
ENDIF()
IF(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION LESS 8)
@@ -712,11 +582,11 @@ IF(OSG_USE_QT AND NOT ANDROID)
IF (DESIRED_QT_VERSION)
IF (DESIRED_QT_VERSION MATCHES 5)
FIND_PACKAGE(Qt5Widgets)
FIND_PACKAGE(Qt5Widgets)
ELSEIF (DESIRED_QT_VERSION MATCHES 4)
FIND_PACKAGE(Qt4)
FIND_PACKAGE(Qt4)
ELSE()
FIND_PACKAGE(Qt3)
FIND_PACKAGE(Qt3)
ENDIF()
ELSE()
@@ -954,10 +824,6 @@ IF(CMAKE_COMPILER_IS_GNUCXX)
# returns too many hits.
# 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.
SET(OSG_AGGRESSIVE_WARNING_FLAGS -Wall -Wparentheses -Wno-long-long -Wno-import -pedantic -Wreturn-type -Wmissing-braces -Wunknown-pragmas -Wunused)
# Previous included -Wformat=2 in OSG_AGGRESSIVE_WARNING_FLAGS but had to remove it due to standard library errors
@@ -977,32 +843,10 @@ ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# remain unset.
IF (APPLE)
SET(OSG_CXX_LANGUAGE_STANDARD "C++11" CACHE STRING "set the c++ language standard (C++98 / GNU++98 / C++11) for OSG" )
MARK_AS_ADVANCED(OSG_CXX_LANGUAGE_STANDARD)
# remove existing flags
REMOVE_CXX_FLAG(-std=c++98)
REMOVE_CXX_FLAG(-std=gnu++98)
REMOVE_CXX_FLAG(-std=c++11)
REMOVE_CXX_FLAG(-stdlib=libstdc++)
REMOVE_CXX_FLAG(-stdlib=libc++)
IF(${OSG_CXX_LANGUAGE_STANDARD} STREQUAL "c++98" OR ${OSG_CXX_LANGUAGE_STANDARD} STREQUAL "C++98")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++98")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libstdc++")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98 -stdlib=libstdc++")
ELSE()
IF(${OSG_CXX_LANGUAGE_STANDARD} STREQUAL "gnu++98" OR ${OSG_CXX_LANGUAGE_STANDARD} STREQUAL "GNU++98")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "gnu++98")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libstdc++")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++98 -stdlib=libstdc++")
ELSE()
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++")
ENDIF()
ENDIF()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-overloaded-virtual -Wno-conversion")
# set standard lib, clang defaults to c++0x
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++98")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libstdc++")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98 -stdlib=libstdc++ -Wno-overloaded-virtual -Wno-conversion")
set(WARNING_CFLAGS "")
ENDIF()
ENDIF()
@@ -1066,21 +910,16 @@ IF(APPLE AND NOT ANDROID)
IF(OSG_BUILD_PLATFORM_IPHONE)
IF(${IPHONE_VERSION_MIN} LESS "7.0")
SET(CMAKE_OSX_ARCHITECTURES "armv6;armv7" CACHE STRING "Build architectures for iOS" FORCE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mno-thumb -pipe -no-cpp-precomp" CACHE STRING "Flags used by the compiler during all build types." FORCE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -miphoneos-version-min=${IPHONE_VERSION_MIN} -mno-thumb -pipe -no-cpp-precomp" CACHE STRING "Flags used by the compiler during all build types." FORCE)
ELSE()
SET(CMAKE_OSX_ARCHITECTURES "armv7;armv7s;arm64" CACHE STRING "Build architectures for iOS" FORCE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pipe -no-cpp-precomp" CACHE STRING "Flags used by the compiler during all build types." FORCE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -miphoneos-version-min=${IPHONE_VERSION_MIN} -pipe -no-cpp-precomp" CACHE STRING "Flags used by the compiler during all build types." FORCE)
ENDIF()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -miphoneos-version-min=${IPHONE_VERSION_MIN}" FORCE)
ELSE()
#simulator uses i386 architectures
SET(CMAKE_OSX_ARCHITECTURES "i386" CACHE STRING "Build architectures for iOS Simulator" FORCE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mno-thumb -arch i386 -pipe -no-cpp-precomp" CACHE STRING "Flags used by the compiler during all build types." FORCE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mios-simulator-version-min=${IPHONE_VERSION_MIN}" FORCE)
ENDIF()
#here we set the specific iphone sdk version. We can only set either device or simulator sdk. So if you want both you currently have to have two seperate projects
@@ -1345,4 +1184,10 @@ ADD_CUSTOM_TARGET(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
#
IF(ANDROID)
message(STATUS "Creating Android Makefile Master files" )
configure_file("${OSG_ANDROID_TEMPLATES}/Android.mk.master.in" "${CMAKE_BINARY_DIR}/Android.mk")
configure_file("${OSG_ANDROID_TEMPLATES}/Application.mk.master.in" "${CMAKE_BINARY_DIR}/Application.mk")
configure_file("${OSG_ANDROID_TEMPLATES}/AndroidManifest.xml.master.in" "${CMAKE_BINARY_DIR}/AndroidManifest.xml")
ENDIF(ANDROID)

View File

@@ -1,9 +1,9 @@
# Locate ASIO-headers (http://think-async.com/Asio)
# This module defines
# ASIO_FOUND, if false, do not try to link to gdal
# ASIO_FOUND, if false, do not try to link to gdal
# ASIO_INCLUDE_DIR, where to find the headers
#
# Created by Stephan Maximilian Huber
# Created by Stephan Maximilian Huber
FIND_PATH(ASIO_INCLUDE_DIR
NAMES
@@ -14,9 +14,7 @@ FIND_PATH(ASIO_INCLUDE_DIR
)
SET(ASIO_FOUND "NO")
IF(ASIO_INCLUDE_DIR)
FIND_PACKAGE( Boost 1.37 )
IF(Boost_FOUND)
SET(ASIO_FOUND "YES")
ENDIF()
FIND_PACKAGE( Boost 1.37 )
IF(Boost_FOUND AND ASIO_INCLUDE_DIR)
SET(ASIO_FOUND "YES")
ENDIF()

View File

@@ -11,16 +11,16 @@
# $COLLADA_DIR is an environment variable that would
# correspond to the ./configure --prefix=$COLLADA_DIR
#
# Created by Robert Osfield.
# Created by Robert Osfield.
# Check if COLLADA_DIR is set, otherwise use ACTUAL_3DPARTY_DIR:
SET( COLLADA_ENV_VAR_AVAILABLE $ENV{COLLADA_DIR} )
IF ( COLLADA_ENV_VAR_AVAILABLE )
SET(COLLADA_DOM_ROOT "$ENV{COLLADA_DIR}/dom" CACHE PATH "Location of Collada DOM directory" FORCE)
ELSE ()
ELSE ( COLLADA_ENV_VAR_AVAILABLE )
SET(COLLADA_DOM_ROOT "${ACTUAL_3DPARTY_DIR}/include/1.4/dom" CACHE PATH "Location of Collada DOM directory" FORCE)
ENDIF()
ENDIF( COLLADA_ENV_VAR_AVAILABLE )
@@ -65,17 +65,16 @@ FIND_PATH(COLLADA_INCLUDE_DIR dae.h
${ACTUAL_3DPARTY_DIR}/include
)
FIND_LIBRARY(COLLADA_DYNAMIC_LIBRARY
NAMES collada_dom collada14dom Collada14Dom libcollada14dom21 libcollada14dom22 collada-dom2.4-dp
FIND_LIBRARY(COLLADA_DYNAMIC_LIBRARY
NAMES collada_dom collada14dom Collada14Dom libcollada14dom21 libcollada14dom22
PATHS
${COLLADA_DOM_ROOT}/build/${COLLADA_BUILDNAME}-1.4
${COLLADA_DOM_ROOT}
$ENV{COLLADA_DIR}/build/${COLLADA_BUILDNAME}-1.4
$ENV{COLLADA_DIR}/lib
$ENV{COLLADA_DIR}/lib-dbg
$ENV{COLLADA_DIR}
~/Library/Frameworks
/Library/Frameworks
/Library/Frameworks
/opt/local/Library/Frameworks #macports
/usr/local/lib
/usr/local/lib64
@@ -89,11 +88,10 @@ FIND_LIBRARY(COLLADA_DYNAMIC_LIBRARY
${ACTUAL_3DPARTY_DIR}/lib
)
FIND_LIBRARY(COLLADA_DYNAMIC_LIBRARY_DEBUG
NAMES collada_dom-d collada14dom-d Collada14Dom-d libcollada14dom21-d libcollada14dom22-d collada-dom2.4-dp-d
FIND_LIBRARY(COLLADA_DYNAMIC_LIBRARY_DEBUG
NAMES collada_dom-d collada14dom-d Collada14Dom-d libcollada14dom21-d libcollada14dom22-d
PATHS
${COLLADA_DOM_ROOT}/build/${COLLADA_BUILDNAME}-1.4-d
${COLLADA_DOM_ROOT}
$ENV{COLLADA_DIR}/build/${COLLADA_BUILDNAME}-1.4-d
$ENV{COLLADA_DIR}/lib
$ENV{COLLADA_DIR}/lib-dbg
@@ -113,7 +111,7 @@ FIND_LIBRARY(COLLADA_DYNAMIC_LIBRARY_DEBUG
${ACTUAL_3DPARTY_DIR}/lib
)
FIND_LIBRARY(COLLADA_STATIC_LIBRARY
FIND_LIBRARY(COLLADA_STATIC_LIBRARY
NAMES libcollada14dom21-s libcollada14dom22-s libcollada14dom.a
PATHS
${COLLADA_DOM_ROOT}/build/${COLLADA_BUILDNAME}-1.4
@@ -136,7 +134,7 @@ FIND_LIBRARY(COLLADA_STATIC_LIBRARY
${ACTUAL_3DPARTY_DIR}/lib
)
FIND_LIBRARY(COLLADA_STATIC_LIBRARY_DEBUG
FIND_LIBRARY(COLLADA_STATIC_LIBRARY_DEBUG
NAMES collada_dom-sd collada14dom-sd libcollada14dom21-sd libcollada14dom22-sd libcollada14dom-d.a
PATHS
${COLLADA_DOM_ROOT}/build/${COLLADA_BUILDNAME}-1.4-d
@@ -175,7 +173,7 @@ FIND_LIBRARY(COLLADA_STATIC_LIBRARY_DEBUG
)
ENDIF(WIN32)
ENDIF(LIBXML2_FOUND)
FIND_PACKAGE(ZLIB)
IF (ZLIB_FOUND)
SET(COLLADA_ZLIB_LIBRARY "${ZLIB_LIBRARY}" CACHE FILEPATH "" FORCE)
@@ -244,7 +242,7 @@ FIND_LIBRARY(COLLADA_STATIC_LIBRARY_DEBUG
)
FIND_LIBRARY(COLLADA_BOOST_FILESYSTEM_LIBRARY
NAMES libboost_filesystem boost_filesystem boost_filesystem-mt libboost_filesystem-${COLLADA_BUILDNAME}0-mt libboost_filesystem-${COLLADA_BUILDNAME}0-mt-1_54 libboost_filesystem-${COLLADA_BUILDNAME}0-mt-1_55
NAMES libboost_filesystem boost_filesystem boost_filesystem-mt libboost_filesystem-${COLLADA_BUILDNAME}0-mt libboost_filesystem-${COLLADA_BUILDNAME}0-mt-1_54 libboost_filesystem-${COLLADA_BUILDNAME}0-mt-1_55
PATHS
${COLLADA_DOM_ROOT}/external-libs/boost/lib/${COLLADA_BUILDNAME}
${COLLADA_DOM_ROOT}/external-libs/boost/lib/mingw
@@ -252,7 +250,7 @@ FIND_LIBRARY(COLLADA_STATIC_LIBRARY_DEBUG
)
FIND_LIBRARY(COLLADA_BOOST_FILESYSTEM_LIBRARY_DEBUG
NAMES libboost_filesystem-d boost_filesystem-d boost_filesystem-mt-d libboost_filesystem-${COLLADA_BUILDNAME}0-mt-gd libboost_filesystem-${COLLADA_BUILDNAME}0-mt-gd-1_54 libboost_filesystem-${COLLADA_BUILDNAME}0-mt-gd-1_55
NAMES libboost_filesystem-d boost_filesystem-d boost_filesystem-mt-d libboost_filesystem-${COLLADA_BUILDNAME}0-mt-gd libboost_filesystem-${COLLADA_BUILDNAME}0-mt-gd-1_54 libboost_filesystem-${COLLADA_BUILDNAME}0-mt-gd-1_55
PATHS
${COLLADA_DOM_ROOT}/external-libs/boost/lib/${COLLADA_BUILDNAME}
${COLLADA_DOM_ROOT}/external-libs/boost/lib/mingw
@@ -260,7 +258,7 @@ FIND_LIBRARY(COLLADA_STATIC_LIBRARY_DEBUG
)
FIND_LIBRARY(COLLADA_BOOST_SYSTEM_LIBRARY
NAMES libboost_system boost_system boost_system-mt libboost_system-${COLLADA_BUILDNAME}0-mt libboost_system-${COLLADA_BUILDNAME}0-mt-1_54 libboost_system-${COLLADA_BUILDNAME}0-mt-1_55
NAMES libboost_system boost_system boost_system-mt libboost_system-${COLLADA_BUILDNAME}0-mt libboost_system-${COLLADA_BUILDNAME}0-mt-1_54 libboost_system-${COLLADA_BUILDNAME}0-mt-1_55
PATHS
${COLLADA_DOM_ROOT}/external-libs/boost/lib/${COLLADA_BUILDNAME}
${COLLADA_DOM_ROOT}/external-libs/boost/lib/mingw
@@ -268,7 +266,7 @@ FIND_LIBRARY(COLLADA_STATIC_LIBRARY_DEBUG
)
FIND_LIBRARY(COLLADA_BOOST_SYSTEM_LIBRARY_DEBUG
NAMES libboost_system-d boost_system-d boost_system-mt-d libboost_system-${COLLADA_BUILDNAME}0-mt-gd libboost_system-${COLLADA_BUILDNAME}0-mt-gd-1_54 libboost_system-${COLLADA_BUILDNAME}0-mt-gd-1_55
NAMES libboost_system-d boost_system-d boost_system-mt-d libboost_system-${COLLADA_BUILDNAME}0-mt-gd libboost_system-${COLLADA_BUILDNAME}0-mt-gd-1_54 libboost_system-${COLLADA_BUILDNAME}0-mt-gd-1_55
PATHS
${COLLADA_DOM_ROOT}/external-libs/boost/lib/${COLLADA_BUILDNAME}
${COLLADA_DOM_ROOT}/external-libs/boost/lib/mingw
@@ -279,20 +277,6 @@ FIND_LIBRARY(COLLADA_STATIC_LIBRARY_DEBUG
SET(COLLADA_FOUND "NO")
IF(COLLADA_DYNAMIC_LIBRARY OR COLLADA_STATIC_LIBRARY)
IF (COLLADA_INCLUDE_DIR)
SET(COLLADA_FOUND "YES")
FIND_PATH(COLLADA_INCLUDE_DOMANY_DIR 1.4/dom/domAny.h
${COLLADA_INCLUDE_DIR}
)
IF (COLLADA_INCLUDE_DOMANY_DIR)
SET(COLLADA_DOM_2_4_OR_LATER TRUE)
ELSEIF()
SET(COLLADA_DOM_2_4_OR_LATER FALSE)
ENDIF()
ENDIF()
ENDIF()
ENDIF(COLLADA_INCLUDE_DIR)
ENDIF(COLLADA_DYNAMIC_LIBRARY OR COLLADA_STATIC_LIBRARY)

View File

@@ -14,8 +14,8 @@
#In OSG ffmpeg plugin, we used "#include <header.h>" for compatibility with old version of ffmpeg
#With the new version of FFmpeg, a file named "time.h" was added that breaks compatability with the old version of ffmpeg.
#We have to search the path which contain the header.h (useful for old version)
#and search the path which contain the libname/header.h (useful for new version)
#We have to search the path which contain the header.h (usefull for old version)
#and search the path which contain the libname/header.h (usefull for new version)
#Then we need to include ${FFMPEG_libname_INCLUDE_DIRS} (in old version case, use by ffmpeg header and osg plugin code)
# (in new version case, use by ffmpeg header)
@@ -32,8 +32,6 @@ MACRO(FFMPEG_FIND varname shortname headername)
PATHS
${FFMPEG_ROOT}/include
$ENV{FFMPEG_DIR}/include
${FFMPEG_ROOT}
$ENV{FFMPEG_DIR}
~/Library/Frameworks
/Library/Frameworks
/usr/local/include
@@ -51,8 +49,6 @@ MACRO(FFMPEG_FIND varname shortname headername)
PATHS
${FFMPEG_ROOT}/include
$ENV{FFMPEG_DIR}/include
${FFMPEG_ROOT}
$ENV{FFMPEG_DIR}
~/Library/Frameworks
/Library/Frameworks
/usr/local/include
@@ -71,8 +67,6 @@ MACRO(FFMPEG_FIND varname shortname headername)
PATHS
${FFMPEG_ROOT}/lib
$ENV{FFMPEG_DIR}/lib
${FFMPEG_ROOT}/lib${shortname}
$ENV{FFMPEG_DIR}/lib${shortname}
~/Library/Frameworks
/Library/Frameworks
/usr/local/lib
@@ -129,14 +123,11 @@ FFMPEG_FIND(LIBAVFORMAT avformat avformat.h)
FFMPEG_FIND(LIBAVDEVICE avdevice avdevice.h)
FFMPEG_FIND(LIBAVCODEC avcodec avcodec.h)
FFMPEG_FIND(LIBAVUTIL avutil avutil.h)
FFMPEG_FIND(LIBSWRESAMPLE swresample swresample.h)
FFMPEG_FIND(LIBAVRESAMPLE avresample avresample.h)
FFMPEG_FIND(LIBSWSCALE swscale swscale.h) # not sure about the header to look for here.
SET(FFMPEG_FOUND "NO")
# Note we don't check FFMPEG_LIBSWSCALE_FOUND here, it's optional.
IF (FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND AND STDINT_OK
AND ( FFMPEG_LIBSWRESAMPLE_FOUND OR FFMPEG_LIBAVRESAMPLE_FOUND ) )
IF (FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND AND STDINT_OK)
SET(FFMPEG_FOUND "YES")

View File

@@ -9,15 +9,6 @@
#
# Created by Robert Osfield.
# prefer FindFLTK from cmake distribution
if(EXISTS ${CMAKE_ROOT}/Modules/FindFLTK.cmake)
include(${CMAKE_ROOT}/Modules/FindFLTK.cmake)
if(FLTK_FOUND)
return()
endif()
endif()
FIND_PATH(FLTK_INCLUDE_DIR Fl/Fl.H Fl/Fl.h
$ENV{FLTK_DIR}/include
$ENV{FLTK_DIR}

View File

@@ -12,15 +12,6 @@
# used in building FREETYPE.
# Created by Eric Wing.
# prefer FindFreetype from cmake distribution
if(EXISTS ${CMAKE_ROOT}/Modules/FindFreetype.cmake)
include(${CMAKE_ROOT}/Modules/FindFreetype.cmake)
if(FREETYPE_FOUND)
return()
endif()
endif()
# Ugh, FreeType seems to use some #include trickery which
# makes this harder than it should be. It looks like they
# put ft2build.h in a common/easier-to-find location which
@@ -33,7 +24,6 @@ endif()
# wants explicit full paths and this trickery doesn't work too well.
# I'm going to attempt to cut out the middleman and hope
# everything still works.
FIND_PATH(FREETYPE_INCLUDE_DIR_ft2build ft2build.h
PATHS
$ENV{FREETYPE_DIR}

View File

@@ -19,15 +19,6 @@
# This makes the presumption that you are include gdal.h like
# #include "gdal.h"
# prefer FindGDAL from cmake distribution
if(EXISTS ${CMAKE_ROOT}/Modules/FindGDAL.cmake)
include(${CMAKE_ROOT}/Modules/FindGDAL.cmake)
if(GDAL_FOUND)
return()
endif()
endif()
FIND_PATH(GDAL_INCLUDE_DIR gdal.h
PATHS
$ENV{GDAL_DIR}

View File

@@ -1,36 +0,0 @@
# Finds the OpenGL Core Profile (cp) header file.
# Looks for glcorearb.h
#
# This script defines the following:
# GLCORE_FOUND // Set to TRUE if glcorearb.h is found
# GLCORE_INCLUDE_DIR // Parent directory of directory (gl, GL3, or OpenGL) containing the CP header.
# GLCORE_GLCOREARB_HEADER // advanced
#
# GLCORE_ROOT can be set as an environment variable or a CMake variable,
# to the parent directory of the gl, GL3, or OpenGL directory containing the CP header.
#
FIND_PATH( GLCORE_GLCOREARB_HEADER
NAMES GL/glcorearb.h GL3/glcorearb.h OpenGL/glcorearb.h gl/glcorearb.h
HINTS ${GLCORE_ROOT}
PATHS ENV GLCORE_ROOT
)
set( GLCORE_INCLUDE_DIR )
if( GLCORE_GLCOREARB_HEADER )
set( GLCORE_INCLUDE_DIR ${GLCORE_GLCOREARB_HEADER} )
endif()
# handle the QUIETLY and REQUIRED arguments and set
# GLCORE_FOUND to TRUE as appropriate
INCLUDE( FindPackageHandleStandardArgs )
FIND_PACKAGE_HANDLE_STANDARD_ARGS( GLCORE
"Set GLCORE_ROOT as the parent of the directory containing the OpenGL core profile header."
GLCORE_INCLUDE_DIR )
MARK_AS_ADVANCED(
GLCORE_INCLUDE_DIR
GLCORE_GLCOREARB_HEADER
)

View File

@@ -1,142 +0,0 @@
# - Try to find Glib and its components (gio, gobject etc)
# Once done, this will define
#
# GLIB_FOUND - system has Glib
# GLIB_INCLUDE_DIRS - the Glib include directories
# GLIB_LIBRARIES - link these to use Glib
#
# Optionally, the COMPONENTS keyword can be passed to find_package()
# and Glib components can be looked for. Currently, the following
# components can be used, and they define the following variables if
# found:
#
# gio: GLIB_GIO_LIBRARIES
# gobject: GLIB_GOBJECT_LIBRARIES
# gmodule: GLIB_GMODULE_LIBRARIES
# gthread: GLIB_GTHREAD_LIBRARIES
#
# Note that the respective _INCLUDE_DIR variables are not set, since
# all headers are in the same directory as GLIB_INCLUDE_DIRS.
#
# Copyright (C) 2012 Raphael Kubo da Costa <rakuco@webkit.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``AS
# IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ITS
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
if (WIN32)
find_library(GLIB_LIBRARIES
NAMES glib-2.0
PATHS C:/gstreamer/1.0/x86_64/lib
)
else ()
find_package(PkgConfig)
pkg_check_modules(PC_GLIB QUIET glib-2.0)
find_library(GLIB_LIBRARIES
NAMES glib-2.0
HINTS ${PC_GLIB_LIBDIR}
${PC_GLIB_LIBRARY_DIRS}
)
endif ()
# Files in glib's main include path may include glibconfig.h, which,
# for some odd reason, is normally in $LIBDIR/glib-2.0/include.
get_filename_component(_GLIB_LIBRARY_DIR ${GLIB_LIBRARIES} PATH)
find_path(GLIBCONFIG_INCLUDE_DIR
NAMES glibconfig.h
HINTS ${PC_LIBDIR} ${PC_LIBRARY_DIRS} ${_GLIB_LIBRARY_DIR}
PATH_SUFFIXES glib-2.0/include
)
if (WIN32)
find_path(GLIB_INCLUDE_DIR
NAMES glib.h
PATHS C:/gstreamer/1.0/x86_64/include
PATH_SUFFIXES glib-2.0
)
else()
find_path(GLIB_INCLUDE_DIR
NAMES glib.h
HINTS ${PC_GLIB_INCLUDEDIR}
${PC_GLIB_INCLUDE_DIRS}
PATH_SUFFIXES glib-2.0
)
endif()
if (GLIBCONFIG_INCLUDE_DIR)
set(GLIB_INCLUDE_DIRS ${GLIB_INCLUDE_DIR} ${GLIBCONFIG_INCLUDE_DIR})
# Version detection
file(READ "${GLIBCONFIG_INCLUDE_DIR}/glibconfig.h" GLIBCONFIG_H_CONTENTS)
string(REGEX MATCH "#define GLIB_MAJOR_VERSION ([0-9]+)" _dummy "${GLIBCONFIG_H_CONTENTS}")
set(GLIB_VERSION_MAJOR "${CMAKE_MATCH_1}")
string(REGEX MATCH "#define GLIB_MINOR_VERSION ([0-9]+)" _dummy "${GLIBCONFIG_H_CONTENTS}")
set(GLIB_VERSION_MINOR "${CMAKE_MATCH_1}")
string(REGEX MATCH "#define GLIB_MICRO_VERSION ([0-9]+)" _dummy "${GLIBCONFIG_H_CONTENTS}")
set(GLIB_VERSION_MICRO "${CMAKE_MATCH_1}")
set(GLIB_VERSION "${GLIB_VERSION_MAJOR}.${GLIB_VERSION_MINOR}.${GLIB_VERSION_MICRO}")
# Additional Glib components. We only look for libraries, as not all of them
# have corresponding headers and all headers are installed alongside the main
# glib ones.
foreach (_component ${GLIB_FIND_COMPONENTS})
if (${_component} STREQUAL "gio")
find_library(GLIB_GIO_LIBRARIES NAMES gio-2.0 HINTS ${_GLIB_LIBRARY_DIR})
set(ADDITIONAL_REQUIRED_VARS ${ADDITIONAL_REQUIRED_VARS} GLIB_GIO_LIBRARIES)
elseif (${_component} STREQUAL "gobject")
find_library(GLIB_GOBJECT_LIBRARIES NAMES gobject-2.0 HINTS ${_GLIB_LIBRARY_DIR})
set(ADDITIONAL_REQUIRED_VARS ${ADDITIONAL_REQUIRED_VARS} GLIB_GOBJECT_LIBRARIES)
elseif (${_component} STREQUAL "gmodule")
find_library(GLIB_GMODULE_LIBRARIES NAMES gmodule-2.0 HINTS ${_GLIB_LIBRARY_DIR})
set(ADDITIONAL_REQUIRED_VARS ${ADDITIONAL_REQUIRED_VARS} GLIB_GMODULE_LIBRARIES)
elseif (${_component} STREQUAL "gthread")
find_library(GLIB_GTHREAD_LIBRARIES NAMES gthread-2.0 HINTS ${_GLIB_LIBRARY_DIR})
set(ADDITIONAL_REQUIRED_VARS ${ADDITIONAL_REQUIRED_VARS} GLIB_GTHREAD_LIBRARIES)
elseif (${_component} STREQUAL "gio-unix")
# gio-unix is compiled as part of the gio library, but the include paths
# are separate from the shared glib ones. Since this is currently only used
# by WebKitGTK+ we don't go to extraordinary measures beyond pkg-config.
pkg_check_modules(GIO_UNIX QUIET gio-unix-2.0)
endif ()
endforeach ()
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLIB REQUIRED_VARS GLIB_INCLUDE_DIRS GLIB_LIBRARIES ${ADDITIONAL_REQUIRED_VARS}
VERSION_VAR GLIB_VERSION)
mark_as_advanced(
GLIBCONFIG_INCLUDE_DIR
GLIB_GIO_LIBRARIES
GLIB_GIO_UNIX_LIBRARIES
GLIB_GMODULE_LIBRARIES
GLIB_GOBJECT_LIBRARIES
GLIB_GTHREAD_LIBRARIES
GLIB_INCLUDE_DIR
GLIB_INCLUDE_DIRS
GLIB_LIBRARIES
)
else()
endif ()

View File

@@ -1,174 +0,0 @@
# - Try to find GStreamer and its plugins
# Once done, this will define
#
# GSTREAMER_FOUND - system has GStreamer
# GSTREAMER_INCLUDE_DIRS - the GStreamer include directories
# GSTREAMER_LIBRARIES - link these to use GStreamer
#
# Additionally, gstreamer-base is always looked for and required, and
# the following related variables are defined:
#
# GSTREAMER_BASE_INCLUDE_DIRS - gstreamer-base's include directory
# GSTREAMER_BASE_LIBRARIES - link to these to use gstreamer-base
#
# Optionally, the COMPONENTS keyword can be passed to find_package()
# and GStreamer plugins can be looked for. Currently, the following
# plugins can be searched, and they define the following variables if
# found:
#
# gstreamer-app: GSTREAMER_APP_INCLUDE_DIRS and GSTREAMER_APP_LIBRARIES
# gstreamer-audio: GSTREAMER_AUDIO_INCLUDE_DIRS and GSTREAMER_AUDIO_LIBRARIES
# gstreamer-fft: GSTREAMER_FFT_INCLUDE_DIRS and GSTREAMER_FFT_LIBRARIES
# gstreamer-pbutils: GSTREAMER_PBUTILS_INCLUDE_DIRS and GSTREAMER_PBUTILS_LIBRARIES
# gstreamer-video: GSTREAMER_VIDEO_INCLUDE_DIRS and GSTREAMER_VIDEO_LIBRARIES
#
# Copyright (C) 2012 Raphael Kubo da Costa <rakuco@webkit.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``AS
# IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ITS
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# Helper macro to find a GStreamer plugin (or GStreamer itself)
# _component_prefix is prepended to the _INCLUDE_DIRS and _LIBRARIES variables (eg. "GSTREAMER_AUDIO")
# _pkgconfig_name is the component's pkg-config name (eg. "gstreamer-1.0", or "gstreamer-video-1.0").
# _header is the component's header, relative to the gstreamer-1.0 directory (eg. "gst/gst.h").
# _library is the component's library name (eg. "gstreamer-1.0" or "gstvideo-1.0")
#macro(FIND_GSTREAMER_COMPONENT _component_prefix _pkgconfig_name _header _library)
# pkg_check_modules(PC_${_component_prefix} QUIET ${_pkgconfig_name})
#
# find_path(${_component_prefix}_INCLUDE_DIRS
# NAMES ${_header}
# HINTS ${PC_${_component_prefix}_INCLUDE_DIRS} ${PC_${_component_prefix}_INCLUDEDIR}
# PATH_SUFFIXES gstreamer-1.0
# )
#
# find_library(${_component_prefix}_LIBRARIES
# NAMES ${_library}
# HINTS ${PC_${_component_prefix}_LIBRARY_DIRS} ${PC_${_component_prefix}_LIBDIR}
# )
#endmacro()
if (WIN32)
macro(FIND_GSTREAMER_COMPONENT _component_prefix _pkgconfig_name _header _library)
find_path(${_component_prefix}_INCLUDE_DIRS
NAMES ${_header}
PATHS C:/gstreamer/1.0/x86_64/include
PATH_SUFFIXES gstreamer-1.0
)
find_library(${_component_prefix}_LIBRARIES
NAMES ${_library}
PATHS C:/gstreamer/1.0/x86_64/lib
)
endmacro()
else ()
find_package(PkgConfig)
macro(FIND_GSTREAMER_COMPONENT _component_prefix _pkgconfig_name _header _library)
pkg_check_modules(${_component_prefix} QUIET ${_pkgconfig_name})
# find_path(${_component_prefix}_INCLUDE_DIRS
# NAMES ${_header}
# HINTS ${PC_${_component_prefix}_INCLUDE_DIRS} ${PC_${_component_prefix}_INCLUDEDIR}
# PATH_SUFFIXES gstreamer-1.0
# )
# find_library(${_component_prefix}_LIBRARIES
# NAMES ${_library}
# HINTS ${PC_${_component_prefix}_LIBRARY_DIRS} ${PC_${_component_prefix}_LIBDIR}
# )
endmacro()
endif ()
# ------------------------
# 1. Find GStreamer itself
# ------------------------
# 1.1. Find headers and libraries
FIND_GSTREAMER_COMPONENT(GSTREAMER gstreamer-1.0 gst/gst.h gstreamer-1.0)
FIND_GSTREAMER_COMPONENT(GSTREAMER_BASE gstreamer-base-1.0 gst/gst.h gstbase-1.0)
# 1.2. Check GStreamer version
if (GSTREAMER_INCLUDE_DIRS)
if (EXISTS "${GSTREAMER_INCLUDE_DIRS}/gst/gstversion.h")
file(READ "${GSTREAMER_INCLUDE_DIRS}/gst/gstversion.h" GSTREAMER_VERSION_CONTENTS)
string(REGEX MATCH "#define +GST_VERSION_MAJOR +\\(([0-9]+)\\)" _dummy "${GSTREAMER_VERSION_CONTENTS}")
set(GSTREAMER_VERSION_MAJOR "${CMAKE_MATCH_1}")
string(REGEX MATCH "#define +GST_VERSION_MINOR +\\(([0-9]+)\\)" _dummy "${GSTREAMER_VERSION_CONTENTS}")
set(GSTREAMER_VERSION_MINOR "${CMAKE_MATCH_1}")
string(REGEX MATCH "#define +GST_VERSION_MICRO +\\(([0-9]+)\\)" _dummy "${GSTREAMER_VERSION_CONTENTS}")
set(GSTREAMER_VERSION_MICRO "${CMAKE_MATCH_1}")
set(GSTREAMER_VERSION "${GSTREAMER_VERSION_MAJOR}.${GSTREAMER_VERSION_MINOR}.${GSTREAMER_VERSION_MICRO}")
endif ()
endif ()
if ("${GStreamer_FIND_VERSION}" VERSION_GREATER "${GSTREAMER_VERSION}")
message(FATAL_ERROR "Required version (" ${GStreamer_FIND_VERSION} ") is higher than found version (" ${GSTREAMER_VERSION} ")")
endif ()
# -------------------------
# 2. Find GStreamer plugins
# -------------------------
FIND_GSTREAMER_COMPONENT(GSTREAMER_APP gstreamer-app-1.0 gst/app/gstappsink.h gstapp-1.0)
FIND_GSTREAMER_COMPONENT(GSTREAMER_AUDIO gstreamer-audio-1.0 gst/audio/audio.h gstaudio-1.0)
FIND_GSTREAMER_COMPONENT(GSTREAMER_FFT gstreamer-fft-1.0 gst/fft/gstfft.h gstfft-1.0)
FIND_GSTREAMER_COMPONENT(GSTREAMER_PBUTILS gstreamer-pbutils-1.0 gst/pbutils/pbutils.h gstpbutils-1.0)
FIND_GSTREAMER_COMPONENT(GSTREAMER_VIDEO gstreamer-video-1.0 gst/video/video.h gstvideo-1.0)
# ------------------------------------------------
# 3. Process the COMPONENTS passed to FIND_PACKAGE
# ------------------------------------------------
set(_GSTREAMER_REQUIRED_VARS GSTREAMER_INCLUDE_DIRS GSTREAMER_LIBRARIES GSTREAMER_VERSION GSTREAMER_BASE_INCLUDE_DIRS GSTREAMER_BASE_LIBRARIES)
foreach (_component ${GStreamer_FIND_COMPONENTS})
set(_gst_component "GSTREAMER_${_component}")
string(TOUPPER ${_gst_component} _UPPER_NAME)
list(APPEND _GSTREAMER_REQUIRED_VARS ${_UPPER_NAME}_INCLUDE_DIRS ${_UPPER_NAME}_LIBRARIES)
endforeach ()
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GStreamer REQUIRED_VARS ${_GSTREAMER_REQUIRED_VARS}
VERSION_VAR GSTREAMER_VERSION)
mark_as_advanced(
GSTREAMER_APP_INCLUDE_DIRS
GSTREAMER_APP_LIBRARIES
GSTREAMER_AUDIO_INCLUDE_DIRS
GSTREAMER_AUDIO_LIBRARIES
GSTREAMER_BASE_INCLUDE_DIRS
GSTREAMER_BASE_LIBRARIES
GSTREAMER_FFT_INCLUDE_DIRS
GSTREAMER_FFT_LIBRARIES
GSTREAMER_INCLUDE_DIRS
GSTREAMER_LIBRARIES
GSTREAMER_PBUTILS_INCLUDE_DIRS
GSTREAMER_PBUTILS_LIBRARIES
GSTREAMER_VIDEO_INCLUDE_DIRS
GSTREAMER_VIDEO_LIBRARIES
)

View File

@@ -9,15 +9,6 @@
#
# Created by Robert Osfield.
# prefer FindJasper from cmake distribution
if(EXISTS ${CMAKE_ROOT}/Modules/FindJasper.cmake)
include(${CMAKE_ROOT}/Modules/FindJasper.cmake)
if(JASPER_FOUND)
return()
endif()
endif()
FIND_PATH(JASPER_INCLUDE_DIR jasper/jasper.h
$ENV{JASPER_DIR}/include
$ENV{JASPER_DIR}/src/libjasper/include

View File

@@ -1,107 +0,0 @@
#---
# File: FindLIBLAS.cmake
#
# Find the native LIBLAS includes and library
#
# LIBLAS_INCLUDE_DIRS - where to find liblas's includes.
# LIBLAS_LIBRARIES - List of libraries when using liblas.
# LIBLAS_FOUND - True if liblas found.
#---
# Set the include dir:
find_path(LIBLAS_INCLUDE_DIR liblas/liblas.hpp)
# Macro for setting libraries:
macro(FIND_LIBLAS_LIBRARY MYLIBRARY MYLIBRARYNAME)
find_library(
"${MYLIBRARY}_DEBUG"
NAMES "${MYLIBRARYNAME}${CMAKE_DEBUG_POSTFIX}"
PATHS
${LIBLAS_DIR}/lib/Debug
${LIBLAS_DIR}/lib64/Debug
${LIBLAS_DIR}/lib
${LIBLAS_DIR}/lib64
$ENV{LIBLAS_DIR}/lib/debug
$ENV{LIBLAS_DIR}/lib64/debug
NO_DEFAULT_PATH
)
find_library(
"${MYLIBRARY}_DEBUG"
NAMES "${MYLIBRARYNAME}${CMAKE_DEBUG_POSTFIX}"
PATHS
~/Library/Frameworks
/Library/Frameworks
/usr/local/lib
/usr/local/lib64
/usr/lib
/usr/lib64
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;LIBLAS_ROOT]/lib
/usr/freeware/lib64
)
find_library(
${MYLIBRARY}
NAMES "${MYLIBRARYNAME}${CMAKE_RELEASE_POSTFIX}"
PATHS
${LIBLAS_DIR}/lib/Release
${LIBLAS_DIR}/lib64/Release
${LIBLAS_DIR}/lib
${LIBLAS_DIR}/lib64
$ENV{LIBLAS_DIR}/lib/Release
$ENV{LIBLAS_DIR}/lib64/Release
$ENV{LIBLAS_DIR}/lib
$ENV{LIBLAS_DIR}/lib64
$ENV{LIBLAS_DIR}
$ENV{LIBLASDIR}/lib
$ENV{LIBLASDIR}/lib64
$ENV{LIBLASDIR}
$ENV{LIBLAS_ROOT}/lib
$ENV{LIBLAS_ROOT}/lib64
NO_DEFAULT_PATH
)
find_library(
${MYLIBRARY}
NAMES "${MYLIBRARYNAME}${CMAKE_RELEASE_POSTFIX}"
PATHS
~/Library/Frameworks
/Library/Frameworks
/usr/local/lib
/usr/local/lib64
/usr/lib
/usr/lib64
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;LIBLAS_ROOT]/lib
/usr/freeware/lib64
)
if( NOT ${MYLIBRARY}_DEBUG )
if( MYLIBRARY )
set( ${MYLIBRARY}_DEBUG ${MYLIBRARY} )
endif(MYLIBRARY)
endif( NOT ${MYLIBRARY}_DEBUG )
endmacro(FIND_LIBLAS_LIBRARY LIBRARY LIBRARYNAME)
FIND_LIBLAS_LIBRARY(LIBLAS_LIBRARY las)
FIND_LIBLAS_LIBRARY(LIBLASC_LIBRARY las_c)
set(LIBLAS_FOUND "NO")
if(LIBLAS_LIBRARY AND LIBLASC_LIBRARY AND LIBLAS_INCLUDE_DIR)
FIND_PACKAGE(Boost) # used by LIBLAS
if(Boost_FOUND)
set(LIBLAS_LIBRARIES ${LIBLAS_LIBRARY} ${LIBLASC_LIBRARY} )
set(LIBLAS_FOUND "YES")
endif()
endif()

View File

@@ -1,83 +0,0 @@
# Locate Lua library
# This module defines
# LUA51_FOUND, if false, do not try to link to Lua
# LUA_LIBRARIES
# LUA_INCLUDE_DIR, where to find lua.h
# LUA_VERSION_STRING, the version of Lua found (since CMake 2.8.8)
#
# Note that the expected include convention is
# #include "lua.h"
# and not
# #include <lua/lua.h>
# This is because, the lua location is not standardized and may exist
# in locations other than lua/
#=============================================================================
# Copyright 2007-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
find_path(LUA_INCLUDE_DIR lua.h
HINTS
ENV LUA_DIR
PATH_SUFFIXES include/lua52 include/lua5.2 include/lua include
PATHS
~/Library/Frameworks
/Library/Frameworks
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
/opt
)
find_library(LUA_LIBRARY
NAMES lua52 lua5.2 lua-5.2 lua
HINTS
ENV LUA_DIR
PATH_SUFFIXES lib
PATHS
~/Library/Frameworks
/Library/Frameworks
/sw
/opt/local
/opt/csw
/opt
)
if(LUA_LIBRARY)
# include the math library for Unix
if(UNIX AND NOT APPLE)
find_library(LUA_MATH_LIBRARY m)
set( LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}" CACHE STRING "Lua Libraries")
# For Windows and Mac, don't need to explicitly include the math library
else()
set( LUA_LIBRARIES "${LUA_LIBRARY}" CACHE STRING "Lua Libraries")
endif()
endif()
if(LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/lua.h")
file(STRINGS "${LUA_INCLUDE_DIR}/lua.h" lua_version_str REGEX "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua .+\"")
string(REGEX REPLACE "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua ([^\"]+)\".*" "\\1" LUA_VERSION_STRING "${lua_version_str}")
unset(lua_version_str)
endif()
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if
# all listed variables are TRUE
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua52
REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR
VERSION_VAR LUA_VERSION_STRING)
mark_as_advanced(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY)

View File

@@ -9,7 +9,6 @@
#
# Created by Robert Osfield.
FIND_PATH(OPENEXR_INCLUDE_DIR OpenEXR/ImfIO.h
$ENV{OPENEXR_DIR}/include
$ENV{OPENEXR_DIR}
@@ -24,41 +23,78 @@ FIND_PATH(OPENEXR_INCLUDE_DIR OpenEXR/ImfIO.h
/usr/freeware/include
)
# Macro to find exr libraries (deduplicating search paths)
# example: OPENEXR_FIND_VAR(OPENEXR_IlmImf_LIBRARY IlmImf)
MACRO(OPENEXR_FIND_VAR varname libname)
FIND_LIBRARY( ${varname}
NAMES ${libname}
PATHS
$ENV{OPENEXR_DIR}/lib
$ENV{OPENEXR_DIR}
~/Library/Frameworks
/Library/Frameworks
/usr/local/lib
/usr/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
/usr/freeware/lib64
)
ENDMACRO(OPENEXR_FIND_VAR)
FIND_LIBRARY(OPENEXR_IlmIlf_LIBRARY
NAMES IlmImf
PATHS
$ENV{OPENEXR_DIR}/lib
$ENV{OPENEXR_DIR}
~/Library/Frameworks
/Library/Frameworks
/usr/local/lib
/usr/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
/usr/freeware/lib64
)
# Macro to find exr libraries (and debug versions)
# example: OPENEXR_FIND(IlmImf)
MACRO(OPENEXR_FIND libname)
OPENEXR_FIND_VAR(OPENEXR_${libname}_LIBRARY ${libname})
OPENEXR_FIND_VAR(OPENEXR_${libname}_LIBRARY_DEBUG ${libname}d)
ENDMACRO(OPENEXR_FIND)
FIND_LIBRARY(OPENEXR_IlmThread_LIBRARY
NAMES IlmThread
PATHS
$ENV{OPENEXR_DIR}/lib
$ENV{OPENEXR_DIR}
~/Library/Frameworks
/Library/Frameworks
/usr/local/lib
/usr/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
/usr/freeware/lib64
)
OPENEXR_FIND(IlmImf)
OPENEXR_FIND(IlmThread)
OPENEXR_FIND(Iex)
OPENEXR_FIND(Half)
FIND_LIBRARY(OPENEXR_Iex_LIBRARY
NAMES Iex
PATHS
$ENV{OPENEXR_DIR}/lib
$ENV{OPENEXR_DIR}
~/Library/Frameworks
/Library/Frameworks
/usr/local/lib
/usr/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
/usr/freeware/lib64
)
FIND_LIBRARY(OPENEXR_Half_LIBRARY
NAMES Half
PATHS
$ENV{OPENEXR_DIR}/lib
$ENV{OPENEXR_DIR}
~/Library/Frameworks
/Library/Frameworks
/usr/local/lib
/usr/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
/usr/freeware/lib64
)
SET(OPENEXR_FOUND "NO")
IF(OPENEXR_INCLUDE_DIR AND OPENEXR_IlmImf_LIBRARY AND OPENEXR_IlmThread_LIBRARY AND OPENEXR_Iex_LIBRARY AND OPENEXR_Half_LIBRARY)
SET(OPENEXR_LIBRARIES ${OPENEXR_IlmImf_LIBRARY} ${OPENEXR_IlmThread_LIBRARY} ${OPENEXR_Half_LIBRARY} ${OPENEXR_Iex_LIBRARY} )
SET(OPENEXR_LIBRARIES_VARS OPENEXR_IlmImf_LIBRARY OPENEXR_IlmThread_LIBRARY OPENEXR_Half_LIBRARY OPENEXR_Iex_LIBRARY )
IF(OPENEXR_INCLUDE_DIR AND OPENEXR_IlmIlf_LIBRARY AND OPENEXR_IlmThread_LIBRARY AND OPENEXR_Iex_LIBRARY AND OPENEXR_Half_LIBRARY)
SET(OPENEXR_LIBRARIES
${OPENEXR_IlmIlf_LIBRARY}
${OPENEXR_IlmThread_LIBRARY}
${OPENEXR_Half_LIBRARY}
${OPENEXR_Iex_LIBRARY}
)
SET(OPENEXR_FOUND "YES")
ENDIF(OPENEXR_INCLUDE_DIR AND OPENEXR_IlmImf_LIBRARY AND OPENEXR_IlmThread_LIBRARY AND OPENEXR_Iex_LIBRARY AND OPENEXR_Half_LIBRARY)
ENDIF(OPENEXR_INCLUDE_DIR AND OPENEXR_IlmIlf_LIBRARY AND OPENEXR_IlmThread_LIBRARY AND OPENEXR_Iex_LIBRARY AND OPENEXR_Half_LIBRARY)

View File

@@ -17,16 +17,6 @@
#
# Created by Eric Wing.
# prefer FindOpenThreads from cmake distribution
if(EXISTS ${CMAKE_ROOT}/Modules/FindOpenThreads.cmake)
include(${CMAKE_ROOT}/Modules/FindOpenThreads.cmake)
if(OPENTHREADS_FOUND)
return()
endif()
endif()
# Header files are presumed to be included like
# #include <OpenThreads/Thread>

View File

@@ -1,14 +1,13 @@
# Locate QuickTime
# This module defines
# QUICKTIME_LIBRARY
# QUICKTIME_FOUND, if false, do not try to link to gdal
# QUICKTIME_FOUND, if false, do not try to link to gdal
# QUICKTIME_INCLUDE_DIR, where to find the headers
#
# $QUICKTIME_DIR is an environment variable that would
# correspond to the ./configure --prefix=$QUICKTIME_DIR
#
# Created by Eric Wing.
# Created by Eric Wing.
# QuickTime on OS X looks different than QuickTime for Windows,
# so I am going to case the two.

View File

@@ -1,178 +0,0 @@
# - Locate SDL library
# This module defines
# SDL2_LIBRARY, the name of the library to link against
# SDL2_FOUND, if false, do not try to link to SDL
# SDL2_INCLUDE_DIR, where to find SDL.h
# SDL2_VERSION_STRING, human-readable string containing the version of SDL
#
# This module responds to the flag:
# SDL2_BUILDING_LIBRARY
# If this is defined, then no SDL2_main will be linked in because
# only applications need main().
# Otherwise, it is assumed you are building an application and this
# module will attempt to locate and set the proper link flags
# as part of the returned SDL2_LIBRARY variable.
#
# Don't forget to include SDLmain.h and SDLmain.m your project for the
# OS X framework based version. (Other versions link to -lSDLmain which
# this module will try to find on your behalf.) Also for OS X, this
# module will automatically add the -framework Cocoa on your behalf.
#
#
# Additional Note: If you see an empty SDL2_LIBRARY_TEMP in your configuration
# and no SDL2_LIBRARY, it means CMake did not find your SDL library
# (SDL.dll, libsdl.so, SDL.framework, etc).
# Set SDL2_LIBRARY_TEMP to point to your SDL library, and configure again.
# Similarly, if you see an empty SDL2MAIN_LIBRARY, you should set this value
# as appropriate. These values are used to generate the final SDL2_LIBRARY
# variable, but when these values are unset, SDL2_LIBRARY does not get created.
#
#
# $SDLDIR is an environment variable that would
# correspond to the ./configure --prefix=$SDLDIR
# used in building SDL.
# l.e.galup 9-20-02
#
# Modified by Eric Wing.
# Added code to assist with automated building by using environmental variables
# and providing a more controlled/consistent search behavior.
# Added new modifications to recognize OS X frameworks and
# additional Unix paths (FreeBSD, etc).
# Also corrected the header search path to follow "proper" SDL guidelines.
# Added a search for SDLmain which is needed by some platforms.
# Added a search for threads which is needed by some platforms.
# Added needed compile switches for MinGW.
#
# On OSX, this will prefer the Framework version (if found) over others.
# People will have to manually change the cache values of
# SDL2_LIBRARY to override this selection or set the CMake environment
# CMAKE_INCLUDE_PATH to modify the search paths.
#
# Note that the header path has changed from SDL/SDL.h to just SDL.h
# This needed to change because "proper" SDL convention
# is #include "SDL.h", not <SDL/SDL.h>. This is done for portability
# reasons because not all systems place things in SDL/ (see FreeBSD).
#=============================================================================
# Copyright 2003-2009 Kitware, Inc.
# Copyright 2012 Benjamin Eikel
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
find_path(SDL2_INCLUDE_DIR SDL.h
HINTS
ENV SDL2DIR
PATH_SUFFIXES include/SDL2
)
# SDL-1.1 is the name used by FreeBSD ports...
# don't confuse it for the version number.
find_library(SDL2_LIBRARY_TEMP
NAMES SDL2
HINTS
ENV SDL2DIR
PATH_SUFFIXES lib
)
if(NOT SDL2_BUILDING_LIBRARY)
if(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework")
# Non-OS X framework versions expect you to also dynamically link to
# SDLmain. This is mainly for Windows and OS X. Other (Unix) platforms
# seem to provide SDLmain for compatibility even though they don't
# necessarily need it.
find_library(SDL2MAIN_LIBRARY
NAMES SDL2main
HINTS
ENV SDL2DIR
PATH_SUFFIXES lib
PATHS
/sw
/opt/local
/opt/csw
/opt
)
endif()
endif()
# SDL may require threads on your system.
# The Apple build may not need an explicit flag because one of the
# frameworks may already provide it.
# But for non-OSX systems, I will use the CMake Threads package.
if(NOT APPLE)
find_package(Threads)
endif()
# MinGW needs an additional library, mwindows
# It's total link flags should look like -lmingw32 -lSDLmain -lSDL -lmwindows
# (Actually on second look, I think it only needs one of the m* libraries.)
if(MINGW)
set(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW")
endif()
if(SDL2_LIBRARY_TEMP)
# For SDLmain
if(SDL2MAIN_LIBRARY AND NOT SDL2_BUILDING_LIBRARY)
list(FIND SDL2_LIBRARY_TEMP "${SDL2MAIN_LIBRARY}" _SDL2_MAIN_INDEX)
if(_SDL2_MAIN_INDEX EQUAL -1)
set(SDL2_LIBRARY_TEMP "${SDL2MAIN_LIBRARY}" ${SDL2_LIBRARY_TEMP})
endif()
unset(_SDL2_MAIN_INDEX)
endif()
# For OS X, SDL uses Cocoa as a backend so it must link to Cocoa.
# CMake doesn't display the -framework Cocoa string in the UI even
# though it actually is there if I modify a pre-used variable.
# I think it has something to do with the CACHE STRING.
# So I use a temporary variable until the end so I can set the
# "real" variable in one-shot.
if(APPLE)
set(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} "-framework Cocoa")
endif()
# For threads, as mentioned Apple doesn't need this.
# In fact, there seems to be a problem if I used the Threads package
# and try using this line, so I'm just skipping it entirely for OS X.
if(NOT APPLE)
set(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT})
endif()
# For MinGW library
if(MINGW)
set(SDL2_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL2_LIBRARY_TEMP})
endif()
# Set the final string here so the GUI reflects the final state.
set(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL Library can be found")
# Set the temp variable to INTERNAL so it is not seen in the CMake GUI
set(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "")
endif()
if(SDL2_INCLUDE_DIR AND EXISTS "${SDL2_INCLUDE_DIR}/SDL2_version.h")
file(STRINGS "${SDL2_INCLUDE_DIR}/SDL2_version.h" SDL2_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL2_MAJOR_VERSION[ \t]+[0-9]+$")
file(STRINGS "${SDL2_INCLUDE_DIR}/SDL2_version.h" SDL2_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL2_MINOR_VERSION[ \t]+[0-9]+$")
file(STRINGS "${SDL2_INCLUDE_DIR}/SDL2_version.h" SDL2_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL2_PATCHLEVEL[ \t]+[0-9]+$")
string(REGEX REPLACE "^#define[ \t]+SDL2_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_VERSION_MAJOR "${SDL2_VERSION_MAJOR_LINE}")
string(REGEX REPLACE "^#define[ \t]+SDL2_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_VERSION_MINOR "${SDL2_VERSION_MINOR_LINE}")
string(REGEX REPLACE "^#define[ \t]+SDL2_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL2_VERSION_PATCH "${SDL2_VERSION_PATCH_LINE}")
set(SDL2_VERSION_STRING ${SDL2_VERSION_MAJOR}.${SDL2_VERSION_MINOR}.${SDL2_VERSION_PATCH})
unset(SDL2_VERSION_MAJOR_LINE)
unset(SDL2_VERSION_MINOR_LINE)
unset(SDL2_VERSION_PATCH_LINE)
unset(SDL2_VERSION_MAJOR)
unset(SDL2_VERSION_MINOR)
unset(SDL2_VERSION_PATCH)
endif()
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2
REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR
VERSION_VAR SDL2_VERSION_STRING)

View File

@@ -1,45 +0,0 @@
# Locate V8
# This module defines
# V8_LIBRARY
# V8_FOUND, if false, do not try to link to gdal
# V8_INCLUDE_DIR, where to find the headers
#
# $V8_DIR is an environment variable that would
# correspond to the ./configure --prefix=$V8_DIR
#
# Created by Robert Osfield (based on FindFLTK.cmake)
FIND_PATH(V8_INCLUDE_DIR v8.h
$ENV{V8_DIR}/include
$ENV{V8_DIR}
~/Library/Frameworks
/Library/Frameworks
/usr/local/include
/usr/include
/sw/include # Fink
/opt/local/include # DarwinPorts
/opt/csw/include # Blastwave
/opt/include
/usr/freeware/include
)
FIND_LIBRARY(V8_LIBRARY
NAMES v8 libv8
PATHS
$ENV{V8_DIR}/lib
$ENV{V8_DIR}
~/Library/Frameworks
/Library/Frameworks
/usr/local/lib
/usr/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
/usr/freeware/lib64
)
SET(V8_FOUND "NO")
IF(V8_LIBRARY AND V8_INCLUDE_DIR)
SET(V8_FOUND "YES")
ENDIF()

View File

@@ -10,16 +10,6 @@
#
# Created by Ulrich Hertlein.
# prefer FindZLIB from cmake distribution
if(EXISTS ${CMAKE_ROOT}/Modules/FindZLIB.cmake)
include(${CMAKE_ROOT}/Modules/FindZLIB.cmake)
if(ZLIB_FOUND)
return()
endif()
endif()
FIND_PATH(ZLIB_INCLUDE_DIR zlib.h
$ENV{ZLIB_DIR}/include
$ENV{ZLIB_DIR}

View File

@@ -25,6 +25,14 @@ IF(MSVC AND OSG_MSVC_VERSIONED_DLL)
HANDLE_MSVC_DLL()
ENDIF()
IF(ANDROID)
INSTALL (
FILES ${TARGET_H}
DESTINATION ${INSTALL_INCDIR}/${LIB_NAME}
COMPONENT libopenscenegraph-dev
)
ELSE(ANDROID)
INSTALL(
TARGETS ${LIB_NAME}
RUNTIME DESTINATION ${INSTALL_BINDIR} COMPONENT libopenscenegraph
@@ -51,3 +59,4 @@ ELSE()
# MESSAGE("${OSG_COMPILE_FRAMEWORKS_INSTALL_NAME_DIR}")
ENDIF()
ENDIF(ANDROID)

View File

@@ -67,7 +67,7 @@ MACRO(ANDROID_3RD_PARTY)
#JPEG
################################################
FIND_PATH(JPEG_INCLUDE_DIR Android.mk
${CMAKE_SOURCE_DIR}/3rdparty/libjpeg NO_CMAKE_FIND_ROOT_PATH
${CMAKE_SOURCE_DIR}/3rdparty/libjpeg
)
#set(ENV{AND_OSG_LIB_NAMES} "$ENV{AND_OSG_LIB_NAMES} libjpeg")
#set(ENV{AND_OSG_LIB_PATHS} "$ENV{AND_OSG_LIB_PATHS}include ${JPEG_INCLUDE_DIR}/Android.mk \n")
@@ -82,7 +82,7 @@ MACRO(ANDROID_3RD_PARTY)
#PNG
################################################
FIND_PATH(PNG_INCLUDE_DIR Android.mk
${CMAKE_SOURCE_DIR}/3rdparty/libpng NO_CMAKE_FIND_ROOT_PATH
${CMAKE_SOURCE_DIR}/3rdparty/libpng
)
#set(ENV{AND_OSG_LIB_NAMES} "$ENV{AND_OSG_LIB_NAMES} libpng")
#set(ENV{AND_OSG_LIB_PATHS} "$ENV{AND_OSG_LIB_PATHS}include ${PNG_INCLUDE_DIR}/Android.mk \n")
@@ -97,7 +97,7 @@ MACRO(ANDROID_3RD_PARTY)
#GIF
################################################
FIND_PATH(GIFLIB_INCLUDE_DIR Android.mk
${CMAKE_SOURCE_DIR}/3rdparty/giflib NO_CMAKE_FIND_ROOT_PATH
${CMAKE_SOURCE_DIR}/3rdparty/giflib
)
#set(ENV{AND_OSG_LIB_NAMES} "$ENV{AND_OSG_LIB_NAMES} libgif")
#set(ENV{AND_OSG_LIB_PATHS} "$ENV{AND_OSG_LIB_PATHS}include ${GIFLIB_INCLUDE_DIR}/Android.mk \n")
@@ -112,7 +112,7 @@ MACRO(ANDROID_3RD_PARTY)
#TIF
################################################
FIND_PATH(TIFF_INCLUDE_DIR Android.mk
${CMAKE_SOURCE_DIR}/3rdparty/libtiff NO_CMAKE_FIND_ROOT_PATH
${CMAKE_SOURCE_DIR}/3rdparty/libtiff
)
#set(ENV{AND_OSG_LIB_NAMES} "$ENV{AND_OSG_LIB_NAMES} libtiff")
#set(ENV{AND_OSG_LIB_PATHS} "$ENV{AND_OSG_LIB_PATHS}include ${TIFF_INCLUDE_DIR}/Android.mk \n")
@@ -142,7 +142,7 @@ MACRO(ANDROID_3RD_PARTY)
#CURL
################################################
FIND_PATH(CURL_DIR Android.mk
${CMAKE_SOURCE_DIR}/3rdparty/curl NO_CMAKE_FIND_ROOT_PATH
${CMAKE_SOURCE_DIR}/3rdparty/curl
)
#set(ENV{AND_OSG_LIB_NAMES} "$ENV{AND_OSG_LIB_NAMES} libcurl")
#set(ENV{AND_OSG_LIB_PATHS} "$ENV{AND_OSG_LIB_PATHS}include ${CURL_DIR}/Android.mk \n")
@@ -159,11 +159,11 @@ MACRO(ANDROID_3RD_PARTY)
#FREETYPE
################################################
FIND_PATH(FREETYPE_DIR Android.mk
${CMAKE_SOURCE_DIR}/3rdparty/freetype NO_CMAKE_FIND_ROOT_PATH
${CMAKE_SOURCE_DIR}/3rdparty/freetype
)
#set(ENV{AND_OSG_LIB_NAMES} "$ENV{AND_OSG_LIB_NAMES} libft2")
#set(ENV{AND_OSG_LIB_PATHS} "$ENV{AND_OSG_LIB_PATHS}include ${FREETYPE_DIR}/Android.mk \n")
set(FREETYPE_INCLUDE_DIRS ${FREETYPE_DIR}/include ${FREETYPE_DIR}/include/freetype/config)
set(FREETYPE_INCLUDE_DIRS "${FREETYPE_DIR}/include ${FREETYPE_DIR}/include/freetype/config")
if(FREETYPE_DIR)
message(STATUS "FREETYPE found ${FREETYPE_DIR}" )
set(FREETYPE_FOUND "Yes")
@@ -175,7 +175,7 @@ MACRO(ANDROID_3RD_PARTY)
#GDAL
################################################
FIND_PATH(GDAL_DIR gdal.h
${CMAKE_SOURCE_DIR}/3rdparty/gdal/include NO_CMAKE_FIND_ROOT_PATH
${CMAKE_SOURCE_DIR}/3rdparty/gdal/include
)
set(GDAL_INCLUDE_DIR "${GDAL_DIR}")
if(GDAL_DIR)

View File

@@ -4,7 +4,7 @@
# full path of the library name. in order to differentiate release and debug, this macro get the
# NAME of the variables, so the macro gets as arguments the target name and the following list of parameters
# is intended as a list of variable names each one containing the path of the libraries to link to
# The existence of a variable name with _DEBUG appended is tested and, in case it' s value is used
# The existance of a variable name with _DEBUG appended is tested and, in case it' s value is used
# for linking to when in debug mode
# the content of this library for linking when in debugging
#######################################################################################################
@@ -212,10 +212,9 @@ ENDMACRO(SET_OUTPUT_DIR_PROPERTY_260 TARGET_TARGETNAME RELATIVE_OUTDIR)
##########################################################################################################
MACRO(SETUP_LIBRARY LIB_NAME)
IF(GLCORE_FOUND)
INCLUDE_DIRECTORIES( ${GLCORE_INCLUDE_DIR} )
ENDIF()
IF(ANDROID)
SETUP_ANDROID_LIBRARY(${LIB_NAME})
ELSE()
SET(TARGET_NAME ${LIB_NAME} )
SET(TARGET_TARGETNAME ${LIB_NAME} )
ADD_LIBRARY(${LIB_NAME}
@@ -243,13 +242,14 @@ MACRO(SETUP_LIBRARY LIB_NAME)
ENDIF(TARGET_LIBRARIES_VARS)
LINK_CORELIB_DEFAULT(${LIB_NAME})
ENDIF()
INCLUDE(ModuleInstall OPTIONAL)
ENDMACRO(SETUP_LIBRARY LIB_NAME)
MACRO(SETUP_PLUGIN PLUGIN_NAME)
IF(GLCORE_FOUND)
INCLUDE_DIRECTORIES( ${GLCORE_INCLUDE_DIR} )
ENDIF()
IF(ANDROID)
SETUP_ANDROID_LIBRARY(${TARGET_DEFAULT_PREFIX}${PLUGIN_NAME})
ELSE()
SET(TARGET_NAME ${PLUGIN_NAME} )
@@ -332,6 +332,7 @@ MACRO(SETUP_PLUGIN PLUGIN_NAME)
ARCHIVE DESTINATION lib${LIB_POSTFIX}/${OSG_PLUGINS} COMPONENT libopenscenegraph-dev
LIBRARY DESTINATION lib${LIB_POSTFIX}/${OSG_PLUGINS} COMPONENT ${PACKAGE_COMPONENT})
ENDIF(WIN32)
ENDIF()
ENDMACRO(SETUP_PLUGIN)
@@ -341,10 +342,6 @@ ENDMACRO(SETUP_PLUGIN)
MACRO(SETUP_EXE IS_COMMANDLINE_APP)
#MESSAGE("in -->SETUP_EXE<-- ${TARGET_NAME}-->${TARGET_SRC} <--> ${TARGET_H}<--")
IF(GL3_FOUND)
INCLUDE_DIRECTORIES( ${GLCORE_INCLUDE_DIR} )
ENDIF()
IF(NOT TARGET_TARGETNAME)
SET(TARGET_TARGETNAME "${TARGET_DEFAULT_PREFIX}${TARGET_NAME}")
ENDIF(NOT TARGET_TARGETNAME)

6715
ChangeLog

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,63 @@
OSG News
========
= OpenSceneGraph 3.2.2 maintance release provides a number of bug and build fixes over the 3.2.1 stable release
PERTHSHIRE, Scotland - 4th August 2015 - OpenSceneGraph Professional Services announces the release of OpenSceneGraph 3.2.2, the industry's leading open-source scene graph technology, designed to accelerate application development and improve 3D graphics performance. OpenSceneGraph 3.2.2 is 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 3.2.2 runs on all Microsoft Windows platforms, Apple OS/X, IOS, GNU/Linux, Android, IRIX, Solaris, HP-UX, AIX and FreeBSD operating systems.
=== Open-source development delivers industry-leading features and performance ===
The OpenSceneGraph 3.2.2 stable release is the culmination of 16 years of work by the open-source community that has grown up around the project. This point release is fully binary compatible with the 3.2.0 and 3.2.1 stable releases. The changes made are focused on addressing bugs and improving build support for latest compilers, OS updates and 3rd changes to Party Libraries.
=== 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/index.php/download-section/stable-releases 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.
=== Professional support and services ===
OpenSceneGraph project is backed up with professional services by [http://www.openscenegraph.com OpenSceneGraph Professional Services], based in Scotland, and [http://www.alphapixel.com AlphaPixel] 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 5000 developers is centred around the public osg-users mailing list/forum, 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/index.php/about/197-contributors-to-openscenegraph-3-2-2 individuals] from around the world that have directly contributed to the development and refinement of the OpenSceneGraph code base.
= OpenSceneGraph 3.2.1 stable release provides a number of bug and build fixes to the 3.2.0 stable release
PERTHSHIRE, Scotland - 4th July 2014 - OpenSceneGraph Professional Services announces the release of OpenSceneGraph 3.2.1, the industry's leading open-source scene graph technology, designed to accelerate application development and improve 3D graphics performance. OpenSceneGraph 3.2 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 3.2 runs on all Microsoft Windows platforms, Apple OS/X, IOS, GNU/Linux, Android, IRIX, Solaris, HP-UX, AIX and FreeBSD operating systems.
=== Open-source development delivers industry-leading features and performance ===
The OpenSceneGraph 3.2.1 stable release is the culmination of 15 years of work by the open-source community that has grown up around the project. This point release is fully binary compatible with the 3.2.0 stable release. The changes made are focused on addressing bugs and improving build support for latest compilers, OS updates and 3rd changes to Party Libraries.
=== 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/index.php/download-section/stable-releases 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.
=== Professional support and services ===
OpenSceneGraph project is backed up with professional services by [http://www.openscenegraph.com OpenSceneGraph Professional Services], based in Scotland, and [http://www.skew-matrix.com Skew-Matrix] and [http://www.alphapixel.com AlphaPixel] 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 5000 developers is centred around the public osg-users mailing list/forum, 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/index.php/about/56-contributors/162-contributors-to-openscenegraph-3-2-1 individuals] from around the world that have directly contributed to the development and refinement of the OpenSceneGraph code base.
= !OpenSceneGraph 3.2 release improves support iOS and Android, supports a range of new OpenGL features much more.
PERTHSHIRE, Scotland - 24th July 2013 - !OpenSceneGraph Professional Services announces the release of !OpenSceneGraph 3.2, the industry's leading open-source scene graph technology, designed to accelerate application development and improve 3D graphics performance. !OpenSceneGraph 3.2 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 3.2 runs on all Microsoft Windows platforms, Apple OS/X, IOS, GNU/Linux, Android, IRIX, Solaris, HP-UX, AIX and FreeBSD operating systems.

File diff suppressed because it is too large Load Diff

View File

@@ -43,12 +43,13 @@ OpenSceneGraph's CMake build can be found at:
http://www.openscenegraph.org/projects/osg/wiki/Build/CMake
Under unices (i.e. Linux, IRIX, Solaris, Free-BSD, HP-Ux, AIX, OSX)
use the cmake or ccmake command-line utils. Note that cmake . defaults
to building Release to ensure that you get the best performance from
your final libraries/applications.
use the cmake or ccmake command-line utils, or use the included tiny
configure script that'll run cmake for you. The configure script
simply runs 'cmake . -DCMAKE_BUILD_TYPE=Release' to ensure that you
get the best performance from your final libraries/applications.
cd OpenSceneGraph
cmake .
./configure
make
sudo make install
@@ -61,7 +62,7 @@ directory alongside the OpenSceneGraph use:
mkdir build
cd build
cmake ../OpenSceneGraph
cmake ../OpenSceneGraph -DCMAKE_BUILD_TYPE=Release
make
sudo make install
@@ -166,7 +167,7 @@ Section 3. Release notes on iOS build, by Thomas Hoghart
This will give us the static build we need for iPhone.
* Disable OSG_GL1_AVAILABLE, OSG_GL2_AVAILABLE, OSG_GL3_AVAILABLE,
OSG_GL_DISPLAYLISTS_AVAILABLE, OSG_GL_VERTEX_FUNCS_AVAILABLE
* Enable OSG_GLES1_AVAILABLE *OR* OSG_GLES2_AVAILABLE *OR* OSG_GLES3_AVAILABLE (GLES3 will enable GLES2 features)
* Enable OSG_GLES1_AVAILABLE *OR* OSG_GLES2_AVAILABLE
* Ensure OSG_WINDOWING_SYSTEM is set to IOS
* Change FREETYPE include and library paths to an iPhone version
(OpenFrameworks has one bundled with its distribution)

View File

@@ -174,7 +174,7 @@ public:
{
texture->setInternalFormatMode(_internalFormatMode);
// need to disable the unref after apply, otherwise the image could go out of scope.
// need to disable the unref after apply, other the image could go out of scope.
bool unrefImageDataAfterApply = texture->getUnRefImageDataAfterApply();
texture->setUnRefImageDataAfterApply(false);
@@ -373,6 +373,16 @@ public:
++_numStateSetRemoved;
}
for(unsigned int i=0;i<node.getNumDrawables();++i)
{
osg::Drawable* drawable = node.getDrawable(i);
if (drawable && drawable->getStateSet())
{
drawable->setStateSet(0);
++_numStateSetRemoved;
}
}
traverse(node);
}
@@ -807,7 +817,7 @@ int main( int argc, char **argv )
root->accept(av);
}
// optimize the scene graph, remove redundant nodes and state etc.
// optimize the scene graph, remove rendundent nodes and state etc.
osgUtil::Optimizer optimizer;
optimizer.optimize(root.get());

View File

@@ -1,5 +1,5 @@
// The majority of the application is dedicated to building the
// current contributors list by parsing the ChangeLog, it just takes
// current contribitors list by parsing the ChangeLog, it just takes
// one line in the main itself to report the version number.
#include <set>

View File

@@ -14,7 +14,6 @@
#include <osg/CoordinateSystemNode>
#include <osg/Switch>
#include <osg/Types>
#include <osgText/Text>
#include <osgViewer/Viewer>
@@ -32,7 +31,113 @@
#include <osgGA/Device>
#include <iostream>
#include <stdint.h>
#include <osg/GLExtensions>
#ifndef GL_ARB_sync
#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111
#define GL_OBJECT_TYPE 0x9112
#define GL_SYNC_CONDITION 0x9113
#define GL_SYNC_STATUS 0x9114
#define GL_SYNC_FLAGS 0x9115
#define GL_SYNC_FENCE 0x9116
#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117
#define GL_UNSIGNALED 0x9118
#define GL_SIGNALED 0x9119
#define GL_ALREADY_SIGNALED 0x911A
#define GL_TIMEOUT_EXPIRED 0x911B
#define GL_CONDITION_SATISFIED 0x911C
#define GL_WAIT_FAILED 0x911D
#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001
#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull
#endif
class MySwapBuffersCallback : public osg::GraphicsContext::SwapCallback
{
public:
MySwapBuffersCallback():
_extensionInitialized(false),
_glFenceSync(0),
_glIsSync(0),
_glDeleteSync(0),
_glClientWaitSync(0),
_glWaitSync(0),
_glGetInteger64v(0),
_glGetSynciv(0),
_previousSync(0)
{
OSG_NOTICE<<"Created Swap callback."<<std::endl;
}
void setUpExtensions()
{
_extensionInitialized = true;
osg::setGLExtensionFuncPtr(_glFenceSync, "glFenceSync");
osg::setGLExtensionFuncPtr(_glIsSync, "glIsSync");
osg::setGLExtensionFuncPtr(_glDeleteSync, "glDeleteSync");
osg::setGLExtensionFuncPtr(_glClientWaitSync, "glClientWaitSync");
osg::setGLExtensionFuncPtr(_glWaitSync, "glWaitSync");
osg::setGLExtensionFuncPtr(_glGetInteger64v, "glGetInteger64v");
osg::setGLExtensionFuncPtr(_glGetSynciv, "glGetSynciv");
}
virtual void swapBuffersImplementation(osg::GraphicsContext* gc)
{
// OSG_NOTICE<<"Before swap - place to do swap ready sync"<<std::endl;
gc->swapBuffersImplementation();
//glFinish();
if (!_extensionInitialized) setUpExtensions();
if (_glClientWaitSync)
{
if (_previousSync)
{
unsigned int num_seconds = 1;
GLuint64 timeout = num_seconds * ((GLuint64)1000 * 1000 * 1000);
_glClientWaitSync(_previousSync, 0, timeout);
_glDeleteSync(_previousSync);
}
_previousSync = _glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
}
//gc->getState()->checkGLErrors("after glWaitSync");
//OSG_NOTICE<<"After swap"<<std::endl;
}
#ifdef _WIN32
typedef __int64 GLint64;
typedef unsigned __int64 GLuint64;
#else
typedef int64_t GLint64;
typedef uint64_t GLuint64;
#endif
typedef struct __GLsync *GLsync;
typedef GLsync (GL_APIENTRY * PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags);
typedef GLboolean (GL_APIENTRY * PFNGLISSYNCPROC) (GLsync sync);
typedef void (GL_APIENTRY * PFNGLDELETESYNCPROC) (GLsync sync);
typedef GLenum (GL_APIENTRY * PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout);
typedef void (GL_APIENTRY * PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout);
typedef void (GL_APIENTRY * PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *params);
typedef void (GL_APIENTRY * PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
bool _extensionInitialized;
PFNGLFENCESYNCPROC _glFenceSync;
PFNGLISSYNCPROC _glIsSync;
PFNGLDELETESYNCPROC _glDeleteSync;
PFNGLCLIENTWAITSYNCPROC _glClientWaitSync;
PFNGLWAITSYNCPROC _glWaitSync;
PFNGLGETINTEGER64VPROC _glGetInteger64v;
PFNGLGETSYNCIVPROC _glGetSynciv;
GLsync _previousSync;
};
int main(int argc, char** argv)
{
@@ -127,6 +232,8 @@ int main(int argc, char** argv)
viewer.setCameraManipulator( keyswitchManipulator.get() );
}
bool doArbSync = arguments.read("--sync");
// add the state manipulator
viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) );
@@ -178,6 +285,18 @@ int main(int argc, char** argv)
viewer.realize();
if (doArbSync)
{
osgViewer::ViewerBase::Contexts contexts;
viewer.getContexts(contexts);
for(osgViewer::ViewerBase::Contexts::iterator itr = contexts.begin();
itr != contexts.end();
++itr)
{
(*itr)->setSwapCallback(new MySwapBuffersCallback);
}
}
return viewer.run();
}

View File

@@ -54,7 +54,7 @@ IF (NOT DYNAMIC_OPENSCENEGRAPH)
osgdb_openflight
osgdb_obj
)
SET(TARGET_ADDED_LIBRARIES ${TARGET_ADDED_LIBRARIES}
osgdb_deprecated_osg osgdb_deprecated_osgparticle osgdb_deprecated_osganimation
osgdb_deprecated_osgfx osgdb_deprecated_osgsim osgdb_deprecated_osgtext

View File

@@ -202,8 +202,7 @@ void DataConverter::write(CameraPacket& cameraPacket)
itr != cameraPacket._events.end();
++itr)
{
osgGA::GUIEventAdapter* event = (*itr)->asGUIEventAdapter();
if (event) write(*(event));
write(*(*itr));
}
}
@@ -250,7 +249,7 @@ void CameraPacket::writeEventQueue(osgViewer::Viewer& viewer)
//////////////////////////////////////////////////////////////////////////////
//
// Receiver
// Reciever
//
Receiver::Receiver( void )
{

View File

@@ -33,21 +33,21 @@ class Receiver
{
public :
Receiver();
~Receiver();
Receiver();
~Receiver();
// setBuffer defines the buffer into which the broadcasted
// message will be received.
void setBuffer( void *buffer, const unsigned int size );
// setBuffer defines the buffer into which the broadcasted
// message will be received.
void setBuffer( void *buffer, const unsigned int size );
// Define what port to listen and bind to
void setPort( const short port );
// Define what port to listen and bind to
void setPort( const short port );
// Sync does a blocking wait to recieve next message
void sync( void );
// Sync does a blocking wait to recieve next message
void sync( void );
private :
bool init( void );
bool init( void );
private :
#if defined (WIN32) && !defined(__CYGWIN__)
@@ -72,25 +72,25 @@ class Broadcaster
{
public :
Broadcaster( void );
~Broadcaster( void );
Broadcaster( void );
~Broadcaster( void );
// Set the broadcast port
void setPort( const short port );
// Set the broadcast port
void setPort( const short port );
// Set the buffer to be broadcast
void setBuffer( void *buffer, const unsigned int buffer_size );
// Set the buffer to be broadcast
void setBuffer( void *buffer, const unsigned int buffer_size );
// Set a recipient host. If this is used, the Broadcaster
// no longer broadcasts, but rather directs UDP packets at
// host.
void setHost( const char *hostname );
// Set a recipient host. If this is used, the Broadcaster
// no longer broadcasts, but rather directs UDP packets at
// host.
void setHost( const char *hostname );
// Sync broadcasts the buffer
void sync( void );
// Sync broadcasts the buffer
void sync( void );
private :
bool init( void );
bool init( void );
private :
#if defined(WIN32) && !defined(__CYGWIN__)

View File

@@ -1,12 +1,12 @@
/* -*-c++-*- Present3D - Copyright (C) 1999-2006 Robert Osfield
/* -*-c++-*- Present3D - Copyright (C) 1999-2006 Robert Osfield
*
* This software is open source and may be redistributed and/or modified under
* This software is open source and may be redistributed and/or modified under
* the terms of the GNU General Public License (GPL) version 2.0.
* The full license is in LICENSE.txt file included with this distribution,.
*
*
* This software 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
* include LICENSE.txt for more details.
*/
@@ -46,16 +46,16 @@ public:
void setSnapImageOnNextFrame(bool flag) { _snapImageOnNextFrame = flag; }
bool getSnapImageOnNextFrame() const { return _snapImageOnNextFrame; }
virtual void operator () (const osg::Camera& camera) const
{
if (!_snapImageOnNextFrame) return;
int x = static_cast<int>(camera.getViewport()->x());
int y = static_cast<int>(camera.getViewport()->y());
unsigned int width = static_cast<unsigned int>(camera.getViewport()->width());
unsigned int height = static_cast<unsigned int>(camera.getViewport()->height());
osg::ref_ptr<osg::Image> image = new osg::Image;
image->readPixels(x,y,width,height,
GL_RGB,GL_UNSIGNED_BYTE);
@@ -64,16 +64,16 @@ public:
{
osg::notify(osg::NOTICE) << "Saved screen image to `"<<_filename<<"`"<< std::endl;
}
_snapImageOnNextFrame = false;
}
protected:
std::string _filename;
mutable bool _snapImageOnNextFrame;
};
std::string ExportHTML::createFileName(const std::string& basename, unsigned int page, const std::string& ext)
@@ -102,7 +102,7 @@ bool ExportHTML::write(osgPresentation::SlideEventHandler* seh, osgViewer::Viewe
image_basename = osgDB::getNameLessExtension(filename);
image_ext = ".jpg";
}
std::cout<<"Writing slides to "<<image_basename<<"_[slidenumber]"<<image_ext<<std::endl;
osg::ref_ptr<SnapImageDrawCallback> sidc = new SnapImageDrawCallback;
@@ -169,7 +169,7 @@ bool ExportHTML::write(osgPresentation::SlideEventHandler* seh, osgViewer::Viewe
}
fout<<"</tr>"<<std::endl;
fout<<"</table>"<<std::endl;
fout<<"<img src=\""<<osgDB::getSimpleFileName(os.str())<<"\">"<<std::endl;
fout<<"<img src=\""<<osgDB::getSimpleFileName(os.str())<<"\">"<<std::endl;
fout<<"</html>"<<std::endl;
}
else

View File

@@ -1,12 +1,12 @@
/* -*-c++-*- Present3D - Copyright (C) 1999-2006 Robert Osfield
/* -*-c++-*- Present3D - Copyright (C) 1999-2006 Robert Osfield
*
* This software is open source and may be redistributed and/or modified under
* This software is open source and may be redistributed and/or modified under
* the terms of the GNU General Public License (GPL) version 2.0.
* The full license is in LICENSE.txt file included with this distribution,.
*
*
* This software 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
* include LICENSE.txt for more details.
*/

View File

@@ -1,12 +1,12 @@
/* -*-c++-*- Present3D - Copyright (C) 1999-2006 Robert Osfield
/* -*-c++-*- Present3D - Copyright (C) 1999-2006 Robert Osfield
*
* This software is open source and may be redistributed and/or modified under
* This software is open source and may be redistributed and/or modified under
* the terms of the GNU General Public License (GPL) version 2.0.
* The full license is in LICENSE.txt file included with this distribution,.
*
*
* This software 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
* include LICENSE.txt for more details.
*/
@@ -54,6 +54,11 @@ bool PointsEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActio
return false;
}
void PointsEventHandler::accept(osgGA::GUIEventHandlerVisitor& v)
{
v.visit(*this);
}
void PointsEventHandler::getUsage(osg::ApplicationUsage& usage) const
{
usage.addKeyboardMouseBinding("+","Increase point size");

View File

@@ -1,12 +1,12 @@
/* -*-c++-*- Present3D - Copyright (C) 1999-2006 Robert Osfield
/* -*-c++-*- Present3D - Copyright (C) 1999-2006 Robert Osfield
*
* This software is open source and may be redistributed and/or modified under
* This software is open source and may be redistributed and/or modified under
* the terms of the GNU General Public License (GPL) version 2.0.
* The full license is in LICENSE.txt file included with this distribution,.
*
*
* This software 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
* include LICENSE.txt for more details.
*/
@@ -22,23 +22,25 @@ class PointsEventHandler : public osgGA::GUIEventHandler
{
public:
PointsEventHandler();
virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&);
virtual void accept(osgGA::GUIEventHandlerVisitor& v);
void getUsage(osg::ApplicationUsage& usage) const;
void setStateSet(osg::StateSet* stateset) { _stateset=stateset; }
osg::StateSet* getStateSet() { return _stateset.get(); }
const osg::StateSet* getStateSet() const { return _stateset.get(); }
void setPointSize(float psize);
float getPointSize() const;
void changePointSize(float delta);
void changePointAttenuation(float scale);
osg::ref_ptr<osg::StateSet> _stateset;

View File

@@ -1,12 +1,12 @@
/* -*-c++-*- Present3D - Copyright (C) 1999-2006 Robert Osfield
/* -*-c++-*- Present3D - Copyright (C) 1999-2006 Robert Osfield
*
* This software is open source and may be redistributed and/or modified under
* This software is open source and may be redistributed and/or modified under
* the terms of the GNU General Public License (GPL) version 2.0.
* The full license is in LICENSE.txt file included with this distribution,.
*
*
* This software 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
* include LICENSE.txt for more details.
*/
@@ -35,7 +35,7 @@ class AddVolumeEditingCallbackVisitor : public osg::NodeVisitor
public:
AddVolumeEditingCallbackVisitor():
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) {}
void apply(osg::Group& group)
{
osgVolume::VolumeTile* volumeTile = dynamic_cast<osgVolume::VolumeTile*>(&group);
@@ -51,7 +51,7 @@ public:
traverse(group);
}
}
};
bool p3d::getFileNames(osg::ArgumentParser& arguments, FileNameList& xmlFiles, FileNameList& normalFiles)
@@ -62,7 +62,7 @@ bool p3d::getFileNames(osg::ArgumentParser& arguments, FileNameList& xmlFiles, F
if (!arguments.isOption(pos))
{
std::string ext = osgDB::getFileExtension(arguments[pos]);
if (osgDB::equalCaseInsensitive(ext,"xml") || osgDB::equalCaseInsensitive(ext,"p3d"))
if (osgDB::equalCaseInsensitive(ext,"xml") || osgDB::equalCaseInsensitive(ext,"p3d"))
{
xmlFiles.push_back(arguments[pos]);
}
@@ -73,7 +73,7 @@ bool p3d::getFileNames(osg::ArgumentParser& arguments, FileNameList& xmlFiles, F
}
}
return (!xmlFiles.empty() || !normalFiles.empty());
}
}
bool p3d::readEnvVars(osg::ArgumentParser& arguments)
{
@@ -94,23 +94,23 @@ bool p3d::readEnvVars(osg::ArgumentParser& arguments)
{
osgDB::getDataFilePathList().push_front(path);
}
if (p3d::readEnvVars(file)) readVars = true;
}
}
}
}
return readVars;
}
bool p3d::readEnvVars(const std::string& fileName)
{
std::string ext = osgDB::getFileExtension(fileName);
if (!osgDB::equalCaseInsensitive(ext,"xml") &&
if (!osgDB::equalCaseInsensitive(ext,"xml") &&
!osgDB::equalCaseInsensitive(ext,"p3d")) return false;
osg::ref_ptr<osgDB::XmlNode> doc = new osgDB::XmlNode;
osgDB::XmlNode* root = 0;
@@ -146,7 +146,7 @@ bool p3d::readEnvVars(const std::string& fileName)
}
bool readVars = false;
for(osgDB::XmlNode::Children::iterator itr = root->children.begin();
itr != root->children.end();
++itr)
@@ -182,7 +182,7 @@ osgDB::Options* createOptions(const osgDB::ReaderWriter::Options* options)
osg::ref_ptr<osg::Node> p3d::readHoldingSlide(const std::string& filename)
{
std::string ext = osgDB::getFileExtension(filename);
if (!osgDB::equalCaseInsensitive(ext,"xml") &&
if (!osgDB::equalCaseInsensitive(ext,"xml") &&
!osgDB::equalCaseInsensitive(ext,"p3d")) return 0;
osg::ref_ptr<osgDB::ReaderWriter::Options> options = createOptions(0);
@@ -260,12 +260,12 @@ osg::ref_ptr<osg::Node> p3d::readShowFiles(osg::ArgumentParser& arguments,const
}
}
}
if (nodeList.empty())
{
return NULL;
}
osg::ref_ptr<osg::Node> root;
if (nodeList.size()==1)
@@ -274,7 +274,7 @@ osg::ref_ptr<osg::Node> p3d::readShowFiles(osg::ArgumentParser& arguments,const
}
else // size >1
{
osg::Switch* sw = new osg::Switch;
for(NodeList::iterator itr=nodeList.begin();
itr!=nodeList.end();
@@ -283,7 +283,7 @@ osg::ref_ptr<osg::Node> p3d::readShowFiles(osg::ArgumentParser& arguments,const
sw->addChild((*itr).get());
}
sw->setSingleChildOn(0);
sw->setEventCallback(new p3d::ShowEventHandler());
root = sw;
@@ -292,7 +292,7 @@ osg::ref_ptr<osg::Node> p3d::readShowFiles(osg::ArgumentParser& arguments,const
if (root.valid())
{
osg::notify(osg::INFO)<<"Got node now adding callback"<<std::endl;
AddVolumeEditingCallbackVisitor avecv;
root->accept(avecv);
}

View File

@@ -1,12 +1,12 @@
/* -*-c++-*- Present3D - Copyright (C) 1999-2006 Robert Osfield
/* -*-c++-*- Present3D - Copyright (C) 1999-2006 Robert Osfield
*
* This software is open source and may be redistributed and/or modified under
* This software is open source and may be redistributed and/or modified under
* the terms of the GNU General Public License (GPL) version 2.0.
* The full license is in LICENSE.txt file included with this distribution,.
*
*
* This software 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
* include LICENSE.txt for more details.
*/
@@ -28,13 +28,13 @@ bool ShowEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionA
case(osgGA::GUIEventAdapter::KEYUP):
{
osg::notify(osg::INFO)<<"ShowEventHandler KEYUP "<<(int)ea.getKey()<<std::endl;
if (ea.getKey()>=osgGA::GUIEventAdapter::KEY_F1 &&
if (ea.getKey()>=osgGA::GUIEventAdapter::KEY_F1 &&
ea.getKey()<=osgGA::GUIEventAdapter::KEY_F8)
{
unsigned int child = ea.getKey()-osgGA::GUIEventAdapter::KEY_F1;
osg::notify(osg::INFO)<<" Select "<<child<<std::endl;
osg::Switch* showSwitch = dynamic_cast<osg::Switch*>(object);
if (showSwitch)
if (showSwitch)
{
if (child<showSwitch->getNumChildren())
{
@@ -52,6 +52,12 @@ bool ShowEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionA
return false;
}
void ShowEventHandler::accept(osgGA::GUIEventHandlerVisitor& v)
{
v.visit(*this);
}
void ShowEventHandler::getUsage(osg::ApplicationUsage& /*usage*/) const
{
}

View File

@@ -1,12 +1,12 @@
/* -*-c++-*- Present3D - Copyright (C) 1999-2006 Robert Osfield
/* -*-c++-*- Present3D - Copyright (C) 1999-2006 Robert Osfield
*
* This software is open source and may be redistributed and/or modified under
* This software is open source and may be redistributed and/or modified under
* the terms of the GNU General Public License (GPL) version 2.0.
* The full license is in LICENSE.txt file included with this distribution,.
*
*
* This software 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
* include LICENSE.txt for more details.
*/
@@ -28,9 +28,11 @@ class ShowEventHandler : public osgGA::GUIEventHandler
ShowEventHandler();
virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa, osg::Object* object, osg::NodeVisitor* nv);
virtual void accept(osgGA::GUIEventHandlerVisitor& v);
virtual void getUsage(osg::ApplicationUsage& usage) const;
};
}

View File

@@ -11,6 +11,7 @@
*/
#include <osg/Geometry>
#include <osg/CameraNode>
#include <osg/Texture2D>
#include <osg/AutoTransform>
#include <osg/Notify>
@@ -36,10 +37,9 @@
#include <osgGA/TerrainManipulator>
#include <osgGA/AnimationPathManipulator>
#include <osgGA/StateSetManipulator>
#include <osgGA/MultiTouchTrackballManipulator>
#include <osgPresentation/SlideEventHandler>
#include <osgPresentation/Cursor>
#include <osgPresentation/SlideShowConstructor>
#include "ReadShowFile.h"
#include "PointsEventHandler.h"
@@ -51,7 +51,6 @@
#include <fstream>
#include <iostream>
#include <string.h>
#ifdef USE_SDL
@@ -130,103 +129,148 @@ void setViewer(osgViewer::Viewer& viewer, float width, float height, float dista
viewer.getCamera()->setProjectionMatrixAsPerspective( vfov, width/height, 0.1, 1000.0);
OSG_INFO<<"setProjectionMatrixAsPerspective( "<<vfov<<", "<<width/height<<", "<<0.1<<", "<<1000.0<<");"<<std::endl;
OSG_NOTICE<<"setProjectionMatrixAsPerspective( "<<vfov<<", "<<width/height<<", "<<0.1<<", "<<1000.0<<");"<<std::endl;
}
class ForwardToDeviceEventHandler : public osgGA::GUIEventHandler {
public:
ForwardToDeviceEventHandler(osgGA::Device* device, bool format_mouse_events) : osgGA::GUIEventHandler(), _device(device), _forwardMouseEvents(format_mouse_events) {}
ForwardToDeviceEventHandler(osgGA::Device* device) : osgGA::GUIEventHandler(), _device(device) {}
virtual bool handle (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa, osg::Object *, osg::NodeVisitor *)
{
switch (ea.getEventType())
{
case osgGA::GUIEventAdapter::PUSH:
case osgGA::GUIEventAdapter::RELEASE:
case osgGA::GUIEventAdapter::MOVE:
case osgGA::GUIEventAdapter::DRAG:
case osgGA::GUIEventAdapter::SCROLL:
if (_forwardMouseEvents)
_device->sendEvent(ea);
break;
default:
_device->sendEvent(ea);
break;
}
OSG_INFO<<"ForwardToDeviceEventHandler::setEvent("<<ea.getKey()<<")"<<std::endl;
_device->sendEvent(ea);
return false;
}
bool handle(osgGA::Event* event, osg::Object* object, osg::NodeVisitor* nv)
{
if (event->asGUIEventAdapter())
return osgGA::GUIEventHandler::handle(event, object, nv);
else
{
_device->sendEvent(*event);
return false;
}
}
private:
osg::ref_ptr<osgGA::Device> _device;
bool _forwardMouseEvents;
};
class DumpEventHandler : public osgGA::GUIEventHandler {
public:
DumpEventHandler() : osgGA::GUIEventHandler() {}
class FollowMouseCallback: public osgGA::GUIEventHandler
{
public:
virtual bool handle (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa, osg::Object *, osg::NodeVisitor *)
{
switch (ea.getEventType())
FollowMouseCallback():
_mousePostition(0.5,0.5) {}
virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa, osg::Object* object, osg::NodeVisitor* nv)
{
case osgGA::GUIEventAdapter::FRAME:
return false;
break;
case osgGA::GUIEventAdapter::PUSH:
std::cout << "PUSH: ";
break;
case osgGA::GUIEventAdapter::RELEASE:
std::cout << "RELEASE: ";
break;
case osgGA::GUIEventAdapter::MOVE:
std::cout << "MOVE: ";
break;
case osgGA::GUIEventAdapter::DRAG:
std::cout << "DRAG: ";
break;
case osgGA::GUIEventAdapter::SCROLL:
std::cout << "SCROLL: ";
break;
break;
osg::AutoTransform* transform = dynamic_cast<osg::AutoTransform*>(object);
if (!transform) return false;
default:
std::cout << ea.getEventType() << " ";
break;
}
std::cout << ea.getX() << "/" << ea.getY() << " " << ea.isMultiTouchEvent() << std::endl;
return false;
}
osg::NotifySeverity level = osg::INFO;
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::PUSH):
case(osgGA::GUIEventAdapter::RELEASE):
case(osgGA::GUIEventAdapter::MOVE):
case(osgGA::GUIEventAdapter::DRAG):
osg::notify(level)<<std::endl<<"ea.getGraphicsContext()="<<ea.getGraphicsContext()<<std::endl;
osg::notify(level)<<"ea.getWindowWidth()="<<ea.getWindowWidth()<<std::endl;
osg::notify(level)<<"ea.getWindowHeight()="<<ea.getWindowHeight()<<std::endl;
osg::notify(level)<<"ea.getX()="<<ea.getX()<<std::endl;
osg::notify(level)<<"ea.getXin()="<<ea.getXmin()<<std::endl;
osg::notify(level)<<"ea.getXmax()="<<ea.getXmax()<<std::endl;
osg::notify(level)<<"ea.getY()="<<ea.getY()<<std::endl;
osg::notify(level)<<"ea.getYin()="<<ea.getYmin()<<std::endl;
osg::notify(level)<<"ea.getYmax()="<<ea.getYmax()<<std::endl;
_mousePostition.set(ea.getXnormalized(), ea.getYnormalized());
break;
case(osgGA::GUIEventAdapter::FRAME):
{
osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa);
bool handle(osgGA::Event* event, osg::Object* object, osg::NodeVisitor* nv)
{
if (event->asGUIEventAdapter())
return osgGA::GUIEventHandler::handle(event, object, nv);
else
{
osg::Camera* camera = view->getCamera();
osg::Matrix VP = camera->getViewMatrix() * camera->getProjectionMatrix();
osg::Matrix inverse_VP;
inverse_VP.invert(VP);
osg::Vec3d start_eye(_mousePostition.x(), _mousePostition.y(), 0.0);
osg::Vec3d end_eye(_mousePostition.x(), _mousePostition.y(), 1.0);
osg::Vec3d start_world = start_eye * inverse_VP;
osg::Vec3d end_world = start_eye * inverse_VP;
osg::notify(level)<<"start_world="<<start_world<<std::endl;
osg::notify(level)<<"end_world="<<end_world<<std::endl;
if (end_world.valid()) transform->setPosition(end_world);
else
{
OSG_NOTICE<<"Ignoring invalid end_world position"<<std::endl;
}
break;
}
case(osgGA::GUIEventAdapter::KEYDOWN):
{
if (ea.getKey()=='c')
{
for(unsigned int i=0; i< transform->getNumChildren(); ++i)
{
osg::Node* node = transform->getChild(i);
node->setNodeMask(
node->getNodeMask()!=0 ?
0 :
0xffffff);
}
}
break;
}
default:
break;
}
return false;
}
}
virtual void accept(osgGA::GUIEventHandlerVisitor& v)
{
v.visit(*this);
}
private:
osg::Vec2d _mousePostition;
};
osg::Node* createCursorSubgraph(const std::string& filename, float size)
{
osg::Geode* geode = new osg::Geode;
size = 20.0f;
osg::Geometry* geom = osg::createTexturedQuadGeometry(osg::Vec3(-size*0.5f,-size*0.5f,0.0f),osg::Vec3(size,0.0f,0.0f),osg::Vec3(0.0f,size,0.0f));
geom->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
osg::Image* image = osgDB::readImageFile(osgDB::findDataFile(filename));
if (image)
{
osg::StateSet* stateset = geom->getOrCreateStateSet();
stateset->setTextureAttributeAndModes(0, new osg::Texture2D(image),osg::StateAttribute::ON|osg::StateAttribute::PROTECTED);
stateset->setMode(GL_BLEND,osg::StateAttribute::ON|osg::StateAttribute::PROTECTED);
// stateset->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF);
stateset->setRenderBinDetails(1000, "DepthSortedBin");
}
geode->addDrawable(geom);
osg::AutoTransform* transform = new osg::AutoTransform;
transform->setAutoRotateMode(osg::AutoTransform::ROTATE_TO_CAMERA);
transform->setAutoScaleToScreen(true);
transform->addChild(geode);
transform->setEventCallback(new FollowMouseCallback());
return transform;
}
enum P3DApplicationType
@@ -248,7 +292,7 @@ void processLoadedModel(osg::ref_ptr<osg::Node>& loadedModel, int optimizer_opti
loadedModel->getOrCreateStateSet()->setMode(GL_ALPHA_TEST, osg::StateAttribute::ON);
#endif
// optimize the scene graph, remove redundant nodes and state etc.
// optimize the scene graph, remove rendundent nodes and state etc.
osgUtil::Optimizer optimizer;
optimizer.optimize(loadedModel.get(), optimizer_options);
@@ -256,15 +300,12 @@ void processLoadedModel(osg::ref_ptr<osg::Node>& loadedModel, int optimizer_opti
{
osg::ref_ptr<osg::Group> group = new osg::Group;
group->addChild(loadedModel.get());
OSG_NOTICE<<"Creating Cursor"<<std::endl;
group->addChild(new osgPresentation::Cursor(cursorFileName, 20.0f));
group->addChild(createCursorSubgraph(cursorFileName, 0.05f));
loadedModel = group;
}
}
void addDeviceTo(osgViewer::Viewer& viewer, const std::string& device_name, bool forward_mouse_events)
void addDeviceTo(osgViewer::Viewer& viewer, const std::string& device_name)
{
osg::ref_ptr<osgGA::Device> dev = osgDB::readFile<osgGA::Device>(device_name);
if (dev.valid())
@@ -272,8 +313,8 @@ void addDeviceTo(osgViewer::Viewer& viewer, const std::string& device_name, bool
OSG_INFO << "Adding Device : " << device_name << std::endl;
viewer.addDevice(dev.get());
if ((dev->getCapabilities() & osgGA::Device::SEND_EVENTS))
viewer.getEventHandlers().push_front(new ForwardToDeviceEventHandler(dev.get(), forward_mouse_events));
if (dev->getCapabilities() & osgGA::Device::SEND_EVENTS)
viewer.getEventHandlers().push_front(new ForwardToDeviceEventHandler(dev.get()));
}
else
{
@@ -307,8 +348,6 @@ int main( int argc, char **argv )
arguments.getApplicationUsage()->addCommandLineOption("--html <filename>","Print out slides to a series of html & image files.");
arguments.getApplicationUsage()->addCommandLineOption("--loop","Switch on looping of presentation.");
arguments.getApplicationUsage()->addCommandLineOption("--devices","Print the Video input capability via QuickTime and exit.");
arguments.getApplicationUsage()->addCommandLineOption("--forwardMouseEvents","forward also mouse/touch-events to the devices");
arguments.getApplicationUsage()->addCommandLineOption("--suppressEnvTags", "suppresses all found ENV-tags in the presentation");
// add alias from xml to p3d to provide backwards compatibility for old p3d files.
osgDB::Registry::instance()->addFileExtensionAlias("xml","p3d");
@@ -321,13 +360,10 @@ int main( int argc, char **argv )
return 1;
}
bool suppress_env_tags = false;
if (arguments.read("--suppressEnvTags"))
suppress_env_tags = true;
// read any env vars from presentations before we create viewer to make sure the viewer
// utilises these env vars
if (!suppress_env_tags && p3d::readEnvVars(arguments))
if (p3d::readEnvVars(arguments))
{
osg::DisplaySettings::instance()->readEnvironmentalVariables();
}
@@ -415,10 +451,6 @@ int main( int argc, char **argv )
doSetViewer = false;
}
bool forwardMouseEvents = false;
if (arguments.read("--forwardMouseEvents"))
forwardMouseEvents = true;
const char* p3dDevice = getenv("P3D_DEVICE");
if (p3dDevice)
{
@@ -426,7 +458,7 @@ int main( int argc, char **argv )
osgDB::split(p3dDevice, devices);
for(osgDB::StringList::iterator i = devices.begin(); i != devices.end(); ++i)
{
addDeviceTo(viewer, *i, forwardMouseEvents);
addDeviceTo(viewer, *i);
}
}
@@ -434,7 +466,7 @@ int main( int argc, char **argv )
std::string device;
while (arguments.read("--device", device))
{
addDeviceTo(viewer, device, forwardMouseEvents);
addDeviceTo(viewer, device);
}
@@ -477,7 +509,7 @@ int main( int argc, char **argv )
{
osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator;
keyswitchManipulator->addMatrixManipulator( '1', "Trackball", new osgGA::MultiTouchTrackballManipulator() );
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() );
@@ -499,8 +531,6 @@ int main( int argc, char **argv )
viewer.setCameraManipulator( keyswitchManipulator.get() );
}
//viewer.getEventHandlers().push_front(new DumpEventHandler());
// add the state manipulator
osg::ref_ptr<osgGA::StateSetManipulator> ssManipulator = new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet());
ssManipulator->setKeyEventToggleTexturing('e');
@@ -599,13 +629,13 @@ int main( int argc, char **argv )
// set up optimizer options
unsigned int optimizer_options = osgUtil::Optimizer::DEFAULT_OPTIMIZATIONS;
bool release_and_compile = false;
bool relase_and_compile = false;
while (arguments.read("--release-and-compile"))
{
release_and_compile = true;
relase_and_compile = true;
}
seh->setReleaseAndCompileOnEachNewSlide(release_and_compile);
if (release_and_compile)
seh->setReleaseAndCompileOnEachNewSlide(relase_and_compile);
if (relase_and_compile)
{
// make sure that imagery stays around after being applied to textures.
viewer.getDatabasePager()->setUnrefImageDataAfterApplyPolicy(true,false);
@@ -652,10 +682,9 @@ int main( int argc, char **argv )
viewer.getUsage(*arguments.getApplicationUsage());
// if user request help write it out to cout.
unsigned int helpType = 0;
if ((helpType = arguments.readHelpType()))
if (arguments.read("-h") || arguments.read("--help"))
{
arguments.getApplicationUsage()->write(std::cout, helpType);
arguments.getApplicationUsage()->write(osg::notify(osg::NOTICE));
return 1;
}
@@ -750,9 +779,6 @@ int main( int argc, char **argv )
osg::ref_ptr<osgDB::ReaderWriter::Options> cacheAllOption = new osgDB::ReaderWriter::Options;
if(suppress_env_tags)
cacheAllOption->setPluginStringData("suppressEnvTags", "true");
cacheAllOption->setObjectCacheHint(osgDB::ReaderWriter::Options::CACHE_ALL);
osgDB::Registry::instance()->setOptions(cacheAllOption.get());
@@ -930,7 +956,7 @@ int main( int argc, char **argv )
}
}
// update the scene by traversing it with the update visitor which will
// update the scene by traversing it with the the update visitor which will
// call all node update callbacks and animations.
viewer.eventTraversal();
@@ -959,7 +985,7 @@ int main( int argc, char **argv )
}
// update the scene by traversing it with the update visitor which will
// update the scene by traversing it with the the update visitor which will
// call all node update callbacks and animations.
viewer.updateTraversal();

1
configure vendored Executable file
View File

@@ -0,0 +1 @@
cmake . -DCMAKE_BUILD_TYPE=Release $@

View File

@@ -27,7 +27,6 @@ IF(DYNAMIC_OPENSCENEGRAPH)
ADD_SUBDIRECTORY(osgautocapture)
ADD_SUBDIRECTORY(osgautotransform)
ADD_SUBDIRECTORY(osgbillboard)
ADD_SUBDIRECTORY(osgblenddrawbuffers)
ADD_SUBDIRECTORY(osgblendequation)
ADD_SUBDIRECTORY(osgcallback)
ADD_SUBDIRECTORY(osgcamera)
@@ -47,6 +46,7 @@ IF(DYNAMIC_OPENSCENEGRAPH)
ADD_SUBDIRECTORY(osgfont)
ADD_SUBDIRECTORY(osgforest)
ADD_SUBDIRECTORY(osgfxbrowser)
ADD_SUBDIRECTORY(osgframerenderer)
ADD_SUBDIRECTORY(osgoutline)
ADD_SUBDIRECTORY(osggameoflife)
ADD_SUBDIRECTORY(osggeometry)
@@ -65,7 +65,6 @@ IF(DYNAMIC_OPENSCENEGRAPH)
ADD_SUBDIRECTORY(osglightpoint)
ADD_SUBDIRECTORY(osglogicop)
ADD_SUBDIRECTORY(osglogo)
ADD_SUBDIRECTORY(osggpucull)
ADD_SUBDIRECTORY(osggpx)
ADD_SUBDIRECTORY(osggraphicscost)
ADD_SUBDIRECTORY(osgmanipulator)
@@ -96,7 +95,6 @@ IF(DYNAMIC_OPENSCENEGRAPH)
ADD_SUBDIRECTORY(osgprerendercubemap)
ADD_SUBDIRECTORY(osgreflect)
ADD_SUBDIRECTORY(osgrobot)
ADD_SUBDIRECTORY(osgSSBO)
ADD_SUBDIRECTORY(osgscalarbar)
ADD_SUBDIRECTORY(osgscribe)
ADD_SUBDIRECTORY(osgsequence)
@@ -120,17 +118,14 @@ IF(DYNAMIC_OPENSCENEGRAPH)
ADD_SUBDIRECTORY(osgstereomatch)
ADD_SUBDIRECTORY(osgterrain)
ADD_SUBDIRECTORY(osgthreadedterrain)
ADD_SUBDIRECTORY(osgtransferfunction)
ADD_SUBDIRECTORY(osgtext)
ADD_SUBDIRECTORY(osgtext3D)
ADD_SUBDIRECTORY(osgtexture1D)
ADD_SUBDIRECTORY(osgtexture2D)
ADD_SUBDIRECTORY(osgtexture2DArray)
ADD_SUBDIRECTORY(osgtexture3D)
ADD_SUBDIRECTORY(osgtexturerectangle)
ADD_SUBDIRECTORY(osgtexturecompression)
ADD_SUBDIRECTORY(osgthirdpersonview)
ADD_SUBDIRECTORY(osgtransformfeedback)
ADD_SUBDIRECTORY(osguniformbuffer)
ADD_SUBDIRECTORY(osguserstats)
ADD_SUBDIRECTORY(osgvertexprogram)

View File

@@ -7,7 +7,7 @@
#include <iostream>
// Search in str for all occurrences of spat and replace them with rpat.
// Search in str for all occurences of spat and replace them with rpat.
void searchAndReplace(std::string& str, const std::string& spat, const std::string& rpat)
{
std::string::size_type pos = 0;
@@ -30,13 +30,13 @@ void writeShader(osg::Shader* shader, const std::string& cppFileName, const std:
searchAndReplace(shaderSource, "\r\n", "\n");
searchAndReplace(shaderSource, "\r", "\n");
searchAndReplace(shaderSource, "\"", "\\\"");
std::string variableString = std::string("char ")+variableName+std::string("[] = ");
std::string::size_type startOfLine = 0;
std::string::size_type endOfLine = shaderSource.find_first_of('\n', startOfLine);
if (endOfLine==std::string::npos)
if (endOfLine==std::string::npos)
{
fout<<variableString<<shaderSource<<"\\n\";"<<std::endl;
}
@@ -63,25 +63,21 @@ int main( int argc, char **argv )
{
// 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 a utility for converting glsl shader files into char arrays that can be compiled into applications.");
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("--shader <filename>","Shader file to create a .cpp file for.");
arguments.getApplicationUsage()->addCommandLineOption("--write-to-source-file-directory","Use the path to the source filename as the directory to write to.");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display command line parameters");
// if user request help write it out to cout.
if (arguments.read("-h") || arguments.read("--help"))
{
{
arguments.getApplicationUsage()->write(std::cout);
return 1;
}
bool useSamePathAsSourceFile = false;
if (arguments.read("--write-to-source-file-directory")) useSamePathAsSourceFile = true;
std::string filename;
if (arguments.read("--shader",filename))
{
@@ -98,11 +94,9 @@ int main( int argc, char **argv )
name[pos] = '_';
pos = name.find_first_of(invalidCharacters);
}
std::string ext = osgDB::getFileExtension(filename);
std::string cppFileName = name + "_" + ext + ".cpp";
if (useSamePathAsSourceFile) cppFileName = osgDB::concatPaths(path, cppFileName);
std::string cppFileName = osgDB::concatPaths(path, name + "_" + ext + ".cpp");
std::string variableName = name + "_" + ext;
writeShader(shader.get(), cppFileName, variableName);
@@ -113,7 +107,7 @@ int main( int argc, char **argv )
std::cout<<"Error: could not find file '"<<filename<<"'"<<std::endl;
return 1;
}
}
std::cout<<"No appropriate command line options used."<<std::endl;

View File

@@ -59,10 +59,10 @@ class ViewerFrameThread : public OpenThreads::Thread
~ViewerFrameThread()
{
if (isRunning())
cancel();
while(isRunning())
{
cancel();
join();
OpenThreads::Thread::YieldCurrentThread();
}
}

View File

@@ -107,25 +107,25 @@ protected:
};
//We would need to document the following somewhere in order to guide people on
//We would need to document the following somewhere in order to guide people on
//what they need to use...
//
//----------------------------------------------
//There are two angles to consider.
//
//1. If someone wants a widget in their Qt app to be an OSG-rendered scene, they
//need GraphicsWindowQt (in the osgViewerQtContext example) or QOSGWidget (in the
//osgViewerQt example). These two allow both OSG and Qt to manage their threads
//in a way which is optimal to them. We've used QOSGWidget in the past and had
//trouble when Qt tried to overlay other widgets over the QOSGWidget (since OSG
//did its rendering independently of Qt, it would overwrite what Qt had drawn). I
//haven't tried GraphicsWindowQt yet, but I expect since it uses QGLWidget, it
//will result in Qt knowing when OSG has drawn and be able to do overlays at the
//1. If someone wants a widget in their Qt app to be an OSG-rendered scene, they
//need GraphicsWindowQt (in the osgViewerQtContext example) or QOSGWidget (in the
//osgViewerQt example). These two allow both OSG and Qt to manage their threads
//in a way which is optimal to them. We've used QOSGWidget in the past and had
//trouble when Qt tried to overlay other widgets over the QOSGWidget (since OSG
//did its rendering independently of Qt, it would overwrite what Qt had drawn). I
//haven't tried GraphicsWindowQt yet, but I expect since it uses QGLWidget, it
//will result in Qt knowing when OSG has drawn and be able to do overlays at the
//right time. Eventually GraphicsWindowQt can be brought into osgViewer I imagine...
//
//2. If someone wants to bring Qt widgets inside their OSG scene (to do HUDs or
//an interface on a computer screen which is inside the 3D scene, or even
//floating Qt widgets, for example). That's where QGraphicsViewAdapter +
//2. If someone wants to bring Qt widgets inside their OSG scene (to do HUDs or
//an interface on a computer screen which is inside the 3D scene, or even
//floating Qt widgets, for example). That's where QGraphicsViewAdapter +
//QWidgetImage will be useful.
//----------------------------------------------
@@ -160,7 +160,7 @@ int main(int argc, char **argv)
bool useLabel = false;
if (arguments.read("--useLabel")) useLabel = true;
// true = make a Qt window with the same content to compare to
// true = make a Qt window with the same content to compare to
// QWebViewImage/QWidgetImage
// false = use QWebViewImage/QWidgetImage (depending on useWidgetImage)
bool sanityCheck = false;
@@ -183,9 +183,9 @@ int main(int argc, char **argv)
//-------------------------------------------------------------------
// QWebViewImage test
//-------------------------------------------------------------------
// Note: When the last few issues with QWidgetImage are fixed,
// QWebViewImage and this if() {} section can be removed since
// QWidgetImage can display a QWebView just like QWebViewImage. Use
// Note: When the last few issues with QWidgetImage are fixed,
// QWebViewImage and this if() {} section can be removed since
// QWidgetImage can display a QWebView just like QWebViewImage. Use
// --useWidgetImage --useBrowser to see that in action.
if (!sanityCheck)
@@ -193,7 +193,7 @@ int main(int argc, char **argv)
osg::ref_ptr<osgQt::QWebViewImage> image = new osgQt::QWebViewImage;
if (arguments.argc()>1) image->navigateTo((arguments[1]));
else image->navigateTo("http://www.openscenegraph.org/");
else image->navigateTo("http://www.youtube.com/");
osgWidget::GeometryHints hints(osg::Vec3(0.0f,0.0f,0.0f),
osg::Vec3(1.0f,0.0f,0.0f),
@@ -208,7 +208,7 @@ int main(int argc, char **argv)
}
else
{
// Sanity check, do the same thing as QGraphicsViewAdapter but in
// Sanity check, do the same thing as QGraphicsViewAdapter but in
// a separate Qt window.
QWebPage* webPage = new QWebPage;
webPage->settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
@@ -218,7 +218,7 @@ int main(int argc, char **argv)
webView->setPage(webPage);
if (arguments.argc()>1) webView->load(QUrl(arguments[1]));
else webView->load(QUrl("http://www.openscenegraph.org/"));
else webView->load(QUrl("http://www.youtube.com/"));
QGraphicsScene* graphicsScene = new QGraphicsScene;
graphicsScene->addWidget(webView);
@@ -240,16 +240,14 @@ int main(int argc, char **argv)
// QWidgetImage test
//-------------------------------------------------------------------
// QWidgetImage still has some issues, some examples are:
//
// 1. Editing in the QTextEdit doesn't work. Also when started with
// --useBrowser, editing in the search field on YouTube doesn't
// work. But that same search field when using QWebViewImage
// works... And editing in the text field in the pop-up getInteger
// dialog works too. All these cases use QGraphicsViewAdapter
//
// 1. Editing in the QTextEdit doesn't work. Also when started with
// --useBrowser, editing in the search field on YouTube doesn't
// work. But that same search field when using QWebViewImage
// works... And editing in the text field in the pop-up getInteger
// dialog works too. All these cases use QGraphicsViewAdapter
// under the hood, so why do some work and others don't?
//
// <<< FIXED, need TextEditorInteraction >>>
//
// a) osgQtBrowser --useWidgetImage [--fullscreen] (optional)
// b) Try to click in the QTextEdit and type, or to select text
// and drag-and-drop it somewhere else in the QTextEdit. These
@@ -261,11 +259,11 @@ int main(int argc, char **argv)
// g) osgQtBrowser
// h) Try the operation in f), it works.
//
// 2. Operations on floating windows (--numFloatingWindows 1 or more).
// Moving by dragging the titlebar, clicking the close button,
// resizing them, none of these work. I wonder if it's because the
// OS manages those functions (they're functions of the window
// decorations) so we need to do something special for that? But
// 2. Operations on floating windows (--numFloatingWindows 1 or more).
// Moving by dragging the titlebar, clicking the close button,
// resizing them, none of these work. I wonder if it's because the
// OS manages those functions (they're functions of the window
// decorations) so we need to do something special for that? But
// in --sanityCheck mode they work.
//
// a) osgQtBrowser --useWidgetImage --numFloatingWindows 1 [--fullscreen]
@@ -274,37 +272,35 @@ int main(int argc, char **argv)
// c) osgQtBrowser --useWidgetImage --numFloatingWindows 1 --sanityCheck
// d) Try the operations in b), all they work.
// e) osgQtBrowser --useWidgetImage [--fullscreen]
// f) Click the button so that the getInteger() dialog is
// displayed, then try to move that dialog or close it with the
// f) Click the button so that the getInteger() dialog is
// displayed, then try to move that dialog or close it with the
// close button, these don't work.
// g) osgQtBrowser --useWidgetImage --sanityCheck
// h) Try the operation in f), it works.
//
// 3. (Minor) The QGraphicsView's scrollbars don't appear when
// using QWidgetImage or QWebViewImage. QGraphicsView is a
// 3. (Minor) The QGraphicsView's scrollbars don't appear when
// using QWidgetImage or QWebViewImage. QGraphicsView is a
// QAbstractScrollArea and it should display scrollbars as soon as
// the scene is too large to fit the view.
//
// <<< FIXED >>>
//
// a) osgQtBrowser --useWidgetImage --fullscreen
// b) Resize the OSG window so it's smaller than the QTextEdit.
// Scrollbars should appear but don't.
// c) osgQtBrowser --useWidgetImage --sanityCheck
// d) Try the operation in b), scrollbars appear. Even if you have
// floating windows (by clicking the button or by adding
// --numFloatingWindows 1) and move them outside the view,
// scrollbars appear too. You can't test that case in OSG for
// d) Try the operation in b), scrollbars appear. Even if you have
// floating windows (by clicking the button or by adding
// --numFloatingWindows 1) and move them outside the view,
// scrollbars appear too. You can't test that case in OSG for
// now because of problem 2 above, but that's pretty cool.
//
// 4. (Minor) In sanity check mode, the widget added to the
// 4. (Minor) In sanity check mode, the widget added to the
// QGraphicsView is centered. With QGraphicsViewAdapter, it is not.
//
// a) osgQtBrowser --useWidgetImage [--fullscreen]
// b) The QTextEdit and button are not in the center of the image
// generated by the QGraphicsViewAdapter.
// c) osgQtBrowser --useWidgetImage --sanityCheck
// d) The QTextEdit and button are in the center of the
// d) The QTextEdit and button are in the center of the
// QGraphicsView.
@@ -350,7 +346,7 @@ int main(int argc, char **argv)
{
QTextEdit* textEdit = new QTextEdit(text);
textEdit->setReadOnly(false);
textEdit->setTextInteractionFlags(Qt::TextEditorInteraction);
textEdit->setTextInteractionFlags(Qt::TextEditable);
QPalette palette = textEdit->palette();
palette.setColor(QPalette::Highlight, Qt::darkBlue);
@@ -392,7 +388,7 @@ int main(int argc, char **argv)
texture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
mt->getOrCreateStateSet()->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);
osgViewer::InteractiveImageHandler* handler;
osgViewer::InteractiveImageHandler* handler;
if (inScene)
{
mt->setMatrix(osg::Matrix::rotate(osg::Vec3(0,1,0), osg::Vec3(0,0,1)));
@@ -402,9 +398,9 @@ int main(int argc, char **argv)
}
else // fullscreen
{
// The HUD camera's viewport needs to follow the size of the
// The HUD camera's viewport needs to follow the size of the
// window. MyInteractiveImageHandler will make sure of this.
// As for the quad and the camera's projection, setting the
// As for the quad and the camera's projection, setting the
// projection resize policy to FIXED takes care of them, so
// they can stay the same: (0,1,0,1) with a quad that fits.
@@ -433,13 +429,13 @@ int main(int argc, char **argv)
overlay->addChild(mt);
root->addChild(overlay);
quad->setEventCallback(handler);
quad->setCullCallback(handler);
}
else
{
// Sanity check, do the same thing as QWidgetImage and
// Sanity check, do the same thing as QWidgetImage and
// QGraphicsViewAdapter but in a separate Qt window.
graphicsScene = new QGraphicsScene;

View File

@@ -1,4 +0,0 @@
SET(TARGET_SRC osgSSBO.cpp )
SETUP_EXAMPLE(osgSSBO)

View File

@@ -1,949 +0,0 @@
//info : osgSSBO example,testing ShaderStorageBufferObjects ,Markus Hein, 2014, osg-3.2.1
//required hardware and driver must support GL >= GL 4.3 or GL ES 3.1 (GL ES not tested, would be nice if someone will test it on a small device)
//testing osg support for Shader Storage Buffer Objects
//version: "first take" from last night session..
#include <osg/StateAttributeCallback>
#include <osg/Texture2D>
#include <osg/Geometry>
#include <osg/Geode>
#include <osgDB/ReadFile>
#include <osgGA/StateSetManipulator>
#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
#include <osg/Node>
#include <osg/PositionAttitudeTransform>
#include <osg/Geometry>
#include <osg/Notify>
#include <osg/MatrixTransform>
#include <osg/Texture2D>
#include <osg/TextureRectangle>
#include <osg/Stencil>
#include <osg/Depth>
#include <osg/Billboard>
#include <osg/Material>
#include <osg/AnimationPath>
#include <osgGA/TrackballManipulator>
#include <osgGA/FlightManipulator>
#include <osgGA/DriveManipulator>
#include <osgUtil/SmoothingVisitor>
#include <osgDB/Registry>
#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
#include <osgViewer/Renderer>
#include <osg/Array>
#include <osg/BoundingSphere>
#include <osg/BufferIndexBinding>
#include <osg/BufferObject>
#include <osg/Group>
#include <osg/Math>
#include <osg/MatrixTransform>
#include <osg/Program>
#include <osg/Shader>
#include <osg/Drawable>
#include <osg/CopyOp>
#include <osg/State>
#include <osg/Matrix>
#include <osg/ShapeDrawable>
#include <osg/GL>
#include <osg/StateSet>
#include <osg/Texture2D>
#include <osg/BlendFunc>
#include <osg/TexEnv>
#include <osg/Material>
#include <osg/PointSprite>
#include <osg/Program>
#include <osg/Notify>
#include <osg/Point>
#include <osg/io_utils>
#include <osg/VertexProgram>
#include <osgText/Font>
#include <osgText/Text>
#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
#include <osgDB/FileNameUtils>
#include <osgUtil/Optimizer>
#include <iostream>
#include <typeinfo>
using namespace osg;
//todo .. #define COMPUTATION_IN_SEPARATE_THREAD
#define WORK_GROUP_SIZE 16
#define PRERENDER_ANTIALIASINGMULTISAMPLES 16
#define PRERENDER_HIGH_QUALITY_ANTIALIASING
#define PRERENDER_WIDTH 1920
#define PRERENDER_HEIGHT 1080
#define SUB_PLACEMENT_OFFSET_HORIZONTAL 0.5
#define SUB_PLACEMENT_OFFSET_VERTICAL 0.5
enum BufferOffset
{
POSITION_NOW_OFFSET,
POSITION_OLD_OFFSET,
POSITION_INIT_OFFSET,
VELOCITY_NOW_OFFSET,
VELOCITY_OLD_OFFSET,
VELOCITY_INIT_OFFSET,
ACCELERATION_OFFSET,
PROPERTIES_OFFSET,
OFFSET_END
};
const int __numDataValuesPerChannel = OFFSET_END;
const int __numChannels = 4;
//512x512x4x7 = 7.340.032 floats in SSBO on GPU
const int NUM_ELEMENTS_X = 512;
const int NUM_ELEMENTS_Y = 512;
float random(float min, float max) { return min + (max - min)*(float)rand() / (float)RAND_MAX; }
enum Channel
{
RED_CHANNEL,
GREEN_CHANNEL,
BLUE_CHANNEL,
ALPHA_CHANNEL,
RGB_CHANNEL,
RGBA_CHANNEL
};
class ShaderStorageBufferCallback : public osg::StateAttributeCallback
{
public:
void operator() (osg::StateAttribute* attr, osg::NodeVisitor* nv)
{
//if you need to process the data in your app-code , better leaving it on GPU and processing there, uploading per frame will make it slow
#if 0
osg::ShaderStorageBufferBinding* ssbb = static_cast<osg::ShaderStorageBufferBinding*>(attr);
osg::ShaderStorageBufferObject* ssbo
= static_cast<osg::ShaderStorageBufferObject*>(ssbb->getBufferObject());
osg::FloatArray* array = static_cast<osg::FloatArray*>(ssbo->getBufferData(0));
float someValue = array->at(0);
//std::cout << "someValue now: " << someValue << std::endl;
//data transfer performance test
// array->dirty();
#endif
}
};
//do not forget to set OSG_FILE_PATH to default OSG-Data and make sure the new shaders are copied there under"shaders"
class ComputeNode : public osg::PositionAttitudeTransform
{
public:
osg::ref_ptr<osg::Program> _computeProgram;
osg::ref_ptr<osg::Shader> _computeShader; //compute and write position data in SSBO
osg::ref_ptr<osg::Shader> _vertexShader; //reading position data from SSBO (OBS!: make sure glMemoryBuffer() is syncing this)
osg::ref_ptr<osg::Shader> _geometryShader; //building a quad looking to the camera
osg::ref_ptr<osg::Shader> _fragmentShader; //use false-colors etc. for making your data visible
osg::ref_ptr<osg::Node> _helperNode; // coordinate system node
ref_ptr<osg::ShaderStorageBufferObject> _ssbo;
ref_ptr<osg::ShaderStorageBufferBinding> _ssbb;
GLfloat* _data; // some data we upload to GPU, initialised with random values
osg::ref_ptr<FloatArray> _dataArray; //
osg::ref_ptr<osg::Group> _computationResultsRenderGroup;
osg::ref_ptr<osg::Program> _computationResultsRenderProgram;
osg::ref_ptr<osg::StateSet> _computationResultsRenderStateSet;
std::string _computeShaderSourcePath;
std::string _vertexShaderSourcePath;
std::string _geometryShaderSourcePath;
std::string _fragmentShaderSourcePath;
void addHelperGeometry();
void addDataMonitor(osg::Vec3 placement, osg::Vec3 relativePlacement, float scale, Channel channel, BufferOffset shaderBufferOffset, std::string labelcaption, float minDataRange, float maxDataRange);
void addComputationResultsRenderTree();
void initComputingSetup();
ComputeNode()
{
const char* envOsgFilePath = getenv("OSG_FILE_PATH");
std::stringstream computeshaderpath; computeshaderpath << envOsgFilePath << "/shaders/osgssboComputeShader.cs";
_computeShaderSourcePath = computeshaderpath.str();
std::stringstream vertexshaderpath; vertexshaderpath << envOsgFilePath << "/shaders/osgssboVertexShader.vs";
_vertexShaderSourcePath = vertexshaderpath.str();
std::stringstream geometryshaderpath; geometryshaderpath << envOsgFilePath << "/shaders/osgssboGeometryShader.gs";
_geometryShaderSourcePath = geometryshaderpath.str();
std::stringstream fragmentshaderpath; fragmentshaderpath << envOsgFilePath << "/shaders/osgssboFragmentShader.fs";
_fragmentShaderSourcePath = fragmentshaderpath.str();
}
};
class ComputeNodeUpdateCallback : public osg::NodeCallback
{
public:
ComputeNode* _computeNode;
osg::Timer_t _prevShaderUpdateTime;
osg::Timer _timer;
ComputeNodeUpdateCallback(){}
ComputeNodeUpdateCallback(ComputeNode* computeNode)
{
_computeNode = computeNode;
_prevShaderUpdateTime = 0;
}
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
{
osg::Timer_t currTime = _timer.tick();
if (_timer.delta_s(_prevShaderUpdateTime, currTime) > 1.0) //one second interval for shader-changed-do-reload check
{
osg::ref_ptr<osg::Shader> reloadedshader;
std::string runningSource;
std::string reloadedstring;
if (_computeNode->_computeShader.valid())
{
runningSource = _computeNode->_computeShader->getShaderSource();
reloadedshader = osg::Shader::readShaderFile(osg::Shader::COMPUTE, _computeNode->_computeShaderSourcePath);
reloadedstring = reloadedshader->getShaderSource();
if (!osgDB::equalCaseInsensitive(runningSource.c_str(), reloadedstring.c_str()))
{
_computeNode->_computeProgram->removeShader(_computeNode->_computeShader.get());
_computeNode->_computeShader = reloadedshader.get();
_computeNode->_computeProgram->addShader(_computeNode->_computeShader.get());
}
}
if (_computeNode->_vertexShader.valid())
{
runningSource = _computeNode->_vertexShader->getShaderSource();
reloadedshader = osg::Shader::readShaderFile(osg::Shader::VERTEX, _computeNode->_vertexShaderSourcePath);
reloadedstring = reloadedshader->getShaderSource();
if (!osgDB::equalCaseInsensitive(runningSource.c_str(), reloadedstring.c_str()))
{
_computeNode->_computationResultsRenderProgram->removeShader(_computeNode->_vertexShader.get());
_computeNode->_vertexShader = reloadedshader.get();
_computeNode->_computationResultsRenderProgram->addShader(_computeNode->_vertexShader.get());
}
}
if (_computeNode->_geometryShader.valid())
{
runningSource = _computeNode->_geometryShader->getShaderSource();
reloadedshader = osg::Shader::readShaderFile(osg::Shader::GEOMETRY, _computeNode->_geometryShaderSourcePath);
reloadedstring = reloadedshader->getShaderSource();
if (!osgDB::equalCaseInsensitive(runningSource.c_str(), reloadedstring.c_str()))
{
_computeNode->_computationResultsRenderProgram->removeShader(_computeNode->_geometryShader.get());
_computeNode->_geometryShader = reloadedshader.get();
_computeNode->_computationResultsRenderProgram->addShader(_computeNode->_geometryShader.get());
}
}
if (_computeNode->_fragmentShader.valid())
{
runningSource = _computeNode->_fragmentShader->getShaderSource();
reloadedshader = osg::Shader::readShaderFile(osg::Shader::FRAGMENT, _computeNode->_fragmentShaderSourcePath);
reloadedstring = reloadedshader->getShaderSource();
if (!osgDB::equalCaseInsensitive(runningSource.c_str(), reloadedstring.c_str()))
{
_computeNode->_computationResultsRenderProgram->removeShader(_computeNode->_fragmentShader.get());
_computeNode->_fragmentShader = reloadedshader.get();
_computeNode->_computationResultsRenderProgram->addShader(_computeNode->_fragmentShader.get());
}
}
_prevShaderUpdateTime = _timer.tick();
}
traverse(node, nv);
}
};
//set OSG_FILE_PATH for loading axes.osgt
void ComputeNode::addHelperGeometry()
{
_helperNode = osgDB::readNodeFile("axes.osgt");
if (_helperNode.valid())
{
addChild(_helperNode.get());
}
//osg::PositionAttitudeTransform* pat = new osg::PositionAttitudeTransform;
//pat->setPosition(osg::Vec3(0.5, 0, 0.5));
//osg::Geode *sphereGeode = new osg::Geode;
//float radius = 0.5f;
//osg::TessellationHints* hints = new osg::TessellationHints;
//hints->setDetailRatio(0.9f);
//osg::ShapeDrawable* sphere = new osg::ShapeDrawable(new osg::Sphere(osg::Vec3(0.0f, 0.0f, 0.0f), radius), hints);
//sphereGeode->addDrawable(sphere);
//sphere->setColor(osg::Vec4(0, 1, 0, 0.1));
//osg::StateSet* stateset = sphereGeode->getOrCreateStateSet();
//osg::BlendFunc *blend = new osg::BlendFunc;
//blend->setFunction(osg::BlendFunc::SRC_ALPHA, osg::BlendFunc::ONE_MINUS_SRC_ALPHA);
//stateset->setAttributeAndModes(blend, osg::StateAttribute::ON);
//pat->addChild(sphereGeode);
//addChild(pat);
}
void ComputeNode::addDataMonitor(osg::Vec3 placement, osg::Vec3 relativePlacement, float scale, Channel colorchannel, BufferOffset shaderStorageBufferOffset, std::string labelCaption, float minDataRange, float maxDataRange)
{
osg::PositionAttitudeTransform* pat = new osg::PositionAttitudeTransform;
pat->setPosition(relativePlacement);
addChild(pat);
osg::Geometry* geom;
if (NUM_ELEMENTS_X >= NUM_ELEMENTS_Y)
{
float ratio = (float)((float)NUM_ELEMENTS_Y / (float)NUM_ELEMENTS_X);
geom = osg::createTexturedQuadGeometry(placement, osg::Vec3(1.0f*scale, 0.0f, 0.0f), osg::Vec3(0.0f, 0.0f, ratio*1.0f*scale));
}
else
{
float ratio = (float)((float)NUM_ELEMENTS_X / (float)NUM_ELEMENTS_Y);
geom = osg::createTexturedQuadGeometry(placement, osg::Vec3(ratio*1.0f*scale, 0.0f, 0.0f), osg::Vec3(0.0f, 0.0f, 1.0f*scale));
}
geom->setVertexAttribArray(1, geom->getTexCoordArray(0), osg::Array::BIND_PER_VERTEX);
osg::ref_ptr<osg::Geode> quad = new osg::Geode;
quad->addDrawable(geom);
quad->setStateSet(getOrCreateStateSet());
pat->addChild(quad.get());
static const char* vertexShaderSrcChannelMonitor = {
"#version 430 \n"
"uniform int numRows;\n"
"uniform int numCols;\n"
"uniform float osg_FrameTime;\n"
"uniform mat4 osg_ProjectionMatrix;\n"
"uniform mat4 osg_ModelViewMatrix;\n"
"out vec2 texCoordFromVertexShader;\n"
"struct particle{ float x; float y; float z; float w;};"
"layout (location = 0) in vec3 vertexpos;\n"
"attribute vec2 tex_coords;\n"
"void main() {\n"
"texCoordFromVertexShader.xy = tex_coords.xy; gl_Position = ( osg_ProjectionMatrix * osg_ModelViewMatrix * vec4(vertexpos.x,vertexpos.y,vertexpos.z,1) ); \n"
"}\n"
};
std::stringstream fragmentshaderstringstreamChannelMonitor;
fragmentshaderstringstreamChannelMonitor << "#version 430\n";
fragmentshaderstringstreamChannelMonitor << "uniform int numRows;\n";
fragmentshaderstringstreamChannelMonitor << "uniform int numCols;\n";
fragmentshaderstringstreamChannelMonitor << "uniform float dataRangeMin;\n";
fragmentshaderstringstreamChannelMonitor << "uniform float dataRangeMax;\n";
fragmentshaderstringstreamChannelMonitor << "in vec2 texCoordFromVertexShader;\n";
fragmentshaderstringstreamChannelMonitor << "struct particle{ float x; float y; float z; float w;};";
fragmentshaderstringstreamChannelMonitor << "layout(std140, binding=0) coherent buffer particles{particle p[];}; ";
fragmentshaderstringstreamChannelMonitor << "\n";
fragmentshaderstringstreamChannelMonitor << "void main(void)\n";
fragmentshaderstringstreamChannelMonitor << "{\n";
fragmentshaderstringstreamChannelMonitor << "ivec2 storePos = ivec2(numRows*texCoordFromVertexShader.x, numCols*texCoordFromVertexShader.y); particle particleData = p[" << shaderStorageBufferOffset * NUM_ELEMENTS_X*NUM_ELEMENTS_Y << " + (storePos.x*numRows + storePos.y)]; ";
//fragmentshaderstringstreamChannelMonitor << " memoryBarrierBuffer(); \n";
fragmentshaderstringstreamChannelMonitor << " float dataRangeMultiplier = 1.0 / abs(dataRangeMax - dataRangeMin); \n";
switch (colorchannel)
{
case RED_CHANNEL:
{
fragmentshaderstringstreamChannelMonitor << " vec4 color; color.x = 0.5+dataRangeMultiplier*particleData.x; color.y =0.0; color.z = 0.0; color.w = 1.0; gl_FragColor = color;\n";
break;
}
case GREEN_CHANNEL:
{
fragmentshaderstringstreamChannelMonitor << " vec4 color; color.x = 0.0; color.y = 0.5+dataRangeMultiplier*particleData.y; color.z = 0.0; color.w = 1.0; gl_FragColor = color;\n";
break;
}
case BLUE_CHANNEL:
{
fragmentshaderstringstreamChannelMonitor << " vec4 color; color.x = 0.0; color.y = 0.0; color.z = 0.5+dataRangeMultiplier*particleData.z; color.w = 0.0 ; gl_FragColor = color;\n";
break;
}
case ALPHA_CHANNEL:
{
fragmentshaderstringstreamChannelMonitor << " vec4 color; color.x = 0.5+dataRangeMultiplier*particleData.w; color.y = 0.5+dataRangeMultiplier*particleData.w; color.z = 0.5+dataRangeMultiplier*particleData.w; color.w = 0.5+0.5*particleData.w; gl_FragColor = color;\n";
break;
}
case RGB_CHANNEL:
{
fragmentshaderstringstreamChannelMonitor << " vec4 color; color.x = 0.5+dataRangeMultiplier*particleData.x; color.y = 0.5+dataRangeMultiplier*particleData.y; color.z = 0.5+dataRangeMultiplier*particleData.z; color.w = 1.0; gl_FragColor = color;\n";
break;
}
case RGBA_CHANNEL:
{
fragmentshaderstringstreamChannelMonitor << " vec4 color; color.x = 0.5+dataRangeMultiplier*particleData.x; color.y = 0.5+dataRangeMultiplier*particleData.y; color.z = 0.5+dataRangeMultiplier*particleData.z; color.w = 0.5+0.5*particleData.w; gl_FragColor = color;\n";
break;
}
}
fragmentshaderstringstreamChannelMonitor << "}\n";
osg::Program * program = new osg::Program;
program->addShader(new osg::Shader(osg::Shader::VERTEX, vertexShaderSrcChannelMonitor));
program->addShader(new osg::Shader(osg::Shader::FRAGMENT, fragmentshaderstringstreamChannelMonitor.str().c_str()));
program->addBindAttribLocation("tex_coords", 1);
osg::StateSet* ss = geom->getOrCreateStateSet();
ss->setAttributeAndModes(program, osg::StateAttribute::ON);
ss->addUniform(new osg::Uniform("numRows", (int)NUM_ELEMENTS_X));
ss->addUniform(new osg::Uniform("numCols", (int)NUM_ELEMENTS_Y));
ss->addUniform(new osg::Uniform("dataRangeMin", (float)minDataRange));
ss->addUniform(new osg::Uniform("dataRangeMax", (float)maxDataRange));
ss->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
//add a label
osgText::Text* text = new osgText::Text;
osgText::Font* font = osgText::readFontFile("fonts/arial.ttf");
text->setFont(font);
text->setColor(osg::Vec4(1, 1, 1, 1));
text->setCharacterSize(0.1*scale);
text->setPosition(placement + osg::Vec3(0.05, 0.05, 0));
pat->setName(labelCaption);
text->setText(pat->getName());
text->setBackdropType(osgText::Text::OUTLINE);
text->setBackdropImplementation(osgText::Text::POLYGON_OFFSET);
text->setBackdropOffset(0.05f);
text->setBackdropColor(osg::Vec4(0.0f, 0.0f, 0.0f, 1.0f));
quad->addDrawable(text);
pat->addChild(quad.get());
}
//compute texture image , taken from osgspotlight
osg::Image* createSpotLightImage(const osg::Vec4& centerColour, const osg::Vec4& backgroudColour, unsigned int size, float power)
{
osg::Image* image = new osg::Image;
image->allocateImage(size, size, 1,
GL_RGBA, GL_UNSIGNED_BYTE);
float mid = (float(size) - 1)*0.5f;
float div = 2.0f / float(size);
for (unsigned int r = 0; r < size; ++r)
{
unsigned char* ptr = image->data(0, r, 0);
for (unsigned int c = 0; c < size; ++c)
{
float dx = (float(c) - mid)*div;
float dy = (float(r) - mid)*div;
float r = powf(1.0f - sqrtf(dx*dx + dy*dy), power);
if (r < 0.0f) r = 0.0f;
osg::Vec4 color = centerColour*r + backgroudColour*(1.0f - r);
*ptr++ = (unsigned char)((color[0])*255.0f);
*ptr++ = (unsigned char)((color[1])*255.0f);
*ptr++ = (unsigned char)((color[2])*255.0f);
*ptr++ = (unsigned char)((color[3])*255.0f);
}
}
return image;
}
void ComputeNode::addComputationResultsRenderTree()
{
_computationResultsRenderProgram = new osg::Program;
_vertexShader = osg::Shader::readShaderFile(osg::Shader::VERTEX, _vertexShaderSourcePath);
_computationResultsRenderProgram->addShader(_vertexShader.get());
_geometryShader = osg::Shader::readShaderFile(osg::Shader::GEOMETRY, _geometryShaderSourcePath);
_computationResultsRenderProgram->addShader(_geometryShader.get());
_fragmentShader = osg::Shader::readShaderFile(osg::Shader::FRAGMENT, _fragmentShaderSourcePath);
_computationResultsRenderProgram->addShader(_fragmentShader.get());
_computationResultsRenderProgram->addBindAttribLocation("tex_coords", 1);
_computationResultsRenderGroup = new osg::Group;
_computationResultsRenderGroup->setDataVariance(osg::Object::DYNAMIC);
_computationResultsRenderStateSet = _computationResultsRenderGroup->getOrCreateStateSet();
_computationResultsRenderStateSet->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
osg::PointSprite *sprite = new osg::PointSprite;
int texture_unit = 0;
_computationResultsRenderStateSet->setTextureAttributeAndModes(texture_unit, sprite, osg::StateAttribute::ON);
_computationResultsRenderStateSet->setAttributeAndModes(_computationResultsRenderProgram.get(), osg::StateAttribute::ON);
_computationResultsRenderStateSet->addUniform(new osg::Uniform("particleTexture", texture_unit));
_computationResultsRenderStateSet->addUniform(new osg::Uniform("numRows", (int)NUM_ELEMENTS_X));
_computationResultsRenderStateSet->addUniform(new osg::Uniform("numCols", (int)NUM_ELEMENTS_Y));
_computationResultsRenderStateSet->setMode(GL_POINT_SMOOTH, osg::StateAttribute::ON);
_computationResultsRenderStateSet->setMode(GL_VERTEX_PROGRAM_POINT_SIZE_ARB, osg::StateAttribute::ON);
_computationResultsRenderStateSet->setMode(GL_ALPHA_TEST, osg::StateAttribute::ON);
_computationResultsRenderStateSet->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
osg::Texture2D *tex = new osg::Texture2D();
osg::Image* particleImage = createSpotLightImage(osg::Vec4(1, 0, 0, 1), osg::Vec4(0.5, 0, 0, 0.0), 32, 0.7);
if (particleImage)
{
tex->setImage(particleImage);
}
_computationResultsRenderStateSet->setTextureAttributeAndModes(texture_unit, tex, osg::StateAttribute::ON);
osg::BlendFunc *blend = new osg::BlendFunc;
if (false) //emissive particles
{
blend->setFunction(osg::BlendFunc::SRC_ALPHA, osg::BlendFunc::ONE);
}
else
{
blend->setFunction(osg::BlendFunc::SRC_ALPHA, osg::BlendFunc::ONE_MINUS_SRC_ALPHA);
}
_computationResultsRenderStateSet->setAttributeAndModes(blend, osg::StateAttribute::ON);
osg::Depth* depth = new osg::Depth;
depth->setRange(0.0f, 0.0f);
depth->setFunction(osg::Depth::ALWAYS);
depth->setWriteMask(false);
depth->setFunction(osg::Depth::ALWAYS);
_computationResultsRenderStateSet->setAttributeAndModes(depth, osg::StateAttribute::OFF);
osg::Geode* particleGeode = new osg::Geode;
unsigned int numVertices = NUM_ELEMENTS_X*NUM_ELEMENTS_Y;
osg::Geometry* particleGeometry = new osg::Geometry;
particleGeometry->setUseDisplayList(false);
particleGeometry->setUseVertexBufferObjects(true);
osg::Vec3Array* vertexarray = new osg::Vec3Array;
osg::Vec2Array* tcoords = new osg::Vec2Array;
osg::Vec2 bottom_texcoord(0.0f, 0.0f);
osg::Vec2 dx_texcoord(1.0f / (float)(NUM_ELEMENTS_X), 0.0f);
osg::Vec2 dy_texcoord(0.0f, 1.0f / (float)(NUM_ELEMENTS_Y));
for (int i = 0; i < NUM_ELEMENTS_X; i++)
{
osg::Vec2 texcoord = bottom_texcoord + dy_texcoord*(float)i;
for (int j = 0; j < NUM_ELEMENTS_Y; j++)
{
vertexarray->push_back(osg::Vec3(texcoord.x(), texcoord.y(), 0.0));
tcoords->push_back(osg::Vec2(texcoord.x(), texcoord.y()));
texcoord += dx_texcoord;
}
}
particleGeometry->setVertexArray(vertexarray);
particleGeometry->addPrimitiveSet(new osg::DrawArrays(GL_POINTS, 0, numVertices));
particleGeometry->setTexCoordArray(0, tcoords);
//this glMemoryBarrier thing... not sure if we could better do instanced drawing? all the data is in Shader Storage Buffer..
particleGeometry->setVertexAttribArray(1, particleGeometry->getTexCoordArray(0), osg::Array::BIND_PER_VERTEX);
_computationResultsRenderGroup->addChild(particleGeode);
particleGeode->addDrawable(particleGeometry);
addChild(_computationResultsRenderGroup.get());
}
void ComputeNode::initComputingSetup()
{
_computeProgram = new osg::Program;
_computeProgram->setComputeGroups((NUM_ELEMENTS_X / WORK_GROUP_SIZE) <= 1 ? 1 : (NUM_ELEMENTS_X / WORK_GROUP_SIZE), (NUM_ELEMENTS_Y / WORK_GROUP_SIZE) <= 1 ? 1 : (NUM_ELEMENTS_Y / WORK_GROUP_SIZE), 1);
_computeShader = osg::Shader::readShaderFile(osg::Shader::COMPUTE, _computeShaderSourcePath);
_computeProgram->addShader(_computeShader.get());
setDataVariance(osg::Object::DYNAMIC);
osg::StateSet* statesetComputation = getOrCreateStateSet();
statesetComputation->setAttributeAndModes(_computeProgram.get());
statesetComputation->addUniform(new osg::Uniform("numCols", (int)NUM_ELEMENTS_X));
statesetComputation->addUniform(new osg::Uniform("numRows", (int)NUM_ELEMENTS_Y));
statesetComputation->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
//blocksize
int numParticles = NUM_ELEMENTS_X * NUM_ELEMENTS_Y;
const unsigned blockSize = numParticles * __numChannels * __numDataValuesPerChannel* sizeof(GLfloat);
//init all the particle data array
int idx = 0;
_data = new GLfloat[NUM_ELEMENTS_X * NUM_ELEMENTS_Y * __numChannels * __numDataValuesPerChannel];
_dataArray = new FloatArray;
//init the data array somehow, this way all is stored in one BufferObject. maybe better using multiple buffers instead? not sure what is faster and better for threading
for (int d = 0; d < __numDataValuesPerChannel; ++d)
{
for (int i = 0; i < NUM_ELEMENTS_X; ++i)
{
for (int j = 0; j < NUM_ELEMENTS_Y; ++j)
{
for (int k = 0; k < __numChannels; ++k)
{
switch (k)
{
case (RED_CHANNEL) :
{
if ((d == POSITION_NOW_OFFSET) || (d == POSITION_OLD_OFFSET) || (d == POSITION_INIT_OFFSET))//position
{
*_data = random(0.25, 0.75);
}
if ((d == VELOCITY_NOW_OFFSET) || (d == VELOCITY_OLD_OFFSET) || (d == VELOCITY_INIT_OFFSET))//velocity
{
*_data = random(-2.4, 2.4);
}
if (d == ACCELERATION_OFFSET) //acceleration
{
*_data = random(-3.0, 3.0);
}
if (d == PROPERTIES_OFFSET) //property particle mass (compute shader is computing sphere mass from radius instead)
{
*_data = random(0.2, 15.0);
}
break;
}
case (GREEN_CHANNEL) :
{
if ((d == POSITION_NOW_OFFSET) || (d == POSITION_OLD_OFFSET) || (d == POSITION_INIT_OFFSET))//position
{
*_data = random(0.25, 0.75);
}
if ((d == VELOCITY_NOW_OFFSET) || (d == VELOCITY_OLD_OFFSET) || (d == VELOCITY_INIT_OFFSET))//velocity
{
*_data = random(-2.4, 2.4);
}
if (d == ACCELERATION_OFFSET)//acceleration
{
*_data = random(-3.0, 3.0);
}
if (d == PROPERTIES_OFFSET) //property particle radius
{
*_data = random(0.07, 0.219);
}
break;
}
case (BLUE_CHANNEL) :
{
if ((d == POSITION_NOW_OFFSET) || (d == POSITION_OLD_OFFSET) || (d == POSITION_INIT_OFFSET))//position
{
*_data = random(0.25, 0.75);
}
if ((d == VELOCITY_NOW_OFFSET) || (d == VELOCITY_OLD_OFFSET) || (d == VELOCITY_INIT_OFFSET))//velocity
{
*_data = random(-2.4, 2.4);
}
if (d == ACCELERATION_OFFSET)//acceleration
{
*_data = random(-3.0, 3.0);
}
if (d == PROPERTIES_OFFSET) //place for some other property
{
*_data = random(0.0, 0.0);
}
break;
}
case (ALPHA_CHANNEL) :
{
if ((d == POSITION_NOW_OFFSET) || (d == POSITION_OLD_OFFSET) || (d == POSITION_INIT_OFFSET))//position
{
*_data = random(1.0, 1.0);
}
if ((d == VELOCITY_NOW_OFFSET) || (d == VELOCITY_OLD_OFFSET) || (d == VELOCITY_INIT_OFFSET))//velocity
{
*_data = random(-2.4, 2.4);
}
if (d == ACCELERATION_OFFSET) //acceleration
{
//*_data = random(1.0, 1.0);
*_data = random(0.0, 0.0);
}
if (d == PROPERTIES_OFFSET) //place for some other property
{
*_data = random(0.3, 0.3);
}
break;
}
}
_dataArray->push_back(*_data);
_data++;
idx++;
}
}
}
}
_ssbo = new osg::ShaderStorageBufferObject;
_dataArray->setBufferObject(_ssbo.get());
_ssbb = new osg::ShaderStorageBufferBinding(0, _ssbo.get(), 0, blockSize);
statesetComputation->setAttributeAndModes(_ssbb.get(), osg::StateAttribute::ON);
//option, do something useful with data or test the transfer speed
//_ssbb->setUpdateCallback(new ShaderStorageBufferCallback);
//adding a quad , visualizing data in buffer
addDataMonitor(osg::Vec3(0, -1, 0), osg::Vec3(SUB_PLACEMENT_OFFSET_HORIZONTAL * 0, -SUB_PLACEMENT_OFFSET_VERTICAL * -2.0, SUB_PLACEMENT_OFFSET_HORIZONTAL * 0), 1.0, RGB_CHANNEL, POSITION_NOW_OFFSET, "X,Y,Z - PositionNow", -1.0, 1.0);
//the coord from default dataset
addHelperGeometry();
addComputationResultsRenderTree();
}
//taken from osgdistorsion example for getting it nice on screen with antialiasing
osg::Node* createPrerenderSubgraph(osg::Node* subgraph, const osg::Vec4& clearColour)
{
osg::Group* prerenderNode = new osg::Group;
unsigned int tex_width = PRERENDER_WIDTH;
unsigned int tex_height = PRERENDER_HEIGHT;
osg::Texture2D* texture = new osg::Texture2D;
texture->setTextureSize(tex_width, tex_height);
texture->setInternalFormat(GL_RGBA);
texture->setFilter(osg::Texture2D::MIN_FILTER, osg::Texture2D::LINEAR);
texture->setFilter(osg::Texture2D::MAG_FILTER, osg::Texture2D::LINEAR);
{
osg::Camera* prerenderCamera = new osg::Camera;
prerenderCamera->setClearColor(clearColour);
prerenderCamera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
prerenderCamera->setReferenceFrame(osg::Transform::RELATIVE_RF);
prerenderCamera->setProjectionMatrix(osg::Matrixd::identity());
prerenderCamera->setViewMatrix(osg::Matrixd::identity());
prerenderCamera->setViewport(0, 0, tex_width, tex_height);
prerenderCamera->setRenderOrder(osg::Camera::PRE_RENDER);
prerenderCamera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
prerenderCamera->attach(osg::Camera::COLOR_BUFFER0, texture, 0, 0, false, PRERENDER_ANTIALIASINGMULTISAMPLES, PRERENDER_ANTIALIASINGMULTISAMPLES);
prerenderCamera->addChild(subgraph);
prerenderNode->addChild(prerenderCamera);
}
{
osg::Geometry* polyGeom = new osg::Geometry();
polyGeom->setSupportsDisplayList(false);
osg::Vec3 origin(0.0f, 0.0f, 0.0f);
osg::Vec3 xAxis(1.0f, 0.0f, 0.0f);
osg::Vec3 yAxis(0.0f, 1.0f, 0.0f);
float height = 1024.0f;
float width = 1280.0f;
int noSteps = 3;
osg::Vec3Array* vertices = new osg::Vec3Array;
osg::Vec2Array* texcoords = new osg::Vec2Array;
osg::Vec4Array* colors = new osg::Vec4Array;
osg::Vec3 bottom = origin;
osg::Vec3 dx = xAxis*(width / ((float)(noSteps - 1)));
osg::Vec3 dy = yAxis*(height / ((float)(noSteps - 1)));
osg::Vec2 bottom_texcoord(0.0f, 0.0f);
osg::Vec2 dx_texcoord(1.0f / (float)(noSteps - 1), 0.0f);
osg::Vec2 dy_texcoord(0.0f, 1.0f / (float)(noSteps - 1));
int i, j;
for (i = 0; i < noSteps; ++i)
{
osg::Vec3 cursor = bottom + dy*(float)i;
osg::Vec2 texcoord = bottom_texcoord + dy_texcoord*(float)i;
for (j = 0; j < noSteps; ++j)
{
vertices->push_back(cursor);
texcoords->push_back(osg::Vec2((sin(texcoord.x()*osg::PI - osg::PI*0.5) + 1.0f)*0.5f, (sin(texcoord.y()*osg::PI - osg::PI*0.5) + 1.0f)*0.5f));
colors->push_back(osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f));
cursor += dx;
texcoord += dx_texcoord;
}
}
polyGeom->setVertexArray(vertices);
polyGeom->setColorArray(colors, osg::Array::BIND_PER_VERTEX);
polyGeom->setTexCoordArray(0, texcoords);
for (i = 0; i < noSteps - 1; ++i)
{
osg::DrawElementsUShort* elements = new osg::DrawElementsUShort(osg::PrimitiveSet::QUAD_STRIP);
for (j = 0; j < noSteps; ++j)
{
elements->push_back(j + (i + 1)*noSteps);
elements->push_back(j + (i)*noSteps);
}
polyGeom->addPrimitiveSet(elements);
}
osg::StateSet* stateset = polyGeom->getOrCreateStateSet();
stateset->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);
stateset->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
osg::Geode* geode = new osg::Geode();
geode->addDrawable(polyGeom);
osg::Camera* nestedRenderCamera = new osg::Camera;
nestedRenderCamera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
nestedRenderCamera->setViewMatrix(osg::Matrix::identity());
nestedRenderCamera->setProjectionMatrixAsOrtho2D(0, 1280, 0, 1024);
nestedRenderCamera->setRenderOrder(osg::Camera::NESTED_RENDER);
nestedRenderCamera->addChild(geode);
prerenderNode->addChild(nestedRenderCamera);
}
return prerenderNode;
}
int main(int argc, char** argv)
{
osg::ArgumentParser arguments(&argc, argv);
osgViewer::Viewer viewer;
osg::ref_ptr<osg::Group> scene = new osg::Group;
viewer.addEventHandler(new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()));
viewer.addEventHandler(new osgViewer::StatsHandler);
viewer.addEventHandler(new osgViewer::WindowSizeHandler);
viewer.addEventHandler(new osgViewer::ThreadingHandler);
viewer.getCamera()->setProjectionMatrixAsPerspective(60.0f, 1.33333, 0.01, 100.0);
viewer.setCameraManipulator(new osgGA::TrackballManipulator());
viewer.setUpViewInWindow(11, 11, 800 + 11, 600 + 11);
//viewer.setUpViewOnSingleScreen(0); // !!
viewer.getCamera()->setClearColor(osg::Vec4(0.3, 0.3, 0.3, 1.0));
viewer.setThreadingModel(osgViewer::Viewer::SingleThreaded);// we can play with threading models later
osg::ref_ptr<ComputeNode> computeNode = new ComputeNode();
computeNode->setPosition(osg::Vec3(0, 0, 0));
computeNode->setUpdateCallback(new ComputeNodeUpdateCallback(computeNode.get())); // on-the-fly reloading the shaders if shader source on disk is changed
computeNode->initComputingSetup();
scene->addChild(computeNode.get());
scene->addChild(computeNode->_computationResultsRenderGroup.get());
#ifdef PRERENDER_HIGH_QUALITY_ANTIALIASING
viewer.setSceneData(createPrerenderSubgraph(scene.get(), osg::Vec4(0.3, 0.4, 0.6, 1)));
#else
viewer.setSceneData(scene.get());
#endif
viewer.realize();
viewer.getCamera()->getGraphicsContext()->getState()->setUseModelViewAndProjectionUniforms(true);
viewer.run();
return 1;
}

View File

@@ -56,7 +56,18 @@ public:
traverse(node);
}
void apply(osg::Drawable& drawable)
void apply(osg::Geode& node)
{
if (!_useStateSets && node.getStateSet()) node.setStateSet(0);
for(unsigned int i = 0; i<node.getNumDrawables(); ++i)
{
process(*node.getDrawable(i));
}
traverse(node);
}
void process(osg::Drawable& drawable)
{
if (!_useStateSets && drawable.getStateSet())
{
@@ -540,7 +551,6 @@ public:
const std::string& outputFilename,
SceneGraphProcessor* sceneGraphProcessor,
osgUtil::IncrementalCompileOperation* ico):
osg::Referenced(true),
Operation("DatabasePaging Operation", false),
_filename(filename),
_outputFilename(outputFilename),

View File

@@ -71,7 +71,7 @@ int main (int argc, char* argv[])
osg::ref_ptr<osg::Geode> geode = new osg::Geode;
geode->addDrawable(new osg::ShapeDrawable(new osg::Box(osg::Vec3(0.0f,0.0f,0.0f),0.5)));
//Transformation to be manipulated by the animation
//Tranformation to be manipulated by the animation
osg::ref_ptr<osg::MatrixTransform> trans = new osg::MatrixTransform();
trans->setName("AnimatedNode");
//Dynamic object, has to be updated during update traversal
@@ -84,7 +84,7 @@ int main (int argc, char* argv[])
//The second element modifies the rotation around x-axis
updatecb->getStackedTransforms().push_back(new osgAnimation::StackedTranslateElement("position"));
updatecb->getStackedTransforms().push_back(new osgAnimation::StackedRotateAxisElement("euler",osg::Vec3(1,0,0),0));
//connect the UpdateMatrixTransform callback to the MatrixTransform
//connect the UpdateMatrixTransform callback to the MatrixTRanform
trans->setUpdateCallback(updatecb);
//initialize MatrixTranform
trans->setMatrix(osg::Matrix::identity());
@@ -102,7 +102,7 @@ int main (int argc, char* argv[])
//add the rest of the scene to the grp node
grp->addChild(root);
// And we finally define our channel for linear Vector interpolation
// And we finaly define our channel for linear Vector interpolation
osgAnimation::Vec3LinearChannel* channelAnimation1 = new osgAnimation::Vec3LinearChannel;
//name of the AnimationUpdateCallback
channelAnimation1->setTargetName("AnimatedCallback");

View File

@@ -1,14 +1,14 @@
/* -*-c++-*-
/* -*-c++-*-
* Copyright (C) 2008 Cedric Pinson <cedric.pinson@plopbyte.net>
*
* 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.
*/
@@ -84,7 +84,7 @@ struct ExampleTimelineUsage : public osgGA::GUIEventHandler
_scratchNose->setLoop(1); // one time
// add the main loop at priority 0 at time 0.
osgAnimation::Timeline* tml = _manager->getTimeline();
tml->play();
tml->addActionAt(0.0, _mainLoop.get(), 0);
@@ -98,9 +98,9 @@ struct ExampleTimelineUsage : public osgGA::GUIEventHandler
{
// we add a scratch head priority 1 each 10 second
// note:
// it's possible to add the same instance more than once on the timeline
// it's possible to add the same instance more then once on the timeline
// the only things you need to take care is if you remove it. It will remove
// all instance that exist on the timeline. If you need to differentiate
// all instance that exist on the timeline. If you need to differtiate
// it's better to create a new instance
tml->addActionAt(5.0 + 10.0 * i, _scratchHead.get(), 1);
}
@@ -139,12 +139,21 @@ struct ExampleTimelineUsage : public osgGA::GUIEventHandler
}
_releaseKey = false;
}
traverse(node, nv);
}
else
{
osgGA::GUIEventHandler::operator()(node, nv);
}
osgGA::EventVisitor* ev = dynamic_cast<osgGA::EventVisitor*>(nv);
if (ev && ev->getActionAdapter() && !ev->getEvents().empty())
{
for(osgGA::EventQueue::Events::iterator itr = ev->getEvents().begin();
itr != ev->getEvents().end();
++itr)
{
handleWithCheckAgainstIgnoreHandledEventsMask(*(*itr), *(ev->getActionAdapter()), node, nv);
}
}
}
traverse(node, nv);
}
};
@@ -159,7 +168,7 @@ int main (int argc, char* argv[])
osgViewer::Viewer viewer(psr);
std::string file = "nathan.osg";
if(argc >= 2)
if(argc >= 2)
file = psr[1];
// replace the manager
@@ -169,7 +178,7 @@ int main (int argc, char* argv[])
return 1;
}
osgAnimation::AnimationManagerBase* animationManager = dynamic_cast<osgAnimation::AnimationManagerBase*>(root->getUpdateCallback());
if(!animationManager)
if(!animationManager)
{
osg::notify(osg::FATAL) << "Did not find AnimationManagerBase updateCallback needed to animate elements" << std::endl;
return 1;
@@ -177,22 +186,22 @@ int main (int argc, char* argv[])
osg::ref_ptr<osgAnimation::TimelineAnimationManager> tl = new osgAnimation::TimelineAnimationManager(*animationManager);
root->setUpdateCallback(tl.get());
ExampleTimelineUsage* callback = new ExampleTimelineUsage(tl.get());
root->setEventCallback(callback);
root->getUpdateCallback()->addNestedCallback(callback);
// 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);

View File

@@ -24,7 +24,6 @@
#include <osg/Geometry>
#include <osg/MatrixTransform>
#include <osg/Geode>
#include <osgDB/FileNameUtils>
#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
#include <osgWidget/ViewerEventHandlers>
@@ -137,30 +136,10 @@ int main(int argc, char** argv)
// Set our Singleton's model.
AnimationManagerFinder finder;
node->accept(finder);
if (finder._am.valid())
{
std::string playModeOpt;
if (arguments.read("--play-mode", playModeOpt))
{
osgAnimation::Animation::PlayMode playMode = osgAnimation::Animation::LOOP;
if (osgDB::equalCaseInsensitive(playModeOpt, "ONCE")) playMode = osgAnimation::Animation::ONCE;
else if (osgDB::equalCaseInsensitive(playModeOpt, "STAY")) playMode = osgAnimation::Animation::STAY;
else if (osgDB::equalCaseInsensitive(playModeOpt, "LOOP")) playMode = osgAnimation::Animation::LOOP;
else if (osgDB::equalCaseInsensitive(playModeOpt, "PPONG")) playMode = osgAnimation::Animation::PPONG;
for (osgAnimation::AnimationList::const_iterator animIter = finder._am->getAnimationList().begin();
animIter != finder._am->getAnimationList().end(); ++animIter)
{
(*animIter)->setPlayMode(playMode);
}
}
if (finder._am.valid()) {
node->setUpdateCallback(finder._am.get());
AnimtkViewerModelController::setModel(finder._am.get());
}
else
{
} else {
osg::notify(osg::WARN) << "no osgAnimation::AnimationManagerBase found in the subgraph, no animations available" << std::endl;
}

View File

@@ -406,7 +406,7 @@ int main( int argc, char **argv )
viewer.renderingTraversals();
osg::Timer_t afterRenderTick = osg::Timer::instance()->tick();
std::cout<<"Rendering time = "<<osg::Timer::instance()->delta_s(beforeRenderTick, afterRenderTick) <<" seconds"<<std::endl;
std::cout<<"Rendring time = "<<osg::Timer::instance()->delta_s(beforeRenderTick, afterRenderTick) <<" seconds"<<std::endl;
return 0;
}

View File

@@ -130,7 +130,7 @@ osg::Node* createModel()
// create the root node which will hold the model.
osg::Group* root = new osg::Group();
// add the drawable into a single geode to be shared...
// add the drawable into a single goede to be shared...
osg::Billboard* center = new osg::Billboard();
center->setMode(osg::Billboard::POINT_ROT_EYE);
center->addDrawable(

View File

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

View File

@@ -1,147 +0,0 @@
/* OpenSceneGraph example, osgblenddrawbuffers.
*
* 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/Geometry>
#include <osg/Geode>
#include <osg/Camera>
#include <osg/Texture2D>
#include <osg/BlendFunci>
#include <osg/ColorMaski>
#include <osg/Capability>
#include <osgDB/ReadFile>
#include <osgViewer/Viewer>
#include <iostream>
osg::Camera* createMRTCamera( std::vector<osg::Texture*>& attachedTextures )
{
osg::ref_ptr<osg::Camera> camera = new osg::Camera;
camera->setClearColor( osg::Vec4(0.0f, 0.0f, 0.0f, 1.0f) );
camera->setClearMask( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT );
camera->setRenderTargetImplementation( osg::Camera::FRAME_BUFFER_OBJECT );
camera->setRenderOrder( osg::Camera::PRE_RENDER );
for ( int i=0; i<4; ++i )
{
osg::Texture2D* tex = new osg::Texture2D;
tex->setTextureSize( 1024, 1024 );
tex->setInternalFormat( GL_RGBA );
tex->setFilter( osg::Texture2D::MIN_FILTER, osg::Texture2D::LINEAR );
tex->setFilter( osg::Texture2D::MAG_FILTER, osg::Texture2D::LINEAR );
attachedTextures.push_back( tex );
camera->setViewport( 0, 0, tex->getTextureWidth(), tex->getTextureHeight() );
camera->attach( osg::Camera::BufferComponent(osg::Camera::COLOR_BUFFER0+i), tex );
}
return camera.release();
}
osg::Camera* createHUDCamera( double left, double right, double bottom, double top )
{
osg::ref_ptr<osg::Camera> camera = new osg::Camera;
camera->setReferenceFrame( osg::Transform::ABSOLUTE_RF );
camera->setClearMask( GL_DEPTH_BUFFER_BIT );
camera->setRenderOrder( osg::Camera::POST_RENDER );
camera->setAllowEventFocus( false );
camera->setProjectionMatrix( osg::Matrix::ortho2D(left, right, bottom, top) );
camera->getOrCreateStateSet()->setMode( GL_LIGHTING, osg::StateAttribute::OFF );
return camera.release();
}
int main( int argc, char **argv )
{
osg::ArgumentParser arguments(&argc, argv);
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName() + " is the example which demonstrates how to enable/disable blending on specified draw buffers in multi-rendering-target cases.");
std::vector<osg::Texture*> textures;
bool useGlobalBlending = false;
if ( arguments.read("--no-draw-buffers") ) useGlobalBlending = true;
// Create a camera to output multi-rendering-targets (MRT)
osg::Camera* mrtCam = createMRTCamera( textures );
mrtCam->addChild( osgDB::readNodeFile("cessna.osgt") );
// Create shader program to be used
const char* mrtFragmentCode = {
"void main() {\n"
" gl_FragData[0] = gl_Color * vec4(1.0, 1.0, 1.0, 0.7);\n"
" gl_FragData[1] = vec4(0.0, 1.0, 1.0, 0.0);\n"
" gl_FragData[2] = vec4(1.0, 0.0, 1.0, 0.3);\n"
" gl_FragData[3] = vec4(1.0, 1.0, 0.0, 1.0);\n"
"}\n"
};
osg::ref_ptr<osg::Program> program = new osg::Program;
program->addShader( new osg::Shader(osg::Shader::FRAGMENT, mrtFragmentCode) );
osg::StateSet* ss = mrtCam->getOrCreateStateSet();
ss->setAttributeAndModes( program.get() );
// Apply blending to the original scene in MRT
if ( !useGlobalBlending )
{
// Only enable blending on the first draw buffer so other three outputs are
// totally opaque, which is important for MRT cases
ss->setAttribute( new osg::Enablei(GL_BLEND, 0) );
ss->setAttribute( new osg::Disablei(GL_BLEND, 1) );
ss->setAttribute( new osg::Disablei(GL_BLEND, 2) );
ss->setAttribute( new osg::Disablei(GL_BLEND, 3) );
// Accept different blend/colormask attributes on multiple render targets
osg::ref_ptr<osg::BlendFunci> blend0 = new osg::BlendFunci(0, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
osg::ref_ptr<osg::ColorMaski> colormask3 = new osg::ColorMaski(3, false, true, false, true);
ss->setAttribute( blend0.get() );
ss->setAttributeAndModes( colormask3.get() );
}
else
{
// When separated blending is disabled, all rendering targets will be affected
// by its alpha channel and you will see each output blended with the background.
//
// This causes a big program in situations like deferred shading because we may
// have to save different scene data to MRT 'GBuffer', in which alpha channels are
// used to store certain attributes rather than opacity. These attributes can be
// reused in following post-processing steps.
//
// For such targets, alpha blending must be disabled; otherwise it will mess the
// output. That is why this example exists!
osg::ref_ptr<osg::BlendFunc> blend = new osg::BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
ss->setAttributeAndModes( blend.get() );
}
// Create some quads to be shown on screen to contain the MRT result
osg::ref_ptr<osg::Geode> quad = new osg::Geode;
for ( unsigned int i=0; i<textures.size(); ++i )
{
osg::Geometry* geom = osg::createTexturedQuadGeometry(
osg::Vec3((float)i/(float)textures.size(), 0.0f, 0.0f),
osg::Vec3(1.0f/(float)textures.size()-0.01f,0.0f,0.0f), osg::Vec3(0.0f,1.0f,0.0f) );
geom->getOrCreateStateSet()->setTextureAttributeAndModes( 0, textures[i] );
quad->addDrawable( geom );
}
osg::Camera* hudCam = createHUDCamera( 0.0, 1.0, 0.0, 1.0 );
hudCam->addChild( quad.get() );
// Construct scene graph and viewer
osg::ref_ptr<osg::Group> root = new osg::Group;
root->addChild( mrtCam );
root->addChild( hudCam );
osgViewer::Viewer viewer;
viewer.setSceneData( root.get() );
return viewer.run();
}

View File

@@ -82,7 +82,7 @@ protected:
bool TechniqueEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&)
{
switch(ea.getEventType())
@@ -104,7 +104,7 @@ bool TechniqueEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIAc
_eq_index--;
if (_eq_index<0) _eq_index=_eq_nb-1;
_blendEq->setEquation(_equations[_eq_index]);
std::cout<<"Equation name = "<<_equations_name[_eq_index]<<std::endl;
std::cout<<"Operation name = "<<_equations_name[_eq_index]<<std::endl;
return true;
}
return false;
@@ -134,7 +134,7 @@ int main( int argc, char **argv )
arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the example which demonstrates how to use glBlendEquation for mixing rendered scene and the frame-buffer.");
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// construct the viewer.
osgViewer::Viewer viewer;
@@ -143,7 +143,7 @@ int main( int argc, char **argv )
// if not loaded assume no arguments passed in, try use default mode instead.
if (!loadedModel) loadedModel = osgDB::readNodeFile("cessnafire.osgt");
if (!loadedModel)
{
std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
@@ -152,18 +152,18 @@ int main( int argc, char **argv )
osg::Group* root = new osg::Group;
root->addChild(loadedModel);
osg::StateSet* stateset = new osg::StateSet;
stateset->setDataVariance(osg::Object::DYNAMIC);
osg::BlendEquation* blendEquation = new osg::BlendEquation(osg::BlendEquation::FUNC_ADD);
blendEquation->setDataVariance(osg::Object::DYNAMIC);
stateset->setAttributeAndModes(blendEquation,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
//tell to sort the mesh before displaying it
stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
loadedModel->setStateSet(stateset);
@@ -171,6 +171,6 @@ int main( int argc, char **argv )
// add a viewport to the viewer and attach the scene graph.
viewer.setSceneData( root );
return viewer.run();
}

View File

@@ -38,7 +38,7 @@
class UpdateCallback : public osg::NodeCallback
{
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
{
{
std::cout<<"update callback - pre traverse"<<node<<std::endl;
traverse(node,nv);
std::cout<<"update callback - post traverse"<<node<<std::endl;
@@ -48,7 +48,7 @@ class UpdateCallback : public osg::NodeCallback
class CullCallback : public osg::NodeCallback
{
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
{
{
std::cout<<"cull callback - pre traverse"<<node<<std::endl;
traverse(node,nv);
std::cout<<"cull callback - post traverse"<<node<<std::endl;
@@ -87,11 +87,11 @@ class InsertCallbacksVisitor : public osg::NodeVisitor
{
public:
InsertCallbacksVisitor():osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN)
{
}
virtual void apply(osg::Node& node)
{
node.setUpdateCallback(new UpdateCallback());
@@ -102,7 +102,7 @@ class InsertCallbacksVisitor : public osg::NodeVisitor
virtual void apply(osg::Geode& geode)
{
geode.setUpdateCallback(new UpdateCallback());
//note, it makes no sense to attach a cull callback to the node
//at there are no nodes to traverse below the geode, only
//drawables, and as such the Cull node callbacks is ignored.
@@ -116,7 +116,7 @@ class InsertCallbacksVisitor : public osg::NodeVisitor
geode.getDrawable(i)->setDrawCallback(new DrawableDrawCallback());
}
}
virtual void apply(osg::Transform& node)
{
apply((osg::Node&)node);
@@ -140,7 +140,7 @@ public:
class CameraUpdateCallback : public osg::NodeCallback
{
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
{
{
std::cout<<"Camera update callback - pre traverse"<<node<<std::endl;
traverse(node,nv);
std::cout<<"Camera update callback - post traverse"<<node<<std::endl;
@@ -150,131 +150,50 @@ class CameraUpdateCallback : public osg::NodeCallback
class CameraEventCallback : public osg::NodeCallback
{
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
{
{
std::cout<<"Camera event callback - pre traverse"<<node<<std::endl;
traverse(node,nv);
std::cout<<"Camera event callback - post traverse"<<node<<std::endl;
}
};
struct TestDrawableUpdateCallback : public osg::Drawable::UpdateCallback
{
TestDrawableUpdateCallback(const std::string &message): _message(message) {}
virtual void update(osg::NodeVisitor*, osg::Drawable* drw) {
printf("%s\n", _message.c_str());
}
std::string _message;
};
struct TestNodeUpdateCallback : public osg::NodeCallback
{
TestNodeUpdateCallback(const std::string &message): _message(message) {}
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv) {
printf("%s\n", _message.c_str());
}
std::string _message;
};
int main( int argc, char **argv )
{
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
// set the osgDB::Registy read file callback to catch all requests for reading files.
osgDB::Registry::instance()->setReadFileCallback(new MyReadFileCallback());
// initialize the viewer.
osgViewer::Viewer viewer;
// load the nodes from the commandline arguments.
osg::ref_ptr<osg::Node> rootnode;
osg::Node* rootnode = osgDB::readNodeFiles(arguments);
if (arguments.read("--test"))
// if not loaded assume no arguments passed in, try use default mode instead.
if (!rootnode) rootnode = osgDB::readNodeFile("cow.osgt");
if (!rootnode)
{
osg::ref_ptr<osg::Group> root = new osg::Group();
rootnode = root;
osg::Node *test1 = new osg::Node();
test1->setUpdateCallback(new TestNodeUpdateCallback("test1"));
root->addChild(test1);
osg::Drawable *test2 = new osg::Drawable();
test2->osg::Node::setUpdateCallback(new TestNodeUpdateCallback("test2"));
root->addChild(test2);
osg::Drawable *test3 = new osg::Drawable();
test3->setUpdateCallback(new TestDrawableUpdateCallback("test3"));
root->addChild(test3);
osg::Geode *test4 = new osg::Geode();
osg::Drawable *drawable1 = new osg::Drawable();
drawable1->osg::Node::setUpdateCallback(new TestNodeUpdateCallback("test4"));
test4->addDrawable(drawable1);
root->addChild(test4);
osg::Geode *test5 = new osg::Geode();
osg::Drawable *drawable2 = new osg::Drawable();
drawable2->setUpdateCallback(new TestDrawableUpdateCallback("test5"));
test5->addDrawable(drawable2);
root->addChild(test5);
osg::Geode *test6 = new osg::Geode();
osg::Drawable *drawable3 = new osg::Drawable();
drawable3->setUpdateCallback(new TestDrawableUpdateCallback("test6"));
test6->addChild(drawable3);
root->addChild(test6);
osg::Geode *test7 = new osg::Geode();
osg::Drawable *drawable4 = new osg::Drawable();
drawable4->osg::Node::setUpdateCallback(new TestNodeUpdateCallback("test7"));
test7->addChild(drawable4);
root->addChild(test7);
printf("Numchildren with updates %u\n", rootnode->getNumChildrenRequiringUpdateTraversal());
osg::notify(osg::NOTICE)<<"Please specify a file on the command line"<<std::endl;
return 1;
}
else
{
rootnode = osgDB::readNodeFiles(arguments);
// if not loaded assume no arguments passed in, try use default mode instead.
if (!rootnode) rootnode = osgDB::readNodeFile("cow.osgt");
if (!rootnode)
{
osg::notify(osg::NOTICE)<<"Please specify a file on the command line"<<std::endl;
return 1;
}
// run optimization over the scene graph
osgUtil::Optimizer optimzer;
optimzer.optimize(rootnode.get());
// insert all the callbacks
InsertCallbacksVisitor icv;
rootnode->accept(icv);
}
// run optimization over the scene graph
osgUtil::Optimizer optimzer;
optimzer.optimize(rootnode);
// insert all the callbacks
InsertCallbacksVisitor icv;
rootnode->accept(icv);
viewer.getCamera()->setUpdateCallback(new CameraUpdateCallback());
viewer.getCamera()->setEventCallback(new CameraEventCallback());
// set the scene to render
viewer.setSceneData(rootnode.get());
viewer.setSceneData(rootnode);
viewer.setCameraManipulator(new osgGA::TrackballManipulator);
viewer.realize();
while(!viewer.done())
{
OSG_NOTICE<<std::endl<<"New Frame"<<std::endl;
viewer.frame();
}
return 0;
return viewer.run();
}

View File

@@ -304,7 +304,7 @@ int main( int argc, char **argv )
osgViewer::View* view = dynamic_cast<osgViewer::View*>(object.get());
if (view)
{
osg::notify(osg::NOTICE)<<"Read config file successfully"<<std::endl;
osg::notify(osg::NOTICE)<<"Read config file succesfully"<<std::endl;
}
else
{

View File

@@ -1366,7 +1366,6 @@ class CompileStateCallback : public osg::Operation
{
public:
CompileStateCallback(GameEventHandler* eh):
osg::Referenced(true),
osg::Operation("CompileStateCallback", false),
_gameEventHandler(eh) {}

View File

@@ -59,7 +59,7 @@ osg::Node* decorate_with_clip_node(osg::Node* subgraph)
rootnode->addChild(wireframe_subgraph);
/*
// simple approach to adding a clipnode above a subgraph.
// simple approach to adding a clipnode above a subrgaph.
// create clipped part.
osg::ClipNode* clipped_subgraph = new osg::ClipNode;
@@ -78,7 +78,7 @@ osg::Node* decorate_with_clip_node(osg::Node* subgraph)
// more complex approach to managing ClipNode, allowing
// ClipNode node to be transformed independently from the subgraph
// ClipNode node to be transformed independantly from the subgraph
// that it is clipping.
osg::MatrixTransform* transform= new osg::MatrixTransform;
@@ -126,7 +126,7 @@ int main( int argc, char **argv )
if (!loadedModel)
{
osg::notify(osg::NOTICE)<<"Please specify a filename on the command line"<<std::endl;
osg::notify(osg::NOTICE)<<"Please specifiy a filename and the command line"<<std::endl;
return 1;
}

View File

@@ -44,6 +44,7 @@
#include "broadcaster.h"
const unsigned int MAX_NUM_EVENTS = 10;
const unsigned int SWAP_BYTES_COMPARE = 0x12345678;
class CameraPacket {
public:
@@ -375,8 +376,7 @@ class DataConverter
itr != cameraPacket._events.end();
++itr)
{
osgGA::GUIEventAdapter* event = (*itr)->asGUIEventAdapter();
if (event) write(*event);
write(*(*itr));
}
}
@@ -614,7 +614,7 @@ int main( int argc, char **argv )
osg::notify(osg::INFO)<<"Time to do cluster sync "<<osg::Timer::instance()->delta_m(startTick,endTick)<<std::endl;
// update the scene by traversing it with the update visitor which will
// update the scene by traversing it with the the update visitor which will
// call all node update callbacks and animations.
viewer.eventTraversal();
viewer.updateTraversal();

View File

@@ -211,7 +211,7 @@ int main( int argc, char **argv )
// ------------- Start of copy specific code -------------------------------------------------------
// do a deep copy, using MyCopyOp to reveal whats going on under the hood,
// do a deep copy, using MyCopyOp to reveal whats going on under the good,
// in your own code you'd typically just use the basic osg::CopyOp something like
osg::ref_ptr<osg::Node> mycopy = dynamic_cast<osg::Node*>(rootnode->clone(osg::CopyOp::DEEP_COPY_ALL));
std::cout << "Doing a deep copy of scene graph"<<std::endl;

View File

@@ -43,21 +43,21 @@
void create_specular_highlights(osg::Node *node)
{
osg::StateSet *ss = node->getOrCreateStateSet();
// create and setup the texture object
osg::TextureCubeMap *tcm = new osg::TextureCubeMap;
tcm->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP);
tcm->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP);
tcm->setWrap(osg::Texture::WRAP_R, osg::Texture::CLAMP);
tcm->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR_MIPMAP_LINEAR);
tcm->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR);
tcm->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR);
// generate the six highlight map images (light direction = [1, 1, -1])
osgUtil::HighlightMapGenerator *mapgen = new osgUtil::HighlightMapGenerator(
osg::Vec3(1, 1, -1), // light direction
osg::Vec4(1, 0.9f, 0.8f, 1), // light color
8); // specular exponent
mapgen->generateMap();
// assign the six images to the texture object
@@ -77,7 +77,7 @@ void create_specular_highlights(osg::Node *node)
ss->setTextureAttributeAndModes(0, tg, osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON);
// use TexEnvCombine to add the highlights to the original lighting
osg::TexEnvCombine *te = new osg::TexEnvCombine;
osg::TexEnvCombine *te = new osg::TexEnvCombine;
te->setCombine_RGB(osg::TexEnvCombine::ADD);
te->setSource0_RGB(osg::TexEnvCombine::TEXTURE);
te->setOperand0_RGB(osg::TexEnvCombine::SRC_COLOR);
@@ -93,7 +93,7 @@ int main(int argc, char *argv[])
// construct the viewer.
osgViewer::Viewer viewer;
// load the nodes from the commandline arguments.
osg::Node* rootnode = osgDB::readNodeFiles(arguments);
@@ -108,16 +108,32 @@ int main(int argc, char *argv[])
// create specular highlights
create_specular_highlights(rootnode);
// run optimization over the scene graph
osgUtil::Optimizer optimzer;
optimzer.optimize(rootnode);
// add a viewport to the viewer and attach the scene graph.
viewer.setSceneData(rootnode);
// create the windows and run the threads.
viewer.realize();
// now check to see if texture cube map is supported.
for(unsigned int contextID = 0;
contextID<osg::DisplaySettings::instance()->getMaxNumberOfGraphicsContexts();
++contextID)
{
osg::TextureCubeMap::Extensions* tcmExt = osg::TextureCubeMap::getExtensions(contextID,false);
if (tcmExt)
{
if (!tcmExt->isCubeMapSupported())
{
std::cout<<"Warning: texture_cube_map not supported by OpenGL drivers, unable to run application."<<std::endl;
return 1;
}
}
}
return viewer.run();
}

View File

@@ -303,7 +303,7 @@ bool DePee::createHUD()
osg::BoundingBox bb;
for(unsigned int i=0;i<geode->getNumDrawables();++i)
{
bb.expandBy(geode->getDrawable(i)->getBoundingBox());
bb.expandBy(geode->getDrawable(i)->getBound());
}
osg::Geometry* geom = new osg::Geometry;

View File

@@ -20,7 +20,7 @@
/*!
The DePee class is main class for setting up and managing depth peeling.
A DePee object can be seen as a virtual node, that has one parent and one child. The rendering of every child and subchil of this child is managed by the DePee node. Besides that, it handles a head up display.
A DePee object can be seen as a virtual node, that has one parent and one child. The rendering of every child and subchil of this child is managed by the the DePee node. Besides that, it handles a head up display.
*/
class DePee : public osg::Referenced
{

View File

@@ -52,96 +52,18 @@
using namespace osg;
struct CommandLineOptions
{
unsigned int width;
unsigned int height;
unsigned int tex_width;
unsigned int tex_height;
double sphere_radius;
double collar_radius;
double distance;
CommandLineOptions():
width(1024),
height(1024),
tex_width(1024),
tex_height(1024),
sphere_radius(1.0),
collar_radius(0.45),
distance(1.0)
{
osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface();
if (!wsi)
{
osg::notify(osg::NOTICE)<<"Error, no WindowSystemInterface available, cannot create windows."<<std::endl;
return;
}
unsigned int width, height;
wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(0), width, height);
distance = sqrt(sphere_radius*sphere_radius - collar_radius*collar_radius);
}
void read(osg::ArgumentParser& arguments)
{
while (arguments.read("--width",width)) {}
while (arguments.read("--height",height)) {}
while (arguments.read("--texture-width",tex_width) || arguments.read("--tx",tex_width) ) {}
while (arguments.read("--texture-height",tex_height) || arguments.read("--ty",tex_height) ) {}
while (arguments.read("--radius", sphere_radius)) {}
while (arguments.read("--collar", collar_radius)) {}
distance = sqrt(sphere_radius*sphere_radius - collar_radius*collar_radius);
while (arguments.read("--distance", distance)) {}
}
};
class WindowResizedHandler : public osgGA::GUIEventHandler
{
public:
WindowResizedHandler()
{
}
virtual bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa, osg::Object* object, osg::NodeVisitor* nv)
{
osg::Camera* camera = dynamic_cast<osg::Camera*>(object);
if (!camera) return false;
const osg::FrameStamp* fs = nv->getFrameStamp();
if (ea.getEventType()==osgGA::GUIEventAdapter::RESIZE)
{
OSG_NOTICE<<"Window resized event context="<<ea.getGraphicsContext()<<" frameNumber = "<<fs->getFrameNumber()<<std::endl;
OSG_NOTICE<<" WindowX="<<ea.getWindowX()<<std::endl;
OSG_NOTICE<<" WindowY="<<ea.getWindowY()<<std::endl;
OSG_NOTICE<<" WindowWidth="<<ea.getWindowWidth()<<std::endl;
OSG_NOTICE<<" WindowHeight="<<ea.getWindowHeight()<<std::endl;
// reset the Camera viewport and associated Texture's to make sure it tracks the new window size.
camera->resize(ea.getWindowWidth(), ea.getWindowHeight());
}
return false;
}
};
osg::Node* createDistortionSubgraph(CommandLineOptions& options, osg::Node* subgraph, const osg::Vec4& clearColour)
osg::Node* createDistortionSubgraph(osg::Node* subgraph, const osg::Vec4& clearColour)
{
osg::Group* distortionNode = new osg::Group;
unsigned int tex_width = 1024;
unsigned int tex_height = 1024;
osg::Texture2D* texture = new osg::Texture2D;
texture->setTextureSize(options.tex_width, options.tex_height);
texture->setTextureSize(tex_width, tex_height);
texture->setInternalFormat(GL_RGBA);
texture->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);
texture->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);
texture->setWrap(osg::Texture2D::WRAP_S, osg::Texture2D::CLAMP_TO_EDGE);
texture->setWrap(osg::Texture2D::WRAP_T, osg::Texture2D::CLAMP_TO_EDGE);
// set up the render to texture camera.
{
@@ -157,7 +79,7 @@ osg::Node* createDistortionSubgraph(CommandLineOptions& options, osg::Node* subg
camera->setViewMatrix(osg::Matrixd::identity());
// set viewport
camera->setViewport(0,0,options.tex_width,options.tex_height);
camera->setViewport(0,0,tex_width,tex_height);
// set the camera to render before the main camera.
camera->setRenderOrder(osg::Camera::PRE_RENDER);
@@ -172,8 +94,6 @@ osg::Node* createDistortionSubgraph(CommandLineOptions& options, osg::Node* subg
camera->addChild(subgraph);
distortionNode->addChild(camera);
camera->addEventCallback(new WindowResizedHandler());
}
// set up the hud camera
@@ -266,13 +186,27 @@ osg::Node* createDistortionSubgraph(CommandLineOptions& options, osg::Node* subg
return distortionNode;
}
void setDomeFaces(osgViewer::Viewer& viewer, CommandLineOptions& options)
void setDomeFaces(osgViewer::Viewer& viewer, osg::ArgumentParser& arguments)
{
osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface();
if (!wsi)
{
osg::notify(osg::NOTICE)<<"Error, no WindowSystemInterface available, cannot create windows."<<std::endl;
return;
}
unsigned int width, height;
wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(0), width, height);
while (arguments.read("--width",width)) {}
while (arguments.read("--height",height)) {}
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
traits->x = 0;
traits->y = 0;
traits->width = options.width;
traits->height = options.height;
traits->width = width;
traits->height = height;
traits->windowDecoration = true;
traits->doubleBuffer = true;
traits->sharedContext = 0;
@@ -285,8 +219,8 @@ void setDomeFaces(osgViewer::Viewer& viewer, CommandLineOptions& options)
}
int center_x = options.width/2;
int center_y = options.height/2;
int center_x = width/2;
int center_y = height/2;
int camera_width = 256;
int camera_height = 256;
@@ -369,18 +303,27 @@ void setDomeFaces(osgViewer::Viewer& viewer, CommandLineOptions& options)
}
osg::Geometry* createDomeDistortionMesh(const osg::Vec3& origin, const osg::Vec3& widthVector, const osg::Vec3& heightVector,
CommandLineOptions& options)
osg::ArgumentParser& arguments)
{
double sphere_radius = 1.0;
if (arguments.read("--radius", sphere_radius)) {}
double collar_radius = 0.45;
if (arguments.read("--collar", collar_radius)) {}
osg::Vec3d center(0.0,0.0,0.0);
osg::Vec3d eye(0.0,0.0,0.0);
double distance = sqrt(sphere_radius*sphere_radius - collar_radius*collar_radius);
if (arguments.read("--distance", distance)) {}
bool centerProjection = false;
osg::Vec3d projector = eye - osg::Vec3d(0.0,0.0, options.distance);
osg::Vec3d projector = eye - osg::Vec3d(0.0,0.0, distance);
osg::notify(osg::NOTICE)<<"Projector position = "<<projector<<std::endl;
osg::notify(osg::NOTICE)<<"distance = "<<options.distance<<std::endl;
osg::notify(osg::NOTICE)<<"distance = "<<distance<<std::endl;
// create the quad to visualize.
@@ -453,15 +396,15 @@ osg::Geometry* createDomeDistortionMesh(const osg::Vec3& origin, const osg::Vec3
// osg::notify(osg::NOTICE)<<"theta = "<<theta<< "phi="<<phi<<std::endl;
double f = options.distance * sin(phi);
double e = options.distance * cos(phi) + sqrt( options.sphere_radius*options.sphere_radius - f*f);
double f = distance * sin(phi);
double e = distance * cos(phi) + sqrt( sphere_radius*sphere_radius - f*f);
double l = e * cos(phi);
double h = e * sin(phi);
double z = l - options.distance;
double z = l - distance;
osg::Vec3 texcoord(h * cos(theta) / options.sphere_radius,
h * sin(theta) / options.sphere_radius,
z / options.sphere_radius);
osg::Vec3 texcoord(h * cos(theta) / sphere_radius,
h * sin(theta) / sphere_radius,
z / sphere_radius);
vertices->push_back(cursor);
colors->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
@@ -494,17 +437,33 @@ osg::Geometry* createDomeDistortionMesh(const osg::Vec3& origin, const osg::Vec3
return geometry;
}
void setDomeCorrection(osgViewer::Viewer& viewer, CommandLineOptions& options)
void setDomeCorrection(osgViewer::Viewer& viewer, osg::ArgumentParser& arguments)
{
osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface();
if (!wsi)
{
osg::notify(osg::NOTICE)<<"Error, no WindowSystemInterface available, cannot create windows."<<std::endl;
return;
}
unsigned int width, height;
wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(0), width, height);
while (arguments.read("--width",width)) {}
while (arguments.read("--height",height)) {}
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
traits->x = 0;
traits->y = 0;
traits->width = options.width;
traits->height = options.height;
traits->width = width;
traits->height = height;
traits->windowDecoration = false;
traits->doubleBuffer = true;
traits->sharedContext = 0;
osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
if (!gc)
{
@@ -512,18 +471,18 @@ void setDomeCorrection(osgViewer::Viewer& viewer, CommandLineOptions& options)
return;
}
int camera_width = options.tex_width;
int camera_height = options.tex_height;
int tex_width = 512;
int tex_height = 512;
int camera_width = tex_width;
int camera_height = tex_height;
osg::TextureCubeMap* texture = new osg::TextureCubeMap;
texture->setTextureSize(options.tex_width, options.tex_height);
texture->setTextureSize(tex_width, tex_height);
texture->setInternalFormat(GL_RGB);
texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR);
texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR);
texture->setWrap(osg::Texture::WRAP_S,osg::Texture::CLAMP_TO_EDGE);
texture->setWrap(osg::Texture::WRAP_T,osg::Texture::CLAMP_TO_EDGE);
texture->setWrap(osg::Texture::WRAP_R,osg::Texture::CLAMP_TO_EDGE);
#if 0
osg::Camera::RenderTargetImplementation renderTargetImplementation = osg::Camera::SEPERATE_WINDOW;
@@ -655,7 +614,7 @@ void setDomeCorrection(osgViewer::Viewer& viewer, CommandLineOptions& options)
// distortion correction set up.
{
osg::Geode* geode = new osg::Geode();
geode->addDrawable(createDomeDistortionMesh(osg::Vec3(0.0f,0.0f,0.0f), osg::Vec3(options.width,0.0f,0.0f), osg::Vec3(0.0f,options.height,0.0f), options));
geode->addDrawable(createDomeDistortionMesh(osg::Vec3(0.0f,0.0f,0.0f), osg::Vec3(width,0.0f,0.0f), osg::Vec3(0.0f,height,0.0f), arguments));
// new we need to add the texture to the mesh, we do so by creating a
// StateSet to contain the Texture StateAttribute.
@@ -667,7 +626,7 @@ void setDomeCorrection(osgViewer::Viewer& viewer, CommandLineOptions& options)
camera->setGraphicsContext(gc.get());
camera->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT );
camera->setClearColor( osg::Vec4(0.1,0.1,1.0,1.0) );
camera->setViewport(new osg::Viewport(0, 0, options.width, options.height));
camera->setViewport(new osg::Viewport(0, 0, width, height));
GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT;
camera->setDrawBuffer(buffer);
camera->setReadBuffer(buffer);
@@ -676,7 +635,7 @@ void setDomeCorrection(osgViewer::Viewer& viewer, CommandLineOptions& options)
//camera->setInheritanceMask(camera->getInheritanceMask() & ~osg::CullSettings::CLEAR_COLOR & ~osg::CullSettings::COMPUTE_NEAR_FAR_MODE);
//camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);
camera->setProjectionMatrixAsOrtho2D(0,options.width,0,options.height);
camera->setProjectionMatrixAsOrtho2D(0,width,0,height);
camera->setViewMatrix(osg::Matrix::identity());
// add subgraph to render
@@ -696,11 +655,8 @@ int main(int argc, char** argv)
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
CommandLineOptions options;
options.read(arguments);
// construct the viewer.
osgViewer::Viewer viewer(arguments);
osgViewer::Viewer viewer;
// load the nodes from the commandline arguments.
osg::Node* loadedModel = osgDB::readNodeFiles(arguments);
@@ -718,20 +674,20 @@ int main(int argc, char** argv)
if (arguments.read("--dome") || arguments.read("--puffer") )
{
setDomeCorrection(viewer, options);
setDomeCorrection(viewer, arguments);
viewer.setSceneData( loadedModel );
}
else if (arguments.read("--faces"))
{
setDomeFaces(viewer, options);
setDomeFaces(viewer, arguments);
viewer.setSceneData( loadedModel );
}
else
{
osg::Node* distortionNode = createDistortionSubgraph( options, loadedModel, viewer.getCamera()->getClearColor());
osg::Node* distortionNode = createDistortionSubgraph( loadedModel, viewer.getCamera()->getClearColor());
viewer.setSceneData( distortionNode );
}
@@ -782,9 +738,6 @@ int main(int argc, char** argv)
viewer.setThreadingModel(osgViewer::Viewer::SingleThreaded);
// add window resize handler
viewer.addEventHandler(new osgViewer::WindowSizeHandler);
// add the state manipulator
viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) );

View File

@@ -19,10 +19,17 @@ void textInfo(osgText::Text* text)
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::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]) << "':"

View File

@@ -812,9 +812,9 @@ class ShaderGeometry : public osg::Drawable
}
}
virtual osg::BoundingBox computeBoundingBox() const
virtual osg::BoundingBox computeBound() const
{
osg::BoundingBox geom_box = _geometry->getBoundingBox();
osg::BoundingBox geom_box = _geometry->getBound();
osg::BoundingBox bb;
for(PositionSizeList::const_iterator itr = _trees.begin();
itr != _trees.end();

View File

@@ -23,6 +23,7 @@
#include <osg/Geometry>
#include <osg/GLExtensions>
#include <osg/Node>
#include <osg/NodeCallback>
#include <osg/Notify>
#include <osg/observer_ptr>
#include <osg/Projection>
@@ -132,10 +133,10 @@ void getPossibleConfigs(GraphicsContext* gc, BufferConfigList& colorConfigs,
unsigned contextID = gc->getState()->getContextID();
colorConfigs.push_back(BufferConfig("RGBA8", GL_RGBA8, 8));
depthConfigs.push_back(BufferConfig("D24", GL_DEPTH_COMPONENT24, 24));
osg::GLExtensions* ext = gc->getState()->get<GLExtensions>();
if (!ext->isRenderbufferMultisampleSupported())
FBOExtensions* fboe = FBOExtensions::instance(contextID, true);
if (!fboe->isSupported())
return;
if (ext->isMultisampleSupported)
if (fboe->isMultisampleSupported())
glGetIntegerv(GL_MAX_SAMPLES_EXT, &maxSamples);
// isMultisampleCoverageSupported
if (isGLExtensionSupported(contextID,
@@ -156,8 +157,9 @@ void getPossibleConfigs(GraphicsContext* gc, BufferConfigList& colorConfigs,
bool checkFramebufferStatus(GraphicsContext* gc, bool silent = false)
{
State& state = *gc->getState();
osg::GLExtensions* ext = state.get<GLExtensions>();
switch(ext->glCheckFramebufferStatus(GL_FRAMEBUFFER_EXT)) {
unsigned contextID = state.getContextID();
FBOExtensions* fboe = FBOExtensions::instance(contextID, true);
switch(fboe->glCheckFramebufferStatus(GL_FRAMEBUFFER_EXT)) {
case GL_FRAMEBUFFER_COMPLETE_EXT:
break;
case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
@@ -241,30 +243,30 @@ bool createFBO(GraphicsContext* gc, FboConfig &config, FboData &data)
}
State& state = *gc->getState();
unsigned int contextID = state.getContextID();
osg::GLExtensions* ext = gc->getState()->get<GLExtensions>();
FBOExtensions* fboe = FBOExtensions::instance(contextID, true);
data.fb->apply(state);
result = checkFramebufferStatus(gc, true);
if (!result)
{
ext->glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
fboe->glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
return false;
}
int query;
if (multisample)
{
GLuint colorRBID = colorRB->getObjectID(contextID, ext);
ext->glBindRenderbuffer(GL_RENDERBUFFER_EXT, colorRBID);
GLuint colorRBID = colorRB->getObjectID(contextID, fboe);
fboe->glBindRenderbuffer(GL_RENDERBUFFER_EXT, colorRBID);
if (csaa)
{
ext->glGetRenderbufferParameteriv(GL_RENDERBUFFER_EXT,
fboe->glGetRenderbufferParameteriv(GL_RENDERBUFFER_EXT,
GL_RENDERBUFFER_COVERAGE_SAMPLES_NV,
&query);
if (query < config.coverageSamples)
result = false;
else
config.coverageSamples = query;
ext->glGetRenderbufferParameteriv(GL_RENDERBUFFER_EXT,
fboe->glGetRenderbufferParameteriv(GL_RENDERBUFFER_EXT,
GL_RENDERBUFFER_COLOR_SAMPLES_NV,
&query);
@@ -276,7 +278,7 @@ bool createFBO(GraphicsContext* gc, FboConfig &config, FboData &data)
}
else
{
ext->glGetRenderbufferParameteriv(GL_RENDERBUFFER_EXT,
fboe->glGetRenderbufferParameteriv(GL_RENDERBUFFER_EXT,
GL_RENDERBUFFER_SAMPLES_EXT,
&query);
if (query < config.depthSamples)
@@ -302,7 +304,7 @@ bool createFBO(GraphicsContext* gc, FboConfig &config, FboData &data)
result = false;
}
}
ext->glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
fboe->glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
return result;
}
@@ -695,15 +697,15 @@ GraphicsContext* setupGC(osgViewer::Viewer& viewer, ArgumentParser& arguments)
DisplaySettings* ds = viewer.getDisplaySettings() ? viewer.getDisplaySettings() : DisplaySettings::instance().get();
GraphicsContext::ScreenIdentifier si;
si.readDISPLAY();
si.setUndefinedScreenDetailsToDefaultScreen();
// displayNum has not been set so reset it to 0.
if (si.displayNum<0) si.displayNum = 0;
bool decoration = true;
if (x < 0)
{
unsigned int w, h;
wsi->getScreenResolution(si, w, h);
OSG_NOTICE<<"Screen resolution is "<<w<<", "<<h<<std::endl;
OSG_NOTICE<<"ScreenIdentifier "<<si.displayNum<<", "<<si.screenNum<<std::endl;
x = 0;
y = 0;
width = w;
@@ -711,9 +713,8 @@ GraphicsContext* setupGC(osgViewer::Viewer& viewer, ArgumentParser& arguments)
decoration = false;
}
OSG_NOTICE<<"x = "<<x<<", y = "<<y<<", width = "<<width<<", height = "<<height<<std::endl;
ref_ptr<GraphicsContext::Traits> traits = new GraphicsContext::Traits(ds);
ref_ptr<GraphicsContext::Traits> traits
= new GraphicsContext::Traits(ds);
traits->hostName = si.hostName;
traits->displayNum = si.displayNum;
traits->screenNum = si.screenNum;
@@ -724,9 +725,10 @@ GraphicsContext* setupGC(osgViewer::Viewer& viewer, ArgumentParser& arguments)
traits->windowDecoration = decoration;
traits->doubleBuffer = true;
traits->sharedContext = 0;
ref_ptr<GraphicsContext> gc = GraphicsContext::createGraphicsContext(traits.get());
osgViewer::GraphicsWindow* gw = dynamic_cast<osgViewer::GraphicsWindow*>(gc.get());
ref_ptr<GraphicsContext> gc
= GraphicsContext::createGraphicsContext(traits.get());
osgViewer::GraphicsWindow* gw
= dynamic_cast<osgViewer::GraphicsWindow*>(gc.get());
if (gw)
{
OSG_NOTIFY(INFO)<<"View::setUpViewOnSingleScreen - GraphicsWindow has been created successfully."<<std::endl;
@@ -749,29 +751,20 @@ GraphicsContext* setupGC(osgViewer::Viewer& viewer, ArgumentParser& arguments)
}
// Context has to be current to test for extensions
gc->realize();
if (!gc->makeCurrent())
{
OSG_NOTIFY(NOTICE) << "Unable to create GraphicsWindow"<<std::endl;
gc->releaseContext();
gc->close(true);
return 0;
}
gc->makeCurrent();
unsigned int contextID = gc->getState()->getContextID();
osg::GLExtensions* ext = gc->getState()->get<GLExtensions>();
if (!ext->isFrameBufferObjectSupported)
FBOExtensions* fboe = FBOExtensions::instance(contextID, true);
if (!fboe->isSupported())
{
OSG_NOTIFY(NOTICE) << "Frame buffer objects are not supported\n";
gc->releaseContext();
gc->close(true);
return 0;
}
if (isGLExtensionSupported(contextID, "GL_ARB_depth_buffer_float"))
depthTextureEnum = GL_DEPTH_COMPONENT32F;
else if (isGLExtensionSupported(contextID, "GL_NV_depth_buffer_float"))
depthTextureEnum = GL_DEPTH_COMPONENT32F_NV;
BufferConfigList colorConfigs;
BufferConfigList depthConfigs;
vector<int> coverageConfigs;

View File

@@ -44,7 +44,7 @@
// wraps OpenGL very thinly and therefore uses all the same enum and naming conventions. The coordinate data is also
// wrapped around OpenGL's vertex arrays and draw arrays/elements calls. Familiarity with
// OpenGL will help you understand the osg::Geometry class which encapsulate all this, or if you
// haven't learned OpenGL yet, learning osg::Geometry will help you understand how OpenGL
// havn't learned OpenGL yet, learning osg::Geometry will help you understand how OpenGL
// works!
// The osg::Geometry class "is a" subclass of osg::Drawable base class, so is an object that provides

View File

@@ -46,7 +46,7 @@
#ifdef ENABLE_GLSL
class SineAnimation: public osg::UniformCallback
class SineAnimation: public osg::Uniform::Callback
{
public:
SineAnimation( float rate = 1.0f, float scale = 1.0f, float offset = 0.0f ) :

View File

@@ -1,84 +0,0 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2014 Robert Osfield
* Copyright (C) 2014 Pawel Ksiezopolski
*
* 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.
*
*/
#include "AggregateGeometryVisitor.h"
AggregateGeometryVisitor::AggregateGeometryVisitor( ConvertTrianglesOperator* ctOperator )
: osg::NodeVisitor( osg::NodeVisitor::TRAVERSE_ALL_CHILDREN)
{
_ctOperator.setConverter(ctOperator);
init();
}
void AggregateGeometryVisitor::init()
{
_aggregatedGeometry = new osg::Geometry;
_ctOperator.initGeometry( _aggregatedGeometry.get() );
_matrixStack.clear();
}
AggregateGeometryVisitor::AddObjectResult AggregateGeometryVisitor::addObject( osg::Node* object, unsigned int typeID, unsigned int lodNumber )
{
unsigned int currentVertexFirst = _aggregatedGeometry->getVertexArray()->getNumElements();
_currentTypeID = typeID;
_currentLodNumber = lodNumber;
object->accept(*this);
unsigned int currentVertexCount = _aggregatedGeometry->getVertexArray()->getNumElements() - currentVertexFirst;
_aggregatedGeometry->addPrimitiveSet( new osg::DrawArrays( osg::PrimitiveSet::TRIANGLES, currentVertexFirst, currentVertexCount ) );
_matrixStack.clear();
return AddObjectResult( currentVertexFirst, currentVertexCount, _aggregatedGeometry->getNumPrimitiveSets()-1 );
}
void AggregateGeometryVisitor::apply( osg::Node& node )
{
bool pushed = _ctOperator.pushNode(&node);
traverse(node);
if( pushed ) _ctOperator.popNode();
}
void AggregateGeometryVisitor::apply( osg::Transform& transform )
{
bool pushed = _ctOperator.pushNode(&transform);
osg::Matrix matrix;
if( !_matrixStack.empty() )
matrix = _matrixStack.back();
transform.computeLocalToWorldMatrix( matrix, this );
_matrixStack.push_back( matrix );
traverse(transform);
_matrixStack.pop_back();
if( pushed ) _ctOperator.popNode();
}
void AggregateGeometryVisitor::apply( osg::Geode& geode )
{
bool pushed = _ctOperator.pushNode(&geode);
osg::Matrix matrix;
if(! _matrixStack.empty() )
matrix = _matrixStack.back();
for( unsigned int i=0; i<geode.getNumDrawables(); ++i)
{
osg::Geometry* geom = geode.getDrawable(i)->asGeometry();
if ( geom != NULL )
{
_ctOperator.setGeometryData( matrix, geom, _aggregatedGeometry.get(), (float) _currentTypeID, (float) _currentLodNumber );
geom->accept( _ctOperator );
}
}
traverse(geode);
if( pushed ) _ctOperator.popNode();
}

View File

@@ -1,290 +0,0 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2014 Robert Osfield
* Copyright (C) 2014 Pawel Ksiezopolski
*
* 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 AGREGATE_GEOMETRY_VISITOR_H
#define AGREGATE_GEOMETRY_VISITOR_H 1
#include <osg/Geode>
#include <osg/Geometry>
#include <osg/Transform>
#include <osg/NodeVisitor>
#include <osg/TriangleIndexFunctor>
// AggregateGeometryVisitor uses ConvertTrianglesOperator to create and fill osg::Geometry
// with data matching users needs
struct ConvertTrianglesOperator : public osg::Referenced
{
ConvertTrianglesOperator()
: osg::Referenced()
{
}
virtual void initGeometry( osg::Geometry* outputGeometry ) = 0;
virtual bool pushNode( osg::Node* node )
{
return false;
}
virtual void popNode() = 0;
virtual void setGeometryData( const osg::Matrix &matrix, osg::Geometry *inputGeometry, osg::Geometry* outputGeometry, float typeID, float lodNumber ) = 0;
virtual void operator() ( unsigned int i1, unsigned int i2, unsigned int i3 ) = 0;
};
class GetVec2FromArrayVisitor : public osg::ValueVisitor
{
public:
GetVec2FromArrayVisitor()
{
}
void apply( GLfloat& value )
{
out = osg::Vec2( value, 0.0 );
}
void apply( osg::Vec2& value )
{
out = osg::Vec2( value.x(), value.y() );
}
virtual void apply( osg::Vec2d& value )
{
out = osg::Vec2( value.x(), value.y() );
}
void apply( osg::Vec3& value )
{
out = osg::Vec2( value.x(), value.y() );
}
void apply( osg::Vec4& value )
{
out = osg::Vec2( value.x(), value.y() );
}
void apply( osg::Vec3d& value )
{
out = osg::Vec2( value.x(), value.y() );
}
void apply( osg::Vec4d& value )
{
out = osg::Vec2( value.x(), value.y() );
}
osg::Vec2 out;
};
// ConvertTrianglesOperatorClassic is a ConvertTrianglesOperator that creates
// aggregated geometry with standard set of vertex attributes : vertices, normals, color and texCoord0.
// texCoord1 holds additional information about vertex ( typeID, lodNumber, boneIndex )
struct ConvertTrianglesOperatorClassic : public ConvertTrianglesOperator
{
ConvertTrianglesOperatorClassic()
: ConvertTrianglesOperator(), _typeID(0.0f), _lodNumber(0.0f)
{
_boneIndices.push_back(0.0);
}
virtual void initGeometry( osg::Geometry* outputGeometry )
{
osg::Vec3Array* vertices = new osg::Vec3Array; outputGeometry->setVertexArray( vertices );
osg::Vec4Array* colors = new osg::Vec4Array; outputGeometry->setColorArray( colors, osg::Array::BIND_PER_VERTEX );
osg::Vec3Array* normals = new osg::Vec3Array; outputGeometry->setNormalArray( normals, osg::Array::BIND_PER_VERTEX );
osg::Vec2Array* texCoords0 = new osg::Vec2Array; outputGeometry->setTexCoordArray( 0, texCoords0 );
osg::Vec3Array* texCoords1 = new osg::Vec3Array; outputGeometry->setTexCoordArray( 1, texCoords1 );
outputGeometry->setStateSet(NULL);
}
virtual bool pushNode( osg::Node* node )
{
std::map<std::string,float>::iterator it = _boneNames.find( node->getName() );
if(it==_boneNames.end())
return false;
_boneIndices.push_back( it->second );
return true;
}
virtual void popNode()
{
_boneIndices.pop_back();
}
virtual void setGeometryData( const osg::Matrix &matrix, osg::Geometry *inputGeometry, osg::Geometry* outputGeometry, float typeID, float lodNumber )
{
_matrix = matrix;
_inputVertices = dynamic_cast<osg::Vec3Array *>( inputGeometry->getVertexArray() );
_inputColors = dynamic_cast<osg::Vec4Array *>( inputGeometry->getColorArray() );
_inputNormals = dynamic_cast<osg::Vec3Array *>( inputGeometry->getNormalArray() );
_inputTexCoord0 = inputGeometry->getTexCoordArray(0);
_outputVertices = dynamic_cast<osg::Vec3Array *>( outputGeometry->getVertexArray() );
_outputColors = dynamic_cast<osg::Vec4Array *>( outputGeometry->getColorArray() );
_outputNormals = dynamic_cast<osg::Vec3Array *>( outputGeometry->getNormalArray() );
_outputTexCoord0 = dynamic_cast<osg::Vec2Array *>( outputGeometry->getTexCoordArray(0) );
_outputTexCoord1 = dynamic_cast<osg::Vec3Array *>( outputGeometry->getTexCoordArray(1) );
_typeID = typeID;
_lodNumber = lodNumber;
}
virtual void operator() ( unsigned int i1, unsigned int i2, unsigned int i3 )
{
unsigned int ic1=i1, ic2=i2, ic3=i3, in1=i1, in2=i2, in3=i3, it01=i1, it02=i2, it03=i3;
if ( _inputColors!=NULL && _inputColors->size() == 1 )
{
ic1=0; ic2=0; ic3=0;
}
if ( _inputNormals!=NULL && _inputNormals->size() == 1 )
{
in1=0; in2=0; in3=0;
}
if ( _inputTexCoord0!=NULL && _inputTexCoord0->getNumElements()==1 )
{
it01=0; it02=0; it03=0;
}
_outputVertices->push_back( _inputVertices->at( i1 ) * _matrix );
_outputVertices->push_back( _inputVertices->at( i2 ) * _matrix );
_outputVertices->push_back( _inputVertices->at( i3 ) * _matrix );
if( _inputColors != NULL )
{
_outputColors->push_back( _inputColors->at( ic1 ) );
_outputColors->push_back( _inputColors->at( ic2 ) );
_outputColors->push_back( _inputColors->at( ic3 ) );
}
else
{
for(unsigned int i=0; i<3; ++i)
_outputColors->push_back( osg::Vec4(1.0,1.0,1.0,1.0) );
}
if( _inputNormals != NULL )
{
_outputNormals->push_back( osg::Matrix::transform3x3( _inputNormals->at( in1 ), _matrix ) );
_outputNormals->push_back( osg::Matrix::transform3x3( _inputNormals->at( in2 ), _matrix ) );
_outputNormals->push_back( osg::Matrix::transform3x3( _inputNormals->at( in3 ), _matrix ) );
}
else
{
for(unsigned int i=0; i<3; ++i)
_outputNormals->push_back( osg::Vec3( 0.0,0.0,1.0 ) );
}
if( _inputTexCoord0 != NULL )
{
_inputTexCoord0->accept( it01, _inputTexCoord0Visitor );
_outputTexCoord0->push_back( _inputTexCoord0Visitor.out );
_inputTexCoord0->accept( it02, _inputTexCoord0Visitor );
_outputTexCoord0->push_back( _inputTexCoord0Visitor.out );
_inputTexCoord0->accept( it03, _inputTexCoord0Visitor );
_outputTexCoord0->push_back( _inputTexCoord0Visitor.out );
}
else
{
for(unsigned int i=0; i<3; ++i)
_outputTexCoord0->push_back( osg::Vec2(0.0,0.0) );
}
for(unsigned int i=0; i<3; ++i)
_outputTexCoord1->push_back( osg::Vec3( _typeID, _lodNumber, _boneIndices.back() ) );
}
void registerBoneByName( const std::string& boneName, int boneIndex )
{
_boneNames[boneName] = float(boneIndex);
}
osg::Matrix _matrix;
osg::Vec3Array* _inputVertices;
osg::Vec4Array* _inputColors;
osg::Vec3Array* _inputNormals;
osg::Array* _inputTexCoord0;
osg::Vec3Array* _outputVertices;
osg::Vec4Array* _outputColors;
osg::Vec3Array* _outputNormals;
osg::Vec2Array* _outputTexCoord0;
osg::Vec3Array* _outputTexCoord1;
float _typeID;
float _lodNumber;
std::vector<float> _boneIndices;
std::map<std::string,float> _boneNames;
GetVec2FromArrayVisitor _inputTexCoord0Visitor;
};
class AggregateGeometryVisitor : public osg::NodeVisitor
{
public:
AggregateGeometryVisitor( ConvertTrianglesOperator* ctOperator );
void init();
// osg::TriangleIndexFunctor uses its template parameter as a base class, so we must use an adapter pattern to hack it
struct ConvertTrianglesBridge
{
inline void setConverter( ConvertTrianglesOperator* cto )
{
_converter = cto;
}
inline void initGeometry( osg::Geometry* outputGeometry )
{
_converter->initGeometry(outputGeometry);
}
inline bool pushNode( osg::Node* node )
{
return _converter->pushNode( node );
}
inline void popNode()
{
_converter->popNode();
}
inline void setGeometryData( const osg::Matrix &matrix, osg::Geometry *inputGeometry, osg::Geometry* outputGeometry, float typeID, float lodNumber )
{
_converter->setGeometryData(matrix,inputGeometry,outputGeometry,typeID, lodNumber);
}
inline void operator() ( unsigned int i1, unsigned int i2, unsigned int i3 )
{
_converter->operator()(i1,i2,i3);
}
osg::ref_ptr<ConvertTrianglesOperator> _converter;
};
// struct returning information about added object ( first vertex, vertex count, primitiveset index )
// used later to create indirect command texture buffers
struct AddObjectResult
{
AddObjectResult( unsigned int f, unsigned int c, unsigned int i )
: first(f), count(c), index(i)
{
}
unsigned int first;
unsigned int count;
unsigned int index;
};
AddObjectResult addObject( osg::Node* object, unsigned int typeID, unsigned int lodNumber );
void apply( osg::Node& node );
void apply( osg::Transform& transform );
void apply( osg::Geode& geode );
inline osg::Geometry* getAggregatedGeometry()
{
return _aggregatedGeometry.get();
}
protected:
osg::ref_ptr<osg::Geometry> _aggregatedGeometry;
osg::TriangleIndexFunctor<ConvertTrianglesBridge> _ctOperator;
std::vector<osg::Matrix> _matrixStack;
unsigned int _currentTypeID;
unsigned int _currentLodNumber;
};
#endif

View File

@@ -1,16 +0,0 @@
SET(TARGET_SRC
ShapeToGeometry.cpp
DrawIndirectPrimitiveSet.cpp
AggregateGeometryVisitor.cpp
osggpucull.cpp
)
SET(TARGET_H
ShapeToGeometry.h
DrawIndirectPrimitiveSet.h
AggregateGeometryVisitor.h
GpuCullShaders.h
)
#### end var setup ###
SETUP_EXAMPLE(osggpucull)

View File

@@ -1,139 +0,0 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2014 Robert Osfield
* Copyright (C) 2014 Pawel Ksiezopolski
*
* 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.
*
*/
#include "DrawIndirectPrimitiveSet.h"
#include <osg/State>
#include <osg/buffered_value>
#include <osg/ref_ptr>
#include <osg/GLExtensions>
#include <osg/Drawable>
void DrawArraysIndirect::draw(osg::State& state, bool useVertexBufferObjects) const
{
if( !_buffer.valid() )
return;
_buffer->bindBufferAs( state.getContextID(), GL_DRAW_INDIRECT_BUFFER );
// if you want to see how many primitives were rendered - uncomment code below, but
// be warned : it is a serious performance killer ( because of GPU->CPU roundtrip )
// osg::Drawable::Extensions *dext = osg::Drawable::getExtensions( state.getContextID(),true );
// int* tab = (int*)dext->glMapBuffer(GL_DRAW_INDIRECT_BUFFER,GL_READ_ONLY);
// int val = _indirect/sizeof(int);
// OSG_WARN<<"DrawArraysIndirect ("<<val<<"): "<< tab[val] << " " << tab[val+1] << " " << tab[val+2] << " " << tab[val+3] << std::endl;
// dext->glUnmapBuffer(GL_DRAW_INDIRECT_BUFFER);
DrawIndirectGLExtensions *ext = DrawIndirectGLExtensions::getExtensions( state.getContextID(),true );
ext->glDrawArraysIndirect( _mode, reinterpret_cast<const void*>(_indirect) );
_buffer->unbindBufferAs( state.getContextID(), GL_DRAW_INDIRECT_BUFFER );
}
void MultiDrawArraysIndirect::draw(osg::State& state, bool useVertexBufferObjects) const
{
if( !_buffer.valid() )
return;
_buffer->bindBufferAs( state.getContextID(), GL_DRAW_INDIRECT_BUFFER );
DrawIndirectGLExtensions *ext = DrawIndirectGLExtensions::getExtensions( state.getContextID(),true );
ext->glMultiDrawArraysIndirect( _mode, reinterpret_cast<const void*>(_indirect), _drawcount, _stride );
_buffer->unbindBufferAs( state.getContextID(), GL_DRAW_INDIRECT_BUFFER );
}
DrawIndirectGLExtensions::DrawIndirectGLExtensions( unsigned int contextID )
{
setupGLExtensions( contextID );
}
DrawIndirectGLExtensions::DrawIndirectGLExtensions( const DrawIndirectGLExtensions &rhs )
: Referenced()
{
_glDrawArraysIndirect = rhs._glDrawArraysIndirect;
_glMultiDrawArraysIndirect = rhs._glMultiDrawArraysIndirect;
_glMemoryBarrier = rhs._glMemoryBarrier;
}
void DrawIndirectGLExtensions::lowestCommonDenominator( const DrawIndirectGLExtensions &rhs )
{
if ( !rhs._glDrawArraysIndirect )
{
_glDrawArraysIndirect = rhs._glDrawArraysIndirect;
}
if ( !rhs._glMultiDrawArraysIndirect )
{
_glMultiDrawArraysIndirect = rhs._glMultiDrawArraysIndirect;
}
if ( !rhs._glMemoryBarrier )
{
_glMemoryBarrier = rhs._glMemoryBarrier;
}
}
void DrawIndirectGLExtensions::setupGLExtensions( unsigned int contextID )
{
_glDrawArraysIndirect = 0;
_glMultiDrawArraysIndirect = 0;
osg::setGLExtensionFuncPtr( _glDrawArraysIndirect, "glDrawArraysIndirect" );
osg::setGLExtensionFuncPtr( _glMultiDrawArraysIndirect, "glMultiDrawArraysIndirect" );
osg::setGLExtensionFuncPtr( _glMemoryBarrier, "glMemoryBarrier" );
}
void DrawIndirectGLExtensions::glDrawArraysIndirect(GLenum mode, const void * indirect) const
{
if ( _glDrawArraysIndirect )
{
_glDrawArraysIndirect( mode, indirect );
}
else
{
OSG_WARN<<"Error: glDrawArraysIndirect not supported by OpenGL driver"<<std::endl;
}
}
void DrawIndirectGLExtensions::glMultiDrawArraysIndirect(GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride)
{
if ( _glMultiDrawArraysIndirect )
{
_glMultiDrawArraysIndirect( mode, indirect, drawcount, stride );
}
else
{
OSG_WARN<<"Error: glMultiDrawArraysIndirect not supported by OpenGL driver"<<std::endl;
}
}
void DrawIndirectGLExtensions::glMemoryBarrier(GLbitfield barriers)
{
if ( _glMemoryBarrier )
{
_glMemoryBarrier( barriers );
}
else
{
OSG_WARN<<"Error: glMemoryBarrier not supported by OpenGL driver"<<std::endl;
}
}
typedef osg::buffered_value< osg::ref_ptr<DrawIndirectGLExtensions> > BufferedDrawIndirectGLExtensions;
static BufferedDrawIndirectGLExtensions bdiExtensions;
DrawIndirectGLExtensions* DrawIndirectGLExtensions::getExtensions( unsigned int contextID,bool createIfNotInitalized )
{
if ( !bdiExtensions[contextID] && createIfNotInitalized )
{
bdiExtensions[contextID] = new DrawIndirectGLExtensions( contextID );
}
return bdiExtensions[contextID].get();
}

View File

@@ -1,100 +0,0 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2014 Robert Osfield
* Copyright (C) 2014 Pawel Ksiezopolski
*
* 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_DRAWINDIRECTPRIMITIVESET
#define OSG_DRAWINDIRECTPRIMITIVESET 1
#include <osg/PrimitiveSet>
#include <osg/BufferObject>
#include <osg/TextureBuffer>
#ifndef GL_ARB_draw_indirect
#define GL_DRAW_INDIRECT_BUFFER 0x8F3F
#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43
#endif
#ifndef GL_SHADER_IMAGE_ACCESS_BARRIER_BIT
#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020
#endif
class DrawArraysIndirect : public osg::DrawArrays
{
public:
DrawArraysIndirect(GLenum mode=0, osg::TextureBuffer* buffer=NULL, unsigned int indirect=0)
: osg::DrawArrays(mode), _buffer(buffer), _indirect(indirect)
{
}
virtual osg::Object* cloneType() const { return new DrawArraysIndirect(); }
virtual osg::Object* clone(const osg::CopyOp& copyop) const { return NULL; }
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const DrawArraysIndirect*>(obj)!=NULL; }
virtual const char* libraryName() const { return "osg"; }
virtual const char* className() const { return "DrawArraysIndirect"; }
virtual void draw(osg::State& state, bool useVertexBufferObjects) const;
protected:
osg::ref_ptr<osg::TextureBuffer> _buffer;
unsigned int _indirect;
};
class MultiDrawArraysIndirect : public osg::DrawArrays
{
public:
MultiDrawArraysIndirect(GLenum mode=0, osg::TextureBuffer* buffer=NULL, unsigned int indirect=0, GLsizei drawcount=0, GLsizei stride=0)
: osg::DrawArrays(mode), _buffer(buffer), _indirect(indirect), _drawcount(drawcount), _stride(stride)
{
}
virtual osg::Object* cloneType() const { return new MultiDrawArraysIndirect(); }
virtual osg::Object* clone(const osg::CopyOp& copyop) const { return NULL; }
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const MultiDrawArraysIndirect*>(obj)!=NULL; }
virtual const char* libraryName() const { return "osg"; }
virtual const char* className() const { return "MultiDrawArraysIndirect"; }
virtual void draw(osg::State& state, bool useVertexBufferObjects) const;
protected:
osg::ref_ptr<osg::TextureBuffer> _buffer;
unsigned int _indirect;
GLsizei _drawcount;
GLsizei _stride;
};
class DrawIndirectGLExtensions : public osg::Referenced
{
public:
DrawIndirectGLExtensions( unsigned int contextID );
DrawIndirectGLExtensions( const DrawIndirectGLExtensions &rhs );
void lowestCommonDenominator( const DrawIndirectGLExtensions &rhs );
void setupGLExtensions( unsigned int contextID );
void glDrawArraysIndirect(GLenum mode, const void * indirect) const;
void glMultiDrawArraysIndirect(GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride);
void glMemoryBarrier(GLbitfield barriers);
static DrawIndirectGLExtensions* getExtensions( unsigned int contextID,bool createIfNotInitalized );
protected:
typedef void ( GL_APIENTRY *DrawArraysIndirectProc ) (GLenum mode, const void * indirect);
typedef void ( GL_APIENTRY *MultiDrawArraysIndirectProc ) (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride);
typedef void ( GL_APIENTRY *MemoryBarrierProc ) (GLbitfield barriers);
DrawArraysIndirectProc _glDrawArraysIndirect;
MultiDrawArraysIndirectProc _glMultiDrawArraysIndirect;
MemoryBarrierProc _glMemoryBarrier;
};
#endif

View File

@@ -1,592 +0,0 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2014 Robert Osfield
* Copyright (C) 2014 Pawel Ksiezopolski
*
* 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 GPU_CULL_SHADERS
#define GPU_CULL_SHADERS 1
char SHADER_STATIC_CULL_VERTEX[] =
"#version 420 compatibility\n"
"\n"
"uniform mat4 osg_ViewMatrixInverse;\n"
"\n"
"layout(R32I) coherent uniform iimageBuffer indirectCommand0;\n"
"layout(R32I) coherent uniform iimageBuffer indirectCommand1;\n"
"uniform int indirectCommandSize; // = sizeof(DrawArraysIndirectCommand) / sizeof(unsigned int) = 4\n"
"\n"
"layout(R32I) coherent uniform iimageBuffer getIndirectCommand( int index )\n"
"{\n"
" if(index==0) return indirectCommand0;\n"
" if(index==1) return indirectCommand1;\n"
" return indirectCommand0;\n"
"}\n"
"\n"
"layout(RGBA32F) coherent uniform imageBuffer indirectTarget0;\n"
"layout(RGBA32F) coherent uniform imageBuffer indirectTarget1;\n"
"\n"
"layout(RGBA32F) coherent uniform imageBuffer getIndirectTarget( int index )\n"
"{\n"
" if(index==0) return indirectTarget0;\n"
" if(index==1) return indirectTarget1;\n"
" return indirectTarget0;\n"
"}\n"
"\n"
"struct InstanceLOD\n"
"{\n"
" vec4 bbMin;\n"
" vec4 bbMax;\n"
" ivec4 indirectTargetParams; // x=targetID, y=indexInTarget, z=offsetInTarget, w=lodMaxQuantity\n"
" vec4 distances; // x=minDistance, y=minFadeDistance, z=maxFadeDistance, w=maxDistance\n"
"};\n"
"\n"
"const int OSGGPUCULL_MAXIMUM_LOD_NUMBER = 8;\n"
"\n"
"struct InstanceType\n"
"{\n"
" vec4 bbMin;\n"
" vec4 bbMax;\n"
" ivec4 params;\n"
" InstanceLOD lods[OSGGPUCULL_MAXIMUM_LOD_NUMBER];\n"
"};\n"
"\n"
"layout(std140) uniform instanceTypesData\n"
"{\n"
" InstanceType instanceTypes[32];\n"
"};\n"
"\n"
"// StaticInstance params are stored in vertex attributes\n"
"layout(location = 0) in vec3 VertexPosition;\n"
"layout(location = 10) in vec4 M0;\n"
"layout(location = 11) in vec4 M1;\n"
"layout(location = 12) in vec4 M2;\n"
"layout(location = 13) in vec4 M3;\n"
"layout(location = 14) in vec4 ExtraParams;\n"
"layout(location = 15) in vec4 IdParams;\n"
"\n"
"out vec4 fColor;\n"
"\n"
"bool boundingBoxInViewFrustum( in mat4 matrix, in vec3 bbMin, in vec3 bbMax )\n"
"{\n"
" vec4 BoundingBox[8];\n"
" BoundingBox[0] = matrix * vec4( bbMax.x, bbMax.y, bbMax.z, 1.0);\n"
" BoundingBox[1] = matrix * vec4( bbMin.x, bbMax.y, bbMax.z, 1.0);\n"
" BoundingBox[2] = matrix * vec4( bbMax.x, bbMin.y, bbMax.z, 1.0);\n"
" BoundingBox[3] = matrix * vec4( bbMin.x, bbMin.y, bbMax.z, 1.0);\n"
" BoundingBox[4] = matrix * vec4( bbMax.x, bbMax.y, bbMin.z, 1.0);\n"
" BoundingBox[5] = matrix * vec4( bbMin.x, bbMax.y, bbMin.z, 1.0);\n"
" BoundingBox[6] = matrix * vec4( bbMax.x, bbMin.y, bbMin.z, 1.0);\n"
" BoundingBox[7] = matrix * vec4( bbMin.x, bbMin.y, bbMin.z, 1.0);\n"
"\n"
" int outOfBound[6] = int[6]( 0, 0, 0, 0, 0, 0 );\n"
" for (int i=0; i<8; i++)\n"
" {\n"
" outOfBound[0] += int( BoundingBox[i].x > BoundingBox[i].w );\n"
" outOfBound[1] += int( BoundingBox[i].x < -BoundingBox[i].w );\n"
" outOfBound[2] += int( BoundingBox[i].y > BoundingBox[i].w );\n"
" outOfBound[3] += int( BoundingBox[i].y < -BoundingBox[i].w );\n"
" outOfBound[4] += int( BoundingBox[i].z > BoundingBox[i].w );\n"
" outOfBound[5] += int( BoundingBox[i].z < -BoundingBox[i].w );\n"
" }\n"
" return (outOfBound[0] < 8 ) && ( outOfBound[1] < 8 ) && ( outOfBound[2] < 8 ) && ( outOfBound[3] < 8 ) && ( outOfBound[4] < 8 ) && ( outOfBound[5] < 8 );\n"
"}\n"
"\n"
"void main(void) \n"
"{\n"
" mat4 instanceMatrix = mat4(M0,M1,M2,M3);\n"
" mat4 mvpoMatrix = gl_ModelViewProjectionMatrix * instanceMatrix;\n"
"\n"
" // gl_Position is created only for debugging purposes\n"
" gl_Position = mvpoMatrix * vec4(0.0,0.0,0.0,1.0);\n"
"\n"
" int instanceTypeIndex = int(IdParams.x);\n"
"\n"
" fColor = vec4(0.0,0.0,0.0,1.0);\n"
" if( boundingBoxInViewFrustum( mvpoMatrix, instanceTypes[instanceTypeIndex].bbMin.xyz, instanceTypes[instanceTypeIndex].bbMax.xyz ) )\n"
" {\n"
" fColor = vec4(1.0,0.0,0.0,1.0);\n"
" float distanceToObject = distance(osg_ViewMatrixInverse[3].xyz / osg_ViewMatrixInverse[3].w, instanceMatrix[3].xyz / instanceMatrix[3].w );\n"
" for(int i=0;i<instanceTypes[instanceTypeIndex].params.x;++i)\n"
" {\n"
" if( boundingBoxInViewFrustum( mvpoMatrix, instanceTypes[instanceTypeIndex].lods[i].bbMin.xyz, instanceTypes[instanceTypeIndex].lods[i].bbMax.xyz ) &&\n"
" ( distanceToObject >= instanceTypes[instanceTypeIndex].lods[i].distances.x ) && ( distanceToObject < instanceTypes[instanceTypeIndex].lods[i].distances.w ) )\n"
" {\n"
" fColor = vec4(1.0,1.0,0.0,1.0);\n"
" float fadeAlpha = 4.0 * ( clamp( (distanceToObject-instanceTypes[instanceTypeIndex].lods[i].distances.x)/( instanceTypes[instanceTypeIndex].lods[i].distances.y - instanceTypes[instanceTypeIndex].lods[i].distances.x), 0.0, 1.0 ) \n"
" + clamp( (distanceToObject- instanceTypes[instanceTypeIndex].lods[i].distances.z)/( instanceTypes[instanceTypeIndex].lods[i].distances.w - instanceTypes[instanceTypeIndex].lods[i].distances.z), 0.0, 1.0 ) );\n"
" int sampleMask = ( 0xF0 >> int(fadeAlpha) ) & 0xF;\n"
" int indirectCommandIndex = instanceTypes[instanceTypeIndex].lods[i].indirectTargetParams.x;\n"
" int indirectCommandAddress = instanceTypes[instanceTypeIndex].lods[i].indirectTargetParams.y;\n"
" int objectIndex = imageAtomicAdd( getIndirectCommand( indirectCommandIndex ), indirectCommandAddress*indirectCommandSize+1, 1 );\n"
" int indirectTargetAddress = 6*(instanceTypes[instanceTypeIndex].lods[i].indirectTargetParams.z + objectIndex);\n"
" imageStore( getIndirectTarget(indirectCommandIndex), indirectTargetAddress+0, M0 );\n"
" imageStore( getIndirectTarget(indirectCommandIndex), indirectTargetAddress+1, M1 );\n"
" imageStore( getIndirectTarget(indirectCommandIndex), indirectTargetAddress+2, M2 );\n"
" imageStore( getIndirectTarget(indirectCommandIndex), indirectTargetAddress+3, M3 );\n"
" imageStore( getIndirectTarget(indirectCommandIndex), indirectTargetAddress+4, ExtraParams );\n"
" imageStore( getIndirectTarget(indirectCommandIndex), indirectTargetAddress+5, vec4(IdParams.x,IdParams.y,float(sampleMask),0.0) );\n"
" }\n"
" }\n"
" }\n"
"}\n";
char SHADER_STATIC_CULL_FRAGMENT[] =
"#version 420 compatibility\n"
"\n"
"layout(location = 0, index = 0) out vec4 FragmentColor;\n"
"\n"
"in vec4 fColor;\n"
"\n"
"void main()\n"
"{\n"
" FragmentColor = fColor;\n"
"}\n";
char SHADER_STATIC_DRAW_0_VERTEX[] =
"#version 420 compatibility\n"
"\n"
"layout(location = 0) in vec4 VertexPosition;\n"
"layout(location = 2) in vec3 VertexNormal;\n"
"layout(location = 3) in vec4 VertexColor;\n"
"layout(location = 8) in vec2 VertexTexCoord0;\n"
"layout(location = 9) in vec3 VertexTexCoord1;\n"
"\n"
"struct InstanceLOD\n"
"{\n"
" vec4 bbMin;\n"
" vec4 bbMax;\n"
" ivec4 indirectTargetParams; // x=targetID, y=indexInTarget, z=offsetInTarget, w=lodMaxQuantity\n"
" vec4 distances; // x=minDistance, y=minFadeDistance, z=maxFadeDistance, w=maxDistance\n"
"};\n"
"\n"
"const int OSGGPUCULL_MAXIMUM_LOD_NUMBER = 8;\n"
"\n"
"struct InstanceType\n"
"{\n"
" vec4 bbMin;\n"
" vec4 bbMax;\n"
" ivec4 params;\n"
" InstanceLOD lods[OSGGPUCULL_MAXIMUM_LOD_NUMBER];\n"
"};\n"
"\n"
"layout(std140) uniform instanceTypesData\n"
"{\n"
" InstanceType instanceTypes[32];\n"
"};\n"
"\n"
"layout(RGBA32F) coherent uniform imageBuffer indirectTarget;\n"
"\n"
"out vec3 ecPosition3;\n"
"out vec3 ecNormal;\n"
"out vec2 TexCoord;\n"
"out vec4 color;\n"
"flat out int sMask;\n"
" \n"
"void main()\n"
"{\n"
" // every vertex has its type coded on VertexTexCoord1.x,\n"
" // and its lodNumber coded in VertexTexCoord1.y\n"
" int instanceTypeIndex = int(VertexTexCoord1.x);\n"
" int instanceLodNumber = int(VertexTexCoord1.y);\n"
" int indirectTargetAddress = 6*(instanceTypes[instanceTypeIndex].lods[instanceLodNumber].indirectTargetParams.z + gl_InstanceID);\n"
" mat4 instanceMatrix = mat4(\n"
" imageLoad(indirectTarget, indirectTargetAddress + 0),\n"
" imageLoad(indirectTarget, indirectTargetAddress + 1),\n"
" imageLoad(indirectTarget, indirectTargetAddress + 2),\n"
" imageLoad(indirectTarget, indirectTargetAddress + 3) );\n"
" vec4 extraParams = imageLoad(indirectTarget, indirectTargetAddress + 4);\n"
" vec4 idParams = imageLoad(indirectTarget, indirectTargetAddress + 5);\n"
"\n"
" sMask = int(idParams.z);\n"
"\n"
" mat4 mvMatrix = gl_ModelViewMatrix * instanceMatrix;\n"
" \n"
" // Do fixed functionality vertex transform\n"
" vec4 ecPos = mvMatrix * vec4(VertexPosition.xyz,1.0);\n"
" gl_Position = gl_ProjectionMatrix * ecPos;\n"
"\n"
" ecPosition3 = ecPos.xyz / ecPos.w;\n"
" ecNormal = normalize( mat3(mvMatrix) * VertexNormal.xyz );\n"
" \n"
" TexCoord = VertexTexCoord0.xy;\n"
" color.xyz = VertexColor.xyz * extraParams.x;\n"
" color.a = VertexColor.a;\n"
"}\n";
char SHADER_STATIC_DRAW_0_FRAGMENT[] =
"#version 420 compatibility\n"
"\n"
"in vec3 ecPosition3;\n"
"in vec3 ecNormal;\n"
"in vec2 TexCoord;\n"
"in vec4 color;\n"
"\n"
"flat in int sMask;\n"
"\n"
"layout(location = 0) out vec4 FragColor;\n"
"\n"
"void main()\n"
"{\n"
"// simple fragment shader that calculates ambient + diffuse lighting with osg::LightSource\n"
" vec3 lightDir = normalize(vec3(gl_LightSource[0].position));\n"
" vec3 normal = normalize(ecNormal);\n"
" float NdotL = max(dot(normal, lightDir), 0.0);\n"
" FragColor = NdotL * color * gl_LightSource[0].diffuse + color * gl_LightSource[0].ambient;\n"
" gl_SampleMask[0] = sMask;\n"
"}\n";
char SHADER_STATIC_DRAW_1_VERTEX[] =
"#version 420 compatibility\n"
"\n"
"layout(location = 0) in vec4 VertexPosition;\n"
"layout(location = 2) in vec3 VertexNormal;\n"
"layout(location = 3) in vec4 VertexColor;\n"
"layout(location = 8) in vec2 VertexTexCoord0;\n"
"layout(location = 9) in vec3 VertexTexCoord1;\n"
"\n"
"struct InstanceLOD\n"
"{\n"
" vec4 bbMin;\n"
" vec4 bbMax;\n"
" ivec4 indirectTargetParams; // x=targetID, y=indexInTarget, z=offsetInTarget, w=lodMaxQuantity\n"
" vec4 distances; // x=minDistance, y=minFadeDistance, z=maxFadeDistance, w=maxDistance\n"
"};\n"
"\n"
"const int OSGGPUCULL_MAXIMUM_LOD_NUMBER = 8;\n"
"\n"
"struct InstanceType\n"
"{\n"
" vec4 bbMin;\n"
" vec4 bbMax;\n"
" ivec4 params;\n"
" InstanceLOD lods[OSGGPUCULL_MAXIMUM_LOD_NUMBER];\n"
"};\n"
"\n"
"layout(std140) uniform instanceTypesData\n"
"{\n"
" InstanceType instanceTypes[32];\n"
"};\n"
"\n"
"layout(RGBA32F) coherent uniform imageBuffer indirectTarget;\n"
"\n"
"uniform vec2 windDirection;\n"
"uniform float osg_FrameTime;\n"
"\n"
"out vec3 ecPosition3;\n"
"out vec3 ecNormal;\n"
"out vec2 TexCoord;\n"
"out vec4 color;\n"
"flat out int sMask;\n"
" \n"
"void main()\n"
"{\n"
" // every vertex has its type coded on VertexTexCoord1.x,\n"
" // and its lodNumber coded in VertexTexCoord1.y\n"
" int instanceTypeIndex = int(VertexTexCoord1.x);\n"
" int instanceLodNumber = int(VertexTexCoord1.y);\n"
" int indirectTargetAddress = 6*(instanceTypes[instanceTypeIndex].lods[instanceLodNumber].indirectTargetParams.z + gl_InstanceID);\n"
" mat4 instanceMatrix = mat4(\n"
" imageLoad(indirectTarget, indirectTargetAddress + 0),\n"
" imageLoad(indirectTarget, indirectTargetAddress + 1),\n"
" imageLoad(indirectTarget, indirectTargetAddress + 2),\n"
" imageLoad(indirectTarget, indirectTargetAddress + 3) );\n"
" vec4 extraParams = imageLoad(indirectTarget, indirectTargetAddress + 4);\n"
" vec4 idParams = imageLoad(indirectTarget, indirectTargetAddress + 5);\n"
"\n"
" sMask = int(idParams.z);\n"
"\n"
" // simple tree waving in the wind. Amplitude, frequency and offset are coded in extraParams\n"
" vec4 mPos = instanceMatrix * vec4(VertexPosition.xyz,1.0);\n"
" float wavingAmplitute = VertexPosition.z * extraParams.y;\n"
" mPos.xy += windDirection * wavingAmplitute * sin( extraParams.z*osg_FrameTime + extraParams.w );\n"
"\n"
" mat4 mvMatrix = gl_ModelViewMatrix * instanceMatrix;\n"
" \n"
" // Do fixed functionality vertex transform\n"
" vec4 ecPos = osg_ModelViewMatrix * mPos;\n"
" gl_Position = gl_ProjectionMatrix * ecPos;\n"
"\n"
" ecPosition3 = ecPos.xyz / ecPos.w;\n"
" ecNormal = normalize( mat3(mvMatrix) * VertexNormal.xyz );\n"
" \n"
" TexCoord = VertexTexCoord0.xy;\n"
" color.xyz = VertexColor.xyz * extraParams.x;\n"
" color.a = VertexColor.a;\n"
"}\n";
char SHADER_STATIC_DRAW_1_FRAGMENT[] =
"#version 420 compatibility\n"
"\n"
"in vec3 ecPosition3;\n"
"in vec3 ecNormal;\n"
"in vec2 TexCoord;\n"
"in vec4 color;\n"
"\n"
"flat in int sMask;\n"
"\n"
"layout(location = 0) out vec4 FragColor;\n"
"\n"
"void main()\n"
"{\n"
"// simple fragment shader that calculates ambient + diffuse lighting with osg::LightSource\n"
" vec3 lightDir = normalize(vec3(gl_LightSource[0].position));\n"
" vec3 normal = normalize(ecNormal);\n"
" float NdotL = max(dot(normal, lightDir), 0.0);\n"
" FragColor = NdotL * color * gl_LightSource[0].diffuse + color * gl_LightSource[0].ambient;\n"
" gl_SampleMask[0] = sMask;\n"
"}\n";
char SHADER_DYNAMIC_CULL_VERTEX[] =
"#version 420 compatibility\n"
"\n"
"uniform mat4 osg_ViewMatrixInverse;\n"
"\n"
"uniform samplerBuffer dynamicInstancesData;\n"
"uniform int dynamicInstancesDataSize; // = sizeof(DynamicInstance) / sizeof(osg::Vec4f)\n"
"\n"
"layout(R32I) coherent uniform iimageBuffer indirectCommand0;\n"
"uniform int indirectCommandSize; // = sizeof(DrawArraysIndirectCommand) / sizeof(unsigned int) = 4\n"
"\n"
"layout(R32I) coherent uniform iimageBuffer getIndirectCommand( int index )\n"
"{\n"
" if(index==0) return indirectCommand0;\n"
"}\n"
"\n"
"layout(RGBA32I) coherent uniform iimageBuffer indirectTarget0;\n"
"\n"
"layout(RGBA32I) coherent uniform iimageBuffer getIndirectTarget( int index )\n"
"{\n"
" if(index==0) return indirectTarget0;\n"
"}\n"
"\n"
"struct InstanceLOD\n"
"{\n"
" vec4 bbMin;\n"
" vec4 bbMax;\n"
" ivec4 indirectTargetParams; // x=targetID, y=indexInTarget, z=offsetInTarget, w=lodMaxQuantity\n"
" vec4 distances; // x=minDistance, y=minFadeDistance, z=maxFadeDistance, w=maxDistance\n"
"};\n"
"\n"
"const int OSGGPUCULL_MAXIMUM_LOD_NUMBER = 8;\n"
"\n"
"struct InstanceType\n"
"{\n"
" vec4 bbMin;\n"
" vec4 bbMax;\n"
" ivec4 params;\n"
" InstanceLOD lods[OSGGPUCULL_MAXIMUM_LOD_NUMBER];\n"
"};\n"
"\n"
"layout(std140) uniform instanceTypesData\n"
"{\n"
" InstanceType instanceTypes[32];\n"
"};\n"
"\n"
"layout(location = 0) in vec3 VertexPosition; // xyz - used only for debugging purposes\n"
"layout(location = 10) in vec4 InstanceID; // typeid, id - points to the data in dynamicInstancesData buffer\n"
"\n"
"bool boundingBoxInViewFrustum( in mat4 matrix, in vec3 bbMin, in vec3 bbMax )\n"
"{\n"
" vec4 BoundingBox[8];\n"
" BoundingBox[0] = matrix * vec4( bbMax.x, bbMax.y, bbMax.z, 1.0);\n"
" BoundingBox[1] = matrix * vec4( bbMin.x, bbMax.y, bbMax.z, 1.0);\n"
" BoundingBox[2] = matrix * vec4( bbMax.x, bbMin.y, bbMax.z, 1.0);\n"
" BoundingBox[3] = matrix * vec4( bbMin.x, bbMin.y, bbMax.z, 1.0);\n"
" BoundingBox[4] = matrix * vec4( bbMax.x, bbMax.y, bbMin.z, 1.0);\n"
" BoundingBox[5] = matrix * vec4( bbMin.x, bbMax.y, bbMin.z, 1.0);\n"
" BoundingBox[6] = matrix * vec4( bbMax.x, bbMin.y, bbMin.z, 1.0);\n"
" BoundingBox[7] = matrix * vec4( bbMin.x, bbMin.y, bbMin.z, 1.0);\n"
"\n"
" int outOfBound[6] = int[6]( 0, 0, 0, 0, 0, 0 );\n"
" for (int i=0; i<8; i++)\n"
" {\n"
" outOfBound[0] += int( BoundingBox[i].x > BoundingBox[i].w );\n"
" outOfBound[1] += int( BoundingBox[i].x < -BoundingBox[i].w );\n"
" outOfBound[2] += int( BoundingBox[i].y > BoundingBox[i].w );\n"
" outOfBound[3] += int( BoundingBox[i].y < -BoundingBox[i].w );\n"
" outOfBound[4] += int( BoundingBox[i].z > BoundingBox[i].w );\n"
" outOfBound[5] += int( BoundingBox[i].z < -BoundingBox[i].w );\n"
" }\n"
" return (outOfBound[0] < 8 ) && ( outOfBound[1] < 8 ) && ( outOfBound[2] < 8 ) && ( outOfBound[3] < 8 ) && ( outOfBound[4] < 8 ) && ( outOfBound[5] < 8 );\n"
"}\n"
"\n"
"void main(void) \n"
"{\n"
" // get object matrices\n"
" int instanceIndex = int(InstanceID.y);\n"
" int instanceAddress = instanceIndex * dynamicInstancesDataSize;\n"
" mat4 instanceMatrix = mat4 (\n"
" texelFetch(dynamicInstancesData, instanceAddress),\n"
" texelFetch(dynamicInstancesData, instanceAddress + 1),\n"
" texelFetch(dynamicInstancesData, instanceAddress + 2),\n"
" texelFetch(dynamicInstancesData, instanceAddress + 3) );\n"
" mat4 mvpoMatrix = gl_ModelViewProjectionMatrix * instanceMatrix;\n"
"\n"
" // gl_Position is created only for debugging purposes\n"
" gl_Position = mvpoMatrix * vec4(0.0,0.0,0.0,1.0);\n"
"\n"
" int instanceTypeIndex = int(InstanceID.x);\n"
"\n"
" if( boundingBoxInViewFrustum( mvpoMatrix, instanceTypes[instanceTypeIndex].bbMin.xyz, instanceTypes[instanceTypeIndex].bbMax.xyz ) )\n"
" {\n"
" float distanceToObject = distance(osg_ViewMatrixInverse[3].xyz / osg_ViewMatrixInverse[3].w, instanceMatrix[3].xyz / instanceMatrix[3].w );\n"
" for(int i=0;i<instanceTypes[instanceTypeIndex].params.x;++i)\n"
" {\n"
" if( boundingBoxInViewFrustum( mvpoMatrix, instanceTypes[instanceTypeIndex].lods[i].bbMin.xyz, instanceTypes[instanceTypeIndex].lods[i].bbMax.xyz ) &&\n"
" ( distanceToObject >= instanceTypes[instanceTypeIndex].lods[i].distances.x ) && ( distanceToObject < instanceTypes[instanceTypeIndex].lods[i].distances.w ) )\n"
" {\n"
" float fadeAlpha = 4.0 * ( clamp( (distanceToObject-instanceTypes[instanceTypeIndex].lods[i].distances.x)/( instanceTypes[instanceTypeIndex].lods[i].distances.y - instanceTypes[instanceTypeIndex].lods[i].distances.x), 0.0, 1.0 ) \n"
" + clamp( (distanceToObject- instanceTypes[instanceTypeIndex].lods[i].distances.z)/( instanceTypes[instanceTypeIndex].lods[i].distances.w - instanceTypes[instanceTypeIndex].lods[i].distances.z), 0.0, 1.0 ) );\n"
" int sampleMask = ( 0xF0 >> int(fadeAlpha) ) & 0xF;\n"
" int indirectCommandIndex = instanceTypes[instanceTypeIndex].lods[i].indirectTargetParams.x;\n"
" int indirectCommandAddress = instanceTypes[instanceTypeIndex].lods[i].indirectTargetParams.y;\n"
" int objectIndex = imageAtomicAdd( getIndirectCommand( indirectCommandIndex ), indirectCommandAddress*indirectCommandSize+1, 1 );\n"
" int indirectTargetAddress = instanceTypes[instanceTypeIndex].lods[i].indirectTargetParams.z + objectIndex;\n"
" ivec4 indirectCommandData = ivec4( instanceTypeIndex, instanceIndex, sampleMask, 0 );\n"
" imageStore( getIndirectTarget(indirectCommandIndex), indirectTargetAddress, indirectCommandData );\n"
" }\n"
" }\n"
" }\n"
"}\n";
char SHADER_DYNAMIC_CULL_FRAGMENT[] =
"#version 420 compatibility\n"
"\n"
"layout(location = 0, index = 0) out vec4 FragmentColor;\n"
"\n"
"void main()\n"
"{\n"
" FragmentColor = vec4(1.0,1.0,0.1,1.0);\n"
"}\n";
char SHADER_DYNAMIC_DRAW_0_VERTEX[] =
"#version 420 compatibility\n"
"\n"
"uniform samplerBuffer dynamicInstancesData;\n"
"uniform int dynamicInstancesDataSize; // = sizeof(DynamicInstance) / sizeof(osg::Vec4f)\n"
"\n"
"layout(location = 0) in vec4 VertexPosition;\n"
"layout(location = 2) in vec3 VertexNormal;\n"
"layout(location = 3) in vec4 VertexColor;\n"
"layout(location = 8) in vec2 VertexTexCoord0;\n"
"layout(location = 9) in vec3 VertexTexCoord1;\n"
"\n"
"struct InstanceLOD\n"
"{\n"
" vec4 bbMin;\n"
" vec4 bbMax;\n"
" ivec4 indirectTargetParams; // x=targetID, y=indexInTarget, z=offsetInTarget, w=lodMaxQuantity\n"
" vec4 distances; // x=minDistance, y=minFadeDistance, z=maxFadeDistance, w=maxDistance\n"
"};\n"
"\n"
"const int OSGGPUCULL_MAXIMUM_LOD_NUMBER = 8;\n"
"\n"
"struct InstanceType\n"
"{\n"
" vec4 bbMin;\n"
" vec4 bbMax;\n"
" ivec4 params;\n"
" InstanceLOD lods[OSGGPUCULL_MAXIMUM_LOD_NUMBER];\n"
"};\n"
"\n"
"layout(std140) uniform instanceTypesData\n"
"{\n"
" InstanceType instanceTypes[32];\n"
"};\n"
"\n"
"layout(RGBA32I) coherent uniform iimageBuffer indirectTarget;\n"
"\n"
"out vec3 ecPosition3;\n"
"out vec3 ecNormal;\n"
"out vec2 TexCoord;\n"
"out vec4 color;\n"
"flat out int sMask;\n"
" \n"
"void main()\n"
"{\n"
" // every vertex has its type coded on VertexTexCoord1.x,\n"
" // its lodNumber coded in VertexTexCoord1.y\n"
" // and bone index coded in VertexTexCoord1.z\n"
" int instanceTypeIndex = int(VertexTexCoord1.x);\n"
" int instanceLodNumber = int(VertexTexCoord1.y);\n"
" int boneIndex = int(VertexTexCoord1.z);\n"
" int indirectTargetAddress = instanceTypes[instanceTypeIndex].lods[instanceLodNumber].indirectTargetParams.z + gl_InstanceID;\n"
"\n"
" // if we know instance type, lod number and gl_InstanceID, we can reconstruct all instance data\n"
" ivec4 indirectCommandData = imageLoad(indirectTarget, indirectTargetAddress);\n"
" // now its time to read instance matrix and other additional params\n"
" int instanceAddress = indirectCommandData.y * dynamicInstancesDataSize;\n"
" mat4 instanceMatrix = mat4 (\n"
" texelFetch(dynamicInstancesData, instanceAddress),\n"
" texelFetch(dynamicInstancesData, instanceAddress + 1),\n"
" texelFetch(dynamicInstancesData, instanceAddress + 2),\n"
" texelFetch(dynamicInstancesData, instanceAddress + 3) );\n"
"\n"
" vec4 instanceExtraParams = texelFetch(dynamicInstancesData, instanceAddress + 4);\n"
" // we also need boneMatrix to animate an object\n"
" int boneAddress = instanceAddress + 6 + 4*boneIndex;\n"
" mat4 boneMatrix = mat4 (\n"
" texelFetch(dynamicInstancesData, boneAddress),\n"
" texelFetch(dynamicInstancesData, boneAddress + 1),\n"
" texelFetch(dynamicInstancesData, boneAddress + 2),\n"
" texelFetch(dynamicInstancesData, boneAddress + 3) );\n"
"\n"
" sMask = indirectCommandData.z;\n"
"\n"
" mat4 mvMatrix = gl_ModelViewMatrix * instanceMatrix * boneMatrix;\n"
" \n"
" // Do fixed functionality vertex transform\n"
" vec4 ecPos = mvMatrix * vec4(VertexPosition.xyz,1.0);\n"
" gl_Position = gl_ProjectionMatrix * ecPos;\n"
"\n"
" ecPosition3 = ecPos.xyz / ecPos.w;\n"
" ecNormal = normalize( mat3(mvMatrix) * VertexNormal.xyz );\n"
" \n"
" TexCoord = VertexTexCoord0.xy;\n"
" color.xyz = VertexColor.xyz * instanceExtraParams.x;\n"
" color.a = VertexColor.a;\n"
"}\n";
char SHADER_DYNAMIC_DRAW_0_FRAGMENT[] =
"#version 420 compatibility\n"
"\n"
"in vec3 ecPosition3;\n"
"in vec3 ecNormal;\n"
"in vec2 TexCoord;\n"
"in vec4 color;\n"
"\n"
"flat in int sMask;\n"
"\n"
"layout(location = 0) out vec4 FragColor;\n"
"\n"
"void main()\n"
"{\n"
"// simple fragment shader that calculates ambient + diffuse lighting with osg::LightSource\n"
" vec3 lightDir = normalize(vec3(gl_LightSource[0].position));\n"
" vec3 normal = normalize(ecNormal);\n"
" float NdotL = max(dot(normal, lightDir), 0.0);\n"
" FragColor = NdotL * color * gl_LightSource[0].diffuse + color * gl_LightSource[0].ambient;\n"
" gl_SampleMask[0] = sMask;\n"
"}\n";
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,97 +0,0 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2014 Robert Osfield
* Copyright (C) 2014 Pawel Ksiezopolski
*
* 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 SHAPE_TO_GEOMETRY
#define SHAPE_TO_GEOMETRY 1
#include <osg/Geometry>
#include <osg/Geode>
#include <osg/ShapeDrawable>
#include <osg/NodeVisitor>
// arbitrary minima for rows & segments ( from shapedrawable.cpp )
const unsigned int MIN_NUM_ROWS = 3;
const unsigned int MIN_NUM_SEGMENTS = 5;
// osg::GLBeginEndAdapter descendant that stores data for osg::Geometry creation
class FakeGLBeginEndAdapter : public osg::GLBeginEndAdapter
{
public:
FakeGLBeginEndAdapter();
void PushMatrix();
void MultMatrixd(const GLdouble* m);
void Translated(GLdouble x, GLdouble y, GLdouble z);
void Scaled(GLdouble x, GLdouble y, GLdouble z);
void Rotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z);
void End();
osg::ref_ptr<osg::Geometry> geometry;
};
class ShapeToGeometryVisitor : public osg::ConstShapeVisitor
{
public:
ShapeToGeometryVisitor(const osg::TessellationHints* hints)
: osg::ConstShapeVisitor(), _hints(hints)
{
}
virtual void apply(const osg::Sphere&);
virtual void apply(const osg::Box&);
virtual void apply(const osg::Cone&);
virtual void apply(const osg::Cylinder&);
virtual void apply(const osg::Capsule&);
virtual void apply(const osg::InfinitePlane&);
virtual void apply(const osg::TriangleMesh&);
virtual void apply(const osg::ConvexHull&);
virtual void apply(const osg::HeightField&);
virtual void apply(const osg::CompositeShape&);
osg::Geometry* getGeometry() { return gl.geometry.get(); }
const osg::TessellationHints* _hints;
FakeGLBeginEndAdapter gl;
protected:
ShapeToGeometryVisitor& operator = (const ShapeToGeometryVisitor&) { return *this; }
enum SphereHalf { SphereTopHalf, SphereBottomHalf };
// helpers for apply( Cylinder | Sphere | Capsule )
void drawCylinderBody(unsigned int numSegments, float radius, float height);
void drawHalfSphere(unsigned int numSegments, unsigned int numRows, float radius, SphereHalf which, float zOffset = 0.0f);
};
osg::Geometry* convertShapeToGeometry(const osg::Shape& shape, const osg::TessellationHints* hints);
osg::Geometry* convertShapeToGeometry(const osg::Shape& shape, const osg::TessellationHints* hints, const osg::Vec4& color);
osg::Geode* convertShapeToGeode(const osg::Shape& shape, const osg::TessellationHints* hints);
osg::Geode* convertShapeToGeode(const osg::Shape& shape, const osg::TessellationHints* hints, const osg::Vec4& color);
// example : how to use convertShapeToGeometry()
// osg::ref_ptr<osg::Capsule> shape = new osg::Capsule( osg::Vec3( 0.0, 0.0, 0.0 ), radius, height );
// osg::ref_ptr<osg::TessellationHints> tessHints = new osg::TessellationHints;
// tessHints->setDetailRatio(0.5f);
// tessHints->setCreateTextureCoords(true);
// osg::ref_ptr<osg::Geometry> capsuleGeometry = convertShapeToGeometry(*shape.get(), tessHints.get());
// osg::ref_ptr<osg::Geometry> redCapsuleGeometry = convertShapeToGeometry(*shape.get(), tessHints.get(), osg::Vec4(1.0,0.0,0.0,1.0) );
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -29,7 +29,6 @@ class CalibrateCostEsimator : public osg::GraphicsOperation
public:
CalibrateCostEsimator(osg::GraphicsCostEstimator* gce):
osg::Referenced(true),
osg::GraphicsOperation("CalbirateCostEstimator",false),
_gce(gce) {}

View File

@@ -151,7 +151,7 @@ osg::Camera* createHUD()
osg::BoundingBox bb;
for(unsigned int i=0;i<geode->getNumDrawables();++i)
{
bb.expandBy(geode->getDrawable(i)->getBoundingBox());
bb.expandBy(geode->getDrawable(i)->getBound());
}
osg::Geometry* geom = new osg::Geometry;
@@ -227,8 +227,6 @@ struct SnapImage : public osg::Camera::DrawCallback
mutable osg::ref_ptr<osg::Image> _image;
};
struct SnapeImageHandler : public osgGA::GUIEventHandler
{
@@ -236,7 +234,7 @@ struct SnapeImageHandler : public osgGA::GUIEventHandler
_key(key),
_snapImage(si) {}
bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter&)
{
if (ea.getHandled()) return false;
@@ -244,18 +242,6 @@ struct SnapeImageHandler : public osgGA::GUIEventHandler
{
case(osgGA::GUIEventAdapter::KEYUP):
{
if (ea.getKey() == 'o' )
{
osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa);
osg::Node* node = view ? view->getSceneData() : 0;
if (node)
{
osgDB::writeNodeFile(*node, "hud.osgt");
osgDB::writeNodeFile(*node, "hud.osgb");
}
return true;
}
if (ea.getKey() == _key)
{
osg::notify(osg::NOTICE)<<"event handler"<<std::endl;
@@ -372,7 +358,7 @@ int main( int argc, char **argv )
viewer.getCamera()->setFinalDrawCallback(finalDrawCallback);
viewer.addEventHandler(new SnapeImageHandler('f',finalDrawCallback));
osg::ref_ptr<osg::Group> group = new osg::Group;
osg::ref_ptr<osg::Group> group = new osg::Group;
// add the HUD subgraph.
if (scene.valid()) group->addChild(scene.get());

View File

@@ -44,12 +44,12 @@ class CreateModelToSaveVisitor : public osg::NodeVisitor
public:
CreateModelToSaveVisitor():
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN)
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN)
{
_group = new osg::Group;
_addToModel = false;
}
virtual void apply(osg::Node& node)
{
osgFX::Scribe* scribe = dynamic_cast<osgFX::Scribe*>(&node);
@@ -65,7 +65,7 @@ public:
traverse(node);
}
}
osg::ref_ptr<osg::Group> _group;
bool _addToModel;
};
@@ -75,10 +75,10 @@ class DeleteSelectedNodesVisitor : public osg::NodeVisitor
public:
DeleteSelectedNodesVisitor():
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN)
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN)
{
}
virtual void apply(osg::Node& node)
{
osgFX::Scribe* scribe = dynamic_cast<osgFX::Scribe*>(&node);
@@ -91,7 +91,7 @@ public:
traverse(node);
}
}
void pruneSelectedNodes()
{
for(SelectedNodes::iterator itr = _selectedNodes.begin();
@@ -104,20 +104,21 @@ public:
pitr != parents.end();
++pitr)
{
(*pitr)->removeChild(node);
osg::Group* parent = *pitr;
parent->removeChild(node);
}
}
}
typedef std::vector< osg::ref_ptr<osgFX::Scribe> > SelectedNodes;
SelectedNodes _selectedNodes;
};
// class to handle events with a pick
class PickHandler : public osgGA::GUIEventHandler
class PickHandler : public osgGA::GUIEventHandler
{
public:
public:
PickHandler():
_mx(0.0),_my(0.0),
@@ -138,7 +139,7 @@ public:
if (ea.getKey()=='s')
{
saveSelectedModel(viewer->getSceneData());
}
}
else if (ea.getKey()=='o')
{
osg::notify(osg::NOTICE)<<"Saved model to file 'saved_model.osgt'"<<std::endl;
@@ -188,7 +189,7 @@ public:
pick(ea,viewer);
}
return true;
}
}
default:
return false;
@@ -247,7 +248,7 @@ public:
node = (nodePath.size()>=1)?nodePath[nodePath.size()-1]:0;
parent = (nodePath.size()>=2)?dynamic_cast<osg::Group*>(nodePath[nodePath.size()-2]):0;
if (node) std::cout<<" Hits "<<node->className()<<" nodePath size "<<nodePath.size()<<std::endl;
if (node) std::cout<<" Hits "<<node->className()<<" nodePath size "<<nodePath.size()<<std::endl;
toggleScribe(parent, node);
}
@@ -283,7 +284,7 @@ public:
if (node) std::cout<<" Hits "<<node->className()<<" nodePath size"<<nodePath.size()<<std::endl;
toggleScribe(parent, node);
}
}
}
// now we try to decorate the hit node by the osgFX::Scribe to show that its been "picked"
}
@@ -318,10 +319,10 @@ public:
void saveSelectedModel(osg::Node* scene)
{
if (!scene) return;
CreateModelToSaveVisitor cmtsv;
scene->accept(cmtsv);
if (cmtsv._group->getNumChildren()>0)
{
std::cout<<"Writing selected compoents to 'selected_model.osgt'"<<std::endl;
@@ -339,19 +340,19 @@ protected:
int main( int argc, char **argv )
{
osg::ref_ptr<osg::Node> loadedModel;
// load the scene.
if (argc>1) loadedModel = osgDB::readNodeFile(argv[1]);
// if not loaded assume no arguments passed in, try use default mode instead.
if (!loadedModel) loadedModel = osgDB::readNodeFile("dumptruck.osgt");
if (!loadedModel)
if (!loadedModel)
{
std::cout << argv[0] <<": No data loaded." << std::endl;
return 1;
}
// create the window to draw to.
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
traits->x = 200;
@@ -375,7 +376,7 @@ int main( int argc, char **argv )
viewer.getCamera()->setGraphicsContext(gc.get());
viewer.getCamera()->setViewport(0,0,800,600);
viewer.setSceneData(loadedModel.get());
// create a tracball manipulator to move the camera around in response to keyboard/mouse events
viewer.setCameraManipulator( new osgGA::TrackballManipulator );

View File

@@ -1,4 +1,4 @@
/* OpenSceneGraph example, osgkeystone.
/* OpenSceneGraph example, osganimate.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -19,7 +19,6 @@
#include <osgDB/ReadFile>
#include <osgUtil/Optimizer>
#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
#include <osg/CoordinateSystemNode>
#include <osgText/Text>
@@ -35,7 +34,6 @@
#include <osgManipulator/TranslateAxisDragger>
#include <osgManipulator/TranslatePlaneDragger>
#include <osgManipulator/RotateCylinderDragger>
#include <osgManipulator/AntiSquish>
#include <osg/ShapeDrawable>
#include <osg/MatrixTransform>
@@ -49,11 +47,11 @@ class PlaneConstraint : public osgManipulator::Constraint
{
public:
PlaneConstraint() {}
virtual bool constrain(osgManipulator::TranslateInLineCommand& command) const
{
OSG_NOTICE<<"PlaneConstraint TranslateInLineCommand "<<command.getTranslation()<<std::endl;
return true;
return true;
}
virtual bool constrain(osgManipulator::TranslateInPlaneCommand& command) const
{
@@ -65,7 +63,7 @@ public:
{
//command.setScale(1.0f);
OSG_NOTICE<<"PlaneConstraint Scale1DCommand"<<command.getScale()<<std::endl;
return true;
return true;
}
virtual bool constrain(osgManipulator::Scale2DCommand& command) const
{
@@ -76,7 +74,7 @@ public:
virtual bool constrain(osgManipulator::ScaleUniformCommand& command) const
{
OSG_NOTICE<<"PlaneConstraint ScaleUniformCommand"<<command.getScale()<<std::endl;
return true;
return true;
}
};
@@ -108,8 +106,6 @@ osgManipulator::Dragger* createDragger(const std::string& name)
{
osgManipulator::TrackballDragger* d = new osgManipulator::TrackballDragger();
d->setupDefaultGeometry();
//d->setAxisLineWidth(5.0f);
//d->setPickCylinderHeight(0.1f);
dragger = d;
}
else if ("Translate1DDragger" == name)
@@ -128,9 +124,6 @@ osgManipulator::Dragger* createDragger(const std::string& name)
{
osgManipulator::TranslateAxisDragger* d = new osgManipulator::TranslateAxisDragger();
d->setupDefaultGeometry();
d->setAxisLineWidth(5.0f);
d->setPickCylinderRadius(0.05f);
d->setConeHeight(0.2f);
dragger = d;
}
else if ("TranslatePlaneDragger" == name)
@@ -170,6 +163,8 @@ osgManipulator::Dragger* createDragger(const std::string& name)
dragger = d;
}
return dragger;
}
@@ -178,29 +173,29 @@ class DraggerContainer : public osg::Group
{
public:
DraggerContainer() : _draggerSize(240.0f), _active(true) {}
DraggerContainer( const DraggerContainer& copy, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY )
: osg::Group(copy, copyop),
_dragger(copy._dragger), _draggerSize(copy._draggerSize), _active(copy._active)
{}
META_Node( osgManipulator, DraggerContainer );
void setDragger( osgManipulator::Dragger* dragger )
{
_dragger = dragger;
if ( !containsNode(dragger) ) addChild( dragger );
}
osgManipulator::Dragger* getDragger() { return _dragger.get(); }
const osgManipulator::Dragger* getDragger() const { return _dragger.get(); }
void setDraggerSize( float size ) { _draggerSize = size; }
float getDraggerSize() const { return _draggerSize; }
void setActive( bool b ) { _active = b; }
bool getActive() const { return _active; }
void traverse( osg::NodeVisitor& nv )
{
if ( _dragger.valid() )
@@ -208,13 +203,13 @@ public:
if ( _active && nv.getVisitorType()==osg::NodeVisitor::CULL_VISITOR )
{
osgUtil::CullVisitor* cv = static_cast<osgUtil::CullVisitor*>(&nv);
float pixelSize = cv->pixelSize(_dragger->getBound().center(), 0.48f);
if ( pixelSize!=_draggerSize )
{
float pixelScale = pixelSize>0.0f ? _draggerSize/pixelSize : 1.0f;
osg::Vec3d scaleFactor(pixelScale, pixelScale, pixelScale);
osg::Vec3 trans = _dragger->getMatrix().getTrans();
_dragger->setMatrix( osg::Matrix::scale(scaleFactor) * osg::Matrix::translate(trans) );
}
@@ -222,7 +217,7 @@ public:
}
osg::Group::traverse(nv);
}
protected:
osg::ref_ptr<osgManipulator::Dragger> _dragger;
float _draggerSize;
@@ -278,7 +273,7 @@ osg::Node* addDraggerToScene(osg::Node* scene, const std::string& name, bool fix
}
osg::Node* createDemoScene(bool fixedSizeInScreen) {
osg::Group* root = new osg::Group;
osg::ref_ptr<osg::Geode> geode_1 = new osg::Geode;
@@ -302,7 +297,7 @@ osg::Node* createDemoScene(bool fixedSizeInScreen) {
osg::ref_ptr<osg::Geode> geode_7 = new osg::Geode;
osg::ref_ptr<osg::MatrixTransform> transform_7 = new osg::MatrixTransform;
@@ -369,18 +364,17 @@ osg::Node* createDemoScene(bool fixedSizeInScreen) {
root->addChild(transform_6.get());
root->addChild(transform_7.get());
return root;
}
//
//
int main( int argc, char **argv )
{
// 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()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
@@ -393,42 +387,16 @@ int main( int argc, char **argv )
arguments.getApplicationUsage()->addCommandLineOption("--dragger <draggername>","Use the specified dragger for manipulation [TabPlaneDragger, TabPlaneTrackballDragger, TrackballDragger, Translate1DDragger, Translate2DDragger, TranslateAxisDragger, TabBoxDragger, TranslatePlaneDragger, Scale1DDragger, Scale2DDragger, RotateCylinderDragger, RotateSphereDragger]");
arguments.getApplicationUsage()->addCommandLineOption("--fixedDraggerSize","Fix the size of the dragger geometry in the screen space");
bool fixedSizeInScreen = false;
while (arguments.read("--fixedDraggerSize")) { fixedSizeInScreen = true; }
// construct the viewer.
osgViewer::Viewer viewer(arguments);
// add the window size toggle handler
viewer.addEventHandler(new osgViewer::WindowSizeHandler);
osgViewer::Viewer viewer;
// get details on keyboard and mouse bindings used by the viewer.
viewer.getUsage(*arguments.getApplicationUsage());
if (arguments.read("--test-NodeMask"))
{
const osg::ref_ptr<osg::Group> group = new osg::Group();
group->setNodeMask(0);
const osg::ref_ptr<osgManipulator::AntiSquish> antiSquish = new osgManipulator::AntiSquish();
group->addChild(antiSquish.get());
const osg::ref_ptr<osg::Node> node = new osg::Node();
node->setInitialBound(osg::BoundingSphere(osg::Vec3(0.0, 0.0, 0.0), 1.0));
antiSquish->addChild(node.get());
group->getBound();
return 1;
}
// 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 ) |
@@ -457,7 +425,7 @@ int main( int argc, char **argv )
// if no model has been successfully loaded report failure.
bool tragger2Scene(true);
if (!loadedModel)
if (!loadedModel)
{
//std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl;
//return 1;
@@ -483,11 +451,11 @@ int main( int argc, char **argv )
osgUtil::Optimizer optimizer;
optimizer.optimize(loadedModel.get());
// pass the loaded scene graph to the viewer.
if ( tragger2Scene ) {
viewer.setSceneData(addDraggerToScene(loadedModel.get(), dragger_name, fixedSizeInScreen));
} else {
} else {
viewer.setSceneData(loadedModel.get());
}

View File

@@ -1,4 +1,4 @@
/* OpenSceneGraph example, osgmemorytest.
/* OpenSceneGraph example, osganimate.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -26,7 +26,6 @@ class MotionBlurOperation: public osg::Operation
{
public:
MotionBlurOperation(double persistence):
osg::Referenced(true),
osg::Operation("MotionBlur",true),
cleared_(false),
persistence_(persistence)

View File

@@ -1,25 +1,14 @@
# INCLUDE_DIRECTORIES( ${OPENAL_INCLUDE_DIR} )
# SET(TARGET_EXTERNAL_LIBRARIES ${OPENAL_LIBRARY} alut)
IF (SDL2_FOUND)
SET(TARGET_EXTERNAL_LIBRARIES ${SDL2_LIBRARY} )
INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIR} )
ADD_DEFINITIONS(-DUSE_SDL2)
IF (MINGW)
SET(TARGET_EXTERNAL_LIBRARIES ${TARGET_EXTERNAL_LIBRARIES} winmm dinput ddraw dxguid)
ENDIF()
ELSEIF (SDL_FOUND)
IF (SDL_FOUND)
SET(TARGET_EXTERNAL_LIBRARIES ${SDL_LIBRARY} )
INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR} )
ADD_DEFINITIONS(-DUSE_SDL)
IF (MINGW)
SET(TARGET_EXTERNAL_LIBRARIES ${TARGET_EXTERNAL_LIBRARIES} winmm dinput ddraw dxguid)
ENDIF()
ENDIF()
ENDIF(SDL_FOUND)
SET(TARGET_SRC osgmovie.cpp )
SET(TARGET_ADDED_LIBRARIES osgGA )

View File

@@ -376,7 +376,7 @@ osg::Geometry* myCreateTexturedQuadGeometry(const osg::Vec3& pos,float width,flo
}
}
#if USE_SDL || USE_SDL2
#if USE_SDL
class SDLAudioSink : public osg::AudioSink
{
@@ -508,11 +508,11 @@ int main(int argc, char** argv)
osg::Vec3 bottomright = pos;
bool xyPlane = fullscreen;
bool useAudioSink = false;
while(arguments.read("--audio")) { useAudioSink = true; }
#if USE_SDL || USE_SDL2
#if USE_SDL
unsigned int numAudioStreamsEnabled = 0;
#endif
@@ -522,18 +522,18 @@ int main(int argc, char** argv)
{
osg::Image* image = osgDB::readImageFile(arguments[i]);
osg::ImageStream* imagestream = dynamic_cast<osg::ImageStream*>(image);
if (imagestream)
if (imagestream)
{
osg::ImageStream::AudioStreams& audioStreams = imagestream->getAudioStreams();
if (useAudioSink && !audioStreams.empty())
{
osg::AudioStream* audioStream = audioStreams[0].get();
osg::notify(osg::NOTICE)<<"AudioStream read ["<<audioStream->getName()<<"]"<<std::endl;
#if USE_SDL || USE_SDL2
#if USE_SDL
if (numAudioStreamsEnabled==0)
{
audioStream->setAudioSink(new SDLAudioSink(audioStream));
++numAudioStreamsEnabled;
}
#endif
@@ -551,7 +551,7 @@ int main(int argc, char** argv)
float height = image->t();
osg::ref_ptr<osg::Drawable> drawable = myCreateTexturedQuadGeometry(pos, width, height,image, useTextureRectangle, xyPlane, flip);
if (image->isImageTranslucent())
{
osg::notify(osg::NOTICE)<<"Transparent movie, enabling blending."<<std::endl;
@@ -606,22 +606,22 @@ int main(int argc, char** argv)
if (fullscreen)
{
viewer.realize();
viewer.getCamera()->setClearColor(osg::Vec4(0.0f,0.0f,0.0f,1.0f));
float screenAspectRatio = 1280.0f/1024.0f;
osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface();
if (wsi)
if (wsi)
{
unsigned int width, height;
wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(0), width, height);
screenAspectRatio = float(width) / float(height);
}
float modelAspectRatio = (bottomright.x()-topleft.x())/(bottomright.y()-topleft.y());
viewer.getCamera()->setViewMatrix(osg::Matrix::identity());
@@ -659,7 +659,7 @@ int main(int argc, char** argv)
}
}
#if USE_SDL || USE_SDL2
#if USE_SDL
#include "SDL.h"
@@ -699,51 +699,22 @@ void SDLAudioSink::play()
osg::notify(osg::NOTICE)<<" audioNbChannels()="<<_audioStream->audioNbChannels()<<std::endl;
osg::notify(osg::NOTICE)<<" audioSampleFormat()="<<_audioStream->audioSampleFormat()<<std::endl;
SDL_AudioSpec specs = { 0 };
SDL_AudioSpec wanted_specs = { 0 };
wanted_specs.freq = _audioStream->audioFrequency();
wanted_specs.format = AUDIO_S16SYS;
wanted_specs.channels = _audioStream->audioNbChannels();
wanted_specs.silence = 0;
wanted_specs.samples = 1024;
wanted_specs.callback = soundReadCallback;
wanted_specs.userdata = this;
wanted_specs.format = 0;
#if SDL_MAJOR_VERSION>=2
switch(_audioStream->audioSampleFormat())
{
case(osg::AudioStream::SAMPLE_FORMAT_U8): { wanted_specs.format = AUDIO_U8; OSG_NOTICE<<" SampleFormat = SAMPLE_FORMAT_U8"<<std::endl; break;}
case(osg::AudioStream::SAMPLE_FORMAT_S16): { wanted_specs.format = AUDIO_S16SYS; OSG_NOTICE<<" SampleFormat = SAMPLE_FORMAT_S16"<<std::endl; break; }
case(osg::AudioStream::SAMPLE_FORMAT_S24): { OSG_NOTICE<<" SampleFormat = SAMPLE_FORMAT_S24 NOT Supported by SDL."<<std::endl; break; }
case(osg::AudioStream::SAMPLE_FORMAT_S32): { wanted_specs.format = AUDIO_S32SYS; OSG_NOTICE<<" SampleFormat = SAMPLE_FORMAT_S32"<<std::endl; break; }
case(osg::AudioStream::SAMPLE_FORMAT_F32): { wanted_specs.format = AUDIO_F32SYS; OSG_NOTICE<<" SampleFormat = SAMPLE_FORMAT_F32"<<std::endl; break; }
}
#else
switch(_audioStream->audioSampleFormat())
{
case(osg::AudioStream::SAMPLE_FORMAT_U8): { wanted_specs.format = AUDIO_U8; OSG_NOTICE<<" SampleFormat = SAMPLE_FORMAT_U8"<<std::endl; break;}
case(osg::AudioStream::SAMPLE_FORMAT_S16): { wanted_specs.format = AUDIO_S16SYS; OSG_NOTICE<<" SampleFormat = SAMPLE_FORMAT_S16"<<std::endl; break; }
case(osg::AudioStream::SAMPLE_FORMAT_S24): { OSG_NOTICE<<" SampleFormat = SAMPLE_FORMAT_S24 NOT Supported by SDL1.x."<<std::endl; break; }
case(osg::AudioStream::SAMPLE_FORMAT_S32): { OSG_NOTICE<<" SampleFormat = SAMPLE_FORMAT_S32 NOT Supported by SDL1.x"<<std::endl; break; }
case(osg::AudioStream::SAMPLE_FORMAT_F32): { OSG_NOTICE<<" SampleFormat = SAMPLE_FORMAT_F32 NOT Supported by SDL1.x"<<std::endl; break; }
}
#endif
if (SDL_OpenAudio(&wanted_specs, &specs) < 0)
throw "SDL_OpenAudio() failed (" + std::string(SDL_GetError()) + ")";
if (wanted_specs.format!=0)
{
SDL_PauseAudio(0);
if (SDL_OpenAudio(&wanted_specs, &specs) < 0)
throw "SDL_OpenAudio() failed (" + std::string(SDL_GetError()) + ")";
SDL_PauseAudio(0);
}
else
{
throw "SDL_OpenAudio() does not support audio format";
}
}
void SDLAudioSink::pause()

View File

@@ -25,7 +25,6 @@
#include <osg/TextureRectangle>
#include <osg/ColorMask>
#include <osg/Material>
#include <osg/Capability>
#include <osgGA/TrackballManipulator>
#include <osgGA/FlightManipulator>
@@ -355,12 +354,6 @@ osg::Node* createScene(osg::Node* cam_subgraph, unsigned int tex_width, unsigned
}
#if 0
// test for new glEnablei/glDisablei functionality.
camera->getOrCreateStateSet()->setAttribute(new osg::Enablei(GL_BLEND, 0));
camera->getOrCreateStateSet()->setAttribute(new osg::Disablei(GL_BLEND, 1));
#endif
// we can also read back any of the targets as an image, modify this image and push it back
if (useImage) {
// which texture to get the image from

View File

@@ -39,22 +39,22 @@ int main( int argc, char **argv )
{
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
// construct the viewer.
osgViewer::Viewer viewer;
// load the nodes from the commandline arguments.
osg::Node* rootnode = osgDB::readNodeFiles(arguments);
// if not loaded assume no arguments passed in, try use default mode instead.
if (!rootnode) rootnode = osgDB::readNodeFile("cessnafire.osgt");
if (!rootnode)
{
osg::notify(osg::NOTICE)<<"Please specify a model filename on the command line."<<std::endl;
return 1;
}
osg::Image* image = osgDB::readImageFile("Images/reflect.rgb");
if (image)
{
@@ -72,7 +72,7 @@ int main( int argc, char **argv )
stateset->setTextureAttributeAndModes(1,texture,osg::StateAttribute::ON);
stateset->setTextureAttributeAndModes(1,texgen,osg::StateAttribute::ON);
stateset->setTextureAttribute(1,texenv);
rootnode->setStateSet(stateset);
}
else
@@ -83,21 +83,21 @@ int main( int argc, char **argv )
// run optimization over the scene graph
osgUtil::Optimizer optimzer;
optimzer.optimize(rootnode);
// add a viewport to the viewer and attach the scene graph.
viewer.setSceneData( rootnode );
// create the windows and run the threads.
viewer.realize();
for(unsigned int contextID = 0;
for(unsigned int contextID = 0;
contextID<osg::DisplaySettings::instance()->getMaxNumberOfGraphicsContexts();
++contextID)
{
osg::GLExtensions* textExt = osg::GLExtensions::Get(contextID,false);
osg::Texture::Extensions* textExt = osg::Texture::getExtensions(contextID,false);
if (textExt)
{
if (!textExt->isMultiTexturingSupported)
if (!textExt->isMultiTexturingSupported())
{
std::cout<<"Warning: multi-texturing not supported by OpenGL drivers, unable to run application."<<std::endl;
return 1;

View File

@@ -401,7 +401,7 @@ int main( int argc, char **argv )
// we must assign callback as both an update and cull callback, as update callback to do the update of
// the osgFX::MultiTextureControl node a thread safe way, and as a cull callback to gather the camera
// the the osgFX::MultiTextureControl node a thread safe way, and as a cull callback to gather the camera
// position information.
ElevationLayerBlendingCallback* elbc = new ElevationLayerBlendingCallback(mtc, elevations);
terrain->setUpdateCallback(elbc);

View File

@@ -98,11 +98,9 @@ osg::Camera* createHUD(unsigned int w, unsigned int h)
class TestMultiTouchEventHandler : public osgGA::GUIEventHandler {
public:
TestMultiTouchEventHandler(osg::Group* parent_group, float w, float h)
TestMultiTouchEventHandler(osg::Group* parent_group)
: osgGA::GUIEventHandler(),
_cleanupOnNextFrame(false),
_w(w),
_h(h)
_cleanupOnNextFrame(false)
{
createTouchRepresentations(parent_group, 10);
}
@@ -151,18 +149,6 @@ private:
virtual bool handle (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa, osg::Object *, osg::NodeVisitor *)
{
if (ea.getEventType() != osgGA::GUIEventAdapter::FRAME) {
std::cout << ea.getTime() << ": ";
switch(ea.getEventType()) {
case osgGA::GUIEventAdapter::PUSH: std::cout << "PUSH"; break;
case osgGA::GUIEventAdapter::DRAG: std::cout << "DRAG"; break;
case osgGA::GUIEventAdapter::MOVE: std::cout << "MOVE"; break;
case osgGA::GUIEventAdapter::RELEASE: std::cout << "RELEASE"; break;
default: std::cout << ea.getEventType();
}
std::cout << std::endl;
}
switch(ea.getEventType())
{
case osgGA::GUIEventAdapter::FRAME:
@@ -188,12 +174,7 @@ private:
for(osgGA::GUIEventAdapter::TouchData::iterator i = ea.getTouchData()->begin(); i != ea.getTouchData()->end(); ++i, ++j)
{
const osgGA::GUIEventAdapter::TouchData::TouchPoint& tp = (*i);
float x = ea.getTouchPointNormalizedX(j);
float y = ea.getTouchPointNormalizedY(j);
// std::cout << j << ": " << tp.x << "/" << tp.y <<" "<< x << " " << y << " " << _w << " " << _h << std::endl;
_mats[j]->setMatrix(osg::Matrix::translate((1+x) * 0.5 * _w, (1+y) * 0.5 * _h, 0));
_mats[j]->setMatrix(osg::Matrix::translate(tp.x, ea.getWindowHeight() - tp.y, 0));
_mats[j]->setNodeMask(0xffff);
std::ostringstream ss;
@@ -257,8 +238,6 @@ private:
std::vector<osg::MatrixTransform*> _mats;
std::vector<osgText::Text*> _texts;
bool _cleanupOnNextFrame;
float _w, _h;
};
@@ -267,21 +246,7 @@ int main( int argc, char **argv )
{
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
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;
}
// read the scene from the list of file specified commandline args.
osg::ref_ptr<osg::Node> scene = osgDB::readNodeFiles(arguments);
@@ -300,19 +265,7 @@ int main( int argc, char **argv )
// construct the viewer.
osgViewer::Viewer viewer(arguments);
//opening devices
std::string device;
while(arguments.read("--device", device))
{
osg::ref_ptr<osgGA::Device> dev = osgDB::readFile<osgGA::Device>(device);
if (dev.valid())
{
viewer.addDevice(dev.get());
}
}
osgViewer::Viewer viewer;
osg::ref_ptr<osg::Group> group = new osg::Group;
@@ -335,7 +288,7 @@ int main( int argc, char **argv )
osg::Camera* hud_camera = createHUD(gc->getTraits()->width, gc->getTraits()->height);
viewer.addEventHandler(new TestMultiTouchEventHandler(hud_camera, gc->getTraits()->width, gc->getTraits()->height));
viewer.addEventHandler(new TestMultiTouchEventHandler(hud_camera));
group->addChild(hud_camera);

View File

@@ -1,4 +1,4 @@
/* OpenSceneGraph example, osgocclusionquery.
/* OpenSceneGraph example, osganimate.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -86,9 +86,9 @@ public:
// check if we need to do some depth buffer copying from a source FBO into the current FBO
if (_source_fbo.get() != NULL)
{
osg::GLExtensions* ext = renderInfo.getState()->get<osg::GLExtensions>();
bool fbo_supported = ext && ext->isFrameBufferObjectSupported;
if (fbo_supported && ext->glBlitFramebuffer)
osg::FBOExtensions* fbo_ext = osg::FBOExtensions::instance(renderInfo.getContextID(),true);
bool fbo_supported = fbo_ext && fbo_ext->isSupported();
if (fbo_supported && fbo_ext->glBlitFramebuffer)
{
// blit the depth buffer from the solid geometry fbo into the current transparency fbo
(_fbo.get())->apply(*renderInfo.getState(), osg::FrameBufferObject::DRAW_FRAMEBUFFER);
@@ -96,7 +96,7 @@ public:
// glReadBuffer(GL_COLOR_ATTACHMENT0_EXT); // only needed to blit the color buffer
// glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT); // only needed to blit the color buffer
ext->glBlitFramebuffer(
fbo_ext->glBlitFramebuffer(
0, 0, static_cast<GLint>(_width), static_cast<GLint>(_height),
0, 0, static_cast<GLint>(_width), static_cast<GLint>(_height),
#ifdef USE_PACKED_DEPTH_STENCIL
@@ -130,17 +130,17 @@ public:
{
// only unbind the fbo if this is the last transparency pass
if (_restore)
{
renderInfo.getState()->get<osg::GLExtensions>()->glBindFramebuffer( GL_FRAMEBUFFER_EXT, 0 );
}
osg::FBOExtensions::instance( renderInfo.getState()->getContextID(), false )->glBindFramebuffer( GL_FRAMEBUFFER_EXT, 0 );
}
protected:
bool _restore;
};
DepthPeeling::CullCallback::CullCallback(unsigned int texUnit, unsigned int offsetValue) :
DepthPeeling::CullCallback::CullCallback(unsigned int texUnit, unsigned int texWidth, unsigned int texHeight, unsigned int offsetValue) :
_texUnit(texUnit),
_texWidth(texWidth),
_texHeight(texHeight),
_offsetValue(offsetValue)
{
}
@@ -315,7 +315,7 @@ void DepthPeeling::createPeeling()
// create some uniform and cull callback objects
osg::Uniform *depthOff = new osg::Uniform("depthtest", (bool)false);
osg::Uniform *depthOn = new osg::Uniform("depthtest", (bool)true);
CullCallback *ccb = new CullCallback(_texUnit, _offsetValue);
CullCallback *ccb = new CullCallback(_texUnit, _texWidth, _texHeight, _offsetValue);
// create a node for solid model rendering
osg::Group *pre_solidNode = new osg::Group;
@@ -410,7 +410,7 @@ void DepthPeeling::createPeeling()
_compositeCamera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
_compositeCamera->setViewMatrix(osg::Matrix());
_compositeCamera->setProjectionMatrix(osg::Matrix::ortho2D(0, 1, 0, 1));
_compositeCamera->setCullCallback(new CullCallback(0, 0));
_compositeCamera->setCullCallback(new CullCallback(0, _texWidth, _texHeight, 0));
osg::StateSet* stateSet = _compositeCamera->getOrCreateStateSet();
stateSet->setRenderBinDetails(100, "TraversalOrderBin", osg::StateSet::OVERRIDE_RENDERBIN_DETAILS);
_root->addChild(_compositeCamera.get());

View File

@@ -63,11 +63,13 @@ protected:
class CullCallback : public osg::NodeCallback {
public:
CullCallback(unsigned int texUnit, unsigned int offsetValue);
CullCallback(unsigned int texUnit, unsigned int texWidth, unsigned int texHeight, unsigned int offsetValue);
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv);
private:
unsigned int _texUnit;
unsigned int _texWidth;
unsigned int _texHeight;
unsigned int _offsetValue;
};

View File

@@ -81,12 +81,8 @@ public:
// an attempt to return a reasonable bounding box. Still does not prevent clipping of the heat map.
virtual const osg::BoundingBox& getBoundingBox() const {return m_bounds;}
virtual osg::BoundingBox computeBoundingBox() const {return m_bounds;}
#ifdef OSG_USE_BOUND
virtual osg::Bound getBound() const { return osg::Bound(m_bounds, m_bounds); }
#else
virtual osg::BoundingBox computeBound() const {return m_bounds;}
virtual const osg::BoundingSphere& getBound() const {return m_bsphere;}
#endif
protected:
osg::BoundingBox m_bounds;

View File

@@ -31,7 +31,6 @@
#include <osg/Camera>
#include <osg/ValueObject>
#include <osg/FrontFace>
#include <osg/ShapeDrawable>
#include <osgDB/ReadFile>
#include <osgText/Text>
@@ -48,8 +47,6 @@
#include <osg/io_utils>
#include <osgViewer/api/Cocoa/GraphicsWindowCocoa>
// class to handle events with a pick
class PickHandler : public osgGA::GUIEventHandler {
@@ -157,14 +154,14 @@ void PickHandler::pick(osgViewer::View* view, const osgGA::GUIEventAdapter& ea)
}
class UserEventHandler : public osgGA::EventHandler {
class UserEventHandler : public osgGA::GUIEventHandler {
public:
UserEventHandler(osgText::Text* text) : osgGA::EventHandler(), _text(text) {}
UserEventHandler(osgText::Text* text) : osgGA::GUIEventHandler(), _text(text) {}
~UserEventHandler() {}
virtual bool handle(osgGA::Event* event, osg::Object* object, osg::NodeVisitor* nv);
bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa);
private:
osg::ref_ptr<osgText::Text> _text;
};
@@ -198,60 +195,56 @@ private:
std::ostringstream _ss;
};
bool UserEventHandler::handle(osgGA::Event* event, osg::Object* object, osg::NodeVisitor* nv)
bool UserEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa)
{
OSG_ALWAYS << "handle user-event: " << event->getName() << std::endl;
if (ea.getEventType() == osgGA::GUIEventAdapter::USER) {
OSG_ALWAYS << "handle user-event: " << ea.getName() << std::endl;
if (event->getName() == "/pick-result")
{
std::string name("");
float x(0), y(0);
event->getUserValue("name", name);
event->getUserValue("x", x);
event->getUserValue("y", y);
std::ostringstream ss;
ss << "Name: " << std::endl << name << std::endl << std::endl;
ss << "x: " << y << " y: " << y << std::endl;
_text->setText(ss.str());
return true;
}
else if(event->getName() == "/osgga")
{
osg::Vec4 rect;
event->getUserValue("resize", rect);
osgGA::EventVisitor* ev = dynamic_cast<osgGA::EventVisitor*>(nv);
osg::View* view = ev ? dynamic_cast<osgViewer::View*>(ev->getActionAdapter()) : NULL;
if (view && (rect[2] > 0) && (rect[3] > 0))
if (ea.getName() == "/pick-result")
{
OSG_ALWAYS << "resizing view to " << rect << std::endl;
osgViewer::GraphicsWindow* win = view->getCamera()->getGraphicsContext() ? dynamic_cast<osgViewer::GraphicsWindow*>(view->getCamera()->getGraphicsContext()) : NULL;
if (win)
win->setWindowRectangle(rect[2] + 10 + rect[0], rect[1], rect[2], rect[3]);
std::string name("");
float x(0), y(0);
ea.getUserValue("name", name);
ea.getUserValue("x", x);
ea.getUserValue("y", y);
std::ostringstream ss;
ss << "Name: " << std::endl << name << std::endl << std::endl;
ss << "x: " << y << " y: " << y << std::endl;
_text->setText(ss.str());
}
return true;
}
else {
const osg::UserDataContainer* udc = event->getUserDataContainer();
if (udc)
else if(ea.getName() == "/osgga")
{
OSG_ALWAYS << "contents of " << udc->getName() << ": " << std::endl;
for(unsigned int i = 0; i < udc->getNumUserObjects(); ++i)
osg::Vec4 rect;
ea.getUserValue("resize", rect);
osg::View* view = dynamic_cast<osgViewer::View*>(&aa);
if (view && (rect[2] > 0) && (rect[3] > 0))
{
const osg::ValueObject* vo = dynamic_cast<const osg::ValueObject*>(udc->getUserObject(i));
OSG_ALWAYS << " " << vo->getName() << ": ";
OSG_ALWAYS << "resizing view to " << rect << std::endl;
osgViewer::GraphicsWindow* win = view->getCamera()->getGraphicsContext() ? dynamic_cast<osgViewer::GraphicsWindow*>(view->getCamera()->getGraphicsContext()) : NULL;
if (win)
win->setWindowRectangle(rect[2] + 10 + rect[0], rect[1], rect[2], rect[3]);
}
}
else {
const osg::UserDataContainer* udc = ea.getUserDataContainer();
if (udc)
{
OSG_ALWAYS << "contents of " << udc->getName() << ": " << std::endl;
for(unsigned int i = 0; i < udc->getNumUserObjects(); ++i)
{
const osg::ValueObject* vo = dynamic_cast<const osg::ValueObject*>(udc->getUserObject(i));
OSG_ALWAYS << " " << vo->getName() << ": ";
MyValueListVisitor vlv;
vo->get(vlv);
OSG_ALWAYS << vlv.value() << std::endl;
MyValueListVisitor vlv;
vo->get(vlv);
OSG_ALWAYS << vlv.value() << std::endl;
}
}
}
return true;
}
return false;
}
@@ -343,13 +336,13 @@ osg::Node* createHUD()
}
class ForwardToDeviceEventHandler : public osgGA::EventHandler {
class ForwardToDeviceEventHandler : public osgGA::GUIEventHandler {
public:
ForwardToDeviceEventHandler(osgGA::Device* device) : osgGA::EventHandler(), _device(device) {}
ForwardToDeviceEventHandler(osgGA::Device* device) : osgGA::GUIEventHandler(), _device(device) {}
virtual bool handle(osgGA::Event* event, osg::Object* object, osg::NodeVisitor* nv)
virtual bool handle (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa, osg::Object *, osg::NodeVisitor *)
{
_device->sendEvent(*event);
_device->sendEvent(ea);
return false;
}
@@ -361,29 +354,31 @@ class OscServiceDiscoveredEventHandler: public ForwardToDeviceEventHandler {
public:
OscServiceDiscoveredEventHandler() : ForwardToDeviceEventHandler(NULL) {}
virtual bool handle(osgGA::Event* event, osg::Object* object, osg::NodeVisitor* nv)
virtual bool handle (const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa, osg::Object *o, osg::NodeVisitor *nv)
{
if (_device.valid())
return ForwardToDeviceEventHandler::handle(event, object, nv);
return ForwardToDeviceEventHandler::handle(ea, aa, o, nv);
if (event->getName() == "/zeroconf/service-added")
if (ea.getEventType() == osgGA::GUIEventAdapter::USER)
{
std::string host;
unsigned int port;
event->getUserValue("host", host);
event->getUserValue("port", port);
if (ea.getName() == "/zeroconf/service-added")
{
std::string host;
unsigned int port;
ea.getUserValue("host", host);
ea.getUserValue("port", port);
OSG_ALWAYS << "new osc-service discovered: " << host << ":" << port << std::endl;
OSG_ALWAYS << "new osc-service discovered: " << host << ":" << port << std::endl;
std::ostringstream ss ;
ss << host << ":" << port << ".sender.osc";
_device = osgDB::readFile<osgGA::Device>(ss.str());
osgGA::EventVisitor* ev = dynamic_cast<osgGA::EventVisitor*>(nv);
osgViewer::View* view = ev ? dynamic_cast<osgViewer::View*>(ev->getActionAdapter()) : NULL;
if (view)
view->addEventHandler(new PickHandler(_device.get()));
return true;
std::ostringstream ss ;
ss << host << ":" << port << ".sender.osc";
_device = osgDB::readFile<osgGA::Device>(ss.str());
osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa);
if (view)
view->addEventHandler(new PickHandler(_device.get()));
return true;
}
}
return false;
}
@@ -407,11 +402,8 @@ int main( int argc, char **argv )
if (!scene)
{
osg::Geode* geode = new osg::Geode();
osg::ShapeDrawable* drawable = new osg::ShapeDrawable(new osg::Box());
geode->addDrawable(drawable);
scene = geode;
std::cout << argv[0] << ": requires filename argument." << std::endl;
return 1;
}
bool use_zeroconf(false);
@@ -496,13 +488,6 @@ int main( int argc, char **argv )
traits->windowName = "Sender / view one";
osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
#ifdef __APPLE__
// as multitouch is disabled by default, enable it now
osgViewer::GraphicsWindowCocoa* win = dynamic_cast<osgViewer::GraphicsWindowCocoa*>(gc.get());
if (win) win->setMultiTouchEnabled(true);
#endif
osgViewer::View* view = new osgViewer::View;

View File

@@ -96,7 +96,7 @@ char fragmentShaderSource[] =
class UniformVarying : public osg::UniformCallback
class UniformVarying : public osg::Uniform::Callback
{
virtual void operator () (osg::Uniform* uniform, osg::NodeVisitor* nv)
{

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