OpenGL ES SDK for Android ARM Developer Center
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
geometry.h
Go to the documentation of this file.
1 /* Copyright (c) 2015-2017, ARM Limited and Contributors
2  *
3  * SPDX-License-Identifier: MIT
4  *
5  * Permission is hereby granted, free of charge,
6  * to any person obtaining a copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
9  * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
14  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19  */
20 
21 #ifndef _geometry_h_
22 #define _geometry_h_
23 #include <stdio.h>
24 #include "matrix.h"
25 #include <GLES3/gl31.h>
26 
27 struct Volume
28 {
30  int x, y, z;
31 };
32 
33 struct App
34 {
37  float frame_time;
38  float elapsed_time;
39  float fov;
40  float z_near;
41  float z_far;
42 
43  // Scene interaction
44  float pointer_x;
45  float pointer_y;
48  float rotate_x;
49  float rotate_y;
50  float translate_z;
53  float voxel_mode;
54 
55  // Geometry construction shader
63 
64  // Backdrop shader
67 
68  // Centroid placement shader
71 
72  // Isosurface generation shader
78 
79  // Geometry
85 
86  // Indirect draw call buffer and
87  // associated indices
90 
91  // 2D textures
93 
94  // 3D textures
97 };
98 
99 void gl_check(const char *msg);
100 void app_initialize(App *app);
102 
104 // Convenience macros
105 
106 #define get_attrib_location(prog, name) \
107  app->a_##prog##_##name = glGetAttribLocation(app->program_##prog, #name); \
108  if (app->a_##prog##_##name < 0) { \
109  LOGE("Invalid or unused attribute %s\n", #name); \
110  }
111 
112 #define get_uniform_location(prog, name) \
113  app->u_##prog##_##name = glGetUniformLocation(app->program_##prog, #name); \
114  if (app->u_##prog##_##name < 0) { \
115  LOGE("Invalid or unused uniform %s\n", #name); \
116  }
117 
118 #define attribfv(prog, name, n, offset) \
119  glEnableVertexAttribArray(app->a_##prog##_##name); \
120  glVertexAttribPointer(app->a_##prog##_##name, n, GL_FLOAT, GL_FALSE, \
121  n * sizeof(float), (void*)offset);
122 
123 #define attribiv(prog, name, n, offset) \
124  glEnableVertexAttribArray(app->a_##prog##_##name); \
125  glVertexAttribPointer(app->a_##prog##_##name, n, GL_INT, GL_FALSE, \
126  n * sizeof(GLint), (void*)offset);
127 
128 #define uniform1f(prog, name, value) glUniform1f(app->u_##prog##_##name, value);
129 #define uniform2f(prog, name, x, y) glUniform2f(app->u_##prog##_##name, x, y);
130 #define uniform3fv(prog, name, value) glUniform3fv(app->u_##prog##_##name, 1, &value[0]);
131 #define uniform1i(prog, name, value) glUniform1i(app->u_##prog##_##name, value);
132 #define uniformm4(prog, name, value) glUniformMatrix4fv(app->u_##prog##_##name, 1, GL_FALSE, value.value_ptr());
133 
134 #endif
vec3 sphere_pos
Definition: geometry.h:51
int z
Definition: geometry.h:30
float sphere_radius
Definition: geometry.h:52
int y
Definition: geometry.h:30
bool pointer_down
Definition: geometry.h:46
GLuint vbo_point
Definition: geometry.h:81
float rotate_x
Definition: geometry.h:48
GLuint program_geometry
Definition: geometry.h:56
GLuint index_buffer
Definition: geometry.h:89
bool pointer_released
Definition: geometry.h:47
Volume tex_surface
Definition: geometry.h:96
Definition: matrix.h:51
GLuint u_geometry_inCentroid
Definition: geometry.h:58
GLuint program_backdrop
Definition: geometry.h:65
GLuint program_centroid
Definition: geometry.h:69
float rotate_y
Definition: geometry.h:49
GLuint u_geometry_view
Definition: geometry.h:61
void app_initialize(App *app)
Definition: geometry.cpp:248
float frame_time
Definition: geometry.h:37
int window_width
Definition: geometry.h:35
GLuint u_geometry_projection
Definition: geometry.h:62
GLuint ibo_points
Definition: geometry.h:83
int x
Definition: geometry.h:30
GLuint a_geometry_texel
Definition: geometry.h:57
float translate_z
Definition: geometry.h:50
GLuint indirect_buffer
Definition: geometry.h:88
float z_near
Definition: geometry.h:40
GLuint vbo_points
Definition: geometry.h:82
float elapsed_time
Definition: geometry.h:38
float z_far
Definition: geometry.h:41
int window_height
Definition: geometry.h:36
float fov
Definition: geometry.h:39
GLuint vao
Definition: geometry.h:80
ClipmapApplication * app
Definition: main.cpp:47
void app_update_and_render(App *app)
Definition: geometry.cpp:297
GLuint tex
Definition: geometry.h:29
float voxel_mode
Definition: geometry.h:53
float pointer_x
Definition: geometry.h:44
GLuint u_generate_sphere_radius
Definition: geometry.h:74
GLuint u_generate_sphere_pos
Definition: geometry.h:75
float pointer_y
Definition: geometry.h:45
GLuint vbo_quad
Definition: geometry.h:84
GLuint u_geometry_inMaterial
Definition: geometry.h:60
GLuint tex_material
Definition: geometry.h:92
Volume tex_centroid
Definition: geometry.h:95
Definition: geometry.h:33
GLuint a_backdrop_position
Definition: geometry.h:66
void gl_check(const char *msg)
GLuint program_generate
Definition: geometry.h:73
GLuint u_centroid_voxel_mode
Definition: geometry.h:70
GLuint u_generate_time
Definition: geometry.h:77
typedef GLuint(GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC)(GLuint count
GLuint u_generate_dimension
Definition: geometry.h:76
GLuint u_geometry_inSurface
Definition: geometry.h:59