Direct3D (DirectX 9.0) Code Samples - Page 8

Creating 2D Sprites with D3DXSprite

This sample demonstrates how to create a animated 2D sprite using D3DXSprite which is hardware accelerated and fully compatible with 3D generated content.


Simple Effect Using .fx Files

This sample demonstrates how to write and use Effect files (.fx) under DirectX 8.1. The sample Effect is very straightforward. It defines a technique called "TwoPassTextureBlend", which has two separate rendering passes, called "Pass0" and "Pass1". The two passes are then used to basically blend two textures together through the simple addition of the texel data.

Relevant Keywords: D3DXCreateEffectFromFile, GetBufferPointer, SetTexture, SetTechnique, Begin, End, texture, technique, pass, AlphaBlendEnable, Texture, ColorOp, ColorArg1, SelectArg1, Disable, and LPD3DXEFFECT.


Simple Vertex & Pixel Shader (HLSL/Fx Effect File)

This sample demonstrates how to write simple vertex and pixel shaders using Direct3D's new High-Level Shading Language. The two shaders reside within a Direct3D .fx Effect File and have matching inputs and outputs, which allow them to be used simultaneously on the same piece of geometry.

Relevant Keywords: D3DXCreateEffectFromFile, SetTechnique, SetMatrix, SetTexture, Begin, End, float4x4, texture, sampler, technique, pass, LPD3DXEFFECT, and LPD3DXBUFFER.


Simple Vertex & Pixel Shader (HLSL)

This sample demonstrates how to write both a simple vertex and pixel shader using Direct3D's HLSL without the help of the .fx Effect File format. The shaders in this sample don't really do anything useful or neat, it's meant to be used as a framework or starting place for experimenting with shaders.

Relevant Keywords: CreateVertexDeclaration, D3DXCompileShaderFromFile, GetBufferPointer, CreateVertexShader, CreatePixelShader, D3DDECL_END, D3DVERTEXELEMENT9, D3DDECLTYPE_FLOAT3, D3DDECLUSAGE_POSITION, D3DDECLTYPE_D3DCOLOR, D3DDECLUSAGE_COLOR, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, SetVertexDeclaration, SetMatrix, SetVertexShader, SetPixelShader, GetConstantByName, GetConstantDesc, LPDIRECT3DVERTEXSHADER9, LPDIRECT3DVERTEXDECLARATION9, LPDIRECT3DPIXELSHADER9, LPD3DXCONSTANTTABLE, LPD3DXBUFFER, D3DXHANDLE, D3DXCONSTANT_DESC, ps_1_1, vs_1_1, POSITION, COLOR0, TEXCOORD0, float2, float3, float4x4, float4, mul, stuct, sampler, tex2d, and return.


Simple Vertex Shader (vs.2.0)

Demonstrates how to write an assembly-level vertex shader using the vs2.0 instruction set defined in DirectX 9.0.

Relevant Keywords: CreateVertexDeclaration, D3DXAssembleShaderFromFile, CreateVertexShader, LPDIRECT3DVERTEXDECLARATION9, LPDIRECT3DVERTEXSHADER9, D3DVERTEXELEMENT9, ID3DXBuffer, D3DDECLTYPE_FLOAT3, D3DDECLUSAGE_COLOR, D3DDECLUSAGE_POSITION, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECL_END, vs.2.0, dcl_position, dcl_color, m4x4, oPos, oD0, and mov.