Visual Computing Library  devel
Loading...
Searching...
No Matches
texture_descriptor.h
1/*****************************************************************************
2 * VCLib *
3 * Visual Computing Library *
4 * *
5 * Copyright(C) 2021-2025 *
6 * Visual Computing Lab *
7 * ISTI - Italian National Research Council *
8 * *
9 * All rights reserved. *
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the Mozilla Public License Version 2.0 as published *
13 * by the Mozilla Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * Mozilla Public License Version 2.0 *
20 * (https://www.mozilla.org/en-US/MPL/2.0/) for more details. *
21 ****************************************************************************/
22
23#ifndef VCL_SPACE_CORE_TEXTURE_DESCRIPTOR_H
24#define VCL_SPACE_CORE_TEXTURE_DESCRIPTOR_H
25
26#include <vclib/base.h>
27
28namespace vcl {
29
42{
43public:
63
71 NONE = -1,
72 NEAREST = 9728,
73 LINEAR
74 };
75
81 enum class WrapMode {
82 REPEAT = 10497,
83 CLAMP_TO_EDGE = 33071,
85 MIRRORED_REPEAT = 33648
86 };
87
88private:
89 std::string mPath;
98
99public:
105
113 TextureDescriptor(const std::string& path) : mPath(path) {}
114
120 bool isNull() const { return mPath.empty(); }
121
126 const std::string& path() const { return mPath; }
127
132 std::string& path() { return mPath; }
133
139
146
152
159
164 WrapMode wrapU() const { return mWrapU; }
165
171 WrapMode& wrapU() { return mWrapU; }
172
177 WrapMode wrapV() const { return mWrapV; }
178
184 WrapMode& wrapV() { return mWrapV; }
185
190 void serialize(std::ostream& os) const
191 {
192 vcl::serialize(os, mPath);
193 vcl::serialize(os, mMinFilter, mMagFilter, mWrapU, mWrapV);
194 }
195
200 void deserialize(std::istream& is)
201 {
202 vcl::deserialize(is, mPath);
203 vcl::deserialize(is, mMinFilter, mMagFilter, mWrapU, mWrapV);
204 }
205
211 bool operator==(const TextureDescriptor& other) const = default;
212};
213
214/* Concepts */
215
226template<typename T>
228 std::derived_from<std::remove_cvref_t<T>, TextureDescriptor>;
229
230} // namespace vcl
231
232#endif // VCL_SPACE_CORE_TEXTURE_DESCRIPTOR_H
A class representing a box in N-dimensional space.
Definition box.h:46
Describes the properties of a texture, such as its source path and rendering parameters.
Definition texture_descriptor.h:42
MinificationFilter & minFilter()
Gets a mutable reference to the minification filter of the texture.
Definition texture_descriptor.h:145
void serialize(std::ostream &os) const
Serializes the TextureDescriptor to an output stream.
Definition texture_descriptor.h:190
WrapMode mWrapV
The wrap mode for the V (T) texture coordinate.
Definition texture_descriptor.h:96
MinificationFilter mMinFilter
The minification filter mode.
Definition texture_descriptor.h:90
void deserialize(std::istream &is)
Deserializes the TextureDescriptor from an input stream.
Definition texture_descriptor.h:200
std::string mPath
The file path to the texture source.
Definition texture_descriptor.h:89
TextureDescriptor(const std::string &path)
Constructs a TextureDescriptor from a file path.
Definition texture_descriptor.h:113
TextureDescriptor()
Default constructor. Initializes with an empty path and default filter/wrap modes.
Definition texture_descriptor.h:104
MagnificationFilter magFilter() const
Gets the magnification filter of the texture.
Definition texture_descriptor.h:151
MinificationFilter minFilter() const
Gets the minification filter of the texture.
Definition texture_descriptor.h:138
WrapMode & wrapV()
Gets a mutable reference to the wrap mode for the V (T) texture coordinate.
Definition texture_descriptor.h:184
std::string & path()
Gets a mutable reference to the file path of the texture.
Definition texture_descriptor.h:132
MinificationFilter
Defines the texture minification filter modes, following the glTF 2.0 specification....
Definition texture_descriptor.h:50
@ NEAREST_MIPMAP_NEAREST
Nearest neighbor filtering with the nearest mipmap level.
@ NEAREST
Nearest neighbor filtering.
WrapMode & wrapU()
Gets a mutable reference to the wrap mode for the U (S) texture coordinate.
Definition texture_descriptor.h:171
MagnificationFilter
Defines the texture magnification filter modes, following the glTF 2.0 specification....
Definition texture_descriptor.h:70
WrapMode wrapU() const
Gets the wrap mode for the U (S) texture coordinate.
Definition texture_descriptor.h:164
MagnificationFilter & magFilter()
Gets a mutable reference to the magnification filter of the texture.
Definition texture_descriptor.h:158
const std::string & path() const
Gets the file path of the texture.
Definition texture_descriptor.h:126
bool isNull() const
Checks whether the texture descriptor is null (i.e., has an empty path).
Definition texture_descriptor.h:120
WrapMode mWrapU
The wrap mode for the U (S) texture coordinate.
Definition texture_descriptor.h:94
MagnificationFilter mMagFilter
The magnification filter mode.
Definition texture_descriptor.h:92
bool operator==(const TextureDescriptor &other) const =default
Compares this TextureDescriptor with another for equality.
WrapMode
Defines the texture wrapping modes for S (U) and T (V) coordinates, following the glTF 2....
Definition texture_descriptor.h:81
@ REPEAT
The texture repeats.
@ MIRRORED_REPEAT
The texture repeats in a mirrored fashion.
WrapMode wrapV() const
Gets the wrap mode for the V (T) texture coordinate.
Definition texture_descriptor.h:177
A concept representing a TextureDescriptor.
Definition texture_descriptor.h:227