From fb58787f6e7d99105b68a71bc9c6026fb77ec8b4 Mon Sep 17 00:00:00 2001 From: "Mike C. Fletcher" Date: Thu, 11 Jul 2013 00:30:25 -0400 Subject: [PATCH] Allow for passing unicode strings to GLUT functions which expect bytes --- OpenGL/raw/GLUT/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/OpenGL/raw/GLUT/__init__.py b/OpenGL/raw/GLUT/__init__.py index ca3344ab..47831f0c 100644 --- a/OpenGL/raw/GLUT/__init__.py +++ b/OpenGL/raw/GLUT/__init__.py @@ -6,6 +6,7 @@ from OpenGL.raw.GLUT.constants import * from ctypes import * +from OpenGL._bytes import unicode from OpenGL import platform, arrays from OpenGL.constant import Constant from OpenGL import constants as GLconstants @@ -17,7 +18,12 @@ else: CALLBACK_FUNCTION_TYPE = platform.PLATFORM.functionTypeFor( platform.GLUT ) -STRING = c_char_p +class STRING( c_char_p ): + @classmethod + def from_param( cls, value ): + if isinstance( value, unicode ): + value = value.encode( 'utf-8' ) + return super( STRING, cls ).from_param( value ) from OpenGL.constants import GLenum from OpenGL.constants import GLfloat from OpenGL.constants import GLdouble