Incremental Engine  1.0.6
A 2D Game Engine to create Idle Games
IncrementalEngine::Texture Class Reference

#include <Texture.h>

Public Member Functions

HRESULT Init (ID3D11Device *device)
 
ID3D11ShaderResourceView * GetTexture ()
 
D3DXVECTOR2 GetSize ()
 
 Texture (std::string filename)
 
virtual ~Texture ()
 

Private Attributes

ID3D11ShaderResourceView * _texture
 
std::string _filename
 
D3DXVECTOR2 _size
 

Detailed Description

Definition at line 12 of file Texture.h.

Constructor & Destructor Documentation

◆ Texture()

IncrementalEngine::Texture::Texture ( std::string  filename)

Definition at line 6 of file Texture.cpp.

6  :
7  _texture(NULL),
8  _size(0, 0),
9  _filename(filename)
10  {
11  }

◆ ~Texture()

IncrementalEngine::Texture::~Texture ( )
virtual

Definition at line 13 of file Texture.cpp.

14  {
15  CHECKED_RELEASE(_texture);
16  }

Member Function Documentation

◆ GetSize()

D3DXVECTOR2 IncrementalEngine::Texture::GetSize ( )

Definition at line 58 of file Texture.cpp.

59  {
60  return _size;
61  }

◆ GetTexture()

ID3D11ShaderResourceView * IncrementalEngine::Texture::GetTexture ( )

Definition at line 53 of file Texture.cpp.

54  {
55  return _texture;
56  }

◆ Init()

HRESULT IncrementalEngine::Texture::Init ( ID3D11Device *  device)

Definition at line 18 of file Texture.cpp.

19  {
20  ID3D11Resource* resource;
21  ID3D11Texture2D* texture2D;
22  D3D11_TEXTURE2D_DESC desc;
23 
24  std::wstring filename(_filename.begin(), _filename.end());
25  HRESULT result = D3DX11CreateShaderResourceViewFromFile(
26  device,
27  filename.c_str(),
28  NULL,
29  NULL,
30  &_texture,
31  NULL
32  );
33 
34  if (FAILED(result))
35  {
36  return CO_E_ERRORINAPP;
37  }
38 
39  _texture->GetResource(&resource);
40  texture2D = static_cast<ID3D11Texture2D*>(resource);
41 
42  if (texture2D == nullptr)
43  {
44  return CO_E_ERRORINAPP;
45  }
46 
47  texture2D->GetDesc(&desc);
48  _size = D3DXVECTOR2(desc.Width, desc.Height);
49 
50  return S_OK;
51  }

Member Data Documentation

◆ _filename

std::string IncrementalEngine::Texture::_filename
private

Definition at line 25 of file Texture.h.

◆ _size

D3DXVECTOR2 IncrementalEngine::Texture::_size
private

Definition at line 26 of file Texture.h.

◆ _texture

ID3D11ShaderResourceView* IncrementalEngine::Texture::_texture
private

Definition at line 24 of file Texture.h.

IncrementalEngine::Texture::_filename
std::string _filename
Definition: Texture.h:25
IncrementalEngine::Texture::_texture
ID3D11ShaderResourceView * _texture
Definition: Texture.h:24
IncrementalEngine::Texture::_size
D3DXVECTOR2 _size
Definition: Texture.h:26