简体   繁体   English

C ++ D3DX字体和转换(需要d3d9和d3d10解决方案)

[英]C++ D3DX Font and transformations (d3d9 and d3d10 solutions needed)

I want to render font in a way that takes account of the current transforms and similar settings, especially the projection transform and viewport. 我想以一种考虑当前变换和类似设置的方式来呈现字体,尤其是投影变换和视口。

I'm thinking that the best way to do that is to have an off screen surface to render the text to, and then render that surface where I really want the text. 我在想,最好的方法是在屏幕外的表面上渲染文本,然后在我真正想要的文本上渲染该表面。

However I'm not certain on a number of aspects of this solution. 但是,我不确定此解决方案的许多方面。

  • Is this the best way to go about it at all? 这是最好的解决办法吗?

  • Are there far better free font renderers around that id be better off spending my time with that allow such things. 是否有更好的围绕该id的免费字体渲染器,最好花些时间允许这些事情。 I see alot of people complaining about the d3dx font interfaces for various reasons, but never a link to a better unicode capable renderer...? 我看到很多人出于各种原因抱怨d3dx字体接口,但是从来没有链接到更好的unicode渲染器...?

  • Is there any advantage to useing certain surface formats and/or surface sizes (eg always using the smallest possible rather than some standard large one, which requires the extra step of trying to work the size out...) 使用某些表面格式和/或表面尺寸是否有任何优势(例如,始终使用尽可能小的尺寸而不是某些标准的大尺寸,这需要额外的步骤来尝试确定尺寸...)

Yeah, render to texture and then drawing a textured quad to orient and position the text is going to be the easiest way to realize this functionality. 是的,先渲染纹理,然后绘制纹理四边形以定向和定位文本,这将是实现此功能的最简单方法。

As for D3DX text renderers, it really depends on which SDK you are using. 对于D3DX文本渲染器,这实际上取决于您使用的SDK。 DirectWrite (only for Windows 7 and Vista) will provide a higher quality text rendering approach for applications that need high quality text rendering in a manner that is interoperable with Direct3D. DirectWrite(仅适用于Windows 7和Vista)将为需要以与Direct3D互操作的方式进行高质量文本呈现的应用程序提供更高质量的文本呈现方法。

You can of course do your own rasterization. 您当然可以自己进行栅格化。 There are font rasterization engines out there that are open source that could be repurposed for this need, but we're talking tons of coding here for a benefit that may not be distinguishable enough to warrant the development expense. 那里有一些字体栅格化引擎,它们是开源的,可以根据需要进行重新利用,但是我们在这里谈论的是大量的编码,其好处可能不足以区分开发费用。

Having said that, there's a completely new alternative available to you with Direct3D and shaders, provided that you have access to the glyph outlines as curve data. 话虽如此,如果您可以访问字形轮廓作为曲线数据,则Direct3D和着色器可以为您提供一种全新的选择。 The idea is to use the shader to rasterize the text and store the curve definitions in the vertex stream and associated textures. 想法是使用着色器光栅化文本并将曲线定义存储在顶点流和关联的纹理中。 Try looking at this paper , which describes the technique. 试着看一下本文 ,其中描述了该技术。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM