SetPrivateData 在 Managed DirectX 中起什么作用?

发布于 2024-08-07 22:43:17 字数 30 浏览 2 评论 0原文

我见过这种纹理方法,有人能解释一下它的作用吗?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

君勿笑 2024-08-14 22:43:17

来自非托管文档< /a>:

将数据与供应用程序而不是 Direct3D 使用的资源相关联。数据按值传递,并且多组数据可以与单个资源关联。

大多数这样的 API 允许您与程序中其他可能不相关的部分进行通信。由于这是许多其他类(包括纹理)的超类的方法,因此它似乎是 Microsoft 提供的传递应用程序特定值的通用方法。

考虑这个(相当人为的)场景:

  1. 您的地图代码已将动态纹理应用到墙壁。

  2. 场景中的项目需要知道墙上的纹理,才能知道如何表现。代码路径完全不相关。

  3. 您的地图引擎可以使用 SetPrivateData 将值应用于您的项目代码稍后可以使用 GetPrivateData,而不是为要检查的项目。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文