DirectX:如何将纹理渲染到屏幕 (DirectX10.1)
我在寻找如何将屏幕外纹理渲染到 屏幕。
谁能帮我指出正确的方向?
谢谢
I'm having some troubles finding out how i can render an offscreen texture to the
screen.
Can anyone help me with pointing me in the right direction?
Thx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基本上,您渲染一个屏幕大小的矩形,将渲染的离屏纹理设置为纹理。
现在,了解一些细节:
最好预先生成所需的顶点缓冲区。您需要一个位置分量(X、Y、Z,尽管从技术上讲您不需要 Z)和 UV 分量。我建议制作其中之一供整个程序使用,左上角位置为 0, 0, 0,UV 0, 0,右下角位置为 1, 1, 0,UV 1, 1。然后,渲染你的纹理,设置纹理(就像任何其他纹理一样),设置矩阵以将其缩放到您想要的任何位置,然后使用该顶点缓冲区发送绘制调用。
Basically, you render a rectangle the size of the screen, setting as the texture the off-screen texture you rendered.
Now, for some details:
It's probably best to just generate your desired vertex buffer beforehand. You'll want a position component (X, Y, Z, though you technically don't need Z), and a UV component. I recommend making one of these for use by the entire program, with upper left corner being position 0, 0, 0 with UV 0, 0 and the bottom right being 1, 1, 0 with UV 1, 1. Then, to render your texture, set your texture (as you would any other texture), set your matrix/matrices to scale that to whereever you want it, and send off a drawcall with that vertex buffer.