Swap to modern OpenGL for TFB usage.

This commit is contained in:
Dr. Chat 2016-01-19 18:31:36 -06:00
parent 47f5896089
commit 9ed0934123
1 changed files with 6 additions and 12 deletions

View File

@ -59,25 +59,23 @@ bool DrawBatcher::Initialize(CircularBuffer* array_data_buffer) {
// Initializes a transform feedback object // Initializes a transform feedback object
// We use this to capture vertex data straight from the vertex/geometry shader. // We use this to capture vertex data straight from the vertex/geometry shader.
bool DrawBatcher::InitializeTFB() { bool DrawBatcher::InitializeTFB() {
glGenBuffers(1, &tfvbo_); glCreateBuffers(1, &tfvbo_);
if (!tfvbo_) { if (!tfvbo_) {
return false; return false;
} }
glGenTransformFeedbacks(1, &tfbo_); glCreateTransformFeedbacks(1, &tfbo_);
if (!tfbo_) { if (!tfbo_) {
return false; return false;
} }
glGenQueries(1, &tfqo_); glCreateQueries(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, 1, &tfqo_);
if (!tfqo_) { if (!tfqo_) {
return false; return false;
} }
// TODO(DrChat): Calculate this based on the number of primitives drawn. // TODO(DrChat): Calculate this based on the number of primitives drawn.
glBindBuffer(GL_ARRAY_BUFFER, tfvbo_); glNamedBufferData(tfvbo_, 16384 * 4, nullptr, GL_STATIC_READ);
glBufferData(GL_ARRAY_BUFFER, 16384 * 4, nullptr, GL_STATIC_READ);
glBindBuffer(GL_ARRAY_BUFFER, 0);
return true; return true;
} }
@ -119,13 +117,9 @@ bool DrawBatcher::ReadbackTFB(void* buffer, size_t size) {
return false; return false;
} }
glBindBuffer(GL_ARRAY_BUFFER, tfvbo_); void* data = glMapNamedBufferRange(tfvbo_, 0, size, GL_MAP_READ_BIT);
void* data = glMapBufferRange(GL_ARRAY_BUFFER, 0, size, GL_MAP_READ_BIT);
std::memcpy(buffer, data, size); std::memcpy(buffer, data, size);
glUnmapNamedBuffer(tfvbo_);
glUnmapBuffer(GL_ARRAY_BUFFER);
glBindBuffer(GL_ARRAY_BUFFER, 0);
return true; return true;
} }