-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathMoreTeapotsRenderer.h
111 lines (93 loc) · 2.94 KB
/
MoreTeapotsRenderer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
* Copyright 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//--------------------------------------------------------------------------------
// MoreTeapotsRenderer.h
// Renderer for teapots
//--------------------------------------------------------------------------------
#ifndef _MoreTeapotsRenderer_H
#define _MoreTeapotsRenderer_H
//--------------------------------------------------------------------------------
// Include files
//--------------------------------------------------------------------------------
#include <random>
#include <vector>
#include <EGL/egl.h>
#include <GLES/gl.h>
#define CLASS_NAME "android/app/NativeActivity"
#define APPLICATION_CLASS_NAME "com/sample/moreteapots/MoreTeapotsApplication"
#include <GLES2/gl2.h>
#include "shader.h" //Shader compiler support
#include "vecmath.h" //Vector math support, C++ implementation n current version
#define BUFFER_OFFSET(i) ((char*)NULL + (i))
struct TEAPOT_VERTEX {
float pos[3];
float normal[3];
};
enum SHADER_ATTRIBUTES {
ATTRIB_VERTEX,
ATTRIB_NORMAL,
ATTRIB_COLOR,
ATTRIB_UV
};
struct SHADER_PARAMS {
GLuint program_;
GLuint light0_;
GLuint material_diffuse_;
GLuint material_ambient_;
GLuint material_specular_;
GLuint matrix_projection_;
GLuint matrix_view_;
};
struct TEAPOT_MATERIALS {
float specular_color[4];
float ambient_color[3];
};
class MoreTeapotsRenderer {
int32_t num_indices_;
int32_t num_vertices_;
GLuint ibo_;
GLuint vbo_;
GLuint ubo_;
int32_t origin_num_indices_;
int32_t origin_num_vertices_;
int32_t size_instance_;
SHADER_PARAMS shader_param_;
bool LoadShaders(SHADER_PARAMS* params, const char* strVsh,
const char* strFsh);
ndk_helper::Mat4 mat_projection_;
ndk_helper::Mat4 mat_view_;
std::vector<ndk_helper::Mat4> vec_mat_models_;
std::vector<ndk_helper::Vec3> vec_colors_;
std::vector<ndk_helper::Vec2> vec_rotations_;
std::vector<ndk_helper::Vec2> vec_current_rotations_;
int32_t teapot_x_;
int32_t teapot_y_;
int32_t teapot_z_;
int32_t ubo_matrix_stride_;
int32_t ubo_vector_stride_;
bool geometry_instancing_support_;
bool arb_support_;
std::string ToString(const int32_t i);
public:
MoreTeapotsRenderer();
virtual ~MoreTeapotsRenderer();
void Init(const int32_t numX, const int32_t numY, const int32_t numZ);
void Render();
void Update(float dTime);
void Unload();
void UpdateViewport();
};
#endif