]> git.tdb.fi Git - libs/gl.git/commitdiff
Use a default sampler in Renderer if null was passed in
authorMikko Rasa <tdb@tdb.fi>
Thu, 7 Apr 2022 07:38:21 +0000 (10:38 +0300)
committerMikko Rasa <tdb@tdb.fi>
Thu, 7 Apr 2022 07:38:21 +0000 (10:38 +0300)
source/render/renderer.cpp
source/render/renderer.h

index 6bbfbbe0d0785628b89d1ec7c84608b2f0905b93..98246da7fb6c7d42bd17dfc0c78f2ad3444b8dc3 100644 (file)
@@ -25,7 +25,8 @@ const Tag Renderer::world_obj_matrix_tag("world_obj_matrix");
 const Tag Renderer::world_obj_normal_matrix_tag("world_obj_normal_matrix");
 
 Renderer::Renderer():
-       placeholder_texture(Resources::get_global().get<Texture>("_placeholder.png"))
+       placeholder_texture(Resources::get_global().get<Texture>("_placeholder.png")),
+       default_sampler(Resources::get_global().get<Sampler>("_linear_clamp.samp"))
 {
        state_stack.reserve(16);
        shdata_stack.reserve(32);
@@ -171,7 +172,11 @@ void Renderer::set_texture(Tag tag, const Texture *tex, int level, const Sampler
                        res_mgr->resource_used(*tex);
                if(!tex->is_loaded())
                        tex = &placeholder_texture;
+               if(!samp)
+                       samp = &default_sampler;
        }
+       else
+               samp = 0;
 
        if(texture_stack.size()>state.texture_count)
        {
index 99c8c5002b242da1d18c694d77996ff8ded0607c..4e70204240f3de2591d987d65551cc44379f97d5 100644 (file)
@@ -117,6 +117,7 @@ private:
        std::vector<BoundProgramData> shdata_stack;
        std::vector<BoundTexture> texture_stack;
        const Texture &placeholder_texture;
+       const Sampler &default_sampler;
        PipelineState *last_pipeline = 0;
        Commands commands;