Ocean
Loading...
Searching...
No Matches
Textures.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#ifndef META_OCEAN_RENDERING_TEXTURES_H
9#define META_OCEAN_RENDERING_TEXTURES_H
10
15
16#include <vector>
17
18namespace Ocean
19{
20
21namespace Rendering
22{
23
24// Forward declaration
25class Textures;
26
27/**
28 * Definition of a smart object reference holding a textures.
29 * @see SmartObjectRef, Textures.
30 * @ingroup rendering
31 */
33
34/**
35 * This class is the base class for all textures objects.
36 * @ingroup rendering
37 */
38class OCEAN_RENDERING_EXPORT Textures : virtual public Attribute
39{
40 public:
41
42 /**
43 * Definition of a vector holding textures.
44 */
45 typedef std::vector<TextureRef> TextureObjects;
46
47 public:
48
49 /**
50 * Returns the texture for a specified texture layer.
51 * @param layerIndex Index of the texture layer to return the texture for
52 * @return Specified texture object
53 */
54 virtual TextureRef texture(const unsigned int layerIndex) const;
55
56 /**
57 * Returns the number of specified texture layers.
58 * @return Number of texture layers
59 */
60 inline unsigned int numberTextures() const;
61
62 /**
63 * Sets the texture for a specified texture layer.
64 * @param texture Texture for the defined texture layer
65 * @param layerIndex Index of the texture layer to set the texture attribute for
66 */
67 virtual void setTexture(const TextureRef& texture, const unsigned int layerIndex);
68
69 /**
70 * Adds a texture at the next free position of the texture layer.
71 * @param texture Texture to add
72 */
73 virtual void addTexture(const TextureRef& texture);
74
75 /**
76 * Returns whether at least one texture has at least one alpha pixel.
77 * @return True, if so
78 */
79 virtual bool hasAlphaTexture() const;
80
81 /**
82 * Returns the type of this object.
83 * @see Object::type().
84 */
85 ObjectType type() const override;
86
87 protected:
88
89 /**
90 * Creates a new textures object.
91 */
93
94 /**
95 * Destructs a textures object.
96 */
97 ~Textures() override;
98
99 protected:
100
101 /// Vector holding texture objects.
103};
104
105inline unsigned int Textures::numberTextures() const
106{
107 return (unsigned int)(textures.size());
108}
109
110}
111
112}
113
114#endif // META_OCEAN_RENDERING_TEXTURES_H
This class is the base class for all rendering attribute objects.
Definition Attribute.h:39
ObjectType
Definition of different object type.
Definition Object.h:63
This class implements a smart rendering object reference.
Definition rendering/ObjectRef.h:34
This class is the base class for all textures objects.
Definition Textures.h:39
virtual bool hasAlphaTexture() const
Returns whether at least one texture has at least one alpha pixel.
~Textures() override
Destructs a textures object.
std::vector< TextureRef > TextureObjects
Definition of a vector holding textures.
Definition Textures.h:45
ObjectType type() const override
Returns the type of this object.
Textures()
Creates a new textures object.
virtual void setTexture(const TextureRef &texture, const unsigned int layerIndex)
Sets the texture for a specified texture layer.
virtual TextureRef texture(const unsigned int layerIndex) const
Returns the texture for a specified texture layer.
virtual void addTexture(const TextureRef &texture)
Adds a texture at the next free position of the texture layer.
TextureObjects textures
Vector holding texture objects.
Definition Textures.h:102
unsigned int numberTextures() const
Returns the number of specified texture layers.
Definition Textures.h:105
SmartObjectRef< Textures > TexturesRef
Definition of a smart object reference holding a textures.
Definition Textures.h:32
The namespace covering the entire Ocean framework.
Definition Accessor.h:15