变更DirectX SDK版本-DirectX8升级DirectX9(二)

二、 细节变化

1、函数参数变化:
SetIndices少了参数BaseVertexIndex,,加到DrawIndexedPrimitive了。
DrawIndexedPrimitive增加第二个参数BaseVertexIndex,第一个顶点相对于顶点缓冲首地址的偏移数

CreateTexture
CreateVolumeTexture
CreateCubeTexture
CreateVertexBuffer
CreateIndexBuffer
CreateRenderTarget
CreateDepthStencilSurface 增加最后一个参数pSharedHandle,Reserverd.

GetBackBuffer
GetDisplayMode增加第一个参数iSwapChain,交换链

SetStreamSource增加了第三个参数OffsetInBytes

GetGammaRamp
SetGammaRamp
GetAdapterModeCount
EnumAdapterModes增加第二参数D3DFORMART

GetAdapterIdentifier:第二参数默认值改变,宏正好相反
D8:GetAdapterIdentifier(D3DADAPTER_DEFAULT, D3DENUM_NO_WHQL_LEVEL , &identifier)=
D9:GetAdapterIdentifier(D3DADAPTER_DEFAULT,0 ,&identifier)

D8:GetAdapterIdentifier(D3DADAPTER_DEFAULT, 0 , &identifier)=
D9:GetAdapterIdentifier(D3DADAPTER_DEFAULT,D3DENUM_WHQL_LEVEL ,&identifier)

 

CheckDeviceType
GetDeviceCaps模式有所变化,具体见SDK,举例如下:
//CheckDeviceType函数区别,   CheckDeviceType和GetDeviceCaps配合使用验证适配器上的设备对希望使用的功能的支持度
#ifdef D3DX8
 if(FAILED(m_pD3D->CheckDeviceType(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,currentmode.Format,currentmode.Format,true)))
  return E_FAIL;
 if(FAILED(m_pD3D->CheckDeviceType(D3DADAPTER_DEFAULT,D3DDEVTYPE_REF,currentmode.Format,currentmode.Format,true)))
  return E_FAIL;
 if(FAILED(m_pD3D->CheckDeviceType(D3DADAPTER_DEFAULT,D3DDEVTYPE_SW,currentmode.Format,currentmode.Format,true)))
 {
  //return E_FAIL;//调用失败
 }
#endif
#ifdef D3DX9
 if(FAILED(m_pD3D->CheckDeviceType(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,currentmode.Format,D3DFMT_UNKNOWN,true))) //D3DFMT_UNKNOWN for window mode
  return E_FAIL;
 if(FAILED(m_pD3D->CheckDeviceType(D3DADAPTER_DEFAULT,D3DDEVTYPE_REF,currentmode.Format,D3DFMT_UNKNOWN,true)))
  return E_FAIL;
 if(FAILED(m_pD3D->CheckDeviceType(D3DADAPTER_DEFAULT,D3DDEVTYPE_SW,currentmode.Format,D3DFMT_UNKNOWN,true)))
 {
 // return E_FAIL; //失败,第3方插件没有?
 }
 if(FAILED(m_pD3D->CheckDeviceType(D3DADAPTER_DEFAULT,D3DDEVTYPE_NULLREF,currentmode.Format,D3DFMT_UNKNOWN,true)))
 {
 // return E_FAIL; //永远失败
 }
#endif
 //D3DDEVTYPE D9比D8多出D3DDEVTYPE_NULLREF这个类型,但所以使用此类型的设备创建的对象都将无效;而且原本无用的D3DDEVTYPE_SW类型有了新作用
 D3dcaps caps;
#ifdef D3DX8
 if(FAILED(m_pD3D->GetDeviceCaps(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,&caps)))
  return E_FAIL;
 if(FAILED(m_pD3D->GetDeviceCaps(D3DADAPTER_DEFAULT,D3DDEVTYPE_REF,&caps)))
  return E_FAIL;
 if(FAILED(m_pD3D->GetDeviceCaps(D3DADAPTER_DEFAULT,D3DDEVTYPE_SW,&caps)))//D8中无意义
 {
  // return E_FAIL;  
 }
#endif
#ifdef D3DX9
 if(FAILED(m_pD3D->GetDeviceCaps(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,&caps)))
  return E_FAIL;
 if(FAILED(m_pD3D->GetDeviceCaps(D3DADAPTER_DEFAULT,D3DDEVTYPE_REF,&caps)))
  return E_FAIL;
 if(FAILED(m_pD3D->GetDeviceCaps(D3DADAPTER_DEFAULT,D3DDEVTYPE_SW,&caps)))//经过IDirect3D9::RegisterSoftwareDevice注册过的第3方设备插件
 {
  // return E_FAIL;   //如果没注册则调用失败
 }
 if(FAILED(m_pD3D->GetDeviceCaps(D3DADAPTER_DEFAULT,D3DDEVTYPE_NULLREF,&caps)))//如上解释,任何调用都会失败
 {
  // return E_FAIL;
 }
#endif

CheckDeviceMultiSampleType增加一个参数pQualityLevels ,可以为NULL

 

SetRenderTarget:
SetRenderTarget(pRenderTarget,pNewZStencil) →功能分割成两个函数
SetRenderTarget(RenderTargetIndex,pRenderTarget)
SetDepthStencilSurface(pNewZStencil)

GetRenderTarget多了个参数RenderTargetIndex

D3DXAssembleShader 参数增加pDefines,顺序也变了,具体见SDK


2、函数名字改变,同样的功能变更到其他函数中:D8→D9
CreateImageSurface→
CreateOffscreenPlainSurface

SetRenderState(D3DRS_SOFTWAREVERTEXPROCESSING ,BOOL b)→
SetSoftwareVertexProcessing(BOOL b)

SetTextureStageState(一些参数,  )→
SetSamplerState(参数,    )
参数:
D3DTSS_ADDRESSU D3DTSS_ADDRESSV D3DTSS_ADDRESSW D3DTSS_BORDERCOLOR
D3DTSS_MAGFILTER D3DTSS_MINFILTER D3DTSS_MIPFILTER
D3DTSS_MIPMAPLODBIAS  D3DTSS_MAXMIPLEVEL D3DTSS_MAXANISOTROPY D3DTSS_FORCE_DWORD →
D3DSAMP_前缀的
D3DSAMP_ADDRESSU = 1,
D3DSAMP_ADDRESSV = 2,
D3DSAMP_ADDRESSW = 3,
D3DSAMP_BORDERCOLOR = 4,
D3DSAMP_MAGFILTER = 5,
D3DSAMP_MINFILTER = 6,
D3DSAMP_MIPFILTER = 7,
D3DSAMP_MIPMAPLODBIAS = 8,
D3DSAMP_MAXMIPLEVEL = 9,
D3DSAMP_MAXANISOTROPY = 10,
D3DSAMP_SRGBTEXTURE = 11,  原来没有
D3DSAMP_ELEMENTINDEX = 12, 原来没有
D3DSAMP_DMAPOFFSET = 13,   原来没有
D3DSAMP_FORCE_DWORD = 0x7fffffff,

SetVertexShader→
①固定管线FIXED-FUNCTION PIPELINE ,SetFVF
②着色器VertexShader,SetVertexShader
Remark:D9要使用SHADER必须先调用SetVertexDeclaration 再调用SetVertexShader
所以得先通过CreateVertexDeclaration()创建个IDirect3DVertexDeclaration9对象
例如:
VertexElement = {0 , 0 ,D3DDECLTYPE_FLOAT3 , D3DDECLMETHOD_DEFAULT ,D3DDECLUSAGE_POSITION , 0};
CreateVertexDeclaration(VertexElement,&VertexDeclaration);

SetVertexShaderConstant→
SetVertexShaderConstantF

ResourceManagerDiscardBytes→
EvictManagedResources

3、属性,结构改变:

D3DPRESENT_PARAMETERS结构变化如下:
d3dpp.FullScreen_PresentationInterval→
d3dpp.PresentationInterval

GetAdapterDisplayMode(D3DADAPTER_DEFAULT,&d3ddm)
d3dpp.BackBufferFormat = d3ddm.Format →
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN  在D8里设为D3DFMT_UNKNOWN 有时候会出错,获取不了当前显示模式。

D3DRENDERSTATETYPE结构变动挺多,具体SDK吧:举个例子
D3DRS_ZBIAS → D3DRS_DEPTHBIAS


D3DTEXTUREFILTERTYPE变动了一些
D3DTEXF_GAUSSIANCUBIC →
D3DTEXF_GAUSSIANQUAD

你可能感兴趣的:(sdk)