initial logo.draw() attempt
This commit is contained in:
parent
a41cd245a9
commit
f328282289
26
src/logo.d
26
src/logo.d
@ -1,3 +1,4 @@
|
|||||||
|
import derelict.opengl3.gl3;
|
||||||
import glamour.vao;
|
import glamour.vao;
|
||||||
import glamour.vbo;
|
import glamour.vbo;
|
||||||
static import logoobj;
|
static import logoobj;
|
||||||
@ -8,30 +9,43 @@ immutable enum int WIRE = 1;
|
|||||||
immutable enum int GENTEX = 0;
|
immutable enum int GENTEX = 0;
|
||||||
immutable enum int CORPORATION = 1;
|
immutable enum int CORPORATION = 1;
|
||||||
|
|
||||||
|
int[][][][][] object_indices;
|
||||||
/* Indexed by: face/wire, word, character */
|
/* Indexed by: face/wire, word, character */
|
||||||
VAO[][2][2] object_vaos;
|
VAO[][2][2] object_vaos;
|
||||||
|
|
||||||
void init()
|
void init()
|
||||||
{
|
{
|
||||||
|
object_indices = [[logoobj.fg, logoobj.fc], [logoobj.lg, logoobj.lc]];
|
||||||
Buffer vertices_buffer = new Buffer(logoobj.vertices);
|
Buffer vertices_buffer = new Buffer(logoobj.vertices);
|
||||||
int[][][][] objects = [logoobj.fg, logoobj.fc, logoobj.lg, logoobj.lc];
|
|
||||||
int objects_index;
|
|
||||||
for (int draw_type = FACE; draw_type <= WIRE; draw_type++)
|
for (int draw_type = FACE; draw_type <= WIRE; draw_type++)
|
||||||
{
|
{
|
||||||
for (int word = GENTEX; word <= CORPORATION; word++)
|
for (int word = GENTEX; word <= CORPORATION; word++)
|
||||||
{
|
{
|
||||||
object_vaos[draw_type][word].length = objects[objects_index].length;
|
object_vaos[draw_type][word].length = object_indices[draw_type][word].length;
|
||||||
for (int char_index = 0;
|
for (int char_index = 0;
|
||||||
char_index < objects[objects_index].length;
|
char_index < object_indices[draw_type][word].length;
|
||||||
char_index++)
|
char_index++)
|
||||||
{
|
{
|
||||||
VAO vao = new VAO();
|
VAO vao = new VAO();
|
||||||
|
vao.bind();
|
||||||
|
|
||||||
vertices_buffer.bind();
|
vertices_buffer.bind();
|
||||||
ElementBuffer ibo = new ElementBuffer(objects[objects_index][char_index]);
|
ElementBuffer ibo = new ElementBuffer(object_indices[draw_type][word][char_index]);
|
||||||
ibo.bind();
|
ibo.bind();
|
||||||
|
|
||||||
object_vaos[draw_type][word][char_index] = vao;
|
object_vaos[draw_type][word][char_index] = vao;
|
||||||
}
|
}
|
||||||
objects_index++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void draw(int draw_type, int word, int character, GLint position_idx)
|
||||||
|
{
|
||||||
|
object_vaos[draw_type][word][character].bind();
|
||||||
|
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,
|
||||||
|
null);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user