Visual Computing Library  devel
Loading...
Searching...
No Matches
texture.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_H
24#define VCL_SPACE_CORE_TEXTURE_H
25
26#include "image.h"
27
28#include <vclib/base.h>
29
30namespace vcl {
31
33{
34 Image mImg;
35 std::string mPath;
36
37public:
38 Texture() {}
39
45 Texture(const std::string& path) : mPath(path) {}
46
53 Texture(const Image& img, const std::string& path) : mImg(img), mPath(path)
54 {
55 }
56
63 Texture(Image&& img, const std::string& path) :
64 mImg(std::move(img)), mPath(path)
65 {
66 }
67
73 const std::string& path() const { return mPath; }
74
80 std::string& path() { return mPath; }
81
87 const Image& image() const { return mImg; }
88
94 Image& image() { return mImg; }
95
96 void serialize(std::ostream& os) const
97 {
98 vcl::serialize(os, mPath);
99 mImg.serialize(os);
100 }
101
102 void deserialize(std::istream& is)
103 {
104 vcl::deserialize(is, mPath);
105 mImg.deserialize(is);
106 }
107};
108
109/* Concepts */
110
121template<typename T>
122concept TextureConcept = std::derived_from<std::remove_cvref_t<T>, Texture>;
123
124} // namespace vcl
125
126#endif // VCL_SPACE_CORE_TEXTURE_H
A class representing a box in N-dimensional space.
Definition box.h:46
The Image class stores an Image in 4 bytes RGBA format.
Definition image.h:44
Definition texture.h:33
Texture(const std::string &path)
Load a texture from a file.
Definition texture.h:45
Texture(Image &&img, const std::string &path)
Creates a Texture object, with the given image and its path.
Definition texture.h:63
std::string & path()
Get the path of the texture.
Definition texture.h:80
const Image & image() const
Get the image of the texture.
Definition texture.h:87
Texture(const Image &img, const std::string &path)
Creates a Texture object, with the given image and its path.
Definition texture.h:53
const std::string & path() const
Get the path of the texture.
Definition texture.h:73
Image & image()
Get the image of the texture.
Definition texture.h:94
A concept representing a Texture.
Definition texture.h:122