Created
September 8, 2011 00:59
-
-
Save dennda/1202327 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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