src/layers/axeslayer.cpp

changeset 377
e1c5e4310f8b
parent 264
76a025db4948
equal deleted inserted replaced
376:3cef3b016330 377:e1c5e4310f8b
67 {{0, 0, 0}, {0, 0, 1}}, 67 {{0, 0, 0}, {0, 0, 1}},
68 {{0, 0, -10000}, {0, 0, 0.5}}, 68 {{0, 0, -10000}, {0, 0, 0.5}},
69 {{0, 0, 0}, {0, 0, 0.5}}, 69 {{0, 0, 0}, {0, 0, 0.5}},
70 }; 70 };
71 constexpr int stride = sizeof(VertexType); 71 constexpr int stride = sizeof(VertexType);
72 this->shader.initialize( 72 gl::initialize_basic_shader(&this->shader,
73 ::vertexShaderSource, 73 ::vertexShaderSource,
74 ::fragmentShaderSource, 74 ::fragmentShaderSource,
75 QOpenGLBuffer::StaticDraw, 75 QOpenGLBuffer::StaticDraw,
76 { 76 {
77 GLAttributeSpec{ 77 GLAttributeSpec{
85 .offset = offsetof(VertexType, color), 85 .offset = offsetof(VertexType, color),
86 .tuplesize = 3, 86 .tuplesize = 3,
87 .stride = stride, 87 .stride = stride,
88 }, 88 },
89 }); 89 });
90 this->shader.bufferData(&data[0], countof(data), sizeof data[0]); 90 gl::buffer_shader_data(&this->shader, &data[0], countof(data), sizeof data[0]);
91 } 91 }
92 92
93 void AxesLayer::overpaint(QPainter* painter) 93 void AxesLayer::overpaint(QPainter* painter)
94 { 94 {
95 painter->save(); 95 painter->save();
150 void AxesLayer::paintGL() 150 void AxesLayer::paintGL()
151 { 151 {
152 glLineWidth(5); 152 glLineWidth(5);
153 glEnable(GL_LINE_SMOOTH); 153 glEnable(GL_LINE_SMOOTH);
154 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); 154 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
155 this->shader.draw(GL_LINES); 155 gl::draw_shader(&this->shader, GL_LINES);
156 glDisable(GL_LINE_SMOOTH); 156 glDisable(GL_LINE_SMOOTH);
157 } 157 }
158 158
159 void AxesLayer::mvpMatrixChanged(const glm::mat4& mvpMatrix) 159 void AxesLayer::mvpMatrixChanged(const glm::mat4& mvpMatrix)
160 { 160 {
161 this->shader.setMvpMatrix(mvpMatrix); 161 gl::set_shader_matrix_uniform(&this->shader, "mvp", mvpMatrix);
162 } 162 }

mercurial