D3DX除了提供concrete 类型外,也提供一些抽象的COM对象来执行渲染有关的任务。Matrix Stack 用于维护坐标体系。Font 和Sprite对象用于文字的渲染和屏幕空间纹理四边形的绘制。渲染到surface和渲染到环境map对象简化了第二个render target的使用和环境map纹理的构建。
D3DX 也提供了一个对象用于实现可视效果。效果通过文本符号指定,并且使用了多个techniques来实现。每个technique由一组渲染passes和每个pass的渲染状态组成。效果也允许应用程序使用参数来控制。
Matrix stack对于实现包含多个坐标系的scene graph很有帮助。D3DXCreateMatrixStack用来创建一个Matrix Stack.
HRESULT D3DXCreateMatrixStack(DWORD zero,ID3DXMatrixStack ** result);
ID3DXMatrixStack
Read-only Properties | |
GetTop | topmost matrix in the stack |
Methods | |
LoadIdentity | Loads an Identity matrix |
LoadMatrix | Loads an arbitrary matrix |
MultMatrix | Post-multiplies a matrix |
MultMatrixLocal | Pre-multiplies a matrix |
Pop | Pops the topmost matrix from the stack |
Push | Pushes a matrix onto the stack |
RotateAxis | Post-mulitiplies a rotation matrix |
RotateAxisLocal | Pre-multiplies a rotation matrix |
RotateYawPitchRoll | Post-multiplies a rotation matrix |
RotateYawPitchRollLocal | Pre-multiplies a rotation matrix |
Scale | Post-multiplies a scaling matrix |
ScaleLocal | Pre-multiplies a scaling matrix |
Translate | Post-multiplies a translation matrix |
TranslateLocal | Pre-multiplies a translation matrix |
D3DX 提供了基于GDI渲染的ID3DXFont接口。使用这个接口,文字首先被GDI光栅化到内存DC,然后内存DC的内容将被拷贝到一个纹理,最后将这个纹理将被渲染到render target。 这个过程里面包含两个效率低的操作:GDI渲染,texture内容被必须被拷贝到设备内存。但这,这种方法渲染出来的文字质量很高,而且可以支持多字节和UNICODE的文字。
HRESULT D3DXCreateFont (IDirect3DDevice9 * device,HFONT font, ID3DXFont ** result);
font参数指定了一个存在GDI font的句柄,
ID3DXFont
Read-only Properties | |
GetDC | GetDC |
GetDescA | GetDescA |
GetDescW | GetDescW |
GetDevice | The associated device |
GetGlyphData | GetGlyphData |
GetTextMetricsA | GetTextMetricsA |
GetTextMetricsW | GetTextMetricsW |
Methods | |
DrawTextA | Render ASCII text |
DrawTextW | Render UNICODE Text |
OnLostDevice | Release device resource |
PreloadCharacters | PreloadCharacters |
PreloadGlyphs | PreloadGlyphs |
PreloadTextA | PreloadTextA |
PreloadTextW | PreloadTextW |
Sprites是一个总是与屏幕平行的纹理化的四边形。D3DX使用ID3DXSprite实现一个sprite对象。D3DXCreateSprite用于创建一个sprite对象实例。
HRESULT D3DXCreateSprite(IDirect3DDevice9 * device, ID3DXSprite ** result);
ID3DXSprite
Read-Only Properties | |
GetDevice | The associated device |
Write-Only Properties | |
SetWorldViewLH | SetWorldViewLH |
SetWorldVideRH | SetWorldViewRH |
Properties | |
GetTransform | |
SetTransform | |
Methods | |
Begin | Begin |
Draw | Draw |
End | End |
Flush | Flush |
OnLostDevice | Release devices resource |
OnResetDevice | Restore device resource |
D3DX提供了ID3DXRenderToSurface接口简化了渲染到任意surface的过程。D3DXCreateRenderToSurface可以用来创建一个对象实例。
HRESULT D3DXCreateRenderToSurface(IDirect3DDevice9 * device, UINT width, UINT height, D3DFORMAT format, BOOL depth_stencil, D3DFORMAT ds_format, ID3DXRenderToSurface ** sesult);
ID3DXRenderToSurface
Read-only Properties | |
GetDesc | A description of the render target surface |
GetDevice | The associated device |
BeginScene | Start rendering to a surface |
EndScene | Finish rendering to a surface |
OnLostDevice | Release device resources |
OnResetDevice | Restore device resources |
HRESULT D3DXCreateRenderToEnvMap(IDirect3DDevice9 * device, UINT size, D3DFORMAT format, BOOL depth_stencil, D3DFORMAT ds_format, ID3DXRenderToEnvMap ** result);
ID3DXRenderToEnvMap
Read-Only Properties | |
GetDesc | A description of the render target used |
GetDevice | The associated device |
Methods | |
BeginCube | Begin rendering to a cube enviroment map |
BeginHemisphere | Begin rendering to a hemispherical enviroment map |
BeginParabolic | Begin rendering to a parabolic enviroment map |
BeginSphere | Begin rendering to a spherical enviroment map |
End | End rendering to an enviroment map |
Face | Select a cubic enviroment map face for rendering |
OnLostDevice | Releases device resources |
OnResetDevice | Restores device resources |