| 50 this->buffer.setUsagePattern(usagePattern); |
50 this->buffer.setUsagePattern(usagePattern); |
| 51 this->vertexArrayObject.create(); |
51 this->vertexArrayObject.create(); |
| 52 this->vertexArrayObject.bind(); |
52 this->vertexArrayObject.bind(); |
| 53 for (std::size_t i = 0; i < attributeSpecs.size(); ++i) { |
53 for (std::size_t i = 0; i < attributeSpecs.size(); ++i) { |
| 54 const auto& spec = attributeSpecs[i]; |
54 const auto& spec = attributeSpecs[i]; |
| 55 this->program->enableAttributeArray(i); |
55 const int attr = narrow<int>(signed_cast(i)); |
| 56 this->program->setAttributeBuffer(i, spec.type, spec.offset, spec.tuplesize, spec.stride); |
56 this->program->enableAttributeArray(attr); |
| |
57 this->program->setAttributeBuffer(attr, spec.type, spec.offset, spec.tuplesize, spec.stride); |
| 57 } |
58 } |
| 58 this->vertexArrayObject.release(); |
59 this->vertexArrayObject.release(); |
| 59 this->buffer.release(); |
60 this->buffer.release(); |
| 60 this->program->release(); |
61 this->program->release(); |
| 61 gl::checkForGLErrors(nullptr); |
62 gl::checkForGLErrors(nullptr); |
| 86 } |
87 } |
| 87 |
88 |
| 88 void BasicShader::bufferData(const void* data, std::size_t count, std::size_t size) |
89 void BasicShader::bufferData(const void* data, std::size_t count, std::size_t size) |
| 89 { |
90 { |
| 90 this->buffer.bind(); |
91 this->buffer.bind(); |
| 91 this->buffer.allocate(data, count * size); |
92 this->buffer.allocate(data, narrow<int>(signed_cast(count * size))); |
| 92 this->buffer.release(); |
93 this->buffer.release(); |
| 93 this->vertexCount = count; |
94 this->vertexCount = narrow<int>(signed_cast(count)); |
| 94 } |
95 } |
| 95 |
96 |
| 96 void BasicShader::draw(GLenum drawMode) |
97 void BasicShader::draw(GLenum drawMode) |
| 97 { |
98 { |
| 98 this->program->bind(); |
99 this->program->bind(); |