1 /* 2 * Copyright 2017 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_HELLOE_AR_POINT_CLOUD_RENDERER_H_ 18 #define C_ARCORE_HELLOE_AR_POINT_CLOUD_RENDERER_H_ 19 20 #include <GLES2/gl2.h> 21 #include <GLES2/gl2ext.h> 22 #include <cstdlib> 23 #include <vector> 24 25 #include "arcore_c_api.h" 26 #include "platform_tools/android/apps/arcore/src/main/cpp/glm.h" 27 28 namespace hello_ar { 29 30 class PointCloudRenderer { 31 public: 32 // Default constructor of PointCloudRenderer. 33 PointCloudRenderer() = default; 34 35 // Default deconstructor of PointCloudRenderer. 36 ~PointCloudRenderer() = default; 37 38 // Initialize the GL content, needs to be called on GL thread. 39 void InitializeGlContent(); 40 41 // Render the AR point cloud. 42 // 43 // @param mvp_matrix, the model view projection matrix of point cloud. 44 // @param ar_session, the session that is used to query point cloud points 45 // from ar_point_cloud. 46 // @param ar_point_cloud, point cloud data to for rendering. 47 void Draw(glm::mat4 mvp_matrix, ArSession *ar_session, 48 ArPointCloud *ar_point_cloud) const; 49 50 private: 51 GLuint shader_program_; 52 GLint attribute_vertices_; 53 GLint uniform_mvp_mat_; 54 }; 55 } // namespace hello_ar 56 57 #endif // C_ARCORE_HELLOE_AR_POINT_CLOUD_RENDERER_H_ 58