@@ -106,16 +106,17 @@ rhi::MeshShaderResource* PointShader::createShaderResource(QRhi* rhi, QRhiBuffer
106106class LineShaderResource : public rhi ::MeshShaderResource
107107{
108108public:
109- enum { MV, COL, CLIP, VCOL };
109+ enum { MV, COL, CLIP, VCOL, TEX };
110110
111111public:
112- LineShaderResource (QRhi* rhi, QRhiBuffer* globalBuf) : rhi::MeshShaderResource(rhi)
112+ LineShaderResource (QRhi* rhi, QRhiBuffer* globalBuf, rhi::Texture& tex1D ) : rhi::MeshShaderResource(rhi)
113113 {
114114 m_data.create ({
115115 {rhi::UniformBlock::MAT4, " mv" },
116116 {rhi::UniformBlock::VEC4, " col" },
117117 {rhi::UniformBlock::INT , " useClipping" },
118- {rhi::UniformBlock::INT , " useVertexColor" }
118+ {rhi::UniformBlock::INT , " useVertexColor" },
119+ {rhi::UniformBlock::INT , " useTexture" }
119120 });
120121
121122 // create the buffer
@@ -129,7 +130,8 @@ class LineShaderResource : public rhi::MeshShaderResource
129130 srb.reset (rhi->newShaderResourceBindings ());
130131 srb->setBindings ({
131132 QRhiShaderResourceBinding::uniformBuffer (0 , visibility, globalBuf),
132- QRhiShaderResourceBinding::uniformBuffer (1 , visibility, ubuf.get ())
133+ QRhiShaderResourceBinding::uniformBuffer (1 , visibility, ubuf.get ()),
134+ QRhiShaderResourceBinding::sampledTexture (2 , visibility, tex1D.texture .get (), tex1D.sampler .get ())
133135 });
134136 srb->create ();
135137 }
@@ -143,6 +145,7 @@ class LineShaderResource : public rhi::MeshShaderResource
143145 m_data.setVec4 (COL, diffuse);
144146 m_data.setInt (CLIP, (m.doClipping ? 1 : 0 ));
145147 m_data.setInt (VCOL, (m.mat .diffuseMap == GLMaterial::VERTEX_COLOR ? 1 : 0 ));
148+ m_data.setInt (TEX , (m.mat .diffuseMap == GLMaterial::TEXTURE_1D ? 1 : 0 ));
146149 }
147150};
148151
@@ -155,18 +158,19 @@ QRhiVertexInputLayout LineShader::meshLayout()
155158{
156159 QRhiVertexInputLayout meshLayout;
157160 meshLayout.setBindings ({
158- { 7 * sizeof (float ) }
161+ { 10 * sizeof (float ) }
159162 });
160163 meshLayout.setAttributes ({
161164 { 0 , 0 , QRhiVertexInputAttribute::Float3, 0 }, // position
162- { 0 , 1 , QRhiVertexInputAttribute::Float4, 3 * sizeof (float ) } // color
165+ { 0 , 1 , QRhiVertexInputAttribute::Float3, 3 * sizeof (float ) }, // texture coordinate
166+ { 0 , 2 , QRhiVertexInputAttribute::Float4, 6 * sizeof (float ) } // color
163167 });
164168 return meshLayout;
165169}
166170
167- rhi::MeshShaderResource* LineShader::createShaderResource (QRhi* rhi, QRhiBuffer* globalBuf)
171+ rhi::MeshShaderResource* LineShader::createShaderResource (QRhi* rhi, QRhiBuffer* globalBuf, rhi::Texture& tex1D )
168172{
169- return new LineShaderResource (rhi, globalBuf);
173+ return new LineShaderResource (rhi, globalBuf, tex1D );
170174}
171175
172176class ColorShaderResource : public rhi ::MeshShaderResource
0 commit comments