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_kVerticesDevice[] = {
32  -1.0f, -1.0f, +1.0f, -1.0f, -1.0f, +1.0f, +1.0f, +1.0f,
33 };
34 //static const GLfloat BackgroundRenderer_kVerticesView[] = {
35 // 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f,
36 //};
37 static const GLfloat BackgroundRenderer_kVerticesView[] = {
38  0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f,
39 };
40 static const GLfloat BackgroundRenderer_kTexCoord[] = {
41  1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
42 };
43 
44 //android phone
45 //11 10 01 00 // portrait
46 //01 11 00 10 // left
47 //10 00 11 01 // right
48 //00 01 10 11 // down
49 
50 
51 // This class renders the passthrough camera image into the OpenGL frame.
53 public:
54  // Positions of the quad vertices in clip space (X, Y).
55 
56  static constexpr int kNumVertices = 4;
57 
58  public:
59  BackgroundRenderer() = default;
61 
62  // Sets up OpenGL state. Must be called on the OpenGL thread and before any
63  // other methods below.
64  void InitializeGlContent(GLuint textureId, bool oes);
65 
66  // Draws the background image. This methods must be called for every ArFrame
67  // returned by ArSession_update() to catch display geometry change events.
68  void Draw(const float * transformed_uvs, const GLuint & depthTexture, int screenWidth, int screenHeight, bool redUnknown);
69 
70 private:
71  static std::vector<GLuint> shaderPrograms_;
73  bool oes_ = false;
74 };
75 
76 #endif // C_ARCORE_AUGMENTED_IMAGE_BACKGROUND_RENDERER_H_
BackgroundRenderer::Draw
void Draw(const float *transformed_uvs, const GLuint &depthTexture, int screenWidth, int screenHeight, bool redUnknown)
Definition: background_renderer.cc:157
BackgroundRenderer_kTexCoord
static const GLfloat BackgroundRenderer_kTexCoord[]
Definition: background_renderer.h:40
BackgroundRenderer_kVerticesDevice
static const GLfloat BackgroundRenderer_kVerticesDevice[]
Definition: background_renderer.h:31
BackgroundRenderer::~BackgroundRenderer
~BackgroundRenderer()
Definition: background_renderer.cc:125
BackgroundRenderer
Definition: background_renderer.h:52
BackgroundRenderer::oes_
bool oes_
Definition: background_renderer.h:73
GLuint
unsigned int GLuint
Definition: dummy.cpp:78
BackgroundRenderer::InitializeGlContent
void InitializeGlContent(GLuint textureId, bool oes)
Definition: background_renderer.cc:134
BackgroundRenderer::shaderPrograms_
static std::vector< GLuint > shaderPrograms_
Definition: background_renderer.h:71
BackgroundRenderer::texture_id_
GLuint texture_id_
Definition: background_renderer.h:72
BackgroundRenderer::BackgroundRenderer
BackgroundRenderer()=default
BackgroundRenderer_kVerticesView
static const GLfloat BackgroundRenderer_kVerticesView[]
Definition: background_renderer.h:37
BackgroundRenderer::kNumVertices
static constexpr int kNumVertices
Definition: background_renderer.h:56
util.h


rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Jul 1 2024 02:42:24