add LineBuffer and change DebugFontBuffer naming

This commit is contained in:
Konstantin Käfer
2014-01-28 11:47:21 +01:00
parent a6434168b3
commit edf2a532af
10 changed files with 132 additions and 92 deletions

View File

@@ -6,20 +6,20 @@
using namespace llmr;
debug_font_buffer::debug_font_buffer()
DebugFontBuffer::DebugFontBuffer()
: buffer(0),
dirty(true) {
}
debug_font_buffer::~debug_font_buffer() {
DebugFontBuffer::~DebugFontBuffer() {
if (buffer != 0) {
glDeleteBuffers(1, &buffer);
buffer = 0;
}
}
void debug_font_buffer::addText(const char *text, double left, double baseline, double scale) {
void DebugFontBuffer::addText(const char *text, double left, double baseline, double scale) {
int32_t length = strlen(text);
for (int32_t i = 0; i < length; i++) {
if (text[i] < 32 || text[i] > 127) {
@@ -52,24 +52,23 @@ void debug_font_buffer::addText(const char *text, double left, double baseline,
dirty = true;
}
void debug_font_buffer::clear() {
void DebugFontBuffer::clear() {
array.clear();
dirty = true;
}
uint32_t debug_font_buffer::length() {
uint32_t DebugFontBuffer::length() {
// We store 2 coordinates per vertex
return array.size() / 2;
}
void debug_font_buffer::bind() {
void DebugFontBuffer::bind() {
if (buffer == 0) {
glGenBuffers(1, &buffer);
glBindBuffer(GL_ARRAY_BUFFER, buffer);
} else {
glBindBuffer(GL_ARRAY_BUFFER, buffer);
}
glBindBuffer(GL_ARRAY_BUFFER, buffer);
if (dirty) {
glBufferData(GL_ARRAY_BUFFER, array.size() * sizeof(uint16_t), array.data(), GL_STATIC_DRAW);
dirty = false;