Commit Graph

12990 Commits

Author SHA1 Message Date
Robert Osfield
43049ebcf1 Moved FBO Extensions into GL2Extensions.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14586 16af8721-9629-0410-8352-f15c8da7e697
2014-12-09 18:30:28 +00:00
Robert Osfield
d5fcdabfa1 Removed no longer used Extension definition
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14585 16af8721-9629-0410-8352-f15c8da7e697
2014-12-09 14:58:34 +00:00
Robert Osfield
e31f682451 Moved local Extensions structs into GL2Extensions
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14584 16af8721-9629-0410-8352-f15c8da7e697
2014-12-09 14:57:25 +00:00
Robert Osfield
3f1e77d479 Moveved Stencil/StencilTwoSided::Extensions into GL2Extensions
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14583 16af8721-9629-0410-8352-f15c8da7e697
2014-12-09 11:14:33 +00:00
Robert Osfield
ec4f898bce Moved local Extensions objects to GL2Extensions
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14582 16af8721-9629-0410-8352-f15c8da7e697
2014-12-09 10:37:09 +00:00
Robert Osfield
cceee38727 Moved Texture*::Extensions functionality into GL2Extensions
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14581 16af8721-9629-0410-8352-f15c8da7e697
2014-12-09 10:05:59 +00:00
Robert Osfield
a8804e2366 MOved VertexProgram and FragmentProgram::Extensions into GL2Extensions.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14580 16af8721-9629-0410-8352-f15c8da7e697
2014-12-08 16:08:44 +00:00
Robert Osfield
35cfbfdb8c Fixed memory leak in RenderStageCache.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14578 16af8721-9629-0410-8352-f15c8da7e697
2014-12-08 11:08:29 +00:00
Robert Osfield
bc424bc54f MOved SampleMaski::Extensions into osg::GL2Extensions
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14577 16af8721-9629-0410-8352-f15c8da7e697
2014-12-07 17:31:49 +00:00
Robert Osfield
9b03b3f8ce Moved TextureCubeMap::Extension functionality into GL2Extensions
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14576 16af8721-9629-0410-8352-f15c8da7e697
2014-12-05 20:05:18 +00:00
Robert Osfield
f634152de0 Moved osg::Drawable::Extensions into osg::GL2Extensions
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14575 16af8721-9629-0410-8352-f15c8da7e697
2014-12-05 17:26:42 +00:00
Robert Osfield
1ce8029f39 Fixed windows build warnings
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14574 16af8721-9629-0410-8352-f15c8da7e697
2014-12-05 10:37:20 +00:00
Robert Osfield
1bcb944ddc Windows build fix
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14573 16af8721-9629-0410-8352-f15c8da7e697
2014-12-05 09:52:42 +00:00
Robert Osfield
aa090f0f99 From the GLintptr + GLsizeiptr defintions to GL2Extensions header
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14572 16af8721-9629-0410-8352-f15c8da7e697
2014-12-05 08:58:23 +00:00
Robert Osfield
d83e641fad Moved osg::BlenFunc::Extensions into osg::GL2Extensions
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14571 16af8721-9629-0410-8352-f15c8da7e697
2014-12-04 19:03:16 +00:00
Robert Osfield
d02c0bdc49 Moved GLBufferObject::Extensions structure into osg::GL2Extensions
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14570 16af8721-9629-0410-8352-f15c8da7e697
2014-12-04 18:13:11 +00:00
Robert Osfield
69407f4054 Removed redundent spaces
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14569 16af8721-9629-0410-8352-f15c8da7e697
2014-12-04 18:12:07 +00:00
Robert Osfield
1791ac08a8 Added glMemoryBarrier, glMapBufferRange and glBindBufferBase to GL2Extensions
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14568 16af8721-9629-0410-8352-f15c8da7e697
2014-12-04 17:12:55 +00:00
Robert Osfield
6569f69de1 Moved old GL2Extensions::Get(..) usage across to new osg::State::get<GL2Extensions>() usage
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14567 16af8721-9629-0410-8352-f15c8da7e697
2014-12-04 16:28:32 +00:00
Robert Osfield
66da1328f8 Ported GL2Extentions across to using the new GL extensions approach - cutting code count by 3000 lines!
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14566 16af8721-9629-0410-8352-f15c8da7e697
2014-12-04 16:22:31 +00:00
Robert Osfield
f8d53b7c8d Build fix for when ref_ptr<> auto conversion is disabled
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14565 16af8721-9629-0410-8352-f15c8da7e697
2014-12-04 15:10:43 +00:00
Robert Osfield
5efe60dcf5 Added osg::Capability and Cabibilityi base classes to wrap up glEnable/glDisable + glEnablei/glDisablei functionality, with osg::Enablei and osg::Disablei concrete implementations.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14564 16af8721-9629-0410-8352-f15c8da7e697
2014-12-03 17:31:16 +00:00
Robert Osfield
457d41d385 Added osg::BlendFunci, osg::BlendEquationi and osg::ColorMaski StateAttrirbutes that wrap the glBlendFunci, glBlendEquationi and glColorMaski functions
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14563 16af8721-9629-0410-8352-f15c8da7e697
2014-12-02 17:12:56 +00:00
Robert Osfield
a9cab19ddb Moved BlendEquation across to using the new GL extension setup approach.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14562 16af8721-9629-0410-8352-f15c8da7e697
2014-12-02 15:37:07 +00:00
Robert Osfield
0ce96fbe8b Fixed typo
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14561 16af8721-9629-0410-8352-f15c8da7e697
2014-12-02 15:21:24 +00:00
Robert Osfield
ff73445bf3 Added a template get and get_exisiting method into osg::State that implements a new mechanism for managing OpenGL extensions.
Refactored the BendFunc::Extensions usage to simplify it utilizing the new osg::State extension mechanism.


git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14560 16af8721-9629-0410-8352-f15c8da7e697
2014-12-02 11:10:23 +00:00
Robert Osfield
b7067ad988 From Rafa Gaitan, "I'm attaching also a new version of the toolchain with support for the r10c ndk. This fixes some CMake Warnings and allows to use the toolchain in macosx."
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14558 16af8721-9629-0410-8352-f15c8da7e697
2014-11-28 16:20:28 +00:00
Robert Osfield
e5f5c30e4d Removed include/osg/Version and include/OpenThreads/Version headers as these are autogenerated.
Changed the paths for the OpenThreads/osg Version headers to be placed in the PROJECT_BINARY_DIR.


git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14557 16af8721-9629-0410-8352-f15c8da7e697
2014-11-28 16:10:14 +00:00
Robert Osfield
d7c6bb1c4b Standardized on defined(__ANDROID__)
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14556 16af8721-9629-0410-8352-f15c8da7e697
2014-11-28 10:54:40 +00:00
Robert Osfield
6d98c5460f Added getlocaledecpoint() workaround for Android build of lua plugin
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14555 16af8721-9629-0410-8352-f15c8da7e697
2014-11-28 10:52:06 +00:00
Robert Osfield
1c9993dd5d Added in source shaders
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14554 16af8721-9629-0410-8352-f15c8da7e697
2014-11-27 15:54:24 +00:00
Robert Osfield
114ddbb0c6 Changed the name of shader files
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14553 16af8721-9629-0410-8352-f15c8da7e697
2014-11-27 15:39:38 +00:00
Robert Osfield
95b3622d1d From Jason Beverage, "It looks like the Callback header got accidentally removed from the CMakeLists.txt in the submission yesterday for the geometry instancing example."
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14551 16af8721-9629-0410-8352-f15c8da7e697
2014-11-26 20:40:57 +00:00
Robert Osfield
4184696809 Windows build fix
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14550 16af8721-9629-0410-8352-f15c8da7e697
2014-11-26 19:05:09 +00:00
Robert Osfield
d76947845a Fixed warnings
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14549 16af8721-9629-0410-8352-f15c8da7e697
2014-11-26 17:08:16 +00:00
Robert Osfield
2f0cc6fbc9 Fixed warnings
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14546 16af8721-9629-0410-8352-f15c8da7e697
2014-11-26 17:04:12 +00:00
Robert Osfield
f802f6d0ed Fixed deprecated warnings
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14545 16af8721-9629-0410-8352-f15c8da7e697
2014-11-26 16:29:53 +00:00
Robert Osfield
a165930b48 Fixed warning
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14542 16af8721-9629-0410-8352-f15c8da7e697
2014-11-26 16:15:37 +00:00
Robert Osfield
0be132c07c Fixed warnings.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14539 16af8721-9629-0410-8352-f15c8da7e697
2014-11-26 16:04:33 +00:00
Robert Osfield
d6ed4c4d6d Fixed warning
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14537 16af8721-9629-0410-8352-f15c8da7e697
2014-11-26 16:00:18 +00:00
Robert Osfield
8fe82b463f Fixed warning
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14536 16af8721-9629-0410-8352-f15c8da7e697
2014-11-26 15:59:23 +00:00
Robert Osfield
dd186fe6a1 Added osgTerrain::DisplacementMappingTechnique serializer
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14535 16af8721-9629-0410-8352-f15c8da7e697
2014-11-26 14:06:27 +00:00
Robert Osfield
dfb0b2ab8e Renamed ShaderTerrain to DisplacementMappingTechnique and moved it from the osgterrain example testbed into the osgTerrain NodeKit
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14534 16af8721-9629-0410-8352-f15c8da7e697
2014-11-26 14:04:20 +00:00
Robert Osfield
d9f93f9d1a Moved osgTerrain::GeometryPool from osgterrain example into osgTerrain NodeKit
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14533 16af8721-9629-0410-8352-f15c8da7e697
2014-11-26 13:36:28 +00:00
Robert Osfield
eaa170809f Removed GL header as it's already included via the ${OPENSCENEGRAPH_OPENGL_HEADER} entry.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14532 16af8721-9629-0410-8352-f15c8da7e697
2014-11-25 14:37:05 +00:00
Robert Osfield
4c5a1885d2 From PawelKsiezopolski, "This submission contains a new example for OSG : a geometry instancing rendering
algorithm consisting of two consequent phases :

- first phase is a GLSL shader performing object culling and LOD picking ( a culling shader ).
  Every culled object is represented as GL_POINT in the input osg::Geometry.
  The output of the culling shader is a set of object LODs that need to be rendered.
  The output is stored in texture buffer objects. No pixel is drawn to the screen
  because GL_RASTERIZER_DISCARD mode is used.

- second phase draws osg::Geometry containing merged LODs using glDrawArraysIndirect()
  function. Information about quantity of instances to render, its positions and other
  parameters is sourced from texture buffer objects filled in the first phase.

The example uses various OpenGL 4.2 features such as texture buffer objects,
atomic counters, image units and functions defined in GL_ARB_shader_image_load_store
extension to achieve its goal and thus will not work on graphic cards with older OpenGL
versions.

The example was tested on Linux and Windows with NVidia 570 and 580 cards.
The tests on AMD cards were not conducted ( due to lack of it ).
The tests were performed using OSG revision 14088.

The main advantages of this rendering method :
- instanced rendering capable of drawing thousands of different objects with
  almost no CPU intervention  ( cull and draw times are close to 0 ms ).
- input objects may be sourced from any OSG graph ( for example - information about
  object points may be stored in a PagedLOD graph. This way we may cover the whole
  countries with trees, buildings and other objects ).
  Furthermore if we create osgDB plugins that generate data on the fly, we may
  generate information for every grass blade for that country.
- every object may have its own parameters and thus may be distinct from other objects
  of the same type.
- relatively low memory footprint ( single object information is stored in a few
  vertex attributes ).
- no GPU->CPU roundtrip typical for such methods ( method uses atomic counters
  and glDrawArraysIndirect() function instead of OpenGL queries. This way
  information about quantity of rendered objects never goes back to CPU.
  The typical GPU->CPU roundtrip cost is about 2 ms ).
- this example also shows how to render dynamic objects ( objects that may change
  its position ) with moving parts ( like car wheels or airplane propellers ) .
  The obvious extension to that dynamic method would be the animated crowd rendering.
- rendered objects may be easily replaced ( there is no need to process the whole
  OSG graphs, because these graphs store only positional information ).

The main disadvantages of a method :
- the maximum quantity of objects to render must be known beforehand
  ( because texture buffer objects holding data between phases have constant size ).
- OSG statistics are flawed ( they don't know anymore how many objects are drawn ).
- osgUtil::Intersection does not work

Example application may be used to make some performance tests, so below you
will find some extended parameter description :
--skip-dynamic       - skip rendering of dynamic objects if you only want to
                       observe static object statistics
--skip-static        - the same for static objects
--dynamic-area-size  - size of the area for dynamic rendering. Default = 1000 meters
                       ( square 1000m x 1000m ). Along with density defines
                       how many dynamic objects is there in the example.
--static-area-size   - the same for static objects. Default = 2000 meters
                       ( square 2000m x 2000m ).

Example application defines some parameters (density, LOD ranges, object's triangle count).
You may manipulate its values using below described modifiers:
--density-modifier   - density modifier in percent. Default = 100%.
                       Density ( along with LOD ranges ) defines maximum
                       quantity of rendered objects. registerType() function
                       accepts maximum density ( in objects per square kilometer )
                       as its parameter.
--lod-modifier       - defines the LOD ranges. Default = 100%.
--triangle-modifier  - defines the number of triangles in finally rendered objects.
                       Default = 100 %.
--instances-per-cell - for static rendering the application builds OSG graph using
                       InstanceCell class ( this class is a modified version of Cell class
                       from osgforest example - it builds simple quadtree from a list
                       of static instances ). This parameter defines maximum number
                       of instances in a single osg::Group in quadtree.
                       If, for example, you modify it to value=100, you will see
                       really big cull time in OSG statistics ( because resulting
                       tree generated by InstanceCell will be very deep ).
                       Default value = 4096 .
--export-objects     - write object geometries and quadtree of instances to osgt files
                       for later analysis.
--use-multi-draw     - use glMultiDrawArraysIndirect() instead of glDrawArraysIndirect() in a
                       draw shader. Thanks to this we may render all ( different ) objects
                       using only one draw call. Requires OpenGL version 4.3 and some more
                       work from me, because now it does not work ( probably I implemented
                       it wrong, or Windows NVidia driver has errors, because it hangs
                       the apllication at the moment ).

This application is inspired by Daniel Rákos work : "GPU based dynamic geometry LOD" that
may be found under this address : http://rastergrid.com/blog/2010/10/gpu-based-dynamic-geometry-lod/
There are however some differences :
- Daniel Rákos uses GL queries to count objects to render, while this example
  uses atomic counters ( no GPU->CPU roundtrip )
- this example does not use transform feedback buffers to store intermediate data
  ( it uses texture buffer objects instead ).
- I use only the vertex shader to cull objects, whereas Daniel Rákos uses vertex shader
  and geometry shader ( because only geometry shader can send more than one primitive
  to transform feedback buffers ).
- objects in the example are drawn using glDrawArraysIndirect() function,
  instead of glDrawElementsInstanced().

Finally there are some things to consider/discuss  :
- the whole algorithm exploits nice OpenGL feature that any GL buffer
  may be bound as any type of buffer ( in our example a buffer is once bound
  as a texture buffer object, and later is bound as GL_DRAW_INDIRECT_BUFFER ).
  osg::TextureBuffer class has one handy method to do that trick ( bindBufferAs() ),
  and new primitive sets use osg::TextureBuffer as input.
  For now I added new primitive sets to example ( DrawArraysIndirect and
  MultiDrawArraysIndirect defined in examples/osggpucull/DrawIndirectPrimitiveSet.h ),
  but if Robert will accept its current implementations ( I mean - primitive
  sets that have osg::TextureBuffer in constructor ), I may add it to
  osg/include/PrimitiveSet header.
- I used BufferTemplate class writen and published by Aurelien in submission forum
  some time ago. For some reason this class never got into osg/include, but is
  really needed during creation of UBOs, TBOs, and possibly SSBOs in the future.
  I added std::vector specialization to that template class.
- I needed to create similar osg::Geometries with variable number of vertices
  ( to create different LODs in my example ). For this reason I've written
  some code allowing me to create osg::Geometries from osg::Shape descendants.
  This code may be found in ShapeToGeometry.* files. Examples of use are in
  osggpucull.cpp . The question is : should this code stay in example, or should
  it be moved to osgUtil ?
- this remark is important for NVidia cards on Linux and Windows : if
  you have "Sync to VBlank" turned ON in nvidia-settings and you want to see
  real GPU times in OSG statistics window, you must set the power management
  settings to "Prefer maximum performance", because when "Adaptive mode" is used,
  the graphic card's clock may be slowed down by the driver during program execution
  ( On Linux when OpenGL application starts in adaptive mode, clock should work
  as fast as possible, but after one minute of program execution, the clock slows down ).
  This happens when GPU time in OSG statistics window is shorter than 3 ms.
"


git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14531 16af8721-9629-0410-8352-f15c8da7e697
2014-11-25 10:58:23 +00:00
Robert Osfield
f06ea2bc6e Removed DrawArrays optimization to simplify the code and open the door to adding primitive combining.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14530 16af8721-9629-0410-8352-f15c8da7e697
2014-11-25 10:33:20 +00:00
Robert Osfield
79a4fff2dc Commented out State::setUpVertexAttribAlias(..) debug message.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14529 16af8721-9629-0410-8352-f15c8da7e697
2014-11-25 10:11:06 +00:00
Robert Osfield
53e337611a 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/trunk@14527 16af8721-9629-0410-8352-f15c8da7e697
2014-11-24 15:19:20 +00:00
Robert Osfield
86ddca4edb Added VertexAttribDivisor class to wrap up glVertexAttribDivisor function
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14526 16af8721-9629-0410-8352-f15c8da7e697
2014-11-24 14:54:39 +00:00