src/gl/gridprogram.cpp

changeset 243
959469a7e149
parent 217
6d95c1a41e6e
child 250
2837b549e616
equal deleted inserted replaced
242:16855456992d 243:959469a7e149
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */ 17 */
18 18
19 #include "gridprogram.h" 19 #include "gridprogram.h"
20 #include "partrenderer.h"
20 21
21 constexpr char vertexShaderSource[] = R"( 22 constexpr char vertexShaderSource[] = R"(
22 #version 330 core 23 #version 330 core
23 24
24 layout (location = 0) in vec2 in_position; 25 layout (location = 0) in vec2 in_position;
80 if (this->isInitialized) { 81 if (this->isInitialized) {
81 this->shader.setUniformVector("gridColor", this->gridColor); 82 this->shader.setUniformVector("gridColor", this->gridColor);
82 } 83 }
83 } 84 }
84 85
86 void GridLayer::settingsChanged()
87 {
88 this->setGridColor(this->renderer->isDark() ? Qt::white : Qt::black);
89 }
90
85 void GridLayer::initializeGL() 91 void GridLayer::initializeGL()
86 { 92 {
87 this->shader.initialize( 93 this->shader.initialize(
88 ::vertexShaderSource, 94 ::vertexShaderSource,
89 ::fragmentShaderSource, 95 ::fragmentShaderSource,
99 ); 105 );
100 this->isInitialized = true; 106 this->isInitialized = true;
101 constexpr auto data = calcGridData<50>(); 107 constexpr auto data = calcGridData<50>();
102 this->shader.setUniformVector("gridColor", this->gridColor); 108 this->shader.setUniformVector("gridColor", this->gridColor);
103 this->setGridMatrix(this->gridMatrix); 109 this->setGridMatrix(this->gridMatrix);
110 this->settingsChanged();
104 this->shader.bufferData(data.data(), data.size(), sizeof data[0]); 111 this->shader.bufferData(data.data(), data.size(), sizeof data[0]);
105 } 112 }
106 113
107 void GridLayer::paintGL() 114 void GridLayer::paintGL()
108 { 115 {

mercurial