VenomEngine
Cross-Platform Modern Graphics Engine
Loading...
Searching...
No Matches
Texture.h
Go to the documentation of this file.
1
8#pragma once
9
12
13#include <venom/common/Types.h>
14
16
17namespace venom
18{
19namespace common
20{
21class GraphicsApplication;
22class Texture;
23
24class VENOM_COMMON_API TextureResource : public GraphicsCachedResource
25{
26public:
28 virtual ~TextureResource();
29
30#ifdef VENOM_BINDLESS_TEXTURES
31 inline int GetTextureID() const { return __textureID; }
32private:
33 const int __textureID;
34#endif
35};
36
38{
39public:
41 virtual ~TextureImpl() = default;
42
43 vc::Error LoadImageFromFile(const char * path);
44 vc::Error LoadImage(const char * path, int id, char * bgraData, unsigned int width, unsigned int height);
45 vc::Error InitDepthBuffer(int width, int height);
46 vc::Error CreateAttachment(int width, int height, int imageCount, vc::ShaderVertexFormat format);
47 static const TextureImpl * GetDummyTexture();
48#ifdef VENOM_BINDLESS_TEXTURES
49 inline int GetTextureID() const { return _GetResourceToCache()->As<TextureResource>()->GetTextureID(); }
50#endif
51 virtual bool HasTexture() const = 0;
52
53 virtual vc::Error LoadImage(unsigned char * pixels, int width, int height, int channels) = 0;
54 virtual vc::Error LoadImageBGRA(unsigned char * pixels, int width, int height, int channels) = 0;
55 virtual vc::Error LoadImage(uint16_t * pixels, int width, int height, int channels) = 0;
56 inline void SetTexturePeakLuminance(float peakLuminance) { __luminance = peakLuminance; }
57 inline const float & GetTexturePeakLuminance() const { return __luminance; }
58protected:
59 virtual vc::Error _InitDepthBuffer(int width, int height) = 0;
60 virtual vc::Error _CreateAttachment(int width, int height, int imageCount, vc::ShaderVertexFormat format) = 0;
61private:
62 friend class Texture;
63 void __CreateDummyTexture();
64
65private:
66 float __luminance;
67};
68
69enum ColorAttachmentType
70{
71 Present = 0,
72 NormalSpecular = 1,
73 MetallicRougnessAO = 2,
74 Position = 3,
75 Depth = 4,
76 Count
77};
78
79class VENOM_COMMON_API Texture : public PluginObjectImplWrapper
80{
81public:
82 Texture();
83 Texture(const char * path);
84 Texture(const char * path, int id, char * bgraData, unsigned int width, unsigned int height);
85 ~Texture();
86
87 inline vc::Error LoadImageFromFile(const char * path) { return _impl->As<TextureImpl>()->LoadImageFromFile(path); }
88 inline vc::Error LoadImage(const char * path, int id, char * bgraData, unsigned int width, unsigned int height) { return _impl->As<TextureImpl>()->LoadImage(path, id, bgraData, width, height); }
89 inline vc::Error InitDepthBuffer(int width, int height) { return _impl->As<TextureImpl>()->InitDepthBuffer(width, height); }
90 inline vc::Error CreateAttachment(int width, int height, int imageCount, vc::ShaderVertexFormat format) { return _impl->As<TextureImpl>()->CreateAttachment(width, height, imageCount, format); }
91 inline bool HasTexture() const { return _impl->As<TextureImpl>()->HasTexture(); }
92#ifdef VENOM_BINDLESS_TEXTURES
93 inline int GetTextureID() const { return _impl->As<TextureImpl>()->GetTextureID(); }
94#endif
95private:
96 friend class GraphicsApplication;
97 inline void __CreateDummyTexture() { _impl->As<TextureImpl>()->__CreateDummyTexture(); }
98};
99
100}
101}
Definition GraphicsApplication.h:27
Base class for cached resource holders.
Definition GraphicsPluginObject.h:57
Base class for cached resources.
Definition GraphicsPluginObject.h:29
Base class for graphics plugin objects.
Definition GraphicsPluginObject.h:80
Interface for the PluginObject different implementations.
Definition PluginObject.h:56
Wrapper for the PluginObjectImpl, inherited by classes like Model or Mesh to make them usable as comp...
Definition PluginObject.h:76
Definition Texture.h:80
Definition Texture.h:38
Definition Texture.h:25
Contains the entirety of the code of the VenomEngine project.
Definition Config.h:13