开发者

What does SetPrivateData does in Managed DirectX?

Iv'e seen this method for a Texture, would someone explain me what d开发者_运维百科oes it do?


From the unmanaged documentation:

Associates data with the resource that is intended for use by the application, not by Direct3D. Data is passed by value, and multiple sets of data can be associated with a single resource.

Most APIs like this allow you to communicate with other, potentially unrelated parts of your program. As this is a method of the superclass of a number of other classes (including Texture), it appears to be a generic Microsoft-provided way to pass application-specific values around.

Consider this (quite contrived) scenario:

  1. Your map code has applied a dynamic texture to a wall.

  2. An item in your scene needs to know what texture is on the wall, in order to know how to behave. The code paths are completely unrelated.

  3. Your map engine can use SetPrivateData to apply a value to the texture that your item code can later query with GetPrivateData, rather than defining a global or some other way for the item to check.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜