From 4b1d63ea6216abe8dd2d078e317f8f4a74ff0df4 Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Tue, 4 Oct 2022 23:16:57 -0500 Subject: [PATCH] Adding default texture to line, fixing texture coordinates --- scwx-qt/res/textures/lines/default-1x7.png | Bin 0 -> 486 bytes scwx-qt/res/textures/lines/test-pattern.png | Bin 0 -> 479 bytes scwx-qt/scwx-qt.qrc | 2 ++ scwx-qt/source/scwx/qt/gl/draw/geo_line.cpp | 24 ++++++++++++-------- 4 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 scwx-qt/res/textures/lines/default-1x7.png create mode 100644 scwx-qt/res/textures/lines/test-pattern.png diff --git a/scwx-qt/res/textures/lines/default-1x7.png b/scwx-qt/res/textures/lines/default-1x7.png new file mode 100644 index 0000000000000000000000000000000000000000..0b72d67c1e88ef1ed732ed3d3834e913794c6db1 GIT binary patch literal 486 zcmV@P)EX>4Tx04R}tkv&MmKpe$iKcrGBB6bjQ$WR@`f>aSlsbUcFVPW-reS>)G@?ahO;rb+OdNtgI`<)5H;3Q7PY> zb6DoQ#aXG=S^J*+g`tAFlHoed5hSpLBvKF{p^gfwFcGCyCB;CR_Tw)8VcVY~mqe}# z7&#VDg96d^ga5(rZjItp%t;Exfu0x3`WOWQyFja9S>MN&)j9!u&%l-1@z?i4s zjutrr`nQ3L>y9Sv0hc?#(32+WqAmGodW%Ki{fxdT4-DP{!8ND1_C8J@fGl;jd;=UD z0%Il0UUzwSZ+CD1o@w{@1HxT$$2hp7I{*Lx97#k$R0!8C#IX$k00_V!;{QL_K^fpR cmB9sp1!Xn`0+>P{0RR91 literal 0 HcmV?d00001 diff --git a/scwx-qt/res/textures/lines/test-pattern.png b/scwx-qt/res/textures/lines/test-pattern.png new file mode 100644 index 0000000000000000000000000000000000000000..b9a0224e943aec2d703c4606d3ea9c58a5df89d6 GIT binary patch literal 479 zcmV<50U-W~P)EX>4Tx04R}tkv&MmKpe$iKcrGBB6bjQ$WR@`f>aSlsbUcFVPW-reS>)G@?ahO;rb+OdNtgI`<)5H;3Q7PY> zb6DoQ#aXG=S^J*+g`tAFlHoed5hSpLBvKF{p^gfwFcGCyCB;CR_Tw)8VcVY~mqe}# z7&#VDg96d^ga5(rZjItp%t;Exfu0x3`WOWQyFja9S>MN&)j9!u&%l-1@z?i4s zjutrr`nQ3L>y9Sv0hc?#(32+WqAmGodW%Ki{fxdT4-DP{!8ND1_C8J@fGl;jd;=UD z0%Il0UUzwSZ+CD1o@w{@1HxT$$2hp7I{*Lx6-h)vR0!7v!2tmP004jx|4$b}P#GTY V1pJFeHCO-u002ovPDHLkV1l7j(enTR literal 0 HcmV?d00001 diff --git a/scwx-qt/scwx-qt.qrc b/scwx-qt/scwx-qt.qrc index bf64e1fd..cf31a039 100644 --- a/scwx-qt/scwx-qt.qrc +++ b/scwx-qt/scwx-qt.qrc @@ -15,5 +15,7 @@ res/fonts/din1451alt_g.ttf res/icons/font-awesome-6/square-minus-regular.svg res/icons/font-awesome-6/square-plus-regular.svg + res/textures/lines/default-1x7.png + res/textures/lines/test-pattern.png diff --git a/scwx-qt/source/scwx/qt/gl/draw/geo_line.cpp b/scwx-qt/source/scwx/qt/gl/draw/geo_line.cpp index 56f8c16b..47350dd2 100644 --- a/scwx-qt/source/scwx/qt/gl/draw/geo_line.cpp +++ b/scwx-qt/source/scwx/qt/gl/draw/geo_line.cpp @@ -32,12 +32,13 @@ public: dirty_ {false}, visible_ {true}, points_ {}, - width_ {1.0f}, + width_ {7.0f}, modulateColor_ {std::nullopt}, shaderProgram_ {nullptr}, uMVPMatrixLocation_(GL_INVALID_INDEX), uMapMatrixLocation_(GL_INVALID_INDEX), uMapScreenCoordLocation_(GL_INVALID_INDEX), + texture_ {GL_INVALID_INDEX}, vao_ {GL_INVALID_INDEX}, vbo_ {GL_INVALID_INDEX} { @@ -55,13 +56,12 @@ public: std::optional modulateColor_; - // TODO: Texture - std::shared_ptr shaderProgram_; GLint uMVPMatrixLocation_; GLint uMapMatrixLocation_; GLint uMapScreenCoordLocation_; + GLuint texture_; GLuint vao_; GLuint vbo_; @@ -105,6 +105,9 @@ void GeoLine::Initialize() logger_->warn("Could not find uMapScreenCoord"); } + p->texture_ = + p->context_->GetTexture(":/res/textures/lines/default-1x7.png"); + gl.glGenVertexArrays(1, &p->vao_); gl.glGenBuffers(1, &p->vbo_); @@ -167,6 +170,9 @@ void GeoLine::Render(const QMapbox::CustomLayerRenderParameters& params) UseMapProjection( params, p->uMapMatrixLocation_, p->uMapScreenCoordLocation_); + gl.glActiveTexture(GL_TEXTURE0); + gl.glBindTexture(GL_TEXTURE_2D, p->texture_); + // Draw line gl.glDrawArrays(GL_TRIANGLES, 0, 6); } @@ -256,12 +262,12 @@ void GeoLine::Impl::Update() { // // Line { - {lx, by, -ox, -oy, 0.0f, 0.0f, mc0, mc1, mc2, mc3}, // BL - {lx, by, +ox, +oy, 0.0f, 1.0f, mc0, mc1, mc2, mc3}, // TL - {rx, ty, -ox, -oy, 1.0f, 0.0f, mc0, mc1, mc2, mc3}, // BR - {rx, ty, -ox, -oy, 1.0f, 0.0f, mc0, mc1, mc2, mc3}, // BR - {rx, ty, +ox, +oy, 1.0f, 1.0f, mc0, mc1, mc2, mc3}, // TR - {lx, by, +ox, +oy, 0.0f, 1.0f, mc0, mc1, mc2, mc3} // TL + {lx, by, -ox, -oy, 0.0f, 1.0f, mc0, mc1, mc2, mc3}, // BL + {lx, by, +ox, +oy, 0.0f, 0.0f, mc0, mc1, mc2, mc3}, // TL + {rx, ty, -ox, -oy, 1.0f, 1.0f, mc0, mc1, mc2, mc3}, // BR + {rx, ty, -ox, -oy, 1.0f, 1.0f, mc0, mc1, mc2, mc3}, // BR + {rx, ty, +ox, +oy, 1.0f, 0.0f, mc0, mc1, mc2, mc3}, // TR + {lx, by, +ox, +oy, 0.0f, 0.0f, mc0, mc1, mc2, mc3} // TL }}; gl.glBufferData(GL_ARRAY_BUFFER,