Direct3D (DirectX 9.0) Code Samples - Page 5

Depth Bias
 

This sample demonstrates how to eliminate z-fighting when rendering polygons directly on top of other polygons  by using Direct3D's D3DRS_SLOPESCALEDEPTHBIAS and D3DRS_DEPTHBIAS render states.

Relevant Keywords: SetRenderState, D3DRS_SLOPESCALEDEPTHBIAS, and D3DRS_DEPTHBIAS.

 

Fonts
 

This sample demonstrates how to render text to the screen using Direct3D's ID3DXFont class.

Relevant Keywords: GetDC, GetDeviceCaps, ReleaseDC, CreateFont, D3DXCreateFont, DeleteObject, SetRect, Begin, End, DrawText, RECT, DT_SINGLELINE, FW_DONTCARE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, and FF_DONTCARE.


First Person Shooter Controls
 

Demonstrates how to manually modify the view matrix using mouse and keyboard input to create a First Person Shooter style control. This sample is very similar to the "First-Person-Shooter View Control" sample except this one uses no DirectInput. Check out the OpenGL source code page for the OpenGL equivalent of this sample.

Relevant Keywords: SetTransform, D3DXMatrixPerspectiveFovLH, D3DXMatrixRotationAxis, D3DXVec3TransformCoord, D3DXMatrixScaling, D3DXMatrixIdentity, D3DXVec3Normalize, D3DXVec3Dot,  D3DXVec3Cross, D3DXLoadMeshFromX, GetBufferPointer, DrawSubset, D3DXMATERIAL, D3DXMESH_SYSTEMMEM, D3DTS_VIEW, D3DTS_WORLD, D3DTS_PROJECTION, LPD3DXMESH, MatD3D, pTextureFilename, Ambient, and Diffuse.

Relevant C# Keywords:

  • Download (Last Updated: 07/08/05 - C++)
  • Download (Last Updated: 07/08/05 - C#)

Point Lighting
 

This sample demonstrates how to setup point lighting with Direct3D. The sample also demonstrates how the tessellation or triangle count of a mesh effects lighting.

Relevant Keywords: SetLight, SetRenderState, LightEnable, D3DXMatrixTranslation, D3DXMatrixRotationZ, D3DXToRadian, D3DXMatrixLookAtLH, D3DXMatrixInverse, D3DXCreateSphere, D3DXCreateCylinder, D3DRS_LIGHTING, D3DLIGHT_POINT, D3DRS_AMBIENT, D3DLIGHT9, D3DMATERIAL9, Diffuse, Ambient, Type, Range, Direction, Position, Attenuation0, Attenuation1, and Attenuation2.


Spot Light
 

This sample demonstrates how to setup a spot light with Direct3D. The sample also demonstrates how the tessellation or triangle count of a mesh effects lighting.

Relevant Keywords: SetLight, SetRenderState, LightEnable, D3DXMatrixTranslation, D3DXMatrixRotationZ, D3DXToRadian, D3DXMatrixLookAtLH, D3DXMatrixInverse, D3DXCreateSphere, D3DXCreateCylinder, D3DRS_LIGHTING, D3DLIGHT_SPOT, D3DRS_AMBIENT, D3DLIGHT9, D3DMATERIAL9, Diffuse, Ambient, Type, Range, Direction, Position, Theta, Phi, Falloff, Attenuation0, Attenuation1, and Attenuation2.