gltk.Buffer constructor takes target parameter.
This commit is contained in:
parent
64c3285fbc
commit
e51953445b
@ -7,7 +7,7 @@ class Buffer
|
||||
|
||||
private GLenum m_target;
|
||||
|
||||
this()
|
||||
this(GLenum target)
|
||||
{
|
||||
m_id = 0u;
|
||||
glGenBuffers(1, &m_id);
|
||||
@ -15,6 +15,7 @@ class Buffer
|
||||
{
|
||||
throw new Exception("Failed to allocate an OpenGL buffer");
|
||||
}
|
||||
m_target = target;
|
||||
}
|
||||
|
||||
~this()
|
||||
@ -32,17 +33,15 @@ class Buffer
|
||||
return m_id;
|
||||
}
|
||||
|
||||
void set_buffer_data(GLenum target, GLenum usage, const void * ptr, size_t size)
|
||||
void set_buffer_data(GLenum usage, const void * ptr, size_t size)
|
||||
{
|
||||
m_target = target;
|
||||
bind();
|
||||
glBufferData(target, size, ptr, usage);
|
||||
glBufferData(m_target, size, ptr, usage);
|
||||
}
|
||||
|
||||
void set_buffer_data(T)(GLenum target, GLenum usage, T[] arr)
|
||||
void set_buffer_data(T)(GLenum usage, T[] arr)
|
||||
{
|
||||
m_target = target;
|
||||
bind();
|
||||
glBufferData(target, arr.length * arr[0].sizeof, arr.ptr, usage);
|
||||
glBufferData(m_target, arr.length * arr[0].sizeof, arr.ptr, usage);
|
||||
}
|
||||
}
|
||||
|
@ -67,14 +67,14 @@ class Font
|
||||
int top = cglyph.top;
|
||||
float s_max = cglyph.width / cast(float)rounded_width;
|
||||
float t_max = cglyph.height / cast(float)rounded_height;
|
||||
m_buffer = new gltk.Buffer();
|
||||
m_buffer = new gltk.Buffer(GL_ARRAY_BUFFER);
|
||||
GLfloat[] data = [
|
||||
cast(GLfloat)left, cast(GLfloat)(top - cglyph.height), 0.0, 0.0,
|
||||
cast(GLfloat)(left + cglyph.width), cast(GLfloat)(top - cglyph.height), s_max, 0.0,
|
||||
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);
|
||||
m_buffer.set_buffer_data(GL_STATIC_DRAW, data);
|
||||
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, null);
|
||||
|
Loading…
x
Reference in New Issue
Block a user