MAGE  v0.171.0
Matthias Advanced Game Engine
mage::rendering::Texture Class Reference

#include <texture.hpp>

Inheritance diagram for mage::rendering::Texture:
mage::Resource< Texture >

Public Member Functions

 Texture (ID3D11Device &device, std::wstring fname)
 
 Texture (ID3D11Device &device, std::wstring guid, const D3D11_TEXTURE2D_DESC &desc, const D3D11_SUBRESOURCE_DATA &initial_data)
 
 Texture (const Texture &texture)=delete
 
 Texture (Texture &&texture) noexcept
 
virtual ~Texture ()
 
Textureoperator= (const Texture &texture)=delete
 
Textureoperator= (Texture &&texture) noexcept
 
ID3D11ShaderResourceView * Get () const noexcept
 
template<typename PipelineStageT >
void Bind (ID3D11DeviceContext &device_context, U32 slot) const noexcept
 
- Public Member Functions inherited from mage::Resource< Texture >
 Resource (std::wstring guid) noexcept
 
 Resource (const Resource &resource)=delete
 
 Resource (Resource &&resource) noexcept
 
virtual ~Resource ()
 
Resourceoperator= (const Resource &resource)=delete
 
Resourceoperator= (Resource &&resource) noexcept
 
const std::wstring_view GetGuid () const noexcept
 
bool IsFileResource () const
 
const std::filesystem::path GetPath () const
 

Private Attributes

ComPtr< ID3D11ShaderResourceView > m_texture_srv
 

Detailed Description

A class of textures.

Constructor & Destructor Documentation

◆ Texture() [1/4]

mage::rendering::Texture::Texture ( ID3D11Device &  device,
std::wstring  fname 
)
explicit

Constructs a texture.

Parameters
[in,out]deviceA reference to the device.
[in]fnameThe filename (the globally unique identifier).
Exceptions
ExceptionFailed to construct the texture.

◆ Texture() [2/4]

mage::rendering::Texture::Texture ( ID3D11Device &  device,
std::wstring  guid,
const D3D11_TEXTURE2D_DESC &  desc,
const D3D11_SUBRESOURCE_DATA &  initial_data 
)
explicit

Constructs a 2D texture.

Parameters
[in,out]deviceA reference to the device.
[in]guidThe globally unique identifier.
[in]descA reference to the texture descriptor.
[in]initial_dataA reference to the initial data.
Exceptions
ExceptionFailed to construct the texture.

◆ Texture() [3/4]

mage::rendering::Texture::Texture ( const Texture texture)
delete

Constructs a texture from the given texture.

Parameters
[in]textureA reference to the texture to copy.

◆ Texture() [4/4]

mage::rendering::Texture::Texture ( Texture &&  texture)
defaultnoexcept

Constructs a texture by moving the given texture.

Parameters
[in]textureA reference to the texture to move.

◆ ~Texture()

mage::rendering::Texture::~Texture ( )
virtualdefault

Destructs this texture.

Member Function Documentation

◆ Bind()

template<typename PipelineStageT >
void mage::rendering::Texture::Bind ( ID3D11DeviceContext &  device_context,
U32  slot 
) const
noexcept

Binds this texture.

Precondition
slot < D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT.
Template Parameters
PipelineStageTThe pipeline stage type.
Parameters
[in,out]device_contextA reference to the device context.
[in]slotThe index into the device's zero-based array to set the shader resource view to (ranges from 0 to D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT - 1).

◆ Get()

ID3D11ShaderResourceView* mage::rendering::Texture::Get ( ) const
noexcept

Returns a pointer to the shader resource view of this texture.

Returns
A pointer to the shader resource view of this texture.

◆ operator=() [1/2]

Texture& mage::rendering::Texture::operator= ( const Texture texture)
delete

Copies the given texture to this texture.

Parameters
[in]textureA reference to the texture to copy.
Returns
A reference to the copy of the given texture (i.e. this texture).

◆ operator=() [2/2]

Texture & mage::rendering::Texture::operator= ( Texture &&  texture)
defaultnoexcept

Moves the given texture to this texture.

Parameters
[in]textureA reference to the texture to move.
Returns
A reference to the moved texture (i.e. this texture).

Member Data Documentation

◆ m_texture_srv

ComPtr< ID3D11ShaderResourceView > mage::rendering::Texture::m_texture_srv
private

A pointer to the shader resource view of this texture.