Ocean
GLESAttribute.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_GLES_ATTRIBUTE_H
9 #define META_OCEAN_RENDERING_GLES_ATTRIBUTE_H
10 
13 
15 
16 namespace Ocean
17 {
18 
19 namespace Rendering
20 {
21 
22 namespace GLESceneGraph
23 {
24 
25 // Forward declaration.
26 class GLESFramebuffer;
27 class GLESShaderProgram;
28 
29 /**
30  * This class wraps a GLESceneGraph attribute object.
31  * @ingroup renderinggles
32  */
33 class OCEAN_RENDERING_GLES_EXPORT GLESAttribute :
34  virtual public GLESObject,
35  virtual public Attribute
36 {
37  public:
38 
39  /**
40  * Definition of different shader functionalities.
41  */
42  enum ProgramType : uint32_t
43  {
44  /// Not specified shader program.
45  PT_UNKNOWN = 0u,
46  /// Shader using a static color.
47  PT_STATIC_COLOR = (1u << 0u),
48  /// Shader using a static color and rendering points.
49  PT_POINTS = (1u << 1u),
50  /// Shader using a default gray material color.
51  PI_DEBUG_GRAY = (1u << 2u),
52  /// Shader using material.
53  PT_MATERIAL = (1u << 3u),
54  /// Shader using light.
55  PT_LIGHT = (1u << 4u),
56  /// Shader using one lower left oriented texture.
57  PT_TEXTURE_LOWER_LEFT = (1u << 5u),
58  /// Shader using one upper left oriented texture.
59  PT_TEXTURE_UPPER_LEFT = (1u << 6u),
60  /// Shader using one Y texture.
61  PT_TEXTURE_Y = (1u << 7u),
62  /// Shader using one RGBA texture.
63  PT_TEXTURE_RGBA = (1u << 8u),
64  /// Shader using one BGRA texture.
65  PT_TEXTURE_BGRA = (1u << 9u),
66  /// Shader using one YUV24 texture.
67  PT_TEXTURE_YUV24 = (1u << 10u),
68  /// Shader using one YVU24 texture.
69  PT_TEXTURE_YVU24 = (1u << 11u),
70  /// Shader using one Y_UV12 texture.
71  PT_TEXTURE_Y_UV12 = (1u << 12u),
72  /// Shader using one Y_VU12 texture.
73  PT_TEXTURE_Y_VU12 = (1u << 13u),
74  /// Shader using one Y_U_V12 texture.
75  PT_TEXTURE_Y_U_V12 = (1u << 14u),
76  /// Shader using multiple textures only.
77  PT_TEXTURES = (1u << 15u),
78  /// Shader for phantom objects using video see-through Augmented Reality.
79  PT_PHANTOM_VIDEO_FAST = (1u << 16u),
80  /// Shader for phantom video textures used in video see-through Augmented Reality.
81  PT_PHANTOM_VIDEO_TEXTURE_COORDINATES_FAST = (1u << 17u),
82  /// Shader for text using a transparent grayscale texture.
83  PT_TEXT_TRANSPARENT_Y = (1u << 18u),
84  /// Shader for text using an opaque grayscale texture.
85  PT_TEXT_OPAQUE_Y = (1u << 19u),
86  /// Shader for color ids.
87  PT_COLOR_ID = (1u << 20u),
88  /// Shader waiting for more specific information.
89  PT_PENDING = (1u << 21u),
90  /// The shader is a custom shader.
91  PT_CUSTOM = (1u << 22u)
92  };
93 
94  public:
95 
96  /**
97  * Binds this attribute.
98  * @param framebuffer Framebuffer initiated the rendering process
99  * @param shaderProgram Shader program to be applied
100  */
101  virtual void bindAttribute(const GLESFramebuffer& framebuffer, GLESShaderProgram& shaderProgram) = 0;
102 
103  /**
104  * Unbinds this attribute.
105  */
106  virtual void unbindAttribute();
107 
108  /**
109  * Returns the shader type necessary to render an object with this attribute.
110  * @return Shader program type
111  */
112  virtual ProgramType necessaryShader() const;
113 
114  /**
115  * Translates the program value type into a string containing the individual sub program type.
116  * @param type The program type(s) to translate
117  * @return The program type as string
118  */
119  static std::string translateProgramType(const GLESAttribute::ProgramType type);
120 
121  protected:
122 
123  /**
124  * Creates a new GLESceneGraph attribute object.
125  */
127 
128  /**
129  * Destructs a GLESceneGraph attribute object.
130  */
131  ~GLESAttribute() override;
132 };
133 
134 }
135 
136 }
137 
138 }
139 
140 #endif // META_OCEAN_RENDERING_GLES_ATTRIBUTE_H
This class is the base class for all rendering attribute objects.
Definition: Attribute.h:39
This class wraps a GLESceneGraph attribute object.
Definition: GLESAttribute.h:36
static std::string translateProgramType(const GLESAttribute::ProgramType type)
Translates the program value type into a string containing the individual sub program type.
virtual ProgramType necessaryShader() const
Returns the shader type necessary to render an object with this attribute.
~GLESAttribute() override
Destructs a GLESceneGraph attribute object.
ProgramType
Definition of different shader functionalities.
Definition: GLESAttribute.h:43
virtual void bindAttribute(const GLESFramebuffer &framebuffer, GLESShaderProgram &shaderProgram)=0
Binds this attribute.
GLESAttribute()
Creates a new GLESceneGraph attribute object.
virtual void unbindAttribute()
Unbinds this attribute.
This class implements a base for all GLESceneGraph framebuffers.
Definition: rendering/glescenegraph/GLESFramebuffer.h:34
This class is the base class for all GLESceneGraph objects.
Definition: GLESObject.h:57
This class implements a container for an OpenGL ES shader program.
Definition: GLESShaderProgram.h:53
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15