gltk.Buffer.set_buffer_data() can take an arbitrary array.

This commit is contained in:
josh committed 2020-12-10 20:26:58 -05:00
1 parent 24b7ee9f16
commit 64c3285fbc
2 files changed
+8 -1

No files matched your search

+7
View File
@@ -38,4 +38,11 @@ class Buffer
bind();
glBufferData(target, size, ptr, usage);
}
void set_buffer_data(T)(GLenum target, GLenum usage, T[] arr)
{
m_target = target;
bind();
glBufferData(target, arr.length * arr[0].sizeof, arr.ptr, usage);
}
}
+1 -1
View File
@@ -74,7 +74,7 @@ class Font
cast(GLfloat)left, cast(GLfloat)top, 0.0, t_max,
cast(GLfloat)(left + cglyph.width), cast(GLfloat)top, s_max, t_max,
];
m_buffer.set_buffer_data(GL_ARRAY_BUFFER, GL_STATIC_DRAW, data.ptr, data.length * GLfloat.sizeof);
m_buffer.set_buffer_data(GL_ARRAY_BUFFER, GL_STATIC_DRAW, data);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, null);