Skip to content

Instantly share code, notes, and snippets.

@dennda
Created September 8, 2011 00:59
Show Gist options
  • Save dennda/1202327 to your computer and use it in GitHub Desktop.
Save dennda/1202327 to your computer and use it in GitHub Desktop.
GLfloat* createSlices(unsigned int num_slices) {
// Each slice has 4 vertices (GL_TRIANGLE_STRIP)
unsigned long total_verts = num_slices * 4;
// Each vertex has 3 coordinates
unsigned long total_elements = total_verts * 3;
// We have 4 verts * 3 coords = 12 elements per slice
const GLfloat one_slice[12] = {
// x, y, z
1., 1., 0.,
1., -1., 0.,
-1., -1., 0.,
-1., 1., 0.,
};
GLfloat *slices = malloc(sizeof(GLfloat) * total_elements);
int i;
for (i = 0; i < num_slices; i+=12) {
memcpy(&slices[i], one_slice, 12);
}
assert(i == total_elements);
return slices;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment