From: Mikko Rasa Date: Thu, 7 Apr 2022 07:38:21 +0000 (+0300) Subject: Use a default sampler in Renderer if null was passed in X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=d638587797a68e3095fb54cd2616f7b2f37a30ee;p=libs%2Fgl.git Use a default sampler in Renderer if null was passed in --- diff --git a/source/render/renderer.cpp b/source/render/renderer.cpp index 6bbfbbe0..98246da7 100644 --- a/source/render/renderer.cpp +++ b/source/render/renderer.cpp @@ -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("_placeholder.png")) + placeholder_texture(Resources::get_global().get("_placeholder.png")), + default_sampler(Resources::get_global().get("_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) { diff --git a/source/render/renderer.h b/source/render/renderer.h index 99c8c500..4e702042 100644 --- a/source/render/renderer.h +++ b/source/render/renderer.h @@ -117,6 +117,7 @@ private: std::vector shdata_stack; std::vector texture_stack; const Texture &placeholder_texture; + const Sampler &default_sampler; PipelineState *last_pipeline = 0; Commands commands;