@@ -20,71 +20,71 @@ TextureSamplerDescriptor::TextureSamplerDescriptor(const std::shared_ptr<class T
2020
2121auto TextureSamplerDescriptor::Empty () const -> bool
2222{
23- return m_texture. expired () || m_sampler. expired ();
23+ return m_texture-> Empty ();
2424}
2525
2626void TextureSamplerDescriptor::Bind (GLint unit, const Shader& shader) const
2727{
28- auto texture = m_texture.lock ();
29- auto sampler = m_sampler.lock ();
3028
31- if (texture && sampler )
29+ if (m_texture && m_sampler )
3230 {
33- texture ->Bind (unit, sampler );
31+ m_texture ->Bind (unit, m_sampler );
3432
3533 shader.SetUniformInt (std::string (" sampler_" + m_samplerName).c_str (), unit);
3634 // Might be setting this more than once if the texture is used with different wrap/filter modes, but this rarely happens.
37- shader.SetUniformFloat4 (std::string (" texsize_" + m_sizeName).c_str (), {texture ->Width (),
38- texture ->Height (),
39- 1 .0f / static_cast <float >(texture ->Width ()),
40- 1 .0f / static_cast <float >(texture ->Height ())});
35+ shader.SetUniformFloat4 (std::string (" texsize_" + m_sizeName).c_str (), {m_texture ->Width (),
36+ m_texture ->Height (),
37+ 1 .0f / static_cast <float >(m_texture ->Width ()),
38+ 1 .0f / static_cast <float >(m_texture ->Height ())});
4139 // Bind shorthand random texture size uniform
4240 if (m_sizeName.substr (0 , 4 ) == " rand" && m_sizeName.length () > 7 && m_sizeName.at (6 ) == ' _' )
4341 {
44- shader.SetUniformFloat4 (std::string (" texsize_" + m_sizeName.substr (0 , 6 )).c_str (), {texture ->Width (),
45- texture ->Height (),
46- 1 .0f / static_cast <float >(texture ->Width ()),
47- 1 .0f / static_cast <float >(texture ->Height ())});
42+ shader.SetUniformFloat4 (std::string (" texsize_" + m_sizeName.substr (0 , 6 )).c_str (), {m_texture ->Width (),
43+ m_texture ->Height (),
44+ 1 .0f / static_cast <float >(m_texture ->Width ()),
45+ 1 .0f / static_cast <float >(m_texture ->Height ())});
4846 }
4947 }
5048}
5149
5250void TextureSamplerDescriptor::Unbind (GLint unit)
5351{
54- auto texture = m_texture.lock ();
55- if (texture)
52+ if (m_texture)
5653 {
57- texture ->Unbind (unit);
54+ m_texture ->Unbind (unit);
5855 }
5956 Sampler::Unbind (unit);
6057}
6158
6259auto TextureSamplerDescriptor::Texture () const -> std::shared_ptr<class Texture>
6360{
64- return m_texture. lock () ;
61+ return m_texture;
6562}
6663
67- void TextureSamplerDescriptor::Texture (std::weak_ptr< class Texture > texture)
64+ void TextureSamplerDescriptor::Texture (const std::shared_ptr<Renderer:: Texture>& texture)
6865{
6966 m_texture = texture;
7067}
7168
69+ void TextureSamplerDescriptor::Texture (const std::weak_ptr<Renderer::Texture>& texture)
70+ {
71+ m_texture = texture.lock ();
72+ }
73+
7274auto TextureSamplerDescriptor::Sampler () const -> std::shared_ptr<class Sampler>
7375{
74- return m_sampler. lock () ;
76+ return m_sampler;
7577}
7678
7779auto TextureSamplerDescriptor::SamplerDeclaration () const -> std::string
7880{
79- auto texture = m_texture.lock ();
80- auto sampler = m_sampler.lock ();
81- if (!texture || !sampler)
81+ if (!m_texture || !m_sampler)
8282 {
8383 return {};
8484 }
8585
8686 std::string declaration = " uniform " ;
87- if (texture ->Type () == GL_TEXTURE_3D)
87+ if (m_texture ->Type () == GL_TEXTURE_3D)
8888 {
8989 declaration.append (" sampler3D sampler_" );
9090 }
@@ -109,9 +109,7 @@ auto TextureSamplerDescriptor::SamplerDeclaration() const -> std::string
109109
110110auto TextureSamplerDescriptor::TexSizeDeclaration () const -> std::string
111111{
112- auto texture = m_texture.lock ();
113- auto sampler = m_sampler.lock ();
114- if (!texture || !sampler)
112+ if (!m_texture || !m_sampler)
115113 {
116114 return {};
117115 }
0 commit comments