载入中...
搜索中...
未找到
IResourceFactory.h
浏览该文件的文档.
1#pragma once
2
3// Narrow resource-factory interface of the Graphics backend.
4// Consumers that only create textures / meshes / shaders / canvases (model3d,
5// animation, avatar, sceneloader) depend on this instead of the full
6// graphics::Graphics god class.
7
8#include <cstdint>
9#include <string>
10#include <vector>
11
12#include <assimp/matrix4x4.h>
13
14struct aiMesh;
15
16namespace eve::font {
17class FontData;
18}
19
20namespace eve::image {
21class ImageData;
22}
23
24namespace eve::graphics {
25
26class Canvas;
27class Font;
28class Mesh;
29class Shader;
30class Texture;
31struct TextureCreateInfo;
32struct TextureSampler;
33
36public:
37 virtual ~IResourceFactory() = default;
38
39 virtual Texture *newTexture(int width, int height, const uint8_t *rgba, bool repeatU = false,
40 bool repeatV = false) = 0;
41 virtual Texture *newTexture(int width, int height, const uint8_t *rgba,
42 const TextureCreateInfo &info) = 0;
43 virtual Texture *newCubemap(int faceSize, const uint8_t *rgbaFaces) = 0;
44 virtual Texture *newCubemap(int faceSize, const uint8_t *rgbaFaces,
45 const TextureCreateInfo &info) = 0;
46 virtual Texture *newTexture(image::ImageData *data) = 0;
47 virtual Texture *newTexture(image::ImageData *data, const TextureCreateInfo &info) = 0;
49 bool repeatV = false) = 0;
51 const TextureCreateInfo &info) = 0;
53 bool generateMipmaps, float maxAnisotropy,
54 const std::string &filter, const std::string &mipmap,
55 float lodBias = 0.f) = 0;
56 virtual void setTextureSamplerParams(Texture *texture, const std::string &filter,
57 const std::string &mipmap, float maxAnisotropy,
58 float lodBias) = 0;
59 virtual void setTextureSampler(Texture *texture, const TextureSampler &sampler) = 0;
60 virtual Texture *newTextureFromFile(const std::string &filename) = 0;
61 virtual Texture *newTextureFromFileRepeated(const std::string &filename, bool repeatU,
62 bool repeatV) = 0;
63 virtual bool reloadTextureFromFile(const std::string &filename) = 0;
64 virtual float getMaxAnisotropy() const = 0;
65 virtual bool releaseTexture(Texture *texture) = 0;
66
67 virtual Mesh *newMeshFromAssimp(const ::aiMesh &mesh) = 0;
68 virtual Mesh *newMeshFromAssimp(const ::aiMesh &mesh, const aiMatrix4x4 &worldTransform) = 0;
69 virtual Mesh *newMeshFromArrays(const float *posXYZ, const float *nrmXYZ, const float *uvST,
70 int vertexCount, const uint32_t *indices, int indexCount) = 0;
71 virtual bool updateMeshVertices(Mesh *mesh, const float *posXYZ, const float *nrmXYZ,
72 const float *uvST, int vertexCount, const uint32_t *indices,
73 int indexCount) = 0;
74 virtual bool bakeMeshMorph(Mesh *mesh) = 0;
75 virtual Mesh *newMeshSphere(int slices, int stacks) = 0;
76 virtual Mesh *newMeshCylinder(int slices, int stacks, bool caps) = 0;
77 virtual Mesh *newMeshCube(float size) = 0;
78 virtual bool releaseMesh(Mesh *mesh) = 0;
79
80 virtual Shader *newShaderFromSpv(const std::vector<uint32_t> &vertSpv,
81 const std::vector<uint32_t> &fragSpv) = 0;
82 virtual Shader *newShaderFromSpvFile(const std::string &vertPath,
83 const std::string &fragPath) = 0;
84 virtual Shader *newShader(const std::string &vertGlsl, const std::string &fragGlsl) = 0;
85 virtual Shader *newMeshShaderFromSpv(const std::vector<uint32_t> &vertSpv,
86 const std::vector<uint32_t> &fragSpv) = 0;
87 virtual Shader *newMeshShaderFromWgsl(const std::string &vertWgsl,
88 const std::string &fragWgsl) = 0;
89 virtual Shader *newMeshShader(const std::string &vertGlsl, const std::string &fragGlsl) = 0;
90 virtual Shader *newHairShaderFromSpv(const std::vector<uint32_t> &vertSpv,
91 const std::vector<uint32_t> &fragSpv) = 0;
92 virtual bool releaseShader(Shader *shader) = 0;
93
94 virtual Canvas *newCanvas(int width, int height) = 0;
95 virtual Font *newFont(font::FontData *data, std::string charset) = 0;
96};
97
98} // namespace eve::graphics
float height
Definition Grass.cpp:235
int width
Mesh * mesh
Shader * shader
bool repeatV
std::string filter
std::string mipmap
bool repeatU
CPU-side decoded font face (FreeType FT_Face + owned font bytes). Does not upload to GPU — rasterize ...
Definition FontData.h:23
GPU-side font: wraps a decoded font::FontData and rasterizes a fixed set of codepoints into a single ...
Definition Font.h:32
Texture / mesh / shader / canvas creation and release.
virtual Shader * newMeshShader(const std::string &vertGlsl, const std::string &fragGlsl)=0
virtual bool updateMeshVertices(Mesh *mesh, const float *posXYZ, const float *nrmXYZ, const float *uvST, int vertexCount, const uint32_t *indices, int indexCount)=0
virtual Shader * newShader(const std::string &vertGlsl, const std::string &fragGlsl)=0
virtual float getMaxAnisotropy() const =0
virtual void setTextureSamplerParams(Texture *texture, const std::string &filter, const std::string &mipmap, float maxAnisotropy, float lodBias)=0
virtual Texture * newTexture(image::ImageData *data)=0
virtual void setTextureSampler(Texture *texture, const TextureSampler &sampler)=0
virtual Canvas * newCanvas(int width, int height)=0
virtual Texture * newTextureFromImageData(image::ImageData *data, const TextureCreateInfo &info)=0
virtual Shader * newShaderFromSpvFile(const std::string &vertPath, const std::string &fragPath)=0
virtual Font * newFont(font::FontData *data, std::string charset)=0
virtual Shader * newHairShaderFromSpv(const std::vector< uint32_t > &vertSpv, const std::vector< uint32_t > &fragSpv)=0
virtual bool releaseMesh(Mesh *mesh)=0
virtual Texture * newTexture(int width, int height, const uint8_t *rgba, bool repeatU=false, bool repeatV=false)=0
virtual Texture * newTextureWithSampler(image::ImageData *data, bool repeatU, bool repeatV, bool generateMipmaps, float maxAnisotropy, const std::string &filter, const std::string &mipmap, float lodBias=0.f)=0
virtual bool reloadTextureFromFile(const std::string &filename)=0
virtual Texture * newCubemap(int faceSize, const uint8_t *rgbaFaces)=0
virtual Mesh * newMeshSphere(int slices, int stacks)=0
virtual Shader * newShaderFromSpv(const std::vector< uint32_t > &vertSpv, const std::vector< uint32_t > &fragSpv)=0
virtual Mesh * newMeshCylinder(int slices, int stacks, bool caps)=0
virtual Mesh * newMeshFromArrays(const float *posXYZ, const float *nrmXYZ, const float *uvST, int vertexCount, const uint32_t *indices, int indexCount)=0
virtual Shader * newMeshShaderFromWgsl(const std::string &vertWgsl, const std::string &fragWgsl)=0
virtual Shader * newMeshShaderFromSpv(const std::vector< uint32_t > &vertSpv, const std::vector< uint32_t > &fragSpv)=0
virtual Texture * newTextureFromFileRepeated(const std::string &filename, bool repeatU, bool repeatV)=0
virtual ~IResourceFactory()=default
virtual Texture * newTexture(int width, int height, const uint8_t *rgba, const TextureCreateInfo &info)=0
virtual Mesh * newMeshCube(float size)=0
virtual bool releaseTexture(Texture *texture)=0
virtual Texture * newTextureFromFile(const std::string &filename)=0
virtual Texture * newTextureFromImageData(image::ImageData *data, bool repeatU=false, bool repeatV=false)=0
virtual Texture * newTexture(image::ImageData *data, const TextureCreateInfo &info)=0
virtual Mesh * newMeshFromAssimp(const ::aiMesh &mesh)=0
virtual bool releaseShader(Shader *shader)=0
virtual Texture * newCubemap(int faceSize, const uint8_t *rgbaFaces, const TextureCreateInfo &info)=0
virtual bool bakeMeshMorph(Mesh *mesh)=0
virtual Mesh * newMeshFromAssimp(const ::aiMesh &mesh, const aiMatrix4x4 &worldTransform)=0
GPU mesh handle (+ optional CPU morph targets).
Definition Mesh.h:18
Custom GPU program.
Definition Shader.h:30
GPU texture created via Graphics::newTexture. Owns GPU resources through an opaque backend handle.
Definition Texture.h:17
Represents raw pixel data.
Definition ImageData.h:26
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition AnimTrail.h:6
Options for Graphics::newTexture / newCubemap. When generateMipmaps is true and sampler....
Sampler state for a Texture (filter, wrap, mip LOD, anisotropy). Defaults match historical engine beh...