views:

95

answers:

1

Iv'e seen this method for a Texture, would someone explain me what does it do?

+2  A: 

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.

Jed Smith