使用模板缓冲区绘制文本(Draw Text with stencil buffer)

编程入门 行业动态 更新时间:2024-10-25 16:24:49
使用模板缓冲区绘制文本(Draw Text with stencil buffer)

我设置了模板缓冲区,因此只有部分屏幕受到绘制调用的影响。 具体来说,我想画一个小区域。 它将成为一个UI,所以绘制的所有内容都将是某种2D精灵。 使用sprite对象非常有效。 该区域外的精灵被切断。 但是,当我添加文本时,之后绘制的所有内容和文本本身都不会被截断。 PIX显示一旦调用绘制文本,就会在关闭模板缓冲区的情况下设置新的DepthStencilState。 该文本由相同的sprite对象绘制,该对象负责绘制其他sprite。

绘图通过SlimDX.Direct3D10.Font.Draw方法执行。

有没有办法强制DirectX不更改状态对象? 我使用SlimDX,但根据它的代码,它似乎不对状态变化负责。

尼科

I set up the stencil buffer so only parts of the screen are affected by draw calls. Specifically, I want to draw into a small area. It will become an UI, so everything drawn will be some kind of 2D sprite. Using the sprite object works very well. Sprites that are outside of the area are cut off. However, when I add text, everything drawn afterwards and the text itself is not cut off. PIX shows that a new DepthStencilState is set with the stencil buffer turned off as soon as draw text is called. The text is drawn by the same sprite object which is responsible for drawing other sprites.

The drawing is performed through the SlimDX.Direct3D10.Font.Draw method.

Is there a way to force DirectX not to change the state object? I use SlimDX, but according to its code it does not seem to be responsible for the state change.

Nico

最满意答案

如果你要切换到D3D11,你可能会对我一直在移植到SlimDX的字体渲染库感兴趣(以及过去几个月发布的DirectX工具包库中的其他一些部分)。

它仍处于开发阶段,因此无法保证任何内容,但您可以在此处找到它(SVN): http : //code.google.com/p/slimdx/source/browse/#svn%2Fbranches%2Flite%2FSlimDX.Toolkit

If you're switching to D3D11, you might be interested in a font rendering library I've been working on porting to SlimDX (along with some other bits from the DirectX toolkit libraries that have been released over the past few months).

It's still in development, so no guarantees about anything, but you can find it here (SVN): http://code.google.com/p/slimdx/source/browse/#svn%2Fbranches%2Flite%2FSlimDX.Toolkit

更多推荐

本文发布于:2023-08-04 09:05:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1412456.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:缓冲区   文本   模板   Draw   stencil

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!