Skip to content

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

Open
@hobbes1069

Description

@hobbes1069

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);
       };

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions