1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#pragma once
#include <OpenImageIO/texture.h>
#include <rust/cxx.h>
#include <memory>
namespace oiio {
using TextureSystem = OIIO::TextureSystem;
using TextureHandle = OIIO::TextureSystem::TextureHandle;
struct TextureLookupOptions;
// A texture system, sharing the process-wide one or private to this caller.
std::shared_ptr<TextureSystem>
texturesystem_create(bool shared);
// A filtered lookup. The derivatives describe how far the texture coordinate
// moves per pixel, which is what lets OpenImageIO pick a mip level and filter
// width; passing zeros asks for a point sample of the highest resolution.
//
// `result` receives one value per channel and must be exactly nchannels long.
//
// A non-empty `missing_color` (at least one value per result channel) makes
// a missing or broken texture fill the result with it and succeed, which is
// OpenImageIO's own missingcolor contract; empty means missing files error.
bool
texturesystem_texture(TextureSystem& texturesystem, const rust::Str filename,
const TextureLookupOptions& options,
rust::Slice<const float> missing_color, float s, float t,
float dsdx, float dtdx, float dsdy, float dtdy,
rust::Slice<float> result, rust::String& error);
// An environment lookup by direction vector; the guards, the fill of the
// channels past the file's, and the missing-color contract are the plain
// texture lookup's.
bool
texturesystem_environment(TextureSystem& texturesystem,
const rust::Str filename,
const TextureLookupOptions& options,
rust::Slice<const float> missing_color, float r_x,
float r_y, float r_z, float drdx_x, float drdx_y,
float drdx_z, float drdy_x, float drdy_y,
float drdy_z, rust::Slice<float> result,
rust::String& error);
// The handle path: resolve a name once, look up many times without the
// per-call name hash. The handle points into state the texture system owns
// and stays valid until the file is invalidated. Both lookups carry the
// same bounds checks and missing-color contract as their by-name twins.
TextureHandle*
texturesystem_get_texture_handle(TextureSystem& texturesystem,
const rust::Str filename);
bool
texturesystem_handle_good(TextureSystem& texturesystem, TextureHandle* handle);
// Whether the handle's file really exists and is readable; good() alone is
// only the broken flag, which a never-opened missing file has not earned.
bool
texturesystem_handle_exists(TextureSystem& texturesystem,
TextureHandle* handle);
rust::String
texturesystem_handle_filename(TextureSystem& texturesystem,
TextureHandle* handle);
bool
texturesystem_texture_by_handle(TextureSystem& texturesystem,
TextureHandle* handle,
const TextureLookupOptions& options,
rust::Slice<const float> missing_color,
float s, float t, float dsdx, float dtdx,
float dsdy, float dtdy,
rust::Slice<float> result,
rust::String& error);
bool
texturesystem_environment_by_handle(TextureSystem& texturesystem,
TextureHandle* handle,
const TextureLookupOptions& options,
rust::Slice<const float> missing_color,
float r_x, float r_y, float r_z,
float drdx_x, float drdx_y, float drdx_z,
float drdy_x, float drdy_y, float drdy_z,
rust::Slice<float> result,
rust::String& error);
// Whether the name is a UDIM pattern such as "tex.<UDIM>.exr".
bool
texturesystem_is_udim(TextureSystem& texturesystem, const rust::Str filename);
// The concrete tile file a UDIM pattern and texture coordinates refer to,
// or an empty string when that tile is unpopulated. The TextureHandle the
// resolution produces never crosses the bridge; it is turned back into a
// filename here.
rust::String
texturesystem_resolve_udim(TextureSystem& texturesystem,
const rust::Str pattern, float s, float t);
// Every concrete file of a UDIM set, indexed as utile + vtile * nutiles,
// with empty strings for unpopulated tiles.
void
texturesystem_inventory_udim(TextureSystem& texturesystem,
const rust::Str pattern,
rust::Vec<rust::String>& filenames, int& nutiles,
int& nvtiles);
rust::String
texturesystem_geterror(TextureSystem& texturesystem);
bool
texturesystem_attribute_int(TextureSystem& texturesystem, const rust::Str name,
int value);
bool
texturesystem_attribute_float(TextureSystem& texturesystem,
const rust::Str name, float value);
rust::String
texturesystem_getstats(const TextureSystem& texturesystem, int level);
void
texturesystem_invalidate(TextureSystem& texturesystem, const rust::Str filename,
bool force);
void
texturesystem_invalidate_all(TextureSystem& texturesystem, bool force);
// Resolution of the texture, as the texture system sees it. Zero when the
// file cannot be read.
bool
texturesystem_resolution(TextureSystem& texturesystem, const rust::Str filename,
rust::Slice<int> resolution);
} // namespace oiio