background_renderer.h
Go to the documentation of this file.
1 /*
2  * Copyright 2018 Google Inc. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef C_ARCORE_AUGMENTED_IMAGE_BACKGROUND_RENDERER_H_
18 #define C_ARCORE_AUGMENTED_IMAGE_BACKGROUND_RENDERER_H_
19 
20 #ifdef __ANDROID__
21 #include <GLES2/gl2.h>
22 #include <GLES2/gl2ext.h>
23 #else // __APPLE__
24 #include <OpenGLES/ES2/gl.h>
25 #include <OpenGLES/ES2/glext.h>
26 #endif
27 #include <cstdlib>
28 
29 #include "util.h"
30 
31 static const GLfloat BackgroundRenderer_kVertices[] = {
32  -1.0f, -1.0f, +1.0f, -1.0f, -1.0f, +1.0f, +1.0f, +1.0f,
33 };
34 static const GLfloat BackgroundRenderer_kTexCoord[] = {
35  1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
36 };
37 
38 //android phone
39 //11 10 01 00 // portrait
40 //01 11 00 10 // left
41 //10 00 11 01 // right
42 //00 01 10 11 // down
43 
44 
45 // This class renders the passthrough camera image into the OpenGL frame.
47 public:
48  // Positions of the quad vertices in clip space (X, Y).
49 
50  static constexpr int kNumVertices = 4;
51 
52  public:
53  BackgroundRenderer() = default;
55 
56  // Sets up OpenGL state. Must be called on the OpenGL thread and before any
57  // other methods below.
58  void InitializeGlContent(GLuint textureId, bool oes);
59 
60  // Draws the background image. This methods must be called for every ArFrame
61  // returned by ArSession_update() to catch display geometry change events.
62  void Draw(const float * transformed_uvs, const GLuint & depthTexture, int screenWidth, int screenHeight, bool redUnknown);
63 
64 private:
65  static std::vector<GLuint> shaderPrograms_;
67  bool oes_ = false;
68 };
69 
70 #endif // C_ARCORE_AUGMENTED_IMAGE_BACKGROUND_RENDERER_H_
static std::vector< GLuint > shaderPrograms_
void Draw(const float *transformed_uvs, const GLuint &depthTexture, int screenWidth, int screenHeight, bool redUnknown)
BackgroundRenderer()=default
static constexpr int kNumVertices
unsigned int GLuint
Definition: dummy.cpp:78
static const GLfloat BackgroundRenderer_kVertices[]
void InitializeGlContent(GLuint textureId, bool oes)
static const GLfloat BackgroundRenderer_kTexCoord[]


rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Jan 23 2023 03:37:27