66 return result; |
66 return result; |
67 } |
67 } |
68 |
68 |
69 void GridLayer::setGridMatrix(const glm::mat4& newGridMatrix) |
69 void GridLayer::setGridMatrix(const glm::mat4& newGridMatrix) |
70 { |
70 { |
71 this->shader.setUniformMatrix("grid", newGridMatrix); |
71 this->gridMatrix = newGridMatrix; |
|
72 if (this->isInitialized) { |
|
73 this->shader.setUniformMatrix("grid", newGridMatrix); |
|
74 } |
72 } |
75 } |
73 |
76 |
74 void GridLayer::setGridColor(const QColor& newGridColor) |
77 void GridLayer::setGridColor(const QColor& newGridColor) |
75 { |
78 { |
76 this->gridColor = gl::colorToVector4(newGridColor); |
79 this->gridColor = gl::colorToVector4(newGridColor); |
95 } |
98 } |
96 ); |
99 ); |
97 this->isInitialized = true; |
100 this->isInitialized = true; |
98 constexpr auto data = calcGridData<50>(); |
101 constexpr auto data = calcGridData<50>(); |
99 this->shader.setUniformVector("gridColor", this->gridColor); |
102 this->shader.setUniformVector("gridColor", this->gridColor); |
100 this->setGridMatrix({{1, 0, 0, 0}, {0, 0, 1, 0}, {0, 1, 0, 0}, {0, 0, 0, 1}}); |
103 this->setGridMatrix(this->gridMatrix); |
101 this->shader.bufferData(data.data(), data.size(), sizeof data[0]); |
104 this->shader.bufferData(data.data(), data.size(), sizeof data[0]); |
102 } |
105 } |
103 |
106 |
104 void GridLayer::paintGL() |
107 void GridLayer::paintGL() |
105 { |
108 { |