Skip to content

Commit 91aee90

Browse files
committed
openexr upgrade from 2.0 to 3.0
1 parent 6b96a1b commit 91aee90

File tree

5 files changed

+139
-172
lines changed

5 files changed

+139
-172
lines changed

src/nbl/CMakeLists.txt

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -496,29 +496,36 @@ endif()
496496
target_include_directories(Nabla PUBLIC ${THIRD_PARTY_SOURCE_DIR}/libpng)
497497
# OpenEXR
498498
if (_NBL_COMPILE_WITH_OPEN_EXR_)
499-
add_dependencies(Nabla OpenEXR)
500-
if(NBL_STATIC_BUILD)
501-
target_link_libraries(Nabla INTERFACE OpenEXR)
502-
else()
503-
target_link_libraries(Nabla PRIVATE OpenEXR)
504-
endif()
505-
506-
target_include_directories(
507-
Nabla PUBLIC $<TARGET_PROPERTY:OpenEXR,INCLUDE_DIRECTORIES>
508-
)
499+
add_dependencies(Nabla OpenEXR)
500+
if(NBL_STATIC_BUILD)
501+
target_link_libraries(Nabla INTERFACE OpenEXR)
502+
else()
503+
target_link_libraries(Nabla PRIVATE OpenEXR)
504+
endif()
505+
506+
target_include_directories(
507+
Nabla PUBLIC $<TARGET_PROPERTY:OpenEXR,INCLUDE_DIRECTORIES>
508+
)
509+
endif()
510+
511+
add_dependencies(Nabla OpenEXRCore OpenEXRUtil)
512+
if(NBL_STATIC_BUILD)
513+
target_link_libraries(Nabla INTERFACE
514+
OpenEXRCore
515+
OpenEXRUtil
516+
)
509517
else()
510-
add_dependencies(Nabla OpenEXRCore)
511-
if(NBL_STATIC_BUILD)
512-
target_link_libraries(Nabla INTERFACE OpenEXRCore)
513-
else()
514-
target_link_libraries(Nabla PRIVATE OpenEXRCore)
515-
endif()
516-
517-
target_include_directories(
518-
Nabla PUBLIC $<TARGET_PROPERTY:OpenEXRCore,INCLUDE_DIRECTORIES> # for OpenEXR's Half-only dependency
519-
)
518+
target_link_libraries(Nabla PRIVATE
519+
OpenEXRCore
520+
OpenEXRUtil
521+
)
520522
endif()
521523

524+
target_include_directories(
525+
Nabla PUBLIC $<TARGET_PROPERTY:OpenEXRCore,INCLUDE_DIRECTORIES> # for OpenEXR's core headers
526+
Nabla PUBLIC $<TARGET_PROPERTY:OpenEXRUtil,INCLUDE_DIRECTORIES> # for OpenEXR's util headers
527+
)
528+
522529
# GLI
523530
if(_NBL_COMPILE_WITH_GLI_)
524531
add_dependencies(Nabla gli)

src/nbl/asset/interchange/CImageLoaderOpenEXR.cpp

Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,7 @@
1-
/*
2-
MIT License
3-
Copyright (c) 2019 AnastaZIuk
4-
Permission is hereby granted, free of charge, to any person obtaining a copy
5-
of this software and associated documentation files (the "Software"), to deal
6-
in the Software without restriction, including without limitation the rights
7-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8-
copies of the Software, and to permit persons to whom the Software is
9-
furnished to do so, subject to the following conditions:
10-
The above copyright notice and this permission notice shall be included in all
11-
copies or substantial portions of the Software.
12-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18-
SOFTWARE.
19-
*/
20-
#if 0 // oldie
1+
// Copyright (C) 2023 - DevSH Graphics Programming Sp. z O.O.
2+
// This file is part of the "Nabla Engine".
3+
// For conditions of distribution and use, see copyright notice in nabla.h
4+
215

226
#include <algorithm>
237
#include <iostream>
@@ -33,16 +17,15 @@ SOFTWARE.
3317

3418
#include "CImageLoaderOpenEXR.h"
3519

36-
#include "openexr/IlmBase/Imath/ImathBox.h"
37-
#include "openexr/OpenEXR/IlmImf/ImfRgbaFile.h"
38-
#include "openexr/OpenEXR/IlmImf/ImfInputFile.h"
39-
#include "openexr/OpenEXR/IlmImf/ImfChannelList.h"
40-
#include "openexr/OpenEXR/IlmImf/ImfChannelListAttribute.h"
41-
#include "openexr/OpenEXR/IlmImf/ImfStringAttribute.h"
42-
#include "openexr/OpenEXR/IlmImf/ImfMatrixAttribute.h"
43-
#include "openexr/OpenEXR/IlmImf/ImfArray.h"
20+
#include "ImfRgbaFile.h"
21+
#include "ImfInputFile.h"
22+
#include "ImfChannelList.h"
23+
#include "ImfChannelListAttribute.h"
24+
#include "ImfStringAttribute.h"
25+
#include "ImfMatrixAttribute.h"
26+
#include "ImfArray.h"
4427

45-
#include "openexr/OpenEXR/IlmImf/ImfNamespace.h"
28+
#include "ImfNamespace.h"
4629
namespace IMF = Imf;
4730
namespace IMATH = Imath;
4831

@@ -86,17 +69,17 @@ class nblIStream : public IMF::IStream
8669
// read the first byte in the file, tellg() returns 0.
8770
//--------------------------------------------------------
8871

89-
virtual IMF::Int64 tellg() override
72+
virtual uint64_t tellg() override
9073
{
91-
return static_cast<IMF::Int64>(fileOffset);
74+
return static_cast<uint64_t>(fileOffset);
9275
}
9376

9477
//-------------------------------------------
9578
// Set the current reading position.
9679
// After calling seekg(i), tellg() returns i.
9780
//-------------------------------------------
9881

99-
virtual void seekg(IMF::Int64 pos) override
82+
virtual void seekg(uint64_t pos) override
10083
{
10184
fileOffset = static_cast<decltype(fileOffset)>(pos);
10285
}
@@ -409,6 +392,11 @@ SAssetBundle CImageLoaderOpenEXR::loadAsset(system::IFile* _file, const asset::I
409392
return SAssetBundle(std::move(meta),std::move(images));
410393
}
411394

395+
bool isImfMagic(char* b)
396+
{
397+
return b[0] == 0x76 && b[1] == 0x2f && b[2] == 0x31 && b[3] == 0x01;
398+
}
399+
412400
bool CImageLoaderOpenEXR::isALoadableFileFormat(system::IFile* _file, const system::logger_opt_ptr logger) const
413401
{
414402
char magicNumberBuffer[sizeof(SContext::magicNumber)];
@@ -609,5 +597,4 @@ bool readHeader(IMF::IStream* nblIStream, SContext& ctx)
609597
}
610598

611599

612-
#endif // _NBL_COMPILE_WITH_OPENEXR_LOADER_
613-
#endif
600+
#endif // _NBL_COMPILE_WITH_OPENEXR_LOADER_

src/nbl/asset/interchange/CImageLoaderOpenEXR.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ class CImageLoaderOpenEXR final : public IImageLoader
2525
public:
2626
CImageLoaderOpenEXR(IAssetManager* _manager) : m_manager(_manager) {}
2727

28-
bool isALoadableFileFormat(system::IFile* _file, const system::logger_opt_ptr logger) const override
29-
{
30-
return false; // TODO: Nahim, implement in cpp file please
31-
}
28+
bool isALoadableFileFormat(system::IFile* _file, const system::logger_opt_ptr logger) const override;
3229

3330
const char** getAssociatedFileExtensions() const override
3431
{
@@ -38,10 +35,7 @@ class CImageLoaderOpenEXR final : public IImageLoader
3835

3936
uint64_t getSupportedAssetTypesBitfield() const override { return asset::IAsset::ET_IMAGE; }
4037

41-
asset::SAssetBundle loadAsset(system::IFile* _file, const asset::IAssetLoader::SAssetLoadParams& _params, asset::IAssetLoader::IAssetLoaderOverride* _override = nullptr, uint32_t _hierarchyLevel = 0u) override
42-
{
43-
return {}; // TODO: Nahim, implement in cpp file please
44-
}
38+
asset::SAssetBundle loadAsset(system::IFile* _file, const asset::IAssetLoader::SAssetLoadParams& _params, asset::IAssetLoader::IAssetLoaderOverride* _override = nullptr, uint32_t _hierarchyLevel = 0u) override;
4539

4640
private:
4741

0 commit comments

Comments
 (0)