Direct3D (DirectX 9.0) Code Samples - Page 7

Particle System (Using Point Sprites)
 

Adding a particle system to your game engine has become all the rage, but where do you start? Here of course! This sample demonstrates how to create a particle system class which uses Direct3D's hardware accelerated point sprites. To learn more about point sprites, check out the Point Sprites sample above. Check out the OpenGL source code page for the OpenGL equivalent of this sample.

 

Off-screen Rendering
 

This code sample demonstrate how to create dynamic textures through the use of an off-screen rendering surface under Direct3D. Check out the OpenGL source code page for the OpenGL equivalent of this sample.

Relevant Keywords: D3DXCreateRenderToSurface, D3DXCreateTexture, D3DXMatrixRotationYawPitchRoll, LPD3DXRENDERTOSURFACE, LPDIRECT3DTEXTURE9, and LPDIRECT3DSURFACE9.

 

Occlusion Query
 

This sample demonstrates how to use Direct3D new occlusion query feature to find out how many pixels of an object are actually visible. The sample is basically a simplified port of the nVIDIA's OpenGL sample, which covers the same subject. Check out the OpenGL source code page for the OpenGL equivalent of this sample.

Relevant Keywords: CreateQuery, GetData, D3DXCreateSphere, D3DXCreateBox, CloneMeshFVF, GetVertexBuffer, GetNumVertices, D3DQUERYTYPE_OCCLUSION, Issue, D3DISSUE_BEGIN, D3DISSUE_END, and LPDIRECT3DQUERY9.

 

Emboss Bump Mapping
 

These samples demonstrate how to perform one-pass and two-pass emboss bump mapping with Direct3D. I've also included code, which demonstrates how to calculate tangent and binormal vectors on a per-vertex basis. These special vectors define the texture space for each vertex, which allows for accurate texture coordinate shifting during the bump mapping process. Check out the OpenGL source code page for the OpenGL equivalent of these samples.

Relevant Keywords: SetTextureStageState, SetRenderState, SetTexture, D3DXVec3Dot, D3DXVec3Normalize, D3DXMatrixInverse, GetTransform, D3DXCreateSphere, D3DTSS_TEXCOORDINDEX, D3DTSS_COLOROP, D3DTSS_COLORARG1, D3DTSS_COLORARG2, D3DTSS_ALPHAOP, D3DTSS_ALPHAARG1, D3DTSS_ALPHAARG2, D3DTOP_MODULATE, D3DTA_TEXTURE, D3DTA_DIFFUSE, D3DTOP_SELECTARG1, D3DTA_CURRENT, D3DTOP_ADDSIGNED, D3DTA_COMPLEMENT, D3DTOP_MODULATE2X, D3DTA_ALPHAREPLICATE, D3DTOP_DISABLE, and D3DRS_ALPHABLENDENABLE.

 

Shadow Volume
 

This code sample demonstrates how to create dynamic shadows with Direct3D using a stencil shadow volume. The sample is basically a simplified re-write of the ShadowVolume sample that ships with the DirectX 9 SDK.

Relevant Keywords: GetBackBuffer, SetRenderState, D3DXLoadMeshFromX, GetDeviceCaps, Lock, Unlock,  D3DSTENCILCAPS_TWOSIDED, D3DBACKBUFFER_TYPE_MONO, D3DRS_STENCILENABLE, D3DRS_SHADEMODE, D3DRS_STENCILENABLE, D3DRS_STENCILFUNC, D3DRS_STENCILZFAIL, D3DRS_STENCILFAIL, D3DRS_STENCILREF, D3DRS_STENCILMASK, D3DRS_STENCILWRITEMASK, D3DCMP_LESSEQUAL, D3DRS_STENCILPASS, D3DSTENCILOP_KEEP, D3DRS_ZWRITEENABLE, D3DRS_ALPHABLENDENABLE, D3DRS_SRCBLEND, D3DRS_DESTBLEND, D3DBLEND_ZERO, D3DBLEND_ONE, D3DSTENCILOP_KEEP, D3DCMP_ALWAYS, D3DSHADE_FLAT, D3DSTENCILOP_DECR, D3DRS_CULLMODE, D3DCULL_NONE, D3DCULL_CCW, D3DSHADE_GOURAUD, D3DRS_FILLMODE, D3DFILL_WIREFRAME, D3DFILL_SOLID, and StencilCaps.