From dfa2c8a502c93d464238b58aa3feb24582212ab3 Mon Sep 17 00:00:00 2001
From: Guillaume Poulin <poulin.guillaume@gmail.com>
Date: Thu, 5 Sep 2013 04:37:41 +0800
Subject: [PATCH] solve some issue with opengl and python3

---
 pyqtgraph/opengl/shaders.py | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/pyqtgraph/opengl/shaders.py b/pyqtgraph/opengl/shaders.py
index 515de33a..8f0d6e1b 100644
--- a/pyqtgraph/opengl/shaders.py
+++ b/pyqtgraph/opengl/shaders.py
@@ -1,4 +1,7 @@
-import OpenGL
+try:
+    from OpenGL import NullFunctionError
+except ImportError:
+    from OpenGL.error import NullFunctionError
 from OpenGL.GL import *
 from OpenGL.GL import shaders
 import re
@@ -219,7 +222,7 @@ class Shader(object):
         if self.compiled is None:
             try:
                 self.compiled = shaders.compileShader(self.code, self.shaderType)
-            except OpenGL.NullFunctionError:
+            except NullFunctionError:
                 raise Exception("This OpenGL implementation does not support shader programs; many features on pyqtgraph will not work.")
             except RuntimeError as exc:
                 ## Format compile errors a bit more nicely
@@ -227,9 +230,12 @@ class Shader(object):
                     err, code, typ = exc.args
                     if not err.startswith('Shader compile failure'):
                         raise
-                    code = code[0].split('\n')
+                    code = code[0].decode('utf_8').split('\n')
                     err, c, msgs = err.partition(':')
                     err = err + '\n'
+                    msgs = re.sub('b\'','',msgs)
+                    msgs = re.sub('\'$','',msgs)
+                    msgs = re.sub('\\\\n','\n',msgs)
                     msgs = msgs.split('\n')
                     errNums = [()] * len(code)
                     for i, msg in enumerate(msgs):
@@ -357,7 +363,7 @@ class ShaderProgram(object):
         
     def uniform(self, name):
         """Return the location integer for a uniform variable in this program"""
-        return glGetUniformLocation(self.program(), bytes(name,'utf_8'))
+        return glGetUniformLocation(self.program(), name.encode('utf_8'))
 
     #def uniformBlockInfo(self, blockName):
         #blockIndex = glGetUniformBlockIndex(self.program(), blockName)
-- 
GitLab