Diligent Engine  v.2.4.g
DynamicTextureAtlas.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019-2021 Diligent Graphics LLC
3  * Copyright 2015-2019 Egor Yusov
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * In no event and under no legal theory, whether in tort (including negligence),
18  * contract, or otherwise, unless required by applicable law (such as deliberate
19  * and grossly negligent acts) or agreed to in writing, shall any Contributor be
20  * liable for any damages, including any direct, indirect, special, incidental,
21  * or consequential damages of any character arising as a result of this License or
22  * out of the use or inability to use the software (including but not limited to damages
23  * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
24  * all other commercial damages or losses), even if such Contributor has been advised
25  * of the possibility of such damages.
26  */
27 
28 #pragma once
29 
32 
33 #include "../../GraphicsEngine/interface/RenderDevice.h"
34 #include "../../GraphicsEngine/interface/DeviceContext.h"
35 #include "../../GraphicsEngine/interface/Texture.h"
36 #include "../../../Common/interface/BasicMath.hpp"
37 
38 namespace Diligent
39 {
40 
41 struct IDynamicTextureAtlas;
42 
43 // {F7ACDCFB-074F-4E31-94C5-DD4C988E4532}
44 static const INTERFACE_ID IID_TextureAtlasSuballocation =
45  {0xf7acdcfb, 0x74f, 0x4e31, {0x94, 0xc5, 0xdd, 0x4c, 0x98, 0x8e, 0x45, 0x32}};
46 
47 
48 // {00E1D6FA-47B4-4062-B96C-D3E191A02351}
49 static const INTERFACE_ID IID_DynamicTextureAtlas =
50  {0xe1d6fa, 0x47b4, 0x4062, {0xb9, 0x6c, 0xd3, 0xe1, 0x91, 0xa0, 0x23, 0x51}};
51 
52 
55 {
57  virtual uint2 GetOrigin() const = 0;
58 
60  virtual Uint32 GetSlice() const = 0;
61 
63  virtual uint2 GetSize() const = 0;
64 
66  virtual float4 GetUVScaleBias() const = 0;
67 
69  virtual IDynamicTextureAtlas* GetAtlas() = 0;
70 
78  virtual void SetUserData(IObject* pUserData) = 0;
79 
84  virtual IObject* GetUserData() const = 0;
85 };
86 
89 {
91 
103  virtual ITexture* GetTexture(IRenderDevice* pDevice, IDeviceContext* pContext) = 0;
104 
105 
107 
118  virtual void Allocate(Uint32 Width,
119  Uint32 Height,
120  ITextureAtlasSuballocation** ppSuballocation) = 0;
121 
122 
124  virtual const TextureDesc& GetAtlasDesc() const = 0;
125 
128  virtual Uint32 GetVersion() const = 0;
129 };
130 
131 
134 {
136 
140 
141 
143 
148 
150 
155 
156 
159 
160 
162 
167 };
168 
170 
177  const DynamicTextureAtlasCreateInfo& CreateInfo,
178  IDynamicTextureAtlas** ppAtlas);
179 
180 } // namespace Diligent
Diligent::INTERFACE_ID
struct INTERFACE_ID INTERFACE_ID
Definition: InterfaceID.h:54
Diligent::IDynamicTextureAtlas::GetAtlasDesc
virtual const TextureDesc & GetAtlasDesc() const =0
Returns the texture atlas description.
Diligent::ITextureAtlasSuballocation::GetOrigin
virtual uint2 GetOrigin() const =0
Returns the suballocation origin.
Diligent::ITextureAtlasSuballocation::SetUserData
virtual void SetUserData(IObject *pUserData)=0
Stores a pointer to the user-provided data object, which may later be retreived through GetUserData()...
Diligent::IObject
Base interface for all dynamic objects in the engine.
Definition: Object.h:41
Diligent::DynamicTextureAtlasCreateInfo
Dynamic texture atlas create information.
Definition: DynamicTextureAtlas.h:133
Diligent::IDynamicTextureAtlas
Dynamic texture atlas.
Definition: DynamicTextureAtlas.h:88
Diligent::IDynamicTextureAtlas::GetTexture
virtual ITexture * GetTexture(IRenderDevice *pDevice, IDeviceContext *pContext)=0
Returns the pointer to the internal texture object.
Diligent::ITextureAtlasSuballocation::GetSlice
virtual Uint32 GetSlice() const =0
Returns the suballocation slice.
Diligent::IDynamicTextureAtlas::GetVersion
virtual Uint32 GetVersion() const =0
Returns internal texture array version. The version is incremented every time the array is expanded.
Diligent::IRenderDevice
Render device interface.
Definition: RenderDevice.h:75
Diligent::TextureDesc
Texture description.
Definition: Texture.h:47
Diligent::ITextureAtlasSuballocation
Dynamic texture atlas suballocation.
Definition: DynamicTextureAtlas.h:54
Diligent::ITextureAtlasSuballocation::GetUserData
virtual IObject * GetUserData() const =0
Returns the pointer to the user data object previously set with SetUserData() method.
Diligent::DynamicTextureAtlasCreateInfo::SuballocationObjAllocationGranularity
Uint32 SuballocationObjAllocationGranularity
Allocation granularity for ITextureAtlasSuballocation objects.
Definition: DynamicTextureAtlas.h:166
Diligent::Uint32
uint32_t Uint32
32-bit unsigned integer
Definition: BasicTypes.h:51
Diligent::Vector2
Definition: BasicMath.hpp:74
Diligent::DynamicTextureAtlasCreateInfo::Desc
TextureDesc Desc
Texture description.
Definition: DynamicTextureAtlas.h:139
Diligent::Vector4< float >
Diligent::DynamicTextureAtlasCreateInfo::ExtraSliceCount
Uint32 ExtraSliceCount
The number of extra slices.
Definition: DynamicTextureAtlas.h:154
Diligent::IDeviceContext
Device context interface.
Definition: DeviceContext.h:1460
Diligent::ITextureAtlasSuballocation::GetAtlas
virtual IDynamicTextureAtlas * GetAtlas()=0
Returns the pointer to the parent texture atlas.
Diligent::DynamicTextureAtlasCreateInfo::TextureGranularity
Uint32 TextureGranularity
Texture region allocation granularity.
Definition: DynamicTextureAtlas.h:147
Diligent::ITextureAtlasSuballocation::GetSize
virtual uint2 GetSize() const =0
Returns the suballocation size.
Diligent::CreateDynamicTextureAtlas
void CreateDynamicTextureAtlas(IRenderDevice *pDevice, const DynamicTextureAtlasCreateInfo &CreateInfo, IDynamicTextureAtlas **ppAtlas)
Creates a new dynamic texture atlas.
Definition: DynamicTextureAtlas.cpp:410
Diligent::IDynamicTextureAtlas::Allocate
virtual void Allocate(Uint32 Width, Uint32 Height, ITextureAtlasSuballocation **ppSuballocation)=0
Performs suballocation from the atlas.
Diligent::ITexture
Texture inteface.
Definition: Texture.h:273
Diligent
The library uses Direct3D-style math:
Definition: AdvancedMath.hpp:37
Diligent::DynamicTextureAtlasCreateInfo::MaxSliceCount
Uint32 MaxSliceCount
Maximum number of slices in texture array.
Definition: DynamicTextureAtlas.h:158
Diligent::ITextureAtlasSuballocation::GetUVScaleBias
virtual float4 GetUVScaleBias() const =0
Returns the texture coordinate scale (xy) and bias (zw).