使用 Direct3D 的 2D 图形

发布于 2024-10-09 06:32:54 字数 332 浏览 0 评论 0原文

我正在尝试使用 Direct3D 渲染 2D 图形,这是自 DirectDraw 弃用以来每个人都推荐的。我确实不关心任何 3D 效果,只是希望能够执行诸如在彼此上绘制线条、圆圈和位图传输图像之类的操作。因此,我的问题是

  1. 我需要从文件中加载大量图像,并将它们相互绘制。纹理会是正确的选择吗?
  2. 非常愚蠢的问题,但我似乎找不到任何东西:如何将一个表面渲染到另一个表面上?
  3. 您应该将所有内容渲染到单个纹理上,然后将其作为精灵绘制到屏幕上,还是只绘制许多纹理?
  4. 如何在纹理/表面/精灵上绘制线条等?我认为有比获取设备上下文并使用 GDI 在其上绘图更好的方法吗?

I'm trying to use Direct3D to render 2D graphics, as recommended by everyone since DirectDraw's deprecation. There really isn't any 3D-ness I care about, and just want to be able to do things like draw lines, circles, and blit images onto each other. My questions are thus

  1. I need to load a lot of images from files, and draw them onto each other. Would textures be the way to go?
  2. Very stupid question, but I can't seem to find anything: How do you render one surface onto another?
  3. Should you render everything onto a single texture and then draw that to screen as a sprite, or just draw many textures?
  4. How do you draw lines, etc, onto a texture/surface/sprite? I assume there's a better way than getting a device context and using GDI to draw on it?

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

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

发布评论

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

评论(1

浅忆 2024-10-16 06:32:54
  1. 创建 2 个三角形形成一个四边形。适当设置 UV 值。 UV 值设置在 0 到 1 的范围内。因此,对于 1024x1024(或者实际上任何分辨率纹理,这就是这样做的原因)图像,左上角是 0,0,右下角是 1,1。 ID3DXSprite 将为您提供帮助。
  2. 最好将多个“帧”放入一个纹理中,以避免过于频繁地更改纹理(这很昂贵)。
  3. 您可以使用 D3DPT_LINELIST/STRIP ...未能使用 2 个三角形(请参阅 ID3DXLine)。
  1. Yes
  2. Create 2 triangles forming a quad. Set the UV values appropriately. UV values are set in the range 0 to 1. So for a 1024x1024 (Or in fact ANY resolution texture which is why it is done this way) image the top left is 0,0 and the bottom right is 1,1. ID3DXSprite will help you here.
  3. Its best to put multiple "frames" in one texture to avoid changing the texture too often (this is expensive).
  4. You could use D3DPT_LINELIST/STRIP ... Failing that use 2 triangles (See ID3DXLine).
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文