70 AxesVertex{{0, 0, 0}, {0, 0, 1}}, |
70 AxesVertex{{0, 0, 0}, {0, 0, 1}}, |
71 AxesVertex{{0, 0, -10000}, {0, 0, 0.5}}, |
71 AxesVertex{{0, 0, -10000}, {0, 0, 0.5}}, |
72 AxesVertex{{0, 0, 0}, {0, 0, 0.5}}, |
72 AxesVertex{{0, 0, 0}, {0, 0, 0.5}}, |
73 }; |
73 }; |
74 |
74 |
|
75 constexpr std::size_t vertexSize = sizeof data[0]; |
|
76 |
|
77 AxesProgram::AxesProgram(QObject* parent) : |
|
78 AbstractShaderProgram{{{GL_LINES, ::vertexSize}}, parent} {} |
|
79 |
75 const char* AxesProgram::vertexShaderSource() const |
80 const char* AxesProgram::vertexShaderSource() const |
76 { |
81 { |
77 return ::vertexShaderSource; |
82 return ::vertexShaderSource; |
78 } |
83 } |
79 |
84 |
85 const void* AxesProgram::vertexData() const |
90 const void* AxesProgram::vertexData() const |
86 { |
91 { |
87 return ::data; |
92 return ::data; |
88 } |
93 } |
89 |
94 |
90 GLenum AxesProgram::drawMode() const |
|
91 { |
|
92 return GL_LINES; |
|
93 } |
|
94 |
|
95 int AxesProgram::vertexSize() const |
|
96 { |
|
97 return sizeof data[0]; |
|
98 } |
|
99 |
|
100 int AxesProgram::vertexCount() const |
|
101 { |
|
102 return countof(data); |
|
103 } |
|
104 |
|
105 void AxesProgram::setupVertexArrays() |
95 void AxesProgram::setupVertexArrays() |
106 { |
96 { |
107 for (int i : {0, 1}) |
97 for (int i : {0, 1}) |
108 { |
98 { |
109 this->program->enableAttributeArray(i); |
99 this->program->enableAttributeArray(i); |
110 } |
100 } |
111 const int stride = this->vertexSize(); |
101 this->program->setAttributeBuffer(0, GL_FLOAT, offsetof(AxesVertex, position), 3, ::vertexSize); |
112 this->program->setAttributeBuffer(0, GL_FLOAT, offsetof(AxesVertex, position), 3, stride); |
102 this->program->setAttributeBuffer(1, GL_FLOAT, offsetof(AxesVertex, color), 3, ::vertexSize); |
113 this->program->setAttributeBuffer(1, GL_FLOAT, offsetof(AxesVertex, color), 3, stride); |
103 this->upload(&this->arrays[0], ::data, countof(data)); |
114 } |
104 } |