From: Mikko Rasa Date: Sat, 30 Oct 2021 20:02:39 +0000 (+0300) Subject: Improve material handling in RenderMethod X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=b1862c511570cb82155cc8c0628e1e903388fc10;p=libs%2Fgl.git Improve material handling in RenderMethod --- diff --git a/source/materials/rendermethod.cpp b/source/materials/rendermethod.cpp index 3208929c..2b4738ef 100644 --- a/source/materials/rendermethod.cpp +++ b/source/materials/rendermethod.cpp @@ -16,6 +16,9 @@ namespace GL { void RenderMethod::set_material_textures() { + if(!material) + return; + const Tag *material_texture_tags = material->get_texture_tags(); for(const Tag *tag=material_texture_tags; tag->id; ++tag) set_texture(*tag, material->get_texture(*tag), material->get_sampler(*tag)); @@ -23,7 +26,7 @@ void RenderMethod::set_material_textures() void RenderMethod::maybe_create_material_shader() { - if(shprog && !shprog_from_material) + if(!material || (shprog && !shprog_from_material)) return; map extra_spec; @@ -45,6 +48,7 @@ void RenderMethod::set_shader_program(const Program *prog, const ProgramData *da shprog = prog; shprog_from_material = false; shdata = (data ? new ProgramData(*data) : 0); + maybe_create_material_shader(); } Tag RenderMethod::get_slotted_uniform_tag(Tag slot) const @@ -94,6 +98,7 @@ void RenderMethod::set_blend(const Blend &b) void RenderMethod::set_receive_shadows(bool rs) { receive_shadows = rs; + maybe_create_material_shader(); } void RenderMethod::apply(Renderer &renderer) const