13 #include <DirectXMath.h>
28 ID3D11ShaderResourceView* srview_;
29 ID3D11Texture2D* texture_;
30 DirectX::XMFLOAT2 size_;
33 virtual void do_create(ID3D11Device* device, D3D11_TEXTURE2D_DESC desc, D3D11_SUBRESOURCE_DATA* subresource);
40 ID3D11ShaderResourceView*
const srv()
const {
return srview_; }
42 void to_vs(ID3D11DeviceContext* context, UINT slot);
43 void to_ps(ID3D11DeviceContext* context, UINT slot);
47 void create(ID3D11Device* device, D3D11_TEXTURE2D_DESC desc, D3D11_SUBRESOURCE_DATA* subresource =
nullptr);
48 void create(ID3D11Device* device,
const DXGI_SURFACE_DESC& desc, UINT num_mipmaps = 1);
49 void create(ID3D11Device* device, UINT width, UINT height, DXGI_FORMAT format,
const DXGI_SAMPLE_DESC& msaa, UINT num_mipmaps = 1);
62 void*
map(ID3D11DeviceContext* context);
65 void unmap(ID3D11DeviceContext* context);
68 DirectX::XMFLOAT2 size()
const;
71 D3D11_TEXTURE2D_DESC desc()
const;
74 ID3D11Texture2D* resource()
const;
void to_vs(ID3D11DeviceContext *context, UINT slot)
Upload the shader resource to register slot of a vertex shader.
Definition: texture.cpp:140
void * map(ID3D11DeviceContext *context)
Map the texture to a pointer.
Definition: texture.cpp:110
A shader resource wrapper.
Definition: shader_resource.h:24
void to_ps(ID3D11DeviceContext *context, UINT slot)
Upload the shader resource to register slot of a pixel shader.
Definition: texture.cpp:146
void create(ID3D11Device *device, D3D11_TEXTURE2D_DESC desc, D3D11_SUBRESOURCE_DATA *subresource=nullptr)
Create an empty texture from given descriptor, other resource or single parameters.
Definition: texture.cpp:58
virtual void destroy()
Destroy the shader_resource and free all memory.
Definition: texture.cpp:98
Wrapper for a Direct3D texture object.
Definition: texture.h:25