MCPcopy Create free account
hub / github.com/comaps/comaps / Build

Method Build

qt/qt_common/map_widget.cpp:274–311  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

272}
273
274void MapWidget::Build()
275{
276 std::string_view vertexSrc;
277 std::string_view fragmentSrc;
278#if defined(OMIM_OS_LINUX)
279 vertexSrc = ":common/shaders/gles_300.vsh.glsl";
280 fragmentSrc = ":common/shaders/gles_300.fsh.glsl";
281#else
282 vertexSrc = ":common/shaders/gl_150.vsh.glsl";
283 fragmentSrc = ":common/shaders/gl_150.fsh.glsl";
284#endif
285
286 m_program = std::make_unique<QOpenGLShaderProgram>(this);
287 m_program->addShaderFromSourceFile(QOpenGLShader::Vertex, vertexSrc.data());
288 m_program->addShaderFromSourceFile(QOpenGLShader::Fragment, fragmentSrc.data());
289 m_program->link();
290
291 m_vao = std::make_unique<QOpenGLVertexArrayObject>(this);
292 m_vao->create();
293 m_vao->bind();
294
295 m_vbo = std::make_unique<QOpenGLBuffer>(QOpenGLBuffer::VertexBuffer);
296 m_vbo->setUsagePattern(QOpenGLBuffer::StaticDraw);
297 m_vbo->create();
298 m_vbo->bind();
299
300 QVector4D vertices[4] = {QVector4D(-1.0, 1.0, 0.0, 1.0), QVector4D(1.0, 1.0, 1.0, 1.0),
301 QVector4D(-1.0, -1.0, 0.0, 0.0), QVector4D(1.0, -1.0, 1.0, 0.0)};
302 m_vbo->allocate(static_cast<void *>(vertices), sizeof(vertices));
303 QOpenGLFunctions * f = QOpenGLContext::currentContext()->functions();
304 // 0-index of the buffer is linked to "a_position" attribute in vertex shader.
305 // Introduced in https://github.com/organicmaps/organicmaps/pull/9814
306 f->glEnableVertexAttribArray(0);
307 f->glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(QVector4D), nullptr);
308
309 m_program->release();
310 m_vao->release();
311}
312
313namespace
314{

Callers

nothing calls this directly

Calls 5

dataMethod · 0.45
createMethod · 0.45
bindMethod · 0.45
allocateMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected