Hi everyone,
I’m new to gwfl I’m using the python bindings (pygwfl) and I only seem to be able put a window title in byte format ?
i.e. glfwSetWindowTitle(window, b’Title’) works
but glfwSetWindowTitle(window, ‘Title’) only gives me the first letter ‘T’ in the title bar…
so in my code I’ve had to use :-
title = WINDOW_TITLE + " %d frames per second" % frameRate
btitle = bytes(title, 'utf-8')
glfwSetWindowTitle(window, btitle)
or more concisely glfwSetWindowTitle(window, str.encode(title))
which works. Any ideas why I can’t just use a string??
Thanks
Thomas Guy
Note that this is really a python question, not a GLFW one, and I’m not an expert in python (neither 2.x nor 3.x), but I’m familiar with both.
This is because the internal representation of strings in python is in Unicode (I think 32bit), see this article on encodings.
You’ll note the 00 after the 50 for the letter P. In C this will be treated as a end of string terminator (the NULL, or 0, terminator), and so you’ll only see the first letter.
Adding the b in front tells python to convert this to byte wise representation, which C will interpret correctly.
1 Like
Thanks that makes sense I’m not familiar with C hence using the python bindings. I have now got a working pyOpengl thanks to glfw from which i can learn GLSL shaders …
