obj2d: generate flat arrays, use ushort for indices

This commit is contained in:
Josh Holtrop committed 2013-11-19 22:46:55 -05:00
1 parent 6985fe462b
commit a746167957
2 files changed
+20 -8

No files matched your search

+5 -4
View File
@@ -9,13 +9,14 @@ immutable enum int WIRE = 1;
immutable enum int GENTEX = 0;
immutable enum int CORPORATION = 1;
int[][][][][] object_indices;
ushort[][][2][2] object_indices;
/* Indexed by: face/wire, word, character */
VAO[][2][2] object_vaos;
void init()
{
object_indices = [[logoobj.fg, logoobj.fc], [logoobj.lg, logoobj.lc]];
object_indices = [[logoobj.get_fg(), logoobj.get_fc()],
[logoobj.get_lg(), logoobj.get_lc()]];
Buffer vertices_buffer = new Buffer(logoobj.vertices);
for (int draw_type = FACE; draw_type <= WIRE; draw_type++)
{
@@ -45,7 +46,7 @@ void draw(int draw_type, int word, int character, GLint position_idx)
glEnableVertexAttribArray(position_idx);
glVertexAttribPointer(position_idx, 2, GL_FLOAT, GL_FALSE, 0, null);
glDrawElements(draw_type == FACE ? GL_TRIANGLES : GL_LINES,
object_indices[draw_type][word].length,
GL_UNSIGNED_INT,
object_indices[draw_type][word][character].length,
GL_UNSIGNED_SHORT,
null);
}