一 : Suface , Sprites, salmon
1: Suface : 储存图片纹理等数据的内存区域
(1) Display buffer:font buffer,back buffer可以通过present()把back buffer内容调入font buffer从而显示出来
(2) Offsceen surface(离屏表面相对于primary surface):是缓存和主屏面值间的缓冲区.
A: 建立offscree suface : CreateOffscreenPlainSureface()
B: 加载资源到 offscree suface: D3DXLoadSurfaceFromFile()
C: 把offscree suface的东东转到back buffer中: StretchRect()
void Render(void)
{
// This will hold the back buffer
IDirect3DSurface9* backbuffer = NULL;
// Check to make sure you have a valid Direct3D device
if( NULL == pd3dDevice )
return;
// Clear the back buffer to a blue color
pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET,
D3DCOLOR_XRGB(0,0,255), 1.0f, 0 );
// Get the back buffer
pd3dDevice->GetBackBuffer( 0,
0,
D3DBACKBUFFER_TYPE_MONO,
&backbuffer );
// Copy the offscreen surface to the back buffer
// Note the use of NULL values for the source and destination RECTs
// This ensures a copy of the entire surface to the back buffer
pd3dDevice->StretchRect( srcSurface,
NULL,
backbuffer,
NULL,
D3DTEXF_NONE );
// Present the back buffer contents to the display
pd3dDevice->Present ( NULL, NULL, NULL, NULL );
}
二
:
3D
1
:
Primary Type
:
DrawPrimitive(), DrawIndexedPrimitive()
Point List, Line List, Line Strip(
许多不相连的线组成
)
,
Line Strip(
许多相连的组成
)
,
Triangle List(
不相连的三角形组成的
)
,
Triangle Strip, Triangle Fan
2: DirectX
中的
Matrix
移动
: D3DXMatrixTranslation()
旋转
(
弧度
): D3DXMatrixRotationX(),D3DXMatrixRotationY(),D3DXMatrixRotationZ()
把角度转化为弧度
: D3DXToRadian(angle)
压缩或放大物体
: D3DXMatrixScaling()
矩阵相乘
: D3DXMatrixMultiply()
把矩阵作用于物体的变换
: SetTransform()
注意
:
各种矩阵作用物体的顺序
,
可以通过各种矩阵在
D3DXMatrixMultiply()
中参数的位置来确定
3:
顶点颜色
D3DCOLOR_ARGB, D3DCOLOR_RGBA,
D3DCOLOR_XRGB, (
默认
alpha
值为
255)
D3DCOLOR_COLORVALUE.(
值时
0.0---1.0
之间
)
4: shade(
着色
):
Flat shading:
通过一个点的颜色来
render
多边形的颜色
Gourand shading:
通过多个点
可以通过
SetRenderStata(D3DRS_SHADEMODE,,)
来设置
shade
方
5 :Fill Mode:
多边形的渲染方式
Point, WireFram, Solid
SetRendeStata(D3DRS_FILLMODE,,,)
6
:
Light
(1)
type:
Ambient Lights(
环境光源
)
(默认光源)
:
来世界的各个方向,均匀的照在物体上,所以同时间只能有一个
Ambient Light
处于活动状态
Direction Lights(
方向光
):
有方向,颜色,但没有位置,世界中可有多个
Direction Lights
Point Lights
():有颜色,位置,可有多个
Point Lights
SpoteLights(
聚焦光源
):
有,位置 ,颜色,方向
(2 )Function
HRESULT SetLight()
HRESULT LightEnable()
Bool GetLightEnalble(): check the stata of Light
SetRederStata(D3DRS_LIGHT,,,)
(4): Create the Light
注意:
Create Ambient Light: SetRenderStata(D3DRS_AMBIENT,D3DCOLOR_XRGB())
7:
Materils :
物体发出和反射光的属性
D3DCOLORVALUE difuss reflection
D3DCOLORVALUE ambient reflection
D3DCOLORVALUE specular reflection
D3DCOLORVALUE Emissive
Float power
SetMaterial()
注意:specular:
SetRederStata(
D3DRS_SPECULARENABLE, TRUE
)
8: Texture
SetTextureStageStata():
设置纹理方式
,
可以是多个纹理同时加在一个物体上
D3DXCreateTextureFromFile():
D3DXCreateTextureFromResuorce():
可以是多个
texture
混合成的
resuorse
SetTexure()
9: Mesh:
Interface : ID3DXMesh
(1)
Creater Mesh
D3DXCreateMesh();
D3DXCreateMeshFVF();
注意
: D3DXDeclaratorFromFvF():
申明所需要的定点格式
(2): Fill the Mesh
(4): Display Mesh
DrawSubset()
(5): Optimizing Mesh
Optimize()
有新的输出
mesh
OptimizeImaplace()
没有新的输出
mesh
(6): Get Detail of Mesh
GetNumVertices()
GetNumFace()