Ocean
Loading...
Searching...
No Matches
GLRendererView.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_PLATFORM_ANDROID_APPLICATION_GL_RENDERER_VIEW_H
9#define META_OCEAN_PLATFORM_ANDROID_APPLICATION_GL_RENDERER_VIEW_H
10
13
15
18
19namespace Ocean
20{
21
22namespace Platform
23{
24
25namespace Android
26{
27
28namespace Application
29{
30
31/**
32 * This class implements an OpenGLES-based view using the OpenGELESceneGraph renderer for Android platform applications.
33 * The main view is implemented as singleton object.
34 * @ingroup platformandroidapplication
35 */
36class OCEAN_PLATFORM_ANDROID_APPLICATION_EXPORT GLRendererView : public GLView
37{
38 public:
39
40 /**
41 * Initializes the view.
42 * @return True, if succeeded
43 */
44 bool initialize() override;
45
46 /**
47 * Releases the view.
48 * @return True, if succeeded
49 */
50 bool release() override;
51
52 /**
53 * Sets the horizontal field of view for this view.
54 * @param fovx Field of view to set in radian
55 * @return True, if succeeded
56 */
57 virtual bool setFovX(const Scalar fovx);
58
59 /**
60 * Sets the background color of this view.
61 * @param color Background color to set
62 * @return True, if succeeded
63 */
64 virtual bool setBackgroundColor(const RGBAColor& color);
65
66 /**
67 * View resize event function.
68 * @param width New view width, with range [1, infinity)
69 * @param height New view height, with range [1, infinity)
70 * @return True, if succeeded
71 */
72 bool resize(const int width, const int height) override;
73
74 /**
75 * Renders the next frame.
76 * @return True, if succeeded
77 */
78 bool render() override;
79
80 /**
81 * Sets whether the user can change the view's position and rotation by touch events.
82 * @param enabled True, to allow the interaction; False, to disable the interaction
83 */
84 virtual void setViewInteractionEnabled(const bool enabled);
85
86 /**
87 * Touch down event function.
88 * @param x Horizontal touch position
89 * @param y Vertical touch position
90 */
91 void onTouchDown(const float x, const float y) override;
92
93 /**
94 * Touch move event function.
95 * @param x Horizontal touch position
96 * @param y Vertical touch position
97 */
98 void onTouchMove(const float x, const float y) override;
99
100 /**
101 * Touch move event function.
102 * @param x Horizontal touch position
103 * @param y Vertical touch position
104 */
105 void onTouchUp(const float x, const float y) override;
106
107 /**
108 * Creates an instance of this object.
109 * @return The new instance
110 */
111 static inline GLView* createInstance();
112
113 protected:
114
115 /**
116 * Creates a new view object.
117 */
118 GLRendererView() = default;
119
120 /**
121 * Destructs a view object.
122 */
123 ~GLRendererView() override;
124
125 protected:
126
127 /// Rendering engine object.
129
130 /// Rendering framebuffer object.
132
133 /// Initial viewport width.
134 unsigned int initialViewportWidth_ = (unsigned int)(-1);
135
136 /// Initial viewport height.
137 unsigned int initialViewportHeight_ = (unsigned int)(-1);
138
139 /// Previous horizontal touch position.
140 float previousTouchX_ = -1.0f;
141
142 /// Previous vertical touch position.
143 float previousTouchY_ = -1.0f;
144
145 /// Rendering start timestamp.
147
148 /// Rendering iterations.
149 unsigned int renderingIterations_ = 0u;
150
151 /// State determining that the view's field of view has to be adjusted to the background's field of view.
152 bool adjustFovXToBackground_ = false;
153
154 /// True, to allow the user to change the view's position and rotation by touch events; False, to disable the user interaction.
155 bool viewInteractionEnabled_ = true;
156
157 /// View lock object.
158 mutable Lock lock_;
159};
160
165
166}
167
168}
169
170}
171
172}
173
174#endif // META_OCEAN_PLATFORM_ANDROID_APPLICATION_GL_RENDERER_VIEW_H
This class implements a recursive lock object.
Definition Lock.h:31
This class implements an OpenGLES-based view using the OpenGELESceneGraph renderer for Android platfo...
Definition GLRendererView.h:37
virtual bool setBackgroundColor(const RGBAColor &color)
Sets the background color of this view.
bool render() override
Renders the next frame.
static GLView * createInstance()
Creates an instance of this object.
Definition GLRendererView.h:161
Rendering::EngineRef engine_
Rendering engine object.
Definition GLRendererView.h:128
bool resize(const int width, const int height) override
View resize event function.
void onTouchMove(const float x, const float y) override
Touch move event function.
GLRendererView()=default
Creates a new view object.
void onTouchUp(const float x, const float y) override
Touch move event function.
bool initialize() override
Initializes the view.
void onTouchDown(const float x, const float y) override
Touch down event function.
Timestamp renderingStartTimestamp_
Rendering start timestamp.
Definition GLRendererView.h:146
Rendering::FramebufferRef framebuffer_
Rendering framebuffer object.
Definition GLRendererView.h:131
virtual void setViewInteractionEnabled(const bool enabled)
Sets whether the user can change the view's position and rotation by touch events.
Lock lock_
View lock object.
Definition GLRendererView.h:158
virtual bool setFovX(const Scalar fovx)
Sets the horizontal field of view for this view.
~GLRendererView() override
Destructs a view object.
This class implements the base class for all OpenGL-ES-based views.
Definition GLView.h:33
This class implements a color defined by red, green, blue and alpha parameters.
Definition RGBAColor.h:41
This class implements a timestamp.
Definition Timestamp.h:36
float Scalar
Definition of a scalar type.
Definition Math.h:129
The namespace covering the entire Ocean framework.
Definition Accessor.h:15