Qt 4.6.3 中 QGLWidget 上的 3D 文本

发布于 2024-09-14 18:33:53 字数 389 浏览 0 评论 0原文

我正在寻找一种在 QGLWidget 上绘制 3D 文本的简单方法,不使用 FTGL、FreeType、“渲染到纹理”或帧缓冲区对象,即仅使用记录的 Qt 4 函数,无需其他库。

有想法吗?

PS“3D 文本”是指字母是平面的且厚度为零,但可以在 3D 空间中旋转。想想“星球大战开场爬行” - 位于 3D 空间中的平面字母。另外,我已经知道我可以编写文本渲染类,将字形渲染到纹理等上。我正在寻找一种简单的方法来使用标准 Qt 4 函数执行相同的操作。例如,QPainter 可能可以在内部访问所有必需的数据。

I'm looking for a simple way to draw 3D text on QGLWidget without using FTGL, FreeType, "render to texture" or framebuffer objects, i.e. using documented Qt 4 functions only, no additional libraries.

Ideas?

P.S. "3D text" means that letters are flat and have zero thickness, but can be rotated in 3D space. Think about "Star wars opening crawl" - flat letters positioned in 3D space. ALso, I already to know that I can write my text rendering class that would render glyphs onto texture, etc. I'm looking for simple a way to do the same thing using standard Qt 4 functions. For example, QPainter probably have access to all required data internally.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

债姬 2024-09-21 18:33:53

发现了一些东西。

picture

QPainterPath path;
glDisable(GL_LIGHTING);
QFont font("Arial", 40);
path.addText(QPointF(0, 0), QFont("Arial", 40), QString(tr("This is a test")));
QList<QPolygonF> poly = path.toSubpathPolygons();
for (QList<QPolygonF>::iterator i = poly.begin(); i != poly.end(); i++){
    glBegin(GL_LINE_LOOP);
    for (QPolygonF::iterator p = (*i).begin(); p != i->end(); p++)
        glVertex3f(p->rx()*0.1f, -p->ry()*0.1f, 0);
    glEnd();
}
glEnable(GL_LIGHTING);

但看起来我仍然需要一个 2D 三角仪。
--编辑--

到目前为止,我还没有找到仅使用 Qt 渲染 3D 文本的其他方法,并且库中没有三角测量例程。我假设 Qt 中尚未实现此功能。

Found something.

picture

QPainterPath path;
glDisable(GL_LIGHTING);
QFont font("Arial", 40);
path.addText(QPointF(0, 0), QFont("Arial", 40), QString(tr("This is a test")));
QList<QPolygonF> poly = path.toSubpathPolygons();
for (QList<QPolygonF>::iterator i = poly.begin(); i != poly.end(); i++){
    glBegin(GL_LINE_LOOP);
    for (QPolygonF::iterator p = (*i).begin(); p != i->end(); p++)
        glVertex3f(p->rx()*0.1f, -p->ry()*0.1f, 0);
    glEnd();
}
glEnable(GL_LIGHTING);

But it looks like I'll still need a 2D triangulator.
--EDIT--

So far I have found no other way to render 3D text using Qt only, and no triangulation routines in library. I'm assuming that this functionality isn't implemented in Qt yet.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文