24 #define SIDES_IN_A_CUBE 6
25 #define NUM_PATCHES (QUAD_RES_X * QUAD_RES_Y * SIDES_IN_A_CUBE)
26 #define VERTICES_PER_PATCH 4
45 #define CUBE_SIDE_BIAS 0.0f
62 v0.x = x0; v0.y = 1.0f; v0.z = y0;
63 v1.
x = x0; v1.
y = 1.0f; v1.
z = y1;
64 v2.
x = x1; v2.
y = 1.0f; v2.
z = y1;
65 v3.
x = x1; v3.
y = 1.0f; v3.
z = y0;
68 v0.x = x0; v0.y = -1.0f; v0.z = y0;
69 v1.
x = x1; v1.
y = -1.0f; v1.
z = y0;
70 v2.
x = x1; v2.
y = -1.0f; v2.
z = y1;
71 v3.
x = x0; v3.
y = -1.0f; v3.
z = y1;
74 v0.x = -1.0f; v0.y = x0; v0.z = y0;
75 v1.
x = -1.0f; v1.
y = x0; v1.
z = y1;
76 v2.
x = -1.0f; v2.
y = x1; v2.
z = y1;
77 v3.
x = -1.0f; v3.
y = x1; v3.
z = y0;
80 v0.x = +1.0f; v0.y = x0; v0.z = y0;
81 v1.
x = +1.0f; v1.
y = x1; v1.
z = y0;
82 v2.
x = +1.0f; v2.
y = x1; v2.
z = y1;
83 v3.
x = +1.0f; v3.
y = x0; v3.
z = y1;
86 v0.x = x0; v0.y = y0; v0.z = +1.0f;
87 v1.
x = x1; v1.
y = y0; v1.
z = +1.0f;
88 v2.
x = x1; v2.
y = y1; v2.
z = +1.0f;
89 v3.
x = x0; v3.
y = y1; v3.
z = +1.0f;
92 v0.x = x0; v0.y = y0; v0.z = -1.0f;
93 v1.
x = x0; v1.
y = y1; v1.
z = -1.0f;
94 v2.
x = x1; v2.
y = y1; v2.
z = -1.0f;
95 v3.
x = x1; v3.
y = y0; v3.
z = -1.0f;
118 glGenBuffers(1, &result);
119 glBindBuffer(GL_ARRAY_BUFFER, result);
120 glBufferData(GL_ARRAY_BUFFER,
sizeof(v), v, GL_STATIC_DRAW);
135 glGenBuffers(1, &result);
136 glBindBuffer(GL_ARRAY_BUFFER, result);
137 glBufferData(GL_ARRAY_BUFFER,
sizeof(v), v, GL_STATIC_DRAW);
143 glGenVertexArrays(1, &app->
vao);
144 glBindVertexArray(app->
vao);
172 int n = (
int)(t / 20.0
f);
173 float modt = t - n * 20.0f;
174 if (modt >= 19.5
f && modt <= 20.0
f)
176 return cos((modt - 19.5
f) * 3.1415926
f);
178 else if (modt <= 0.5
f)
180 return sin(modt * 3.1415926
f);
187 float rx = -0.3f + 0.25f * sin(t * 0.1
f);
189 float zoom = 0.5f + 0.5f * sin(t * 0.25f);
190 float z = -5.0f + 3.0f * sin(t * 0.25f);
206 glEnable(GL_CULL_FACE);
210 glEnable(GL_DEPTH_TEST);
211 glDepthFunc(GL_LEQUAL);
213 glEnable(GL_DEPTH_TEST);
214 glDepthMask(GL_TRUE);
215 glDepthRangef(0.0, 1.0);
218 glClearColor(0.0
f, 0.0
f, 0.0
f, 1.0
f);
219 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
222 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
223 glBlendEquation(GL_FUNC_ADD);
227 glDepthMask(GL_FALSE);
229 glBindBuffer(GL_ARRAY_BUFFER, app->
vbo_quad);
235 glDrawArrays(GL_TRIANGLES, 0, 6);
236 glDepthMask(GL_TRUE);
241 glBindBuffer(GL_ARRAY_BUFFER, app->
vbo_cube);
244 glActiveTexture(GL_TEXTURE0);
245 glBindTexture(GL_TEXTURE_CUBE_MAP, scene.
heightmap);
248 glActiveTexture(GL_TEXTURE1);
249 glBindTexture(GL_TEXTURE_CUBE_MAP, scene.
diffusemap);
256 uniformm4(mapping, model, mat_cube_model);
#define get_attrib_location(prog, name)
#define GL_PATCH_VERTICES
#define attribfv(prog, name, n, offset)
mat4 animate_camera(float t)
#define get_uniform_location(prog, name)
GLint GLfloat GLfloat GLfloat v2
#define glPatchParameteri
GLint GLfloat GLfloat GLfloat GLfloat v3
static mat4 rotateY(float rad)
int fill_cube_side(Vertex *v, CubeSide side)
#define uniform3fv(prog, name, value)
static mat4 rotateX(float rad)
#define VERTICES_PER_PATCH
#define uniformm4(prog, name, value)
float animate_model_scale(float t)
GLint GLint GLint GLint GLint x
#define uniform1i(prog, name, value)
#define uniform1f(prog, name, value)
void app_update_and_render(App *app)
static float aspect_ratio
void app_initialize(App *app)
typedef GLuint(GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC)(GLuint count
static mat4 translate(float x, float y, float z)
#define uniform2f(prog, name, x, y)