DirectX9 Rendering Settings

Source: Internet
Author: User

In a fixed pipeline:

1. Create a vertex and index cache for the device

HRESULT Idirect3ddevice9::createvertexbuffer (
UINT Length,
DWORD Usage,
DWORD FVF,
D3dpool Pool
idirect3dvertexbuffer9** Ppvertexbuffer,
handle* Psharedhandle
);
Ppvertexbuffer: Caching
FVF: Cached fixed-point format

2. Read/write Cache:
HRESULT Idirect3dvertexbuffer9::lock (
UINT Offsettolock,
UINT Sizetolock,
byte** Ppbdata,
DWORD Flags
);
Lock Cache
Read/write Cache
Unlock Cache

3. Set the resource flow (specify a cache to be rendered to the device)
HRESULT Idirect3ddevice9::setstreamsource (
UINT Streamnumber,
idirect3dvertexbuffer9* pstreamdata,//Render this cache
UINT Offsetinbytes,
UINT Stride
);

4. Set the vertex format (here we specify the vertex format for the vertices that are later used for drawing calls.) )
_DEVICE->SETFVF (d3dfvf_xyz | D3dfvf_diffuse | D3DFVF_TEX1);
It is also the format used for subsequent vertex declarations. Tell the GPU what each data in the vertex structure means, and then pass it on to shader.

5. Setting the index cache
_device->setindices (_IB); Pass a copy of an index cache pointer

6. Draw with the specified cache
IDirect3DDevice9::D rawprimitive
This method does not use index information to draw entities.
IDirect3DDevice9::D rawindexedprimitive
This method uses index information to draw an entity.
The GPU draws the specified object with the resources it has set up to

Programmable Pipeline:
1. Vertex shader (vertex shader)
is a program that executes on the GPU of a graphics card,
It replaces the transform (transformation) and illumination (lighting) phases in the fixed function pipeline (the pipeline).

2. Vertex declaration: Same FVF

3. Description Vertex declaration: D3dvertexelement9
typedef struct _D3DVERTEXELEMENT9 {
BYTE Stream;
BYTE Offset; offset--offset, in bytes, relative to the start of the vertex component of the vertex structure member
BYTE Type;
BYTE Method;
BYTE Usage;
BYTE Usageindex;
} d3dvertexelement9;

As an D3DVERTEXELEMENT9 array

4. Create vertex declaration: Idirect3dvertexdeclaration9

HRESULT Idirect3ddevice9::createvertexdeclaration (
CONST d3dvertexelement9* pvertexelements,
idirect3dvertexdeclaration9** ppdecl
);

Idirect3dvertexdeclaration9 the vertex declaration returned


5. Set vertex declarations
Device->setvertexdeclaration (_DECL);

6. Semantics:
The function is a mapping of data members that define the elements of a vertex declaration to the input structure of the vertex shader

7. Compiler shader: D3dxbuffer
D3dxcompileshaderfromfile
Returns a D3dxbuffer pointer representing the shader code binary

8. Create a vertex shader: Idirect3dvertexshader9
HRESULT Idirect3ddevice9::createvertexshader (
Const DWORD *pfunction,
idirect3dvertexshader9** Ppshader
);
pfunction--A pointer to the compiled shader code
ppshader--returns a pointer to a IDIRECT3DVERTEXSHADER9 interface

9. Set the vertex shader:
The vertex shader used for rendering the device
HRESULT Idirect3ddevice9::setvertexshader (
idirect3dvertexshader9* Pshader
);
10. Destroying the vertex shader

DirectX9 Rendering Settings

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.