mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 02:20:04 +00:00 
			
		
		
		
	Clean up placefile lines, draw second line underneath for a black border
This commit is contained in:
		
							parent
							
								
									ddf11884a8
								
							
						
					
					
						commit
						c6c64de169
					
				
					 2 changed files with 133 additions and 136 deletions
				
			
		|  | @ -1,12 +1,8 @@ | ||||||
| #include <scwx/qt/gl/draw/placefile_lines.hpp> | #include <scwx/qt/gl/draw/placefile_lines.hpp> | ||||||
| #include <scwx/qt/util/geographic_lib.hpp> | #include <scwx/qt/util/geographic_lib.hpp> | ||||||
| #include <scwx/qt/util/maplibre.hpp> | #include <scwx/qt/util/maplibre.hpp> | ||||||
| #include <scwx/qt/util/texture_atlas.hpp> |  | ||||||
| #include <scwx/util/logger.hpp> | #include <scwx/util/logger.hpp> | ||||||
| 
 | 
 | ||||||
| #include <QUrl> |  | ||||||
| #include <boost/unordered/unordered_flat_map.hpp> |  | ||||||
| 
 |  | ||||||
| namespace scwx | namespace scwx | ||||||
| { | { | ||||||
| namespace qt | namespace qt | ||||||
|  | @ -23,11 +19,11 @@ static constexpr std::size_t kNumRectangles        = 1; | ||||||
| static constexpr std::size_t kNumTriangles         = kNumRectangles * 2; | static constexpr std::size_t kNumTriangles         = kNumRectangles * 2; | ||||||
| static constexpr std::size_t kVerticesPerTriangle  = 3; | static constexpr std::size_t kVerticesPerTriangle  = 3; | ||||||
| static constexpr std::size_t kVerticesPerRectangle = kVerticesPerTriangle * 2; | static constexpr std::size_t kVerticesPerRectangle = kVerticesPerTriangle * 2; | ||||||
| static constexpr std::size_t kPointsPerVertex      = 11; | static constexpr std::size_t kPointsPerVertex      = 9; | ||||||
| static constexpr std::size_t kBufferLength = | static constexpr std::size_t kBufferLength = | ||||||
|    kNumTriangles * kVerticesPerTriangle * kPointsPerVertex; |    kNumTriangles * kVerticesPerTriangle * kPointsPerVertex; | ||||||
| 
 | 
 | ||||||
| static const std::string kTextureName_ = "lines/default-1x7"; | static const boost::gil::rgba8_pixel_t kBlack_ {0, 0, 0, 255}; | ||||||
| 
 | 
 | ||||||
| class PlacefileLines::Impl | class PlacefileLines::Impl | ||||||
| { | { | ||||||
|  | @ -47,23 +43,29 @@ public: | ||||||
| 
 | 
 | ||||||
|    ~Impl() {} |    ~Impl() {} | ||||||
| 
 | 
 | ||||||
|  |    void BufferLine(const gr::Placefile::LineDrawItem::Element& e1, | ||||||
|  |                    const gr::Placefile::LineDrawItem::Element& e2, | ||||||
|  |                    const float                                 width, | ||||||
|  |                    const float                                 angle, | ||||||
|  |                    const boost::gil::rgba8_pixel_t             color, | ||||||
|  |                    const GLint                                 threshold); | ||||||
|  |    void UpdateBuffers(std::shared_ptr<const gr::Placefile::LineDrawItem>); | ||||||
|  |    void Update(); | ||||||
|  | 
 | ||||||
|    std::shared_ptr<GlContext> context_; |    std::shared_ptr<GlContext> context_; | ||||||
| 
 | 
 | ||||||
|    bool dirty_ {false}; |    bool dirty_ {false}; | ||||||
|    bool thresholded_ {false}; |    bool thresholded_ {false}; | ||||||
| 
 | 
 | ||||||
|    std::mutex lineMutex_; |    std::mutex lineMutex_ {}; | ||||||
| 
 |  | ||||||
|    std::vector<std::shared_ptr<const gr::Placefile::LineDrawItem>> |  | ||||||
|       currentLineList_ {}; |  | ||||||
|    std::vector<std::shared_ptr<const gr::Placefile::LineDrawItem>> |  | ||||||
|       newLineList_ {}; |  | ||||||
| 
 | 
 | ||||||
|    std::size_t currentNumLines_ {}; |    std::size_t currentNumLines_ {}; | ||||||
|    std::size_t newNumLines_ {}; |    std::size_t newNumLines_ {}; | ||||||
| 
 | 
 | ||||||
|    std::vector<float> lineBuffer_ {}; |    std::vector<float> currentLinesBuffer_ {}; | ||||||
|    std::vector<GLint> thresholdBuffer_ {}; |    std::vector<GLint> currentThresholdBuffer_ {}; | ||||||
|  |    std::vector<float> newLinesBuffer_ {}; | ||||||
|  |    std::vector<GLint> newThresholdBuffer_ {}; | ||||||
| 
 | 
 | ||||||
|    std::shared_ptr<ShaderProgram> shaderProgram_; |    std::shared_ptr<ShaderProgram> shaderProgram_; | ||||||
|    GLint                          uMVPMatrixLocation_; |    GLint                          uMVPMatrixLocation_; | ||||||
|  | @ -75,9 +77,6 @@ public: | ||||||
|    std::array<GLuint, 2> vbo_; |    std::array<GLuint, 2> vbo_; | ||||||
| 
 | 
 | ||||||
|    GLsizei numVertices_; |    GLsizei numVertices_; | ||||||
| 
 |  | ||||||
|    void UpdateBuffers(); |  | ||||||
|    void Update(bool textureAtlasChanged); |  | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| PlacefileLines::PlacefileLines(std::shared_ptr<GlContext> context) : | PlacefileLines::PlacefileLines(std::shared_ptr<GlContext> context) : | ||||||
|  | @ -135,22 +134,13 @@ void PlacefileLines::Initialize() | ||||||
|                             reinterpret_cast<void*>(2 * sizeof(float))); |                             reinterpret_cast<void*>(2 * sizeof(float))); | ||||||
|    gl.glEnableVertexAttribArray(1); |    gl.glEnableVertexAttribArray(1); | ||||||
| 
 | 
 | ||||||
|    // aTexCoord
 |  | ||||||
|    gl.glVertexAttribPointer(2, |  | ||||||
|                             2, |  | ||||||
|                             GL_FLOAT, |  | ||||||
|                             GL_FALSE, |  | ||||||
|                             kPointsPerVertex * sizeof(float), |  | ||||||
|                             reinterpret_cast<void*>(4 * sizeof(float))); |  | ||||||
|    gl.glEnableVertexAttribArray(2); |  | ||||||
| 
 |  | ||||||
|    // aModulate
 |    // aModulate
 | ||||||
|    gl.glVertexAttribPointer(3, |    gl.glVertexAttribPointer(3, | ||||||
|                             4, |                             4, | ||||||
|                             GL_FLOAT, |                             GL_FLOAT, | ||||||
|                             GL_FALSE, |                             GL_FALSE, | ||||||
|                             kPointsPerVertex * sizeof(float), |                             kPointsPerVertex * sizeof(float), | ||||||
|                             reinterpret_cast<void*>(6 * sizeof(float))); |                             reinterpret_cast<void*>(4 * sizeof(float))); | ||||||
|    gl.glEnableVertexAttribArray(3); |    gl.glEnableVertexAttribArray(3); | ||||||
| 
 | 
 | ||||||
|    // aAngle
 |    // aAngle
 | ||||||
|  | @ -159,7 +149,7 @@ void PlacefileLines::Initialize() | ||||||
|                             GL_FLOAT, |                             GL_FLOAT, | ||||||
|                             GL_FALSE, |                             GL_FALSE, | ||||||
|                             kPointsPerVertex * sizeof(float), |                             kPointsPerVertex * sizeof(float), | ||||||
|                             reinterpret_cast<void*>(10 * sizeof(float))); |                             reinterpret_cast<void*>(8 * sizeof(float))); | ||||||
|    gl.glEnableVertexAttribArray(4); |    gl.glEnableVertexAttribArray(4); | ||||||
| 
 | 
 | ||||||
|    gl.glBindBuffer(GL_ARRAY_BUFFER, p->vbo_[1]); |    gl.glBindBuffer(GL_ARRAY_BUFFER, p->vbo_[1]); | ||||||
|  | @ -171,25 +161,23 @@ void PlacefileLines::Initialize() | ||||||
|                              GL_INT, |                              GL_INT, | ||||||
|                              0, |                              0, | ||||||
|                              static_cast<void*>(0)); |                              static_cast<void*>(0)); | ||||||
|    gl.glVertexAttribDivisor(5, 2); // One value per rectangle
 |  | ||||||
|    gl.glEnableVertexAttribArray(5); |    gl.glEnableVertexAttribArray(5); | ||||||
| 
 | 
 | ||||||
|    p->dirty_ = true; |    p->dirty_ = true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void PlacefileLines::Render( | void PlacefileLines::Render( | ||||||
|    const QMapLibreGL::CustomLayerRenderParameters& params, |    const QMapLibreGL::CustomLayerRenderParameters& params) | ||||||
|    bool                                            textureAtlasChanged) |  | ||||||
| { | { | ||||||
|    std::unique_lock lock {p->lineMutex_}; |    std::unique_lock lock {p->lineMutex_}; | ||||||
| 
 | 
 | ||||||
|    if (!p->currentLineList_.empty()) |    if (p->currentNumLines_ > 0) | ||||||
|    { |    { | ||||||
|       gl::OpenGLFunctions& gl = p->context_->gl(); |       gl::OpenGLFunctions& gl = p->context_->gl(); | ||||||
| 
 | 
 | ||||||
|       gl.glBindVertexArray(p->vao_); |       gl.glBindVertexArray(p->vao_); | ||||||
| 
 | 
 | ||||||
|       p->Update(textureAtlasChanged); |       p->Update(); | ||||||
|       p->shaderProgram_->Use(); |       p->shaderProgram_->Use(); | ||||||
|       UseRotationProjection(params, p->uMVPMatrixLocation_); |       UseRotationProjection(params, p->uMVPMatrixLocation_); | ||||||
|       UseMapProjection( |       UseMapProjection( | ||||||
|  | @ -208,10 +196,6 @@ void PlacefileLines::Render( | ||||||
|          gl.glUniform1f(p->uMapDistanceLocation_, 0.0f); |          gl.glUniform1f(p->uMapDistanceLocation_, 0.0f); | ||||||
|       } |       } | ||||||
| 
 | 
 | ||||||
|       // Interpolate texture coordinates
 |  | ||||||
|       gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |  | ||||||
|       gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |  | ||||||
| 
 |  | ||||||
|       // Draw icons
 |       // Draw icons
 | ||||||
|       gl.glDrawArrays(GL_TRIANGLES, 0, p->numVertices_); |       gl.glDrawArrays(GL_TRIANGLES, 0, p->numVertices_); | ||||||
|    } |    } | ||||||
|  | @ -226,15 +210,15 @@ void PlacefileLines::Deinitialize() | ||||||
| 
 | 
 | ||||||
|    std::unique_lock lock {p->lineMutex_}; |    std::unique_lock lock {p->lineMutex_}; | ||||||
| 
 | 
 | ||||||
|    p->currentLineList_.clear(); |    p->currentLinesBuffer_.clear(); | ||||||
|    p->lineBuffer_.clear(); |    p->currentThresholdBuffer_.clear(); | ||||||
|    p->thresholdBuffer_.clear(); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void PlacefileLines::StartLines() | void PlacefileLines::StartLines() | ||||||
| { | { | ||||||
|    // Clear the new buffer
 |    // Clear the new buffers
 | ||||||
|    p->newLineList_.clear(); |    p->newLinesBuffer_.clear(); | ||||||
|  |    p->newThresholdBuffer_.clear(); | ||||||
| 
 | 
 | ||||||
|    p->newNumLines_ = 0u; |    p->newNumLines_ = 0u; | ||||||
| } | } | ||||||
|  | @ -242,13 +226,10 @@ void PlacefileLines::StartLines() | ||||||
| void PlacefileLines::AddLine( | void PlacefileLines::AddLine( | ||||||
|    const std::shared_ptr<gr::Placefile::LineDrawItem>& di) |    const std::shared_ptr<gr::Placefile::LineDrawItem>& di) | ||||||
| { | { | ||||||
|    if (di != nullptr) |    if (di != nullptr && !di->elements_.empty()) | ||||||
|    { |    { | ||||||
|       p->newLineList_.emplace_back(di); |       p->UpdateBuffers(di); | ||||||
|       if (!di->elements_.empty()) |       p->newNumLines_ += (di->elements_.size() - 1) * 2; | ||||||
|       { |  | ||||||
|          p->newNumLines_ += di->elements_.size() - 1; |  | ||||||
|       } |  | ||||||
|    } |    } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -257,124 +238,141 @@ void PlacefileLines::FinishLines() | ||||||
|    std::unique_lock lock {p->lineMutex_}; |    std::unique_lock lock {p->lineMutex_}; | ||||||
| 
 | 
 | ||||||
|    // Swap buffers
 |    // Swap buffers
 | ||||||
|    p->currentLineList_.swap(p->newLineList_); |    p->currentLinesBuffer_.swap(p->newLinesBuffer_); | ||||||
|  |    p->currentThresholdBuffer_.swap(p->newThresholdBuffer_); | ||||||
| 
 | 
 | ||||||
|    // Clear the new buffers
 |    // Clear the new buffers
 | ||||||
|    p->newLineList_.clear(); |    p->newLinesBuffer_.clear(); | ||||||
|  |    p->newThresholdBuffer_.clear(); | ||||||
| 
 | 
 | ||||||
|    // Update the number of lines
 |    // Update the number of lines
 | ||||||
|    p->currentNumLines_ = p->newNumLines_; |    p->currentNumLines_ = p->newNumLines_; | ||||||
|  |    p->numVertices_ = | ||||||
|  |       static_cast<GLsizei>(p->currentNumLines_ * kVerticesPerRectangle); | ||||||
| 
 | 
 | ||||||
|    // Mark the draw item dirty
 |    // Mark the draw item dirty
 | ||||||
|    p->dirty_ = true; |    p->dirty_ = true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void PlacefileLines::Impl::UpdateBuffers() | void PlacefileLines::Impl::UpdateBuffers( | ||||||
|  |    std::shared_ptr<const gr::Placefile::LineDrawItem> di) | ||||||
| { | { | ||||||
|    auto texture = |    // Threshold value
 | ||||||
|       util::TextureAtlas::Instance().GetTextureAttributes(kTextureName_); |    units::length::nautical_miles<double> threshold = di->threshold_; | ||||||
|  |    GLint thresholdValue = static_cast<GLint>(std::round(threshold.value())); | ||||||
| 
 | 
 | ||||||
|    // Texture coordinates (rotated)
 |    std::vector<float> angles {}; | ||||||
|    const float ls = texture.tTop_; |    angles.reserve(di->elements_.size() - 1); | ||||||
|    const float rs = texture.tBottom_; |  | ||||||
|    const float tt = texture.sLeft_; |  | ||||||
|    const float bt = texture.sRight_; |  | ||||||
| 
 | 
 | ||||||
|    lineBuffer_.clear(); |    // For each element pair inside a Line statement, render a black line
 | ||||||
|    lineBuffer_.reserve(currentNumLines_ * kBufferLength); |    for (std::size_t i = 0; i < di->elements_.size() - 1; ++i) | ||||||
|    thresholdBuffer_.clear(); |  | ||||||
|    thresholdBuffer_.reserve(currentNumLines_); |  | ||||||
|    numVertices_ = 0; |  | ||||||
| 
 |  | ||||||
|    for (auto& di : currentLineList_) |  | ||||||
|    { |    { | ||||||
|       // Threshold value
 |       // Latitude and longitude coordinates in degrees
 | ||||||
|       units::length::nautical_miles<double> threshold = di->threshold_; |       const float lat1 = static_cast<float>(di->elements_[i].latitude_); | ||||||
|       GLint thresholdValue = static_cast<GLint>(std::round(threshold.value())); |       const float lon1 = static_cast<float>(di->elements_[i].longitude_); | ||||||
|  |       const float lat2 = static_cast<float>(di->elements_[i + 1].latitude_); | ||||||
|  |       const float lon2 = static_cast<float>(di->elements_[i + 1].longitude_); | ||||||
| 
 | 
 | ||||||
|       // TODO: Angle in degrees
 |       // Calculate angle
 | ||||||
|       // const float a = 0.0f;
 |       const units::angle::degrees<double> angle = | ||||||
|  |          util::GeographicLib::GetAngle(lat1, lon1, lat2, lon2); | ||||||
|  |       float angleValue = angle.value(); | ||||||
|  |       angles.push_back(angleValue); | ||||||
| 
 | 
 | ||||||
|       // Line width / half width
 |       BufferLine(di->elements_[i], | ||||||
|       const float lw = static_cast<float>(di->width_); |                  di->elements_[i + 1], | ||||||
|       const float hw = lw * 0.5f; |                  di->width_ + 2, | ||||||
| 
 |                  static_cast<float>(angleValue), | ||||||
|       // For each element pair inside a Line statement
 |                  kBlack_, | ||||||
|       for (std::size_t i = 0; i < di->elements_.size() - 1; ++i) |                  thresholdValue); | ||||||
|       { |  | ||||||
|          // Latitude and longitude coordinates in degrees
 |  | ||||||
|          const float lat1 = static_cast<float>(di->elements_[i].latitude_); |  | ||||||
|          const float lon1 = static_cast<float>(di->elements_[i].longitude_); |  | ||||||
|          const float lat2 = static_cast<float>(di->elements_[i + 1].latitude_); |  | ||||||
|          const float lon2 = static_cast<float>(di->elements_[i + 1].longitude_); |  | ||||||
| 
 |  | ||||||
|          // TODO: Base X/Y offsets in pixels
 |  | ||||||
|          // const float x1 = static_cast<float>(di->elements_[i].x_);
 |  | ||||||
|          // const float y1 = static_cast<float>(di->elements_[i].y_);
 |  | ||||||
|          // const float x2 = static_cast<float>(di->elements_[i + 1].x_);
 |  | ||||||
|          // const float y2 = static_cast<float>(di->elements_[i + 1].y_);
 |  | ||||||
| 
 |  | ||||||
|          // TODO: Refactor this to placefile update time instead of buffer time
 |  | ||||||
|          const units::angle::degrees<double> angle = |  | ||||||
|             util::GeographicLib::GetAngle(lat1, lon1, lat2, lon2); |  | ||||||
|          const float a = static_cast<float>(angle.value()); |  | ||||||
| 
 |  | ||||||
|          // Final X/Y offsets in pixels
 |  | ||||||
|          const float lx = -hw; |  | ||||||
|          const float rx = +hw; |  | ||||||
|          const float ty = +hw; |  | ||||||
|          const float by = -hw; |  | ||||||
| 
 |  | ||||||
|          // Modulate color
 |  | ||||||
|          const float mc0 = di->color_[0] / 255.0f; |  | ||||||
|          const float mc1 = di->color_[1] / 255.0f; |  | ||||||
|          const float mc2 = di->color_[2] / 255.0f; |  | ||||||
|          const float mc3 = di->color_[3] / 255.0f; |  | ||||||
| 
 |  | ||||||
|          lineBuffer_.insert( |  | ||||||
|             lineBuffer_.end(), |  | ||||||
|             { |  | ||||||
|                // Icon
 |  | ||||||
|                lat1, lon1, lx, by, ls, bt, mc0, mc1, mc2, mc3, a, // BL
 |  | ||||||
|                lat2, lon2, lx, ty, ls, tt, mc0, mc1, mc2, mc3, a, // TL
 |  | ||||||
|                lat1, lon1, rx, by, rs, bt, mc0, mc1, mc2, mc3, a, // BR
 |  | ||||||
|                lat1, lon1, rx, by, rs, bt, mc0, mc1, mc2, mc3, a, // BR
 |  | ||||||
|                lat2, lon2, rx, ty, rs, tt, mc0, mc1, mc2, mc3, a, // TR
 |  | ||||||
|                lat2, lon2, lx, ty, ls, tt, mc0, mc1, mc2, mc3, a  // TL
 |  | ||||||
|             }); |  | ||||||
|          thresholdBuffer_.push_back(thresholdValue); |  | ||||||
|       } |  | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    dirty_ = true; |    // For each element pair inside a Line statement, render a colored line
 | ||||||
|  |    for (std::size_t i = 0; i < di->elements_.size() - 1; ++i) | ||||||
|  |    { | ||||||
|  |       float angleValue = angles[i]; | ||||||
|  | 
 | ||||||
|  |       BufferLine(di->elements_[i], | ||||||
|  |                  di->elements_[i + 1], | ||||||
|  |                  di->width_, | ||||||
|  |                  static_cast<float>(angleValue), | ||||||
|  |                  di->color_, | ||||||
|  |                  thresholdValue); | ||||||
|  |    } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void PlacefileLines::Impl::Update(bool textureAtlasChanged) | void PlacefileLines::Impl::BufferLine( | ||||||
|  |    const gr::Placefile::LineDrawItem::Element& e1, | ||||||
|  |    const gr::Placefile::LineDrawItem::Element& e2, | ||||||
|  |    const float                                 width, | ||||||
|  |    const float                                 angle, | ||||||
|  |    const boost::gil::rgba8_pixel_t             color, | ||||||
|  |    const GLint                                 threshold) | ||||||
| { | { | ||||||
|    // If the texture atlas has changed
 |    // Latitude and longitude coordinates in degrees
 | ||||||
|    if (dirty_ || textureAtlasChanged) |    const float lat1 = static_cast<float>(e1.latitude_); | ||||||
|    { |    const float lon1 = static_cast<float>(e1.longitude_); | ||||||
|       // Update OpenGL buffer data
 |    const float lat2 = static_cast<float>(e2.latitude_); | ||||||
|       UpdateBuffers(); |    const float lon2 = static_cast<float>(e2.longitude_); | ||||||
| 
 | 
 | ||||||
|  |    // TODO: Base X/Y offsets in pixels
 | ||||||
|  |    // const float x1 = static_cast<float>(e1.x_);
 | ||||||
|  |    // const float y1 = static_cast<float>(e1.y_);
 | ||||||
|  |    // const float x2 = static_cast<float>(e2.x_);
 | ||||||
|  |    // const float y2 = static_cast<float>(e2.y_);
 | ||||||
|  | 
 | ||||||
|  |    // Angle
 | ||||||
|  |    const float a = angle; | ||||||
|  | 
 | ||||||
|  |    // Final X/Y offsets in pixels
 | ||||||
|  |    const float hw = width * 0.5f; | ||||||
|  |    const float lx = -hw; | ||||||
|  |    const float rx = +hw; | ||||||
|  |    const float ty = +hw; | ||||||
|  |    const float by = -hw; | ||||||
|  | 
 | ||||||
|  |    // Modulate color
 | ||||||
|  |    const float mc0 = color[0] / 255.0f; | ||||||
|  |    const float mc1 = color[1] / 255.0f; | ||||||
|  |    const float mc2 = color[2] / 255.0f; | ||||||
|  |    const float mc3 = color[3] / 255.0f; | ||||||
|  | 
 | ||||||
|  |    // Update buffers
 | ||||||
|  |    newLinesBuffer_.insert(newLinesBuffer_.end(), | ||||||
|  |                           { | ||||||
|  |                              // Line
 | ||||||
|  |                              lat1, lon1, lx, by, mc0, mc1, mc2, mc3, a, // BL
 | ||||||
|  |                              lat2, lon2, lx, ty, mc0, mc1, mc2, mc3, a, // TL
 | ||||||
|  |                              lat1, lon1, rx, by, mc0, mc1, mc2, mc3, a, // BR
 | ||||||
|  |                              lat1, lon1, rx, by, mc0, mc1, mc2, mc3, a, // BR
 | ||||||
|  |                              lat2, lon2, rx, ty, mc0, mc1, mc2, mc3, a, // TR
 | ||||||
|  |                              lat2, lon2, lx, ty, mc0, mc1, mc2, mc3, a  // TL
 | ||||||
|  |                           }); | ||||||
|  |    newThresholdBuffer_.insert( | ||||||
|  |       newThresholdBuffer_.end(), | ||||||
|  |       {threshold, threshold, threshold, threshold, threshold, threshold}); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void PlacefileLines::Impl::Update() | ||||||
|  | { | ||||||
|  |    // If the placefile has been updated
 | ||||||
|  |    if (dirty_) | ||||||
|  |    { | ||||||
|       gl::OpenGLFunctions& gl = context_->gl(); |       gl::OpenGLFunctions& gl = context_->gl(); | ||||||
| 
 | 
 | ||||||
|       // Buffer vertex data
 |       // Buffer lines data
 | ||||||
|       gl.glBindBuffer(GL_ARRAY_BUFFER, vbo_[0]); |       gl.glBindBuffer(GL_ARRAY_BUFFER, vbo_[0]); | ||||||
|       gl.glBufferData(GL_ARRAY_BUFFER, |       gl.glBufferData(GL_ARRAY_BUFFER, | ||||||
|                       sizeof(float) * lineBuffer_.size(), |                       sizeof(float) * currentLinesBuffer_.size(), | ||||||
|                       lineBuffer_.data(), |                       currentLinesBuffer_.data(), | ||||||
|                       GL_DYNAMIC_DRAW); |                       GL_DYNAMIC_DRAW); | ||||||
| 
 | 
 | ||||||
|       // Buffer threshold data
 |       // Buffer threshold data
 | ||||||
|       gl.glBindBuffer(GL_ARRAY_BUFFER, vbo_[1]); |       gl.glBindBuffer(GL_ARRAY_BUFFER, vbo_[1]); | ||||||
|       gl.glBufferData(GL_ARRAY_BUFFER, |       gl.glBufferData(GL_ARRAY_BUFFER, | ||||||
|                       sizeof(GLint) * thresholdBuffer_.size(), |                       sizeof(GLint) * currentThresholdBuffer_.size(), | ||||||
|                       thresholdBuffer_.data(), |                       currentThresholdBuffer_.data(), | ||||||
|                       GL_DYNAMIC_DRAW); |                       GL_DYNAMIC_DRAW); | ||||||
| 
 |  | ||||||
|       numVertices_ = |  | ||||||
|          static_cast<GLsizei>(lineBuffer_.size() / kVerticesPerRectangle); |  | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    dirty_ = false; |    dirty_ = false; | ||||||
|  |  | ||||||
|  | @ -28,8 +28,7 @@ public: | ||||||
|    void set_thresholded(bool thresholded); |    void set_thresholded(bool thresholded); | ||||||
| 
 | 
 | ||||||
|    void Initialize() override; |    void Initialize() override; | ||||||
|    void Render(const QMapLibreGL::CustomLayerRenderParameters& params, |    void Render(const QMapLibreGL::CustomLayerRenderParameters& params) override; | ||||||
|                bool textureAtlasChanged) override; |  | ||||||
|    void Deinitialize() override; |    void Deinitialize() override; | ||||||
| 
 | 
 | ||||||
|    /**
 |    /**
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat