OpenGL ES SDK for Android ARM Developer Center
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
tessellation.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 _tessellation_h_
22 #define _tessellation_h_
23 #include <stdio.h>
24 #include "matrix.h"
25 
26 #define NUM_SCENES 5
27 struct Scene
28 {
32  bool use_mip;
34  float height_scale;
35  float fov;
36  float z_near;
37  float z_far;
38 };
39 
40 struct App
41 {
42  int window_width;
43  int window_height;
44  float elapsed_time;
45 
48 
49  // Displacement mapping shader
61 
62  // Backdrop shader
69 
70  // Geometry
71  GLuint vao;
74 };
75 
76 void app_initialize(App *app);
78 
80 // Convenience macros
81 
82 #define get_attrib_location(prog, name) \
83  app->a_##prog##_##name = glGetAttribLocation(app->program_##prog, #name); \
84  if (app->a_##prog##_##name < 0) { \
85  printf("Invalid or unused attribute %s\n", #name); \
86  }
87 
88 #define get_uniform_location(prog, name) \
89  app->u_##prog##_##name = glGetUniformLocation(app->program_##prog, #name); \
90  if (app->u_##prog##_##name < 0) { \
91  printf("Invalid or unused uniform %s\n", #name); \
92  }
93 
94 #define attribfv(prog, name, n, offset) \
95  glEnableVertexAttribArray(app->a_##prog##_##name); \
96  glVertexAttribPointer(app->a_##prog##_##name, n, GL_FLOAT, GL_FALSE, \
97  n * sizeof(float), (void*)offset);
98 
99 #define uniform1f(prog, name, value) glUniform1f(app->u_##prog##_##name, value);
100 #define uniform2f(prog, name, x, y) glUniform2f(app->u_##prog##_##name, x, y);
101 #define uniform3fv(prog, name, value) glUniform3fv(app->u_##prog##_##name, 1, &value[0]);
102 #define uniform1i(prog, name, value) glUniform1i(app->u_##prog##_##name, value);
103 #define uniformm4(prog, name, value) glUniformMatrix4fv(app->u_##prog##_##name, 1, GL_FALSE, value.value_ptr());
104 
105 #endif
GLuint u_mapping_heightmap
Definition: tessellation.h:57
GLuint diffusemap
Definition: tessellation.h:30
float height_scale
Definition: tessellation.h:34
GLuint u_backdrop_sun_dir
Definition: tessellation.h:66
Definition: matrix.h:51
GLuint program_backdrop
Definition: geometry.h:65
GLuint u_mapping_height_scale
Definition: tessellation.h:52
GLuint u_mapping_view
Definition: tessellation.h:59
int window_width
Definition: geometry.h:35
GLuint u_backdrop_view
Definition: tessellation.h:65
vec3 sun_dir
Definition: tessellation.h:31
void app_update_and_render(App *app)
Definition: geometry.cpp:297
GLuint heightmap
Definition: tessellation.h:29
GLuint u_mapping_use_mip
Definition: tessellation.h:53
GLuint u_mapping_projection
Definition: tessellation.h:60
GLuint u_mapping_max_lod_coverage
Definition: tessellation.h:54
float z_near
Definition: tessellation.h:36
GLuint u_backdrop_screen_size
Definition: tessellation.h:67
GLuint a_mapping_position
Definition: tessellation.h:51
int current_scene
Definition: tessellation.h:46
float max_lod_coverage
Definition: tessellation.h:33
void app_initialize(App *app)
Definition: geometry.cpp:248
float elapsed_time
Definition: geometry.h:38
Definition: scene.hpp:29
int window_height
Definition: geometry.h:36
GLuint vao
Definition: geometry.h:80
ClipmapApplication * app
Definition: main.cpp:47
float fov
Definition: tessellation.h:35
bool use_mip
Definition: tessellation.h:32
GLuint u_mapping_model
Definition: tessellation.h:58
GLuint vbo_cube
Definition: tessellation.h:72
GLuint vbo_quad
Definition: geometry.h:84
GLuint u_backdrop_inv_tan_fov
Definition: tessellation.h:68
float z_far
Definition: tessellation.h:37
GLuint u_mapping_screen_size
Definition: tessellation.h:55
GLuint u_mapping_diffusemap
Definition: tessellation.h:56
Definition: geometry.h:33
GLuint a_backdrop_position
Definition: geometry.h:66
GLuint program_mapping
Definition: tessellation.h:50
typedef GLuint(GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC)(GLuint count
Scene scenes[5]
Definition: tessellation.h:47