D3D9中UnBind Cg的方法

来源:互联网 发布:sql查询 编辑:程序博客网 时间:2024/05/03 04:23

在D3D9中使用cg程序,发现只有bind接口cgD3D9BindProgram,却始终找不到UnBind的方法,导致只要Bind了一个Cg程序,在整个绘制过程中就一直有效,这通常不会是我们想要的效果。

 

cggl有cgGLDisableProfile接口,但cgd3d9中没有对应的函数,尝试用cgD3D9UnloadProgram,cgD3D9UnloadAllPrograms,cgD3D9SetDevice等都行不通,后来在帮助手册中注意到这样一段话:“cgD3D9BindProgram activates a program with D3D. The program is activated using IDirect3DDevice9::SetVertexShader or IDirect3DDevice9::SetPixelShader depending on the program's profile type.”

 

就是说cg实际上是间接调用了Dx的接口函数,于是查了IDirect3DDevice9::SetVertexShade,发现只要使用参数NULL调用,就可以达到UnBind的效果。 

 

 

原创粉丝点击