Skip to content

Commit

Permalink
Merge branch 'master' of github.com:gwaldron/osgearth
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonbeverage committed Feb 14, 2024
2 parents c941789 + 36e0c50 commit 47b9ce4
Show file tree
Hide file tree
Showing 195 changed files with 3,395 additions and 3,187 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:

strategy:
matrix:
os: ['macos-13']
os: ['macos-14']
include:
- os: 'macos-13'
- os: 'macos-14'
triplet: 'x64-macosx'

steps:
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ set(OSGEARTH_PATCH_VERSION 0)
set(OSGEARTH_VERSION ${OSGEARTH_MAJOR_VERSION}.${OSGEARTH_MINOR_VERSION}.${OSGEARTH_PATCH_VERSION})

# Increment this each time the ABI changes
set(OSGEARTH_SOVERSION 149)
set(OSGEARTH_SOVERSION 150)

# Require C++11
set_property(GLOBAL PROPERTY CXX_STANDARD 11)
Expand Down
2 changes: 2 additions & 0 deletions CMakeModules/oe_unix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ IF(UNIX AND NOT ANDROID)
FIND_PACKAGE(X11)
# Some Unicies need explicit linkage to the Math library or the build fails.
FIND_LIBRARY(MATH_LIBRARY m)
# for ptheads in linux
find_package(Threads REQUIRED)
ENDIF(UNIX AND NOT ANDROID)
112 changes: 112 additions & 0 deletions docs/source/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,118 @@ set OSG_GL_CONTEXT_PROFILE_MASK=1

The context version and profile mask are also settable via the `osg::DisplaySettings` class in the OpenSceneGraph API.

## Linux Build Example
vcpkg is one option for building osgEarth and all the dependencies, but it is also possible to use the Linux binary repositories to install dependencies quickly. This is based on Ubuntu but the idea is the same, install the required dependencies and compile osgEarth. Here are the basics:

Install Build essentials
```
sudo apt update && sudo apt install build-essential
```
Install GDAL:
```
sudo apt-get install libgdal-dev
```
Install GLEW
```
sudo apt-get install libglew-dev
```
Build Openscenegraph. This sets GL profile and context which aren't necessary so change accordingly for your needs.
```
git clone https://github.com/openscenegraph/OpenSceneGraph.git
cd OpenSceneGraph
mkdir build && cd build
cmake .. -DOPENGL_PROFILE=GL3 -DOSG_GL_CONTEXT_VERSION=4.6
make -j8
sudo make install
```
Build Draco. This is optional but included in case it is not available in a repo. The -fPIC flag may be required on some platforms but not others.
```
git clone https://github.com/google/draco.git
cd draco
mkdir build && cd build
cmake .. -DCMAKE_CXX_FLAGS=-fPIC
make -j8
sudo make install
```
Build osgEarth. Turning off OSGEARTH_ENABLE_FASTDXT may not be necessary but left it here for platforms where it will not build
```
git clone https://github.com/gwaldron/osgearth.git
cd osgEarth
mkdir build && cd build
cmake .. -DOSGEARTH_ENABLE_FASTDXT=OFF
make -j8
sudo make install
```
After a successful build, it might be necessary to set your dynamic library search path to find both OpenScenegraph and osgEarth libraries. Check path to osgPlugins folders also.
```
export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64
```
## Tips for Running on Windows WSL2 with nVidia GPU
In WSL2 (I have tried Ubuntu 20 and 22), follow the previous Linux build example with this change to Openscenegraph:
Build Openscenegraph. This sets GL profile to Core and context to 3.3 for Mesa compatibility
```
git clone https://github.com/openscenegraph/OpenSceneGraph.git
cd OpenSceneGraph
mkdir build && cd build
cmake .. -DOPENGL_PROFILE=GL3 -DOSG_GL_CONTEXT_VERSION=3.3
make -j8
sudo make install
```
At that point, you should have all the osgEarth binaries built and installed.
Next follow this guide: [https://canonical-ubuntu-wsl.readthedocs-hosted.com/en/latest/tutorials/gpu-cuda/](https://canonical-ubuntu-wsl.readthedocs-hosted.com/en/latest/tutorials/gpu-cuda/#install-nvidia-cuda-on-ubuntu)

Shortcut steps but see the above link for more information.
```
sudo apt-key del 7fa2af80
wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin
sudo mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/3bf863cc.pub
sudo add-apt-repository 'deb https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/ /'
sudo apt-get update
sudo apt-get -y install cuda
```
If you are on Ubuntu 23.10, there is a CUDA install problem. This is the fix:

The libtinfo5 package isn't available in Ubuntu 23.10's default repositories yet. We can install it by adding the universe repo for Ubuntu 23.04 (Lunar Lobster).

Open a terminal window and run:
```
sudo nano /etc/apt/sources.list
```
Add this line (adds the Ubuntu 23.04 aka "Lunar Lobster" universe repository to apt):
```
deb http://archive.ubuntu.com/ubuntu/ lunar universe
```
Save and exit, then run:
```
sudo apt update
```
...and now the install command for CUDA should work, automatically downloading and installing libtinfo5 while installing CUDA

I did clone the CUDA samples repo and build deviceQuery which will be a quick test to make sure your GPU is recognized
```
git clone https://github.com/nvidia/cuda-samples
cd cuda-samples/Samples/1_Utilities/deviceQuery
make
./deviceQuery
```
If that successfully recognizes your nVidia GPU, you can try:
```
osgearth_version --caps
[osgEarth] Hello, world.
[osgEarth] [Registry] Note: GDAL_DATA environment variable is not set
[osgEarth] [Capabilities] osgEarth Version: 3.5.0 build 149
[osgEarth] [Capabilities] GDAL Version: 3.4.1
[osgEarth] [Capabilities] OSG Version: 3.7.0
[osgEarth] [Capabilities] OSG GL3 Features: yes
[osgEarth] [Capabilities] OSG FFP Available: no
[osgEarth] [Capabilities] CPU Cores: 16
[osgEarth] [Capabilities] GL_VENDOR: Microsoft Corporation
[osgEarth] [Capabilities] GL_RENDERER: D3D12 (NVIDIA GeForce RTX 3070 Ti)
[osgEarth] [Capabilities] GL_VERSION: 4.2 (Core Profile) Mesa 23.0.4-0ubuntu1~22.04.1
[osgEarth] [Capabilities] GL CORE Profile: yes
```
## Tips for VMware Users

Running osgEarth in a virtual machine environment can be tricky since they usually don't have direct access to the graphics hardware by default. If you are having trouble you can try these tips.
Expand Down
10 changes: 4 additions & 6 deletions docs/source/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,23 @@

#### Error: 'gl_ModelViewMatrix is removed after version 140'

osgEarth works best with OpenSceneGraph that was built with the GL3 or GLCORE profile. If you build OSG with the GL2 profile (which is the default) you may need to take some extra steps.

The most common symptom is error messages like this:
If you build OSG with the GL2 profile (which is the default) you may see errors like this:
```
VERTEX Shader "..." infolog:
0(94) : error C7616: global variable gl_ModelViewMatrix is removed after version 140
0(124) : error C7616: global variable gl_MultiTexCoord1 is removed after version 140
0(125) : error C7616: global variable gl_MultiTexCoord2 is removed after version 140
```

If you see this with an OSG GL2 build, you can include code like this to get things working:
If so, you can include code like this to get things working:
```c++
#include <osgEarth/GLUtils>
#include <osgEarth/ExampleResources>
...
viewer.setRealizeOperation(new GL3RealizeOperation());
MapNodeHelper().configureView(&viewer);
```

The `osgearth_simple.cpp` example shows how to do this in your application.


## Earth File

Expand Down
3 changes: 1 addition & 2 deletions src/applications/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ IF(NOT OSGEARTH_BUILD_PLATFORM_IPHONE)
SET(TARGET_DEFAULT_APPLICATION_FOLDER "Tools")
ADD_SUBDIRECTORY(osgearth_viewer)
ADD_SUBDIRECTORY(osgearth_imgui)
ADD_SUBDIRECTORY(osgearth_toc)
ADD_SUBDIRECTORY(osgearth_tfs)
ADD_SUBDIRECTORY(osgearth_boundarygen)
ADD_SUBDIRECTORY(osgearth_version)
Expand Down Expand Up @@ -60,6 +59,7 @@ IF(NOT OSGEARTH_BUILD_PLATFORM_IPHONE)
IF(OSGEARTH_BUILD_EXAMPLES)
SET(TARGET_DEFAULT_LABEL_PREFIX "Example")
SET(TARGET_DEFAULT_APPLICATION_FOLDER "Examples")
ADD_SUBDIRECTORY(osgearth_simple)
ADD_SUBDIRECTORY(osgearth_manip)
ADD_SUBDIRECTORY(osgearth_cluster)
ADD_SUBDIRECTORY(osgearth_features)
Expand All @@ -70,7 +70,6 @@ IF(NOT OSGEARTH_BUILD_PLATFORM_IPHONE)
ADD_SUBDIRECTORY(osgearth_annotation)
ADD_SUBDIRECTORY(osgearth_tracks)
ADD_SUBDIRECTORY(osgearth_transform)
ADD_SUBDIRECTORY(osgearth_city)
ADD_SUBDIRECTORY(osgearth_graticule)
ADD_SUBDIRECTORY(osgearth_occlusionculling)
ADD_SUBDIRECTORY(osgearth_minimap)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ struct ProgressReporter : public osgEarth::ProgressCallback
unsigned totalStages,
const std::string& msg)
{
ScopedMutexLock lock(_mutex);
std::lock_guard<std::mutex> lock(_mutex);

if (_first)
{
Expand Down Expand Up @@ -388,7 +388,7 @@ struct ProgressReporter : public osgEarth::ProgressCallback
return false;
}

Threading::Mutex _mutex;
std::mutex _mutex;
bool _first;
osg::Timer_t _start;
};
Expand All @@ -407,8 +407,6 @@ class TileListVisitor : public osgEarth::MultithreadedTileVisitor
// Start up the task service
OE_INFO << "Starting " << _numThreads << " threads " << std::endl;

_arena = std::make_shared<JobArena>("oe.mttilevisitor", _numThreads);

_profile = mapProfile;

// Reset the progress in case this visitor has been ran before.
Expand Down
1 change: 0 additions & 1 deletion src/applications/osgearth_clamp/osgearth_clamp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ struct App
osg::ref_ptr<OGRFeatureSource> input;
osg::ref_ptr<OGRFeatureSource> output;
Threading::Mutexed<std::queue<FeatureList*> > outputQueue;
Threading::Event gate;
std::string attrName;
bool verbose;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,11 +485,12 @@ void computeIntersectionsThreaded(osg::Node* node, std::vector< IntersectionQuer
}
}
}

JobArena::get("oe.intersections")->setConcurrency(num_threads);

auto pool = jobs::get_pool("oe.intersections");
pool->set_concurrency(num_threads);

// Poor man's parallel for
JobGroup intersections;
jobs::jobgroup intersections;

//unsigned int workSize = 500;
// Try to split the jobs evenly among the threads
Expand All @@ -505,12 +506,16 @@ void computeIntersectionsThreaded(osg::Node* node, std::vector< IntersectionQuer
unsigned int curSize = curStart + workSize <= queries.size() ? workSize : queries.size() - curStart;
if (curSize > 0)
{
Job job;
job.setArena("oe.intersections");
job.setGroup(&intersections);
job.dispatch([node, curStart, curSize, &queries](Cancelable*) {
jobs::context context;
context.pool = pool;
context.group = &intersections;

jobs::dispatch([node, curStart, curSize, &queries](Cancelable&) {
computeIntersections(node, queries, curStart, curSize);
});
return true;
},
context
);
++numJobs;
}
start += workSize;
Expand Down
20 changes: 7 additions & 13 deletions src/applications/osgearth_conv/osgearth_conv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ struct ProgressReporter : public osgEarth::ProgressCallback
unsigned totalStages,
const std::string& msg )
{
ScopedMutexLock lock(_mutex);
std::lock_guard<std::mutex> lock(_mutex);

if (_first)
{
Expand Down Expand Up @@ -278,7 +278,7 @@ struct ProgressReporter : public osgEarth::ProgressCallback
return false;
}

Threading::Mutex _mutex;
std::mutex _mutex;
bool _first;
osg::Timer_t _start;
};
Expand Down Expand Up @@ -489,17 +489,11 @@ main(int argc, char** argv)
// create the visitor.
osg::ref_ptr<TileVisitor> visitor;

unsigned numThreads = 1;
if (args.read("--threads", numThreads))
{
MultithreadedTileVisitor* mtv = new MultithreadedTileVisitor();
mtv->setNumThreads(numThreads < 1 ? 1 : numThreads);
visitor = mtv;
}
else
{
visitor = new TileVisitor();
}
unsigned numThreads = 4;
args.read("--threads", numThreads);
MultithreadedTileVisitor* mtv = new MultithreadedTileVisitor();
mtv->setNumThreads(numThreads < 1 ? 1 : numThreads);
visitor = mtv;

bool overwrite = true;
if (args.read("--no-overwrite"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,18 +172,11 @@ main(int argc, char** argv)
if (keys.empty())
return usage(argv[0], "No data in extent");

JobArena arena("Vegetation Export", 1u);

std::cout << "Exporting " << keys.size() << " keys.." << std::endl;

for(const auto key : keys)
{
Job(&arena).dispatch(
[&app, key](Cancelable*)
{
app.exportKey(key);
}
);
jobs::dispatch([&app, key]() { app.exportKey(key); });
}


Expand Down
2 changes: 1 addition & 1 deletion src/applications/osgearth_features/osgearth_features.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ using namespace osgEarth::Util;

int usage( const std::string& app )
{
OE_NOTICE "\n" << app << "\n"
OE_NOTICE << "\n" << app << "\n"
<< " --rasterize : draw features as rasterized image tiles \n"
<< " --drape : draw features as projected texture \n"
<< " --clamp : draw features using shader clamping \n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ using namespace osgEarth;
int
fail(const std::string& msg, char** argv)
{
OE_WARN LC << msg << std::endl;
OE_WARN LC << argv[0]
OE_WARN << LC << msg << std::endl;
OE_WARN << LC << argv[0]
<< "\n --in <filename> ; model to process"
<< "\n --out <filename> ; output texture filename"
<< "\n --size <n> ; dimension of texture"
Expand Down
2 changes: 2 additions & 0 deletions src/applications/osgearth_map/osgearth_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <osgEarth/ImageLayer>
#include <osgEarth/ModelLayer>
#include <osgEarth/GeoTransform>
#include <osgEarth/GLUtils>

#include <osgEarth/TMS>
#include <osgEarth/WMS>
Expand Down Expand Up @@ -222,6 +223,7 @@ main(int argc, char** argv)

// initialize a viewer:
osgViewer::Viewer viewer(arguments);
viewer.setRealizeOperation( new GL3RealizeOperation() );
viewer.setCameraManipulator( new EarthManipulator() );
viewer.getCamera()->setSmallFeatureCullingPixelSize(-1.0f);
viewer.setSceneData( node );
Expand Down
7 changes: 7 additions & 0 deletions src/applications/osgearth_simple/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
INCLUDE_DIRECTORIES(${OSG_INCLUDE_DIRS} )
SET(TARGET_LIBRARIES_VARS OSG_LIBRARY OSGDB_LIBRARY OSGGA_LIBRARY OSGUTIL_LIBRARY OSGVIEWER_LIBRARY OSGSIM_LIBRARY OSGSHADOW_LIBRARY OSGTEXT_LIBRARY OSGMANIPULATOR_LIBRARY OPENTHREADS_LIBRARY)

SET(TARGET_SRC osgearth_simple.cpp )

#### end var setup ###
SETUP_APPLICATION(osgearth_simple)

0 comments on commit 47b9ce4

Please sign in to comment.