Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python OpenGL utf-8字符串渲染_Python_Opengl_Utf 8_Pyopengl - Fatal编程技术网

Python OpenGL utf-8字符串渲染

Python OpenGL utf-8字符串渲染,python,opengl,utf-8,pyopengl,Python,Opengl,Utf 8,Pyopengl,是否有一个python模块可以在OpenGL中显示UTF-8字符串 我找到了pyFTGL,但当我运行以下代码时: glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, [1, 1, 1, 1]) font = FTGL.PolygonFont("NeoTechStd-Medium.ttf") font.FaceSize(8) font.line_height font.Render("Angle = ? \u03C4

是否有一个python模块可以在OpenGL中显示UTF-8字符串

我找到了pyFTGL,但当我运行以下代码时:

    glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, [1, 1, 1, 1])
    font = FTGL.PolygonFont("NeoTechStd-Medium.ttf")
    font.FaceSize(8)
    font.line_height
    font.Render("Angle = ? \u03C4")
我得到这个错误:

    font.Render(u"Weld Head Angle = ? \u03C4")
Boost.Python.ArgumentError: Python argument types in
    PolygonFont.Render(PolygonFont, unicode)
did not match C++ signature:
    Render(FontWrapper<FTPolygonFont> {lvalue}, char const*, double)
    Render(FontWrapper<FTPolygonFont> {lvalue}, char const*)
DEBUG:Helpers.opengl_pipe:Redrawing contents of GLArea.
font.Render(u“焊接头角度=?\u03C4”)
ArgumentError:中的Python参数类型
Render(PolygonFont,unicode)
与C++签名不匹配:
呈现(FontWrapper{lvalue},char const*,double)
Render(FontWrapper{lvalue},char const*)
调试:Helpers.opengl_管道:重绘GLArea的内容。

您没有传递渲染方法UTF-8;您正在传递一个unicode文本

您需要将其编码为UTF-8:

font.Render("Angle = ? \u03C4".encode('utf8'))
我可以衷心地建议您阅读,以帮助理解其中的差异