各种 DirectX 绘图方法的成本/收益?
我正在使用 C++ 和 DirectX9 开发 2D 游戏,并且已经完成了相当多的工作。截至目前,我对所有内容都使用 sprite.draw :玩家、背景(用 for 循环平铺)、墙壁、HUD 等。然后我开始质疑我是如何绘制的游戏是最好的方式。使用精灵和使用纹理基元之间有主要区别吗?有没有一种方法可以从我自己的函数中单独设置每个像素,这实用吗?如果我以后可以添加照明和 Alpha 混合,那就太好了,如果它不会使程序速度减慢太多,我会自己编写代码。我只想立即把事情搞清楚,确保没有遗漏任何东西。
I'm working on a 2D game using C++ and DirectX9 and I've got a decent amount of it working. As of now I have it using sprite.draw for everything: the player, the backgrounds (tiled with for loops), the walls, the HUD, etc. Then I started questioning if how I was drawing the game was the best way to go. Are there major differences between using sprites and using textured primitives? Is there a way to just set each pixel individually from my own functions, and would that be practical? It'd be nice if I could later add lighting and alpha blending, and I'd be up for coding that myself if it doesn't slow the program down too much. I just want to get things straight right away and make sure there's nothing I'm missing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
精灵绘制很好,它的优点是它可以为您处理所有纹理坐标,并且可能也是硬件加速的。
这是可能的,但不实用。 CPU 无法在每一帧处理如此多的像素,而且其总线也不够宽,无法在每一帧发送所有像素。这就是显卡的用途,它的像素处理速度要快得多,并且到显示器的总线要宽得多。
是可能的,有用于灯光和 alpha 混合的内置函数,您甚至可以自己编写代码(称为着色器)。
Sprite drawing is fine, the advantage of it is that it handles all the texture coordinates for you and probably is also hardware accelerated.
It is possible, but not practical. The cpu cannot process so much pixels at each frame, and neither its buses are wide enough to send all of them every frame. Thats what the graphic card is for, it is much faster with pixel processing and has much wider buses to the display.
It is possible, with built in functions for lights and alpha blending, and you can even code it yourself (its called a shader).