自批:读者注意,以下都是肤浅之谈,诚不足作为参考。

继续沿袭大片贴源码风格,发一个Managed Direct3D的典型2D渲染实例: ) 采用了Sprite+Texture方式,速度其实也不算慢,代码也还算简洁可靠(除了控制Device Lost异常比较烦琐以外),尤其是在窗口模式下,要考虑的底层细节比DirectDraw要少得多,什么裁剪区域、页切换链等等,如果不想去碰它们,均可交给Direct3D自动管理,当然,如果需要的话也可以自行设置。

不爽的地方在于Direct3D对硬件要求起点比DirectDraw要高,实际2D绘制效率比起DirectDraw还是要慢不少;此外,Direct3D中以纹理绘制方式实现2D渲染决定了其局限性:纹理的形状必须是正方形的,则制作2D Sprite时也不得不将其制作成正方形的,这很不自然;更令人郁闷的是,纹理的象素尺寸必须是2的整数幂,否则在渲染时其尺寸将会被拉伸导致图像模糊、变形;上述两点要求对于传统的2D场景渲染而言都可以说是一些非常不合理的约束,不过我想至今还没有哪款2D Game是纯粹地用Direct3D来做的吧,呵呵,下面这个实例就当见识一下M$向我们所推荐的“未来”的2D渲染编程方式吧。

结论:对于2D的我还是喜欢用DirectDraw — Speed Rules!

Concise Sample of Managed Direct3D for 2D Rendering (9.0c)//#define FULL_SCREEN
Concise Sample of Managed Direct3D for 2D Rendering (9.0c)

Concise Sample of Managed Direct3D for 2D Rendering (9.0c)
using System;
Concise Sample of Managed Direct3D for 2D Rendering (9.0c)
using System.Drawing;
Concise Sample of Managed Direct3D for 2D Rendering (9.0c)
using System.Collections;
Concise Sample of Managed Direct3D for 2D Rendering (9.0c)
using System.ComponentModel;
Concise Sample of Managed Direct3D for 2D Rendering (9.0c)
using System.Windows.Forms;
Concise Sample of Managed Direct3D for 2D Rendering (9.0c)
using System.Data;
Concise Sample of Managed Direct3D for 2D Rendering (9.0c)
using System.Threading;
Concise Sample of Managed Direct3D for 2D Rendering (9.0c)
Concise Sample of Managed Direct3D for 2D Rendering (9.0c)
using Microsoft.DirectX;
Concise Sample of Managed Direct3D for 2D Rendering (9.0c)
using Microsoft.DirectX.Direct3D;
Concise Sample of Managed Direct3D for 2D Rendering (9.0c)
Concise Sample of Managed Direct3D for 2D Rendering (9.0c)
namespace MDirect3D
}

相关文章:

  • 2021-09-13
  • 2022-12-23
  • 2021-12-07
  • 2021-08-27
  • 2022-12-23
  • 2021-06-19
  • 2022-02-08
  • 2021-12-16
猜你喜欢
  • 2021-09-05
  • 2022-12-23
  • 2022-12-23
  • 2021-08-31
  • 2021-07-09
  • 2021-12-22
  • 2021-07-30
相关资源
相似解决方案