Share via


D3D Texture Mapping

Windows Mobile SupportedWindows Embedded CE Not Supported

8/28/2008

This code sample is named tut05_textures. It is the second in a series of tutorials on using Direct3D Mobile. It demonstrates how to create 3D texture-mapped objects.

Feature Area

Relevant APIs

Usage

To run the code sample

  1. Navigate to the solution file (*.sln), and double-click it. By default, the solution file is copied to the following folder:

    C:\Program Files\Windows Mobile 6 SDK\Samples\PocketPC\CPP\win32\directx\d3dm\tutorials\tut05_textures

    Microsoft Visual Studio 2005 launches and loads the solution.

  2. Build the solution (Ctrl+Shift+B).

  3. Deploy the solution (F5).

Remarks

The tut05_textures code sample is an extension of tut04_lights.

3D objects look much more convincing when texture-mapped than they do when lit with just lights and materials. Textures can be thought of as wallpaper that is shrink-wrapped to form to an object.

Textures are typically loaded from image files. Like a Vertex Buffer, textures have Lock() and Unlock() functions to access (read or write) the image data. Textures have width, height, MipLevel, and pixel format. The MipLevel is for "mipmapped" textures — an advanced performance-enhancing feature that uses lower resolutions of the texture for objects in the distance, where detail is less noticeable. The pixel format determines how the colors are stored in a texel. The most common formats are the 16-bit R5G6B5 format (5 bits of red, 6-bits of green and 5 bits of blue) and the 32-bit A8R8G8B8 format (8 bits each of alpha, red, green, and blue).

Textures are associated with geometry through texture coordinates. Each vertex has one or more sets of texture coordinates, which are named tu and tv, and range from 0.0 to 1.0. Texture coordinates can be supplied by the geometry, or they can be automatically generated using Direct3D Mobile texture coordinate generation (an advanced feature).

Development Environments

Pocket PC SDK: Windows Mobile 6 Professional SDK 

Development Environment: Visual Studio 2005.

ActiveSync: Version 4.5.

See Also

Reference

Concepts

Code Samples for Windows Mobile
D3D Create Device
D3D Vertices
D3D Matrices
D3D Dynamic Lighting
D3D Fixed Point Data

Other Resources

Texture Coordinate Transformation