GameApi 28
Library used by GameApi Builder tool
Loading...
Searching...
No Matches
texture_library.h
Go to the documentation of this file.
1// Copyright 2019 The Draco Authors.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15#ifndef DRACO_TEXTURE_TEXTURE_LIBRARY_H_
16#define DRACO_TEXTURE_TEXTURE_LIBRARY_H_
17
19
20#ifdef DRACO_TRANSCODER_SUPPORTED
21#include <memory>
22#include <unordered_map>
23#include <vector>
24
26
27namespace draco {
28
29// Container class for storing draco::Texture objects in an indexed list.
30class TextureLibrary {
31 public:
32 // Copies textures from the source library to this library. Order of the
33 // copied textures is preserved.
34 void Copy(const TextureLibrary &src);
35
36 // Appends all textures from the source library to this library. All textures
37 // are copied over.
38 void Append(const TextureLibrary &src);
39
40 // Removes all textures from the library.
41 void Clear();
42
43 // Pushes a new texture into the library. Returns an index of the newly
44 // inserted texture.
45 int PushTexture(std::unique_ptr<Texture> texture);
46
47 size_t NumTextures() const { return textures_.size(); }
48
49 Texture *GetTexture(int index) { return textures_[index].get(); }
50 const Texture *GetTexture(int index) const { return textures_[index].get(); }
51
52 // Returns a map from texture pointer to texture index for all textures.
53 std::unordered_map<const Texture *, int> ComputeTextureToIndexMap() const;
54
55 // Removes and returns a texture from the library. The returned texture can be
56 // either used by the caller or ignored in which case it would be
57 // automatically deleted.
58 std::unique_ptr<Texture> RemoveTexture(int index);
59
60 private:
61 std::vector<std::unique_ptr<Texture>> textures_;
62};
63
64} // namespace draco
65
66#endif // DRACO_TRANSCODER_SUPPORTED
67#endif // DRACO_TEXTURE_TEXTURE_LIBRARY_H_
tag src
Definition meshpage.php:1786
Definition attribute_octahedron_transform.cc:21