Files
elsid be06c08fdc Use std::atomic to implement OpenThreads::Atomic and AtomicPtr
Current implementation of atomic load is suboptimal that is visible on
ARM: https://godbolt.org/z/r4E7srWcE

This also triggers thread sanitizer warnings like:

```
WARNING: ThreadSanitizer: data race (pid=42478)
  Atomic write of size 4 at 0x7254001afb90 by main thread:
    #0 OpenThreads::Atomic::operator++()      OpenThreads/Atomic:110
    #1 osg::Referenced::ref()                 osg/Referenced:164
    #2 osg::ref_ptr<osg::Drawable>::ref_ptr   osg/ref_ptr:37
    #3 osgUtil::RenderLeaf::RenderLeaf        osgUtil/RenderLeaf:41
    #4 osgUtil::CullVisitor::createOrReuseRenderLeaf
    #5 osgUtil::CullVisitor::addDrawableAndDepth
  Previous read of size 4 at 0x7254001afb90 by thread T112 (mutexes: write M0):
    #0 OpenThreads::Atomic::operator unsigned int() const   OpenThreads/Atomic:225
    #1 osg::Referenced::referenceCount()                    osg/Referenced:97
    #2 Resource::GenericObjectCache<Terrain::ChunkKey>::update  components/resource/objectcache.hpp:82
    ...
    #5 Resource::GenericObjectCache<Terrain::ChunkKey>::update  components/resource/objectcache.hpp:77
```

Remove all related code along with unnecessary mutex based reference
counter.
2026-08-16 21:25:30 +02:00
..
2017-06-22 09:44:06 +07:00
2017-06-22 09:44:06 +07:00
2017-06-22 09:44:06 +07:00
2017-06-22 09:44:06 +07:00
2017-06-22 09:44:06 +07:00

How to build osgemscripten example

1. Install Emscripten

Download and install Emscripten portable SDK

2. Create build directory

Run the following commands:

mkdir /path/to/build/dir

cd /path/to/build/dir

3. Configure example

Run the following command:

cmake -DCMAKE_TOOLCHAIN_FILE=/path/to/emsdk-portable/emscripten/<version>/cmake/Modules/Platform/Emscripten.cmake /path/to/OpenSceneGraph/examples/osgemscripten

This also configures OpenSceneGraph as a dependency

3. Build example

Run the following command:

make

This also builds OpenSceneGraph under /path/to/OpenSceneGraph/build/Emscripten if it has not yet been built.

4. Launch example

Firefox only: locate and open osgemscripten.html file.

All browsers:

  • go to the directory with osgemscripten.html
  • run python -m SimpleHTTPServer 8080 from there
  • open http://localhost:8080/osgemscripten.html in any browser

You should now see red cube in your web browser.