| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- //
- // manager.hpp
- // graphics
- //
- // Created by Sam Jaffe on 5/25/19.
- // Copyright © 2019 Sam Jaffe. All rights reserved.
- //
- #pragma once
- #include <memory>
- #include <unordered_map>
- #include "game/graphics/graphics_fwd.h"
- #include "game/math/math_fwd.hpp"
- namespace graphics {
- class manager {
- public:
- manager();
- ~manager();
- /**
- * @brief Load a material - from either cache or by fetching data from the
- * given arguments - and return its identifier.
- * A material is a linkage of shader(s) and texture(s), that desribe the
- * needed details to draw it on a page.
- * @param program The shader program that should be used to paint this
- * material.
- * @param texture The path to an image file for this material
- * @param uniform The name of the uniform to use as a fallback texture
- */
- identity<material> get(identity<shader_program> program,
- std::string const & texture,
- std::string const & uniform) const;
- /**
- * @brief Load a shader - from either cache or by fetching data from the
- * given arguments - and return its identifier.
- * A shader is a type of program that is run on the GPU by a library like
- * OpenGL.
- * @param type A shader type describe what it draws...
- * @param path The path to the shader's source code file.
- */
- identity<shader> get(shaders::type type, std::string const & path) const;
- /**
- * @brief Load a shader_program - from either cache or by fetching data from
- * the given arguments - and return its identifier.
- * @param fragment The file path to the fragment shader code.
- * @param vertex The file path to the vertex shader code.
- */
- identity<shader_program> get(std::string const & fragment,
- std::string const & vertex) const;
- /**
- * @brief Load a texture - from either cache or by fetching data from the
- * given arguments - and return its identifier.
- * @param path The file path to an imagefile that contains one or more
- * drawings of the object to be rendered.
- */
- identity<texture> get(std::string const & path) const;
- // TODO: This is kinda dumb...
- object create_object(identity<material> fromMaterial, math::vec2 atPosition,
- math::vec2 frameWidth, float scale) const;
- /**
- * @brief Translate a material identity into an actual object.
- * Used for internal linkage with the implementation code.
- */
- material const & get(identity<material> identity) const;
- /**
- * @brief Translate a texture identity into an actual object.
- * Used for internal linkage with the implementation code.
- */
- texture const & get(identity<texture> identity) const;
- private:
- void prepare_uniforms() const;
- identity<texture> texture_or_uniform(std::string const & path,
- std::string const & uniform) const;
- virtual shader compile(shaders::type type,
- std::string const & path) const = 0;
- virtual shader_program compile(identity<shader> fragment,
- identity<shader> vertex) const = 0;
- virtual texture compile(textures::format color, math::vec2i size,
- void const * buffer) const = 0;
- std::unique_ptr<struct manager_cache> pcache_;
- };
- }
|