Game Development Reference
In-Depth Information
Also, while we
re on the subject, many other things can go wrong with huge polygons in world space, such as
lighting and collision. It
'
s always a good idea to tessellate, or break up, larger surfaces into smaller polygons
that will provide the renderer with a good balance between polygon size and vertex count.
'
You might have heard of something called trilinear filtering. If the renderer switches
between one mip-map level on the same polygon, it
ll notice the
switch. Most renderers can sample the texels from more than one mip-map and
blend their color in real time. This creates a smooth transition from one mip-map
level to another, a much more realistic effect. As you approach something like a
newspaper, the mip-maps are sampled in such a way that eventually the blurry
image of the headline can resolve into something you can read and react to.
'
s likely that you
'
Introducing ID3D11Device and ID3D11DeviceContext
In the following pages you
ll see some code that uses two DXUT11 functions: DXUT-
GetD3D11Device() and DXUTGetD3D11DeviceContext() . DXUTGetD3D11De-
vice() returns a ID3D11Device * and represents a virtual adapter. You use it to
create resources used in rendering, everything from textures to geometry. DXUT-
GetD3D11DeviceContext() returns ID3D11DeviceContext * , and it represents
the current state of the virtual adapter. You ' ll use this to set which resources are
being used by all subsequent calls, such as setting the graphics system to use a spe-
cific texture. Of course, this is a gross oversimplification of these two interfaces, the
full description of which is much better done by a dedicated Direct3D 11 book, but
at least you ' ll have some inkling of what they do by looking at what kinds of methods
each of these interfaces supports.
'
Loading Textures in D3D11
You are finally ready to see how to load textures for Direct3D 11, and you can do so
right from the resource cache described in Chapter 8. Textures need to be processed
into two interfaces for Direct3D 11. First, the ID3DShaderResourceView interface
defines data that can be used by the shader, in this case our texture data. Second, the
ID3DSamplerState defines how the data is to be sampled, most especially to avoid
the problems of subsampling you just learned.
First, we define a class that implements IResourceExtraData interface so that tex-
tures managed by the ResCache class from Chapter 8 can be loaded:
class D3DTextureResourceExtraData11 : public IResourceExtraData
{
friend class TextureResourceLoader;
 
 
 
Search WWH ::




Custom Search