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

RFE: OpenEXR 3.x support (with minimal patch) #1075

Open
hobbes1069 opened this issue Jul 23, 2021 · 2 comments
Open

RFE: OpenEXR 3.x support (with minimal patch) #1075

hobbes1069 opened this issue Jul 23, 2021 · 2 comments

Comments

@hobbes1069
Copy link

I have ported OSG to OpenEXR 3.x on Fedora. Provided is a minimal port that may not work on all platforms yet so I'll provide it here instead of in a pull request.

Index: OpenSceneGraph-OpenSceneGraph-3.4.1/CMakeLists.txt
===================================================================
--- OpenSceneGraph-OpenSceneGraph-3.4.1.orig/CMakeLists.txt
+++ OpenSceneGraph-OpenSceneGraph-3.4.1/CMakeLists.txt
@@ -650,7 +650,22 @@ ELSE()
     FIND_PACKAGE(Freetype)
     FIND_PACKAGE(Inventor)
     FIND_PACKAGE(Jasper)
-    FIND_PACKAGE(OpenEXR)
+	FIND_PACKAGE(Imath CONFIG)
+	IF(TARGET Imath::Imath)
+        FIND_PACKAGE(OpenEXR REQUIRED CONFIG)
+	    set(OPENEXR_LIBRARIES_VARS
+		    OpenEXR::OpenEXR
+			Imath::Imath
+			Imath::Half)
+		get_target_property(OPENEXR_INCLUDE_DIR
+		    OpenEXR::OpenEXRConfig INTERFACE_INCLUDE_DIRECTORIES)
+		get_target_property(IMATH_INCLUDE_DIR
+			Imath::ImathConfig INTERFACE_INCLUDE_DIRECTORIES)
+		list(APPEND OPENEXR_INCLUDE_DIR ${IMATH_INCLUDE_DIR})
+		set(OPENEXR_FOUND TRUE)
+	ELSE()
+        FIND_PACKAGE(OpenEXR)
+	ENDIF()
     FIND_PACKAGE(COLLADA)
     FIND_PACKAGE(FBX)
     FIND_PACKAGE(ZLIB)
Index: OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/CMakeLists.txt
===================================================================
--- OpenSceneGraph-OpenSceneGraph-3.4.1.orig/src/osgPlugins/CMakeLists.txt
+++ OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/CMakeLists.txt
@@ -85,9 +85,7 @@ ENDIF()
 IF(JASPER_FOUND)
     ADD_SUBDIRECTORY(jp2)
 ENDIF()
-IF(OPENEXR_FOUND AND ZLIB_FOUND AND OSG_CPP_EXCEPTIONS_AVAILABLE)
     ADD_SUBDIRECTORY(exr)
-ENDIF()
 IF(GIFLIB_FOUND)
     ADD_SUBDIRECTORY(gif)
 ENDIF()
Index: OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/exr/CMakeLists.txt
===================================================================
--- OpenSceneGraph-OpenSceneGraph-3.4.1.orig/src/osgPlugins/exr/CMakeLists.txt
+++ OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/exr/CMakeLists.txt
@@ -1,4 +1,4 @@
-INCLUDE_DIRECTORIES( ${OPENEXR_INCLUDE_DIR}/OpenEXR )
+INCLUDE_DIRECTORIES( ${OPENEXR_INCLUDE_DIR} )
 
 SET(TARGET_SRC ReaderWriterEXR.cpp )
 
Index: OpenSceneGraph-OpenSceneGraph-3.4.1/CMakeModules/FindOpenEXR.cmake
===================================================================
--- OpenSceneGraph-OpenSceneGraph-3.4.1.orig/CMakeModules/FindOpenEXR.cmake
+++ OpenSceneGraph-OpenSceneGraph-3.4.1/CMakeModules/FindOpenEXR.cmake
@@ -23,6 +23,7 @@ FIND_PATH(OPENEXR_INCLUDE_DIR OpenEXR/Im
     /opt/include
     /usr/freeware/include
 )
+SET(OPENEXR_INCLUDE_DIR ${OPENEXR_INCLUDED_DIR}/OpenEXR)
 
 # Macro to find exr libraries (deduplicating search paths)
 # example: OPENEXR_FIND_VAR(OPENEXR_IlmImf_LIBRARY IlmImf)
Index: OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/exr/ReaderWriterEXR.cpp
===================================================================
--- OpenSceneGraph-OpenSceneGraph-3.4.1.orig/src/osgPlugins/exr/ReaderWriterEXR.cpp
+++ OpenSceneGraph-OpenSceneGraph-3.4.1/src/osgPlugins/exr/ReaderWriterEXR.cpp
@@ -41,11 +41,11 @@ public:
       {
         return _inStream->read(c,n).good();
       };
-      virtual Int64    tellg ()
+      virtual uint64_t    tellg ()
       {
           return _inStream->tellg();
       };
-      virtual void    seekg (Int64 pos)
+      virtual void    seekg (uint64_t pos)
       {
         _inStream->seekg(pos);
       };
@@ -69,11 +69,11 @@ public:
       {
         _outStream->write(c,n);
       };
-      virtual Int64    tellp ()
+      virtual uint64_t    tellp ()
       {
         return _outStream->tellp();
       };
-      virtual void seekp (Int64 pos)
+      virtual void seekp (uint64_t pos)
       {
         _outStream->seekp(pos);
       };
esok added a commit to esok/OpenSceneGraph that referenced this issue Dec 24, 2021
@DarthGandalf
Copy link

Here's Gentoo version: https://github.com/gentoo/gentoo/blob/9523b20c27d12dd72d1fd5ced3ba4995099925a2/dev-games/openscenegraph/files/openscenegraph-3.6.5-openexr3.patch and Findilmbase.cmake and FindOpenEXR.cmake can be removed

I tried to link to Imath::Imath too, but that didn't appear in ldd osgdb_exr.so

@meshula
Copy link

meshula commented Mar 25, 2022

Landing this would be great ~ it needs to be resolved to land OpenEXR 3 on vcpkg.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants