Use this vertex structure for your 2D GUI.
Code:
struct GUIVertex
{
D3DXVECTOR3 Pos;
float Rhw;
D3DCOLOR Diffuse;
D3DCOLOR Specular;
float u,v;
static const DWORD FVF;
};
Code:
const DWORD GUIVertex::FVF=D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1
Create a vertex buffer with this structure. Set Pos.z to 1.0f and set x and y in SCREEN space. Just like you are drawing right to the screen. Using D3DFVF_XYZRHW will force a complete bypass of the T&L DX pipeline. Basically we are saying this vertex has already been processed so don't do any math on it.
Create your quads like this:
0........1
............
............
2.........3
For CCW:
Triangle 1 - 0,1,2
Triangle 2 - 1,3,2
For CW:
Triangle 1 - 2,1,0
Triangle 2 - 3,1,2
Texture coords should be:
0 - 0.0f,0.0f
1 - 1.0f,0.0f
2 - 0.0f,1.0f
3 - 1.0f,1.0f
To get DX to draw to your 'Window' per se without drawing outside of the boundaries of it (all drawing is clipped to the control) use
IDirect3DDevice9::SetViewPort()