25 const float hs = 1.0f;
29 -hs, 0.0f, -hs, 0.0f, 1.0f, 0.0f,
30 hs, 0.0f, -hs, 0.0f, 1.0f, 0.0f,
31 hs, 0.0f, hs, 0.0f, 1.0f, 0.0f,
32 -hs, 0.0f, hs, 0.0f, 1.0f, 0.0f
47 const float hs = 1.0f;
51 -hs, -hs, 0.0f, 0.0f, 0.0f,
52 hs, -hs, 0.0f, 1.0f, 0.0f,
53 hs, hs, 0.0f, 1.0f, 1.0f,
54 -hs, hs, 0.0f, 0.0f, 1.0f
74 float dtheta = 2.0f *
PI /
float(t_samples);
75 float dphi =
PI /
float(s_samples);
76 for (
int t = 0; t < t_samples; ++t)
78 for (
int s = 0; s < s_samples; ++s)
80 float theta = t * dtheta;
84 float r1 = sin(phi + dphi);
86 vec3 v00(r0 * cos(theta), cos(phi), r0 * sin(theta));
87 vec3 v10(r0 * cos(theta + dtheta), cos(phi), r0 * sin(theta + dtheta));
88 vec3 v01(r1 * cos(theta), cos(phi + dphi), r1 * sin(theta));
89 vec3 v11(r1 * cos(theta + dtheta), cos(phi + dphi), r1 * sin(theta + dtheta));
91 vertices[vertex_index + 0] = v00;
92 vertices[vertex_index + 1] = v01;
93 vertices[vertex_index + 2] = v11;
94 vertices[vertex_index + 3] = v10;
96 indices[index_index + 0] = vertex_index + 0;
97 indices[index_index + 1] = vertex_index + 1;
98 indices[index_index + 2] = vertex_index + 2;
99 indices[index_index + 3] = vertex_index + 2;
100 indices[index_index + 4] = vertex_index + 3;
101 indices[index_index + 5] = vertex_index + 0;
Mesh gen_unit_sphere(int t_samples, int s_samples)
void del_buffer(GLuint buffer)
GLsizei GLenum const void * indices
GLuint gen_buffer(GLenum target, GLenum usage, GLsizei size, const void *data)