--- a/src/gl/axesprogram.cpp Fri Feb 05 14:23:16 2021 +0200 +++ b/src/gl/axesprogram.cpp Wed Feb 17 16:49:35 2021 +0200 @@ -72,6 +72,11 @@ AxesVertex{{0, 0, 0}, {0, 0, 0.5}}, }; +constexpr std::size_t vertexSize = sizeof data[0]; + +AxesProgram::AxesProgram(QObject* parent) : + AbstractShaderProgram{{{GL_LINES, ::vertexSize}}, parent} {} + const char* AxesProgram::vertexShaderSource() const { return ::vertexShaderSource; @@ -87,28 +92,13 @@ return ::data; } -GLenum AxesProgram::drawMode() const -{ - return GL_LINES; -} - -int AxesProgram::vertexSize() const -{ - return sizeof data[0]; -} - -int AxesProgram::vertexCount() const -{ - return countof(data); -} - void AxesProgram::setupVertexArrays() { for (int i : {0, 1}) { this->program->enableAttributeArray(i); } - const int stride = this->vertexSize(); - this->program->setAttributeBuffer(0, GL_FLOAT, offsetof(AxesVertex, position), 3, stride); - this->program->setAttributeBuffer(1, GL_FLOAT, offsetof(AxesVertex, color), 3, stride); + this->program->setAttributeBuffer(0, GL_FLOAT, offsetof(AxesVertex, position), 3, ::vertexSize); + this->program->setAttributeBuffer(1, GL_FLOAT, offsetof(AxesVertex, color), 3, ::vertexSize); + this->upload(&this->arrays[0], ::data, countof(data)); }