Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Cesium Native build #2414

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 40 additions & 28 deletions CMakeModules/FindCesiumNative.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,56 @@ FIND_PATH(CESIUM_NATIVE_INCLUDE_DIR CesiumUtility/Uri.h

MACRO( FIND_CESIUM_LIBRARY MYLIBRARY MYLIBRARYNAME )

FIND_LIBRARY(${MYLIBRARY}
FIND_LIBRARY(${MYLIBRARY}_LIBRARY_DEBUG
NAMES
${MYLIBRARYNAME}
${MYLIBRARYNAME}d
PATHS
${CESIUM_NATIVE_DIR}/lib
$ENV{CESIUM_NATIVE_DIR}
PATH_SUFFIXES lib64 lib
NO_DEFAULT_PATH
)

FIND_LIBRARY(${MYLIBRARY}_LIBRARY_RELEASE
NAMES
${MYLIBRARYNAME}
PATHS
${CESIUM_NATIVE_DIR}/lib
$ENV{CESIUM_NATIVE_DIR}
PATH_SUFFIXES lib64 lib
NO_DEFAULT_PATH
)

select_library_configurations(${MYLIBRARY})

ENDMACRO(FIND_CESIUM_LIBRARY LIBRARY LIBRARYNAME)

FIND_CESIUM_LIBRARY(CESIUM_NATIVE_3DTILES_LIBRARY Cesium3DTiles)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_3DTILES_SELECTION_LIBRARY Cesium3DTilesSelection)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_GEOSPATIAL_LIBRARY CesiumGeospatial)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_UTILITY_LIBRARY CesiumUtility)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_ION_CLIENT_LIBRARY CesiumIonClient)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_GLTF_READER_LIBRARY CesiumGltfReader)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_3DTILES_READER_LIBRARY Cesium3DTilesReader)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_GEOMETRY_LIBRARY CesiumGeometry)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_GLTF_LIBRARY CesiumGltf)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_KTX_READ_LIBRARY ktx_read)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_DRACO_LIBRARY draco)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_SPDLOG_LIBRARY spdlog)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_ASYNC++_LIBRARY async++)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_WEBPDECODER_LIBRARY webpdecoder)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_MESHOPTIMIZER_LIBRARY meshoptimizer)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_URIPARSER_LIBRARY uriparser)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_TURBOJPEG_LIBRARY turbojpeg)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_CSPRNG_LIBRARY csprng)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_MODPB64_LIBRARY modp_b64)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_JSONREADER_LIBRARY CesiumJsonReader)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_ASYNC_LIBRARY CesiumAsync)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_S2GEOMETRY_LIBRARY s2geometry)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_RASTER_OVERLAYS_LIBRARY CesiumRasterOverlays)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_3DTILES_CONTENT_LIBRARY Cesium3DTilesContent)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_GLTF_CONTENT_LIBRARY CesiumGltfContent)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_TINYXML2_LIBRARY tinyxml2)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_3DTILES Cesium3DTiles)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_3DTILES_SELECTION Cesium3DTilesSelection)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_GEOSPATIAL CesiumGeospatial)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_UTILITY CesiumUtility)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_ION_CLIENT CesiumIonClient)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_GLTF_READER CesiumGltfReader)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_3DTILES_READER Cesium3DTilesReader)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_GEOMETRY CesiumGeometry)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_GLTF CesiumGltf)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_KTX_READ ktx_read)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_DRACO draco)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_SPDLOG spdlog)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_ASYNC++ async++)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_WEBPDECODER webpdecoder)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_MESHOPTIMIZER meshoptimizer)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_URIPARSER uriparser)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_TURBOJPEG turbojpeg)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_CSPRNG csprng)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_MODPB64 modp_b64)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_JSONREADER CesiumJsonReader)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_ASYNC CesiumAsync)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_S2GEOMETRY s2geometry)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_RASTER_OVERLAYS CesiumRasterOverlays)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_3DTILES_CONTENT Cesium3DTilesContent)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_GLTF_CONTENT CesiumGltfContent)
FIND_CESIUM_LIBRARY(CESIUM_NATIVE_TINYXML2 tinyxml2)



Expand Down
2 changes: 2 additions & 0 deletions CMakeModules/FindDraco.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ else()
find_library(draco_LIBRARIES NAMES draco.lib libdraco.a)
endif()

select_library_configurations(draco)

# Store path to library.
get_filename_component(draco_LIBRARY_DIRS ${draco_LIBRARIES} DIRECTORY)

Expand Down
11 changes: 8 additions & 3 deletions src/osgEarthCesium/PrepareRenderResources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ using namespace osgEarth::Cesium;

namespace
{
#ifdef GL_R
const GLenum redFormat = GL_R;
#else
const GLenum redFormat = GL_RED;
#endif

osg::Image* getOsgImage(CesiumGltf::ImageCesium& image)
{
Expand All @@ -48,7 +53,7 @@ namespace
switch (image.channels)
{
case 1:
format = GL_R;
format = redFormat;
texFormat = GL_R8;
break;
case 2:
Expand Down Expand Up @@ -82,7 +87,7 @@ namespace
texFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
break;
case CesiumGltf::GpuCompressedPixelFormat::BC4_R:
format = GL_R;
format = redFormat;
texFormat = GL_COMPRESSED_RED_RGTC1_EXT;
break;
case CesiumGltf::GpuCompressedPixelFormat::BC5_RG:
Expand Down Expand Up @@ -114,7 +119,7 @@ namespace
return nullptr;
break;
case CesiumGltf::GpuCompressedPixelFormat::ETC2_EAC_R11:
format = GL_R;
format = redFormat;
texFormat = GL_COMPRESSED_R11_EAC;
break;
case CesiumGltf::GpuCompressedPixelFormat::ETC2_EAC_RG11:
Expand Down
Loading