turns out to be a hellish task due to the somewhat "abomination" that is the "MSDN" which doesn't really say exactly what to do or if it does it's so vague that I can't quite grasp the function order and names so with that can someone please ethier tell me what I need to do to use,create and code pixel and vertex shaders or provide me a non-retardedly technical resource for learning Direct3D9 that actually works out of the box so I can learn the hell out of it please.
All the info on the MSDN should also be available in your SDK installation, in a file named something like windows_graphics.chm. As well as the reference pages, that just give you the vague descriptions, there will also be guides, tutorials and sample programs.
Instead of using D3DXCompileShaderFromFile, etc, I would recommend using fxc.exe, which is a shader compiler that comes with the SDK that allows you to compile your shaders ahead of time.
See here: http://msdn.microsoft.com/en-us/library/windows/desktop/bb509710(v=vs.85).aspx
The compiler will produce binary "object" files, containing your compiled shader code. You then load these files at runtime, and pass the contents of the file to CreatePixelShader/CreateVertexShader, e.g.
IDirect3DPixelShader9* result = 0;
char* data = /*load your compiled shader file*/;
bool everythingIsOk = SUCCEEDED( device->CreatePixelShader( (DWORD*)data, &result ) );
The overall pipeline looks like:
To bind a vertex buffer to the device, for use by any vertex shader, you use SetStreamSource( slot, buffer, offset, stride ).
To bind an index buffer to the device, for use by any vertex shader, you use SetIndices.
To configure the input assembler stage, you bind a "vertex declaration" with SetVertexDeclaration.
This object defines how streams (VBO's) are read and turned into an input vertex, which is passed to the vertex shader. It is the "glue" between vertex buffers and vertex shaders.
To create one, you make an array of D3DVERTEXELEMENT9 elements, describing each 'varying' variable to be input to the vertex shader. This array must contain one extra entry at the end, which is set to D3DDECL_END to signify the end of the array. You then pass this array to CreateVertexDeclaration.
To set the pixel/vertex shader code that will be used, you use SetPixelShader and SetVertexShader.
To configure the rasterization stage, you use SetRenderState with D3DRS_CULLMODE, D3DRS_FILLMODE, D3DRS_DEPTHBIAS and D3DRS_SLOPESCALEDEPTHBIAS.
To configure the depth-stencil test, you use SetRenderState with D3DRS_ZENABLE, D3DRS_ZWRITEENABLE, D3DRS_ZFUNC, D3DRS_STENCILENABLE, D3DRS_STENCILREF, D3DRS_STENCILMASK, D3DRS_STENCILWRITEMASK, D3DRS_STENCILFUNC, D3DRS_STENCILPASS, D3DRS_STENCILFAIL and D3DRS_STENCILZFAIL.
To bind a texture to the device for use by any pixel shader, you use SetTexture( slot, texture )
To bind a texture to the device for use by any vertex shader, you use SetTexture( D3DVERTEXTEXTURESAMPLER0+slot, texture )
To configure how textures are sampled, you use SetSamplerState( slot, type, value ), where type is D3DSAMP_ADDRESSU, D3DSAMP_ADDRESSV, D3DSAMP_ADDRESSW, D3DSAMP_MAGFILTER, D3DSAMP_MINFILTER, D3DSAMP_MIPFILTER, D3DSAMP_MIPMAPLODBIAS, D3DSAMP_MAXMIPLEVEL, D3DSAMP_MAXANISOTROPY and D3DSAMP_BORDERCOLOR.
To set a uniform variable, for use by any pixel shader, you use SetPixelShaderConstantF( slot, data, numberOfFloat4sInData ).
To set a uniform variable, for use by any vertex shader, you use SetVertexShaderConstantF( slot, data, numberOfFloat4sInData ).
Unlike GL 1.x/2.x, uniform variables are set on the device, not on a shader program. Shader programs and uniform values are completely independent.
Once you set a uniform variable, it will remain in that slot (for any bound shader) until a new uniform variable is set.
To configure the output merger stage, you use SetRenderState with D3DRS_COLORWRITEENABLE, D3DRS_ALPHABLENDENABLE, D3DRS_SRCBLEND, D3DRS_DESTBLEND, D3DRS_BLENDOP, D3DRS_ALPHAFUNC and D3DRS_ALPHAREF.
To change your render-targets (frame buffer objects), you use SetDepthStencilSurface and SetRenderTarget.
To set the viewport rect you use SetViewport.
To set the scissor rect you use SetScissorRect.
You can then draw primitives with DrawPrimitive and DrawIndexedPrimitive.
If you've got specific, non-vague questions, ask away.
many GOOD Games were been made with dx9
many old video-cards not support dx11
and it will be funny if your LITTLE game will work only on top hardware ;[
The Dx11 API can be used to write games for SM2 (~2003), SM4 (~2006) and SM5 (~2010) class hardware.
You do this via "feature levels". i.e. you can use the Dx11 API, but select the "D3D9 feature level" so that your game works on old hardware.
The only catch is that your users require Win Vista/7/8...
The Dx9 API can be used to write games for SM2 and SM3 (~2005) class hardware.
The good thing about this is that your users only require Win XP.