D3DX Helper Objects

本文介绍了D3DX中的渲染技术,包括MatrixStack用于坐标变换管理,ID3DXFont和ID3DXSprite用于文本和屏幕空间纹理四边形的渲染,以及ID3DXRenderToSurface和ID3DXRenderToEnvMap简化渲染到表面和环境映射的过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

    D3DX除了提供concrete 类型外,也提供一些抽象的COM对象来执行渲染有关的任务。Matrix Stack 用于维护坐标体系。Font 和Sprite对象用于文字的渲染和屏幕空间纹理四边形的绘制。渲染到surface和渲染到环境map对象简化了第二个render target的使用和环境map纹理的构建。

    D3DX 也提供了一个对象用于实现可视效果。效果通过文本符号指定,并且使用了多个techniques来实现。每个technique由一组渲染passes和每个pass的渲染状态组成。效果也允许应用程序使用参数来控制。  

 

Matrix Stacks

   Matrix stack对于实现包含多个坐标系的scene graph很有帮助。D3DXCreateMatrixStack用来创建一个Matrix Stack.

   HRESULT D3DXCreateMatrixStack(DWORD zero,ID3DXMatrixStack ** result);

 

 ID3DXMatrixStack

Read-only Properties 
GetToptopmost matrix in the stack
Methods 
LoadIdentityLoads an Identity matrix
LoadMatrixLoads an arbitrary matrix
MultMatrixPost-multiplies a matrix
MultMatrixLocalPre-multiplies a matrix
PopPops the topmost matrix from the stack
PushPushes a matrix onto the stack
RotateAxisPost-mulitiplies a rotation matrix
RotateAxisLocalPre-multiplies a rotation matrix
RotateYawPitchRollPost-multiplies a rotation matrix
RotateYawPitchRollLocalPre-multiplies a rotation matrix
ScalePost-multiplies a scaling matrix
ScaleLocalPre-multiplies a scaling matrix
TranslatePost-multiplies a translation matrix
TranslateLocal Pre-multiplies a translation matrix

 

Fonts

 

  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 
GetDCGetDC
GetDescAGetDescA
GetDescWGetDescW
GetDeviceThe associated device
GetGlyphDataGetGlyphData
GetTextMetricsAGetTextMetricsA
GetTextMetricsWGetTextMetricsW
Methods 
DrawTextARender ASCII text
DrawTextWRender UNICODE Text
OnLostDeviceRelease device resource
PreloadCharactersPreloadCharacters
PreloadGlyphsPreloadGlyphs
PreloadTextAPreloadTextA
PreloadTextWPreloadTextW

 

Sprites

 

    Sprites是一个总是与屏幕平行的纹理化的四边形。D3DX使用ID3DXSprite实现一个sprite对象。D3DXCreateSprite用于创建一个sprite对象实例。

     HRESULT D3DXCreateSprite(IDirect3DDevice9 * device, ID3DXSprite ** result);

ID3DXSprite

Read-Only Properties 
GetDeviceThe associated device
Write-Only Properties 
SetWorldViewLHSetWorldViewLH
SetWorldVideRHSetWorldViewRH
Properties 
GetTransform 
SetTransform 
Methods 
BeginBegin
DrawDraw
EndEnd
FlushFlush
OnLostDeviceRelease devices resource
OnResetDeviceRestore device resource

 

Surface Rendering

 

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 
GetDescA description of the render target surface
GetDeviceThe associated device
BeginSceneStart rendering to a surface
EndSceneFinish rendering to a surface
OnLostDeviceRelease device resources
OnResetDeviceRestore device resources

 

Enviroment Map Rending

 

  HRESULT D3DXCreateRenderToEnvMap(IDirect3DDevice9 * device, UINT size, D3DFORMAT format, BOOL depth_stencil, D3DFORMAT ds_format, ID3DXRenderToEnvMap ** result);

ID3DXRenderToEnvMap

Read-Only Properties 
GetDescA description of the render target used
GetDeviceThe associated device
Methods 
BeginCubeBegin rendering to a cube enviroment map
BeginHemisphereBegin rendering to a hemispherical enviroment map
BeginParabolicBegin rendering to a parabolic enviroment map
BeginSphereBegin rendering to a spherical enviroment map
EndEnd rendering to an enviroment map
FaceSelect a cubic enviroment map face for rendering
OnLostDeviceReleases device resources
OnResetDevice Restores device resources
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值