Iv'e seen this method for a Texture, would someone explain me what does 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:
Your map code has applied a dynamic texture to a wall.
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.
Your map engine can use
SetPrivateData
to apply a value to the texture that your item code can later query withGetPrivateData
, rather than defining a global or some other way for the item to check.