From 247e15befa260a7c9e7d0c1bde0dda63fbd99214 Mon Sep 17 00:00:00 2001 From: TonVanDenBroek Date: Wed, 30 Jun 2021 12:17:59 +1200 Subject: [PATCH 1/2] Changes to support OpenEXR 3.0. --- source/backend/povray.cpp | 13 ++++++++++++- source/base/image/openexr.cpp | 24 +++++++----------------- unix/config/ax_check_openexr.m4 | 12 +++--------- 3 files changed, 22 insertions(+), 27 deletions(-) diff --git a/source/backend/povray.cpp b/source/backend/povray.cpp index 7692eff84..eaf3a1f8e 100644 --- a/source/backend/povray.cpp +++ b/source/backend/povray.cpp @@ -68,14 +68,21 @@ extern "C" const char* TIFFGetVersion(void); #endif #ifndef OPENEXR_MISSING - #include #include + #if (OPENEXR_VERSION_MAJOR < 3) + #include + #else + #include + #endif // NOTE: // Versions of OpenEXR and IlmImf prior to 1.7.1 do not seem to have a way to get the version number, // nor do the official hard-coded Windows config headers. #ifndef ILMBASE_PACKAGE_STRING #define ILMBASE_PACKAGE_STRING "IlmBase" #endif + #ifndef IMATH_PACKAGE_STRING + #define IMATH_PACKAGE_STRING "Imath" + #endif #ifndef OPENEXR_PACKAGE_STRING #define OPENEXR_PACKAGE_STRING "OpenEXR" #endif @@ -458,7 +465,11 @@ void BuildInitInfo(POVMSObjectPtr msg) err = POVMSAttr_New(&attr); if(err == kNoErr) { +#if (OPENEXR_VERSION_MAJOR < 3) const char *tempstr = OPENEXR_PACKAGE_STRING " and " ILMBASE_PACKAGE_STRING ", Copyright (c) 2002-2011 Industrial Light & Magic."; +#else + const char *tempstr = OPENEXR_PACKAGE_STRING " and " IMATH_PACKAGE_STRING ", Copyright (c) Contributors to the OpenEXR Project."; +#endif err = POVMSAttr_Set(&attr, kPOVMSType_CString, reinterpret_cast(tempstr), (int) strlen(tempstr) + 1); if(err == kNoErr) err = POVMSAttrList_Append(&attrlist, &attr); diff --git a/source/base/image/openexr.cpp b/source/base/image/openexr.cpp index 5050a897e..f005cf3b6 100644 --- a/source/base/image/openexr.cpp +++ b/source/base/image/openexr.cpp @@ -46,21 +46,11 @@ #ifndef OPENEXR_MISSING -#ifdef NON_UNIX_OPENEXR_HEADERS - #include #include #include #include -#else - -#include -#include -#include -#include - -#endif #include "metadata.h" // this must be the last file included @@ -105,7 +95,7 @@ class POV_EXR_OStream : public Imf::OStream throw POV_EXCEPTION(kFileDataErr, "Error while writing EXR output"); } - Int64 tellp() + unsigned long tellp() { unsigned long pos = os.tellg(); if((int) pos == -1) @@ -113,9 +103,9 @@ class POV_EXR_OStream : public Imf::OStream return(pos); } - void seekp(Int64 pos) + void seekp(unsigned long pos) { - if(!os.seekg((unsigned long)pos)) + if(!os.seekg(pos)) throw POV_EXCEPTION(kFileDataErr, "Error when writing EXR output"); } private: @@ -147,7 +137,7 @@ class POV_EXR_IStream : public Imf::IStream return (is.tellg() < fsize); } - Int64 tellg() + unsigned long tellg() { unsigned long pos = is.tellg(); if((int)pos == -1) @@ -155,9 +145,9 @@ class POV_EXR_IStream : public Imf::IStream return pos; } - void seekg(Int64 pos) + void seekg(unsigned long pos) { - if(!is.seekg((unsigned long)pos)) + if(!is.seekg(pos)) throw POV_EXCEPTION(kFileDataErr, "Error while reading EXR file"); } private: @@ -282,7 +272,7 @@ void Write(OStream *file, const Image *image, const Image::WriteOptions& options comments += meta.getComment3() + "\n"; if (!meta.getComment4().empty()) comments += meta.getComment4() + "\n"; - + if (!comments.empty()) hdr.insert("comments",StringAttribute(comments.c_str())); diff --git a/unix/config/ax_check_openexr.m4 b/unix/config/ax_check_openexr.m4 index 69a2cb646..6c53f1952 100644 --- a/unix/config/ax_check_openexr.m4 +++ b/unix/config/ax_check_openexr.m4 @@ -8,7 +8,7 @@ # # LAST MODIFICATION # -# 2007-11-08 +# 2021-06-15 # # COPYLEFT # @@ -46,17 +46,11 @@ AC_DEFUN([AX_CHECK_OPENEXR], ax_check_openexr_save_cppflags="$CPPFLAGS" ax_check_openexr_save_libs="$LIBS" CPPFLAGS="$ax_check_openexr_cflags $CPPFLAGS" + LIBS="$ax_check_openexr_libs $LIBS" - # FIXME: workaround for versions >= 1.4.0 - AX_COMPARE_VERSION([$ax_check_openexr_version], [ge], [1.4], - [LIBS="$ax_check_openexr_libs -lIlmThread $LIBS"], - [LIBS="$ax_check_openexr_libs $LIBS"] - ) - - # check include file AC_CHECK_HEADER( [OpenEXR/ImfCRgbaFile.h], - [AC_CHECK_LIB([IlmImf], [ImfInputReadPixels], [], [ax_check_openexr="not found"])], + [ax_check_openexr="ok"], [ax_check_openexr="no headers"] ) fi From b17cf3cbe0d09f147e902e3f4ebd7fd7c3d58761 Mon Sep 17 00:00:00 2001 From: TonVanDenBroek Date: Thu, 8 Jul 2021 12:33:16 +1200 Subject: [PATCH 2/2] Some more modifications for openexr 3. --- source/base/image/openexr.cpp | 23 ++++++++++++++--------- windows/vs10/povbase.vcxproj | 10 +++++----- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/source/base/image/openexr.cpp b/source/base/image/openexr.cpp index f005cf3b6..808d6f0ba 100644 --- a/source/base/image/openexr.cpp +++ b/source/base/image/openexr.cpp @@ -68,6 +68,11 @@ using namespace Imath; /***************************************************************************** * Local preprocessor defines ******************************************************************************/ +#if (OPENEXR_VERSION_MAJOR < 3) + #define OPENEXR_INT64 Int64 +#else + #define OPENEXR_INT64 uint64_t +#endif /***************************************************************************** * Local typedefs @@ -95,17 +100,17 @@ class POV_EXR_OStream : public Imf::OStream throw POV_EXCEPTION(kFileDataErr, "Error while writing EXR output"); } - unsigned long tellp() + OPENEXR_INT64 tellp() { - unsigned long pos = os.tellg(); + POV_LONG pos = os.tellg(); if((int) pos == -1) throw POV_EXCEPTION(kFileDataErr, "Error while writing EXR output"); return(pos); } - void seekp(unsigned long pos) + void seekp(OPENEXR_INT64 pos) { - if(!os.seekg(pos)) + if(!os.seekg((POV_LONG)pos)) throw POV_EXCEPTION(kFileDataErr, "Error when writing EXR output"); } private: @@ -137,22 +142,22 @@ class POV_EXR_IStream : public Imf::IStream return (is.tellg() < fsize); } - unsigned long tellg() + OPENEXR_INT64 tellg() { - unsigned long pos = is.tellg(); + POV_LONG pos = is.tellg(); if((int)pos == -1) throw POV_EXCEPTION(kFileDataErr, "Error while reading EXR file"); return pos; } - void seekg(unsigned long pos) + void seekg(OPENEXR_INT64 pos) { - if(!is.seekg(pos)) + if(!is.seekg((POV_LONG)pos)) throw POV_EXCEPTION(kFileDataErr, "Error while reading EXR file"); } private: pov_base::IStream& is; - unsigned long fsize; + POV_LONG fsize; }; /***************************************************************************** diff --git a/windows/vs10/povbase.vcxproj b/windows/vs10/povbase.vcxproj index d46f1880a..f24ec74f4 100644 --- a/windows/vs10/povbase.vcxproj +++ b/windows/vs10/povbase.vcxproj @@ -119,7 +119,7 @@ Disabled true ..\..\libraries\ilmbase\config.windows;..\..\libraries\openexr\config.windows;..\..\libraries\openexr\IlmImf;..\..\libraries\ilmbase\Half;..\..\libraries\ilmbase\Imath;..\..\libraries\ilmbase\Iex;..\..\libraries\boost;..\..\vfe\win;..\..\vfe;..\..\source;..\..\source\base;..\..\source\backend;..\..\source\frontend;..\..\libraries\jpeg;..\..\libraries\zlib;..\..\libraries\png;..\..\libraries\tiff\libtiff;%(AdditionalIncludeDirectories) - BOOST_ALL_NO_LIB;NON_UNIX_OPENEXR_HEADERS;_DEBUG;WIN32;WIN32_LEAN_AND_MEAN;_WINDOWS;WINVER=0x0500;_WIN32_WINNT=0x0500;COMMONCTRL_VERSION=0x500;CLASSLIB_DEFS_H;NOMINMAX;ISOLATION_AWARE_ENABLED;_CRT_SECURE_NO_DEPRECATE;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) + BOOST_ALL_NO_LIB;_DEBUG;WIN32;WIN32_LEAN_AND_MEAN;_WINDOWS;WINVER=0x0500;_WIN32_WINNT=0x0500;COMMONCTRL_VERSION=0x500;CLASSLIB_DEFS_H;NOMINMAX;ISOLATION_AWARE_ENABLED;_CRT_SECURE_NO_DEPRECATE;_HAS_ITERATOR_DEBUGGING=0;%(PreprocessorDefinitions) true Sync Default @@ -165,7 +165,7 @@ Disabled true ..\..\libraries\ilmbase\config.windows;..\..\libraries\openexr\config.windows;..\..\libraries\openexr\IlmImf;..\..\libraries\ilmbase\Half;..\..\libraries\ilmbase\Imath;..\..\libraries\ilmbase\Iex;..\..\libraries\boost;..\..\vfe\win\;..\..\vfe\;..\..\source;..\..\source\base;..\..\source\backend;..\..\source\frontend;..\..\libraries\jpeg;..\..\libraries\zlib;..\..\libraries\png;..\..\libraries\tiff\libtiff;%(AdditionalIncludeDirectories) - BOOST_ALL_NO_LIB;NON_UNIX_OPENEXR_HEADERS;_DEBUG;WIN32;WIN32_LEAN_AND_MEAN;_WINDOWS;CLASSLIB_DEFS_H;NOMINMAX;ISOLATION_AWARE_ENABLED;_CRT_SECURE_NO_DEPRECATE;_HAS_ITERATOR_DEBUGGING=0;BUILDING_AMD64=1;%(PreprocessorDefinitions) + BOOST_ALL_NO_LIB;_DEBUG;WIN32;WIN32_LEAN_AND_MEAN;_WINDOWS;CLASSLIB_DEFS_H;NOMINMAX;ISOLATION_AWARE_ENABLED;_CRT_SECURE_NO_DEPRECATE;_HAS_ITERATOR_DEBUGGING=0;BUILDING_AMD64=1;%(PreprocessorDefinitions) true Sync Default @@ -212,7 +212,7 @@ false true ..\..\libraries\ilmbase\config.windows;..\..\libraries\openexr\config.windows;..\..\libraries\openexr\IlmImf;..\..\libraries\ilmbase\Half;..\..\libraries\ilmbase\Imath;..\..\libraries\ilmbase\Iex;..\..\libraries\boost;..\..\vfe\win;..\..\vfe;..\..\source;..\..\source\base;..\..\source\backend;..\..\source\frontend;..\..\libraries\jpeg;..\..\libraries\zlib;..\..\libraries\png;..\..\libraries\tiff\libtiff;%(AdditionalIncludeDirectories) - BOOST_ALL_NO_LIB;NON_UNIX_OPENEXR_HEADERS;NDEBUG;WIN32;WIN32_LEAN_AND_MEAN;_WINDOWS;COMMONCTRL_VERSION=0x500;CLASSLIB_DEFS_H;WINVER=0x0500;_WIN32_WINNT=0x0500;NOMINMAX;ISOLATION_AWARE_ENABLED;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;%(PreprocessorDefinitions) + BOOST_ALL_NO_LIB;NDEBUG;WIN32;WIN32_LEAN_AND_MEAN;_WINDOWS;COMMONCTRL_VERSION=0x500;CLASSLIB_DEFS_H;WINVER=0x0500;_WIN32_WINNT=0x0500;NOMINMAX;ISOLATION_AWARE_ENABLED;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;%(PreprocessorDefinitions) true Sync MultiThreaded @@ -262,7 +262,7 @@ false false ..\..\libraries\ilmbase\config.windows;..\..\libraries\openexr\config.windows;..\..\libraries\openexr\IlmImf;..\..\libraries\ilmbase\Half;..\..\libraries\ilmbase\Imath;..\..\libraries\ilmbase\Iex;..\..\libraries\boost;..\..\vfe\win\;..\..\vfe\;..\..\source;..\..\source\base;..\..\source\backend;..\..\source\frontend;..\..\libraries\jpeg;..\..\libraries\zlib;..\..\libraries\png;..\..\libraries\tiff\libtiff;%(AdditionalIncludeDirectories) - BOOST_ALL_NO_LIB;NON_UNIX_OPENEXR_HEADERS;NDEBUG;WIN32;WIN32_LEAN_AND_MEAN;_WINDOWS;CLASSLIB_DEFS_H;NOMINMAX;ISOLATION_AWARE_ENABLED;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;BUILDING_AMD64=1;%(PreprocessorDefinitions) + BOOST_ALL_NO_LIB;NDEBUG;WIN32;WIN32_LEAN_AND_MEAN;_WINDOWS;CLASSLIB_DEFS_H;NOMINMAX;ISOLATION_AWARE_ENABLED;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;BUILDING_AMD64=1;%(PreprocessorDefinitions) true Sync MultiThreaded @@ -309,7 +309,7 @@ false true ..\..\libraries\ilmbase\config.windows;..\..\libraries\openexr\config.windows;..\..\libraries\openexr\IlmImf;..\..\libraries\ilmbase\Half;..\..\libraries\ilmbase\Imath;..\..\libraries\ilmbase\Iex;..\..\libraries\boost;..\..\vfe\win\;..\..\vfe\;..\..\source;..\..\source\base;..\..\source\backend;..\..\source\frontend;..\..\libraries\jpeg;..\..\libraries\zlib;..\..\libraries\png;..\..\libraries\tiff\libtiff;%(AdditionalIncludeDirectories) - BOOST_ALL_NO_LIB;NON_UNIX_OPENEXR_HEADERS;NDEBUG;WIN32;WIN32_LEAN_AND_MEAN;_WINDOWS;COMMONCTRL_VERSION=0x500;CLASSLIB_DEFS_H;WINVER=0x0500;_WIN32_WINNT=0x0500;NOMINMAX;ISOLATION_AWARE_ENABLED;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;BUILD_SSE2=1;%(PreprocessorDefinitions) + BOOST_ALL_NO_LIB;NDEBUG;WIN32;WIN32_LEAN_AND_MEAN;_WINDOWS;COMMONCTRL_VERSION=0x500;CLASSLIB_DEFS_H;WINVER=0x0500;_WIN32_WINNT=0x0500;NOMINMAX;ISOLATION_AWARE_ENABLED;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;BUILD_SSE2=1;%(PreprocessorDefinitions) true Sync MultiThreaded