Code is here.
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
import sys
def initial():
glClearColor(1.0, 1.0, 1.0, 1.0)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluOrtho2D(-10.0, 10.0, -10.0, 10.0)
def Display():
glClear(GL_COLOR_BUFFER_BIT)
glColor3f(1.0, 0.0, 0.0)
glViewport(0, 0, 200, 200)
glColor3f(0.0, 0.0, 1.0)
glViewport(200, 0, 200, 200)
glFlush()
def main():
glutInit(sys.argv)
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)
glutInitWindowPosition(100, 100)
glutInitWindowSize(400, 200)
glutCreateWindow("一二三四")
initial()
glutDisplayFunc(Display)
glutMainLoop()
if __name__ == "__main__":
main()
The title is "一二三四", but it turns out to be
I don't want to change from UTF-8 to GBK, so is there any way to solve it?
As far as I know, glfw can support Chinese. But I am not familiar with it.
My Python version is 3.7.0 32-bit
After some test, I find the solution:
Just need to change
glutCreateWindow("一二三四")
to
glutCreateWindow("一二三四".encode("gb2312"))