Class ResourceProvider
Defined in File resource-provider.h
Inheritance Relationships
Base Types
public CE::Rendering::Resources::Provider(Struct Provider)private CE::Assets::Shaders::Builder(Struct Builder)
Class Documentation
-
class ResourceProvider : public CE::Rendering::Resources::Provider, private CE::Assets::Shaders::Builder
Declaration:
finalTranslate backend-neutral resource requests into OpenGL images, buffers, and programs.
Calls require the rendering context current on the calling thread; CPU data is copied during construction and need not outlive each call.
Public Functions
-
inline explicit ResourceProvider(Renderer &renderer)
Borrow the renderer that defines all created resource domains.
- Parameters:
renderer – Initialized before upload calls and kept alive through this provider’s use/destruction. Construction performs no upload; weak preset/sampler caches do not pin resources after final external release.
-
virtual ::CE::Rendering::GraphicsDomain graphics_domain() const noexcept override
Declaration:
[[nodiscard]]Forward the renderer’s retained native domain, or an empty token when unsupported.
-
inline virtual CE::Assets::Shaders::Builder *shader_asset_builder() noexcept override
Declaration:
[[nodiscard]]- Returns:
Borrowed builder implemented by this provider, valid only while the provider lives. Builder construction calls retain normal OpenGL upload affinity.
-
virtual std::shared_ptr<CE::Rendering::Resources::Image> create_image(const CE::Assets::Images::Decoded &image) override
Declaration:
[[nodiscard]]Copy top-to-bottom RGBA8 pixels into a complete native image.
- Parameters:
image – Nonzero int-representable dimensions with exactly four bytes per pixel.
- Returns:
Retained OpenGL texture: linear filtering, clamp-to-edge, full mipmaps and available maximum anisotropy. Requires the renderer’s initialized live owner/current context. Invalid dimensions/count throw invalid_args; native/allocation errors propagate. CPU pixels are not retained and no cache entry is published.
-
virtual std::shared_ptr<const CE::Rendering::Sampling::Sampler> create_sampler(const CE::Rendering::Sampling::Options &options) override
Declaration:
[[nodiscard]]Return a retained immutable sampler for an exact requested-options key.
- Parameters:
options – Valid filter/wrap/anisotropy request.
- Returns:
Existing live weak-cache candidate or a newly created native sampler. Requires initialized live owner/current context; unsupported anisotropy resolves to 1. Failure publishes no candidate; final external release permits cache expiration.
-
virtual std::shared_ptr<CE::Rendering::Resources::Image> create_font_atlas(std::span<const unsigned char> alpha, CE::Rendering::Geometry::PixelSize size) override
Declaration:
[[nodiscard]]Upload one-byte glyph alpha with the baker’s row/UV order unchanged.
- Parameters:
alpha – Exactly width*height bytes, borrowed until return.
size – Nonzero int-representable pixel dimensions.
- Returns:
Retained red-channel texture swizzled to white RGB/alpha, with linear isotropic base-level clamp sampling. Requires initialized live owner/current context. Invalid data or native/allocation failure rejects creation without cache publication.
-
virtual std::shared_ptr<CE::Rendering::Geometry::Buffer2D> upload_geometry(std::span<const CE::Rendering::Geometry::Vertex2D> vertices, CE::Rendering::Geometry::Topology topology) override
Declaration:
[[nodiscard]]Copy transient position/UV vertices into an immutable OpenGL VertexArray.
- Parameters:
vertices – Nonempty contiguous storage within native buffer/draw size limits, borrowed until return.
topology – Triangles or TriangleStrip, retained by the upload.
- Returns:
Same-domain geometry retaining no CPU vertex storage. Requires initialized live owner/current context; input/native/allocation failures propagate without cache publication.
-
virtual std::shared_ptr<CE::Rendering::Geometry::Buffer2D> upload_geometry(std::span<const CE::Rendering::Geometry::Vertex2DColor> vertices, CE::Rendering::Geometry::Topology topology) override
Declaration:
[[nodiscard]]Copy transient position/UV/RGBA vertices into an immutable OpenGL VertexArray.
- Parameters:
vertices – Nonempty contiguous storage within native buffer/draw size limits, borrowed until return.
topology – Triangles or TriangleStrip, retained by the upload.
- Returns:
Same-domain geometry retaining no CPU vertex storage. Requires initialized live owner/current context; input/native/allocation failures propagate without cache publication.
-
virtual std::shared_ptr<CE::Rendering::Resources::Program> link_program(const std::vector<std::filesystem::path> &stages) override
Declaration:
[[nodiscard]]Read, compile and link shader stage files into a tracked OpenGL executable.
- Parameters:
stages – Stage paths borrowed through the call; extension mapping follows the native program builder.
- Returns:
Complete retained Program in this renderer’s native domain. Requires initialized live owner/current context. File/compile/link/native/allocation failures retire adopted transient objects and return no executable/cache publication.
-
std::shared_ptr<const Pipeline> build_pipeline(CE::Rendering::Pipelines::Definition definition, const PipelineBindings &bindings)
Declaration:
[[nodiscard]]Validate the recipe, compile its stage files and reflect an immutable native pipeline.
- Parameters:
definition – Owned pipeline snapshot consumed by value.
bindings – Stable explicit uniform/attribute mappings borrowed through construction.
- Returns:
Complete same-domain pipeline, without cache publication. Requires initialized live owner/current context. Common validation, file/compile/link/reflection/native/allocation failures return no pipeline; existing generations remain unchanged.
-
std::shared_ptr<const CE::Rendering::Resources::Material> build_material(CE::Rendering::Materials::Definition definition)
Declaration:
[[nodiscard]]Validate and retain a material using this provider’s OpenGL pipeline/sampler domain.
See also
- Parameters:
definition – Owned recipe with required same-domain OpenGL pipeline and optional same-domain samplers.
- Returns:
Complete immutable material after validating default image bindings. Requires initialized live owner/current context. Foreign/null resources or invalid defaults reject before publication; native/allocation failures propagate.
Declaration:
[[nodiscard]]Compatibility wrapper borrowing a retained CPU array for the transient span upload.
- Parameters:
vertices – Owner of at least vertex_count contiguous vertices.
vertex_count – Nonzero array count, not bytes.
topology – Uploaded primitive interpretation.
- Returns:
Backend geometry independent of the CPU array. Null/zero input throws invalid_args. The CPU owner is retained only until the delegated upload returns; normal backend affinity/failures apply.
-
inline explicit ResourceProvider(Renderer &renderer)