Practical No.
1 b):
Aim: Loading models into DirectX 11 and rendering
DirectX for Managed Code
Purpose
Microsoft DirectX is your backstage pass to multimedia applications that sizzle.
Where Applicable
DirectX is a set of low-level application programming interfaces (APIs) for creating games and other
high-performance multimedia applications. It includes support for high-performance 2-D and 3-D
graphics, sound, and input.
Create texture
public static Texture FromFile(
Device device,
string srcFile,
int width,
int height,
int mipLevels,
Usage usage,
Format format,
Pool pool,
Filter filter,
Filter mipFilter,
int colorKey
)
Parameters
device
Type: Microsoft.WindowsMobile.DirectX.Direct3D.Device
The device to associate with the texture.
srcFile
Type: System.String
The name of the file from which to create the texture.
width
Type: System.Int32
The width of the texture in pixels. If this value is 0 (zero), the dimensions are taken from
the file.
height
Type: System.Int32
The height of the texture in pixels. If this value is 0 (zero), the dimensions are taken from
the file.
mipLevels
Type: System.Int32
The number of mip levels requested. If this value is 0 (zero), a complete mipmap chain is
created.
usage
• System.Drawing Namespace : The System.Drawing namespace provides access to
GDI+ basic graphics functionality.
• Font class: Defines a particular format for text, including font face, size, and style
attributes. This class cannot be inherited.
▪ Constructor:
1) Font(FontFamily, Single, FontStyle) : Initializes a new Font using a specified
size and style.
▪ Method:
1) Font.DrawText : Draws formatted text.
• Sprite class: Provides methods and properties that simplify the process of drawing
sprites using Microsoft Direct3D.
▪ Methods:
1) Begin : Prepares a device for drawing sprites.
2) Draw2D : Adds a sprite to the list of batched sprites. Used for presentation
in 2-D space.
• TextureLoader.FromFile(Device,String,Int32,Int32,Int32,Usage,Format,Pool,Filter,Filter,In
t 32) method: Creates a texture from a file.
▪ Parameters:
1) device : A Device object that represents the device to associate with the
texture.
2) srcFile : String that specifies the file name.
3) width : Width of the texture in pixels. If this value is zero, the
dimensions are taken from the file.
4) height : Height of the texture in pixels. If this value is zero, the
dimensions are taken from the file.
5) mipLevels : Number of mip levels requested. If this value is 0, a
complete mipmap chain is created.
6) usage : Zero or Usage.RenderTarget, or Usage.Dynamic. Setting this flag
to Usage.RenderTarget indicates that the surface will be used as a render
target.
7) format : Member of the Format enumerated type that describes the
requested pixel format for the cube texture.
8) pool : Member of the Pool enumerated type that describes the memory
class into which the cube texture should be placed.
9) filter : One or more Filter flags that control how the image is filtered.
10) mipFilter : One or more Filter flags that control how the mipmaps are
filtered.
11) colorKey : An Int32 value to replace with transparent black, or 0 to
disable the color key.