Game Development Reference
In-Depth Information
float get() { return _pos.x; }
void set(float val) { _pos.x = val; }
}
property float Y
{
float get() { return _pos.y; }
void set(float val) { _pos.y = val; }
}
Texture(Platform::String^ path);
};
Here we're defining a simple
Texture
class that has properties for the co-ordinates
of the texture and a way to load the texture. We need to use internal visibility be-
cause DirectXTK is implemented as a set of standard C++ classes, and therefore
can't be exposed to WinRT. By using the internal modifier we can limit access to
the
Load
method from code within the same assembly, allowing us to use standard
pointers in a WinRT (ref) class, which does not allow standard C++ pointers to be
exposed publicly.
Inside
Texture.cpp
, we want to define a constructor that sets the
_path
field and
then define the
Load
method, as follows:
void
Texture::Load(Microsoft::WRL::ComPtr<ID3D11Device>
device)
{
DirectX::CreateDDSTextureFromFile(
device.Get(),
_path->Data(),
&_tex,
&_srv
);
}
Make sure you include the header file
DDSTextureLoader.h
from DirectXTK for
this to work.