From 68a5c400f14fcca2ee7edd0787114cf97df45e37 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 15 Jul 2023 00:08:28 +0300 Subject: [PATCH] Add getters for textures and samplers in RenderMethod --- source/materials/rendermethod.cpp | 12 ++++++++++++ source/materials/rendermethod.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/source/materials/rendermethod.cpp b/source/materials/rendermethod.cpp index 9e9a477e..e489dbe7 100644 --- a/source/materials/rendermethod.cpp +++ b/source/materials/rendermethod.cpp @@ -98,6 +98,18 @@ Tag RenderMethod::get_texture_tag(const string &slot) const return (i!=textures.end() ? i->tag : Tag()); } +const Texture *RenderMethod::get_texture(Tag tag) const +{ + auto i = find_member(textures, tag, &TextureSlot::tag); + return (i!=textures.end() ? i->texture : nullptr); +} + +const Sampler *RenderMethod::get_sampler(Tag tag) const +{ + auto i = find_member(textures, tag, &TextureSlot::tag); + return (i!=textures.end() ? i->sampler : nullptr); +} + void RenderMethod::set_face_cull(CullMode fc) { face_cull = fc; diff --git a/source/materials/rendermethod.h b/source/materials/rendermethod.h index d8d8b4c7..b3140dd3 100644 --- a/source/materials/rendermethod.h +++ b/source/materials/rendermethod.h @@ -111,6 +111,8 @@ public: const std::string &get_material_slot_name() const { return material_slot; } void set_texture(Tag, const Texture *, const Sampler * = 0); Tag get_texture_tag(const std::string &) const; + const Texture *get_texture(Tag) const; + const Sampler *get_sampler(Tag) const; void set_face_cull(CullMode); CullMode get_face_cull() const { return face_cull; } void set_blend(const Blend &); -- 2.45.2