Mercurial > touhou
comparison pytouhou/ui/opengl/shader.pyx @ 590:e15672733c93
Switch to Python 3.x instead of 2.7.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Tue, 30 Sep 2014 17:14:24 +0200 |
parents | 538b52aafbca |
children | aca9551ee8b4 |
comparison
equal
deleted
inserted
replaced
589:0768122da817 | 590:e15672733c93 |
---|---|
40 | 40 |
41 # cache the uniforms location | 41 # cache the uniforms location |
42 self.location_cache = {} | 42 self.location_cache = {} |
43 | 43 |
44 # create the vertex shader | 44 # create the vertex shader |
45 self.create_shader(vert[0], GL_VERTEX_SHADER) | 45 self.create_shader(vert[0].encode(), GL_VERTEX_SHADER) |
46 # create the fragment shader | 46 # create the fragment shader |
47 self.create_shader(frag[0], GL_FRAGMENT_SHADER) | 47 self.create_shader(frag[0].encode(), GL_FRAGMENT_SHADER) |
48 | 48 |
49 #TODO: put those elsewhere. | 49 #TODO: put those elsewhere. |
50 glBindAttribLocation(self.handle, 0, 'in_position') | 50 glBindAttribLocation(self.handle, 0, 'in_position') |
51 glBindAttribLocation(self.handle, 1, 'in_texcoord') | 51 glBindAttribLocation(self.handle, 1, 'in_texcoord') |
52 glBindAttribLocation(self.handle, 2, 'in_color') | 52 glBindAttribLocation(self.handle, 2, 'in_color') |
114 else: | 114 else: |
115 # all is well, so we are linked | 115 # all is well, so we are linked |
116 self.linked = True | 116 self.linked = True |
117 | 117 |
118 cdef GLint get_uniform_location(self, name): | 118 cdef GLint get_uniform_location(self, name): |
119 if isinstance(name, str): | |
120 name = name.encode() | |
119 if name not in self.location_cache: | 121 if name not in self.location_cache: |
120 loc = glGetUniformLocation(self.handle, name) | 122 loc = glGetUniformLocation(self.handle, name) |
121 if loc == -1: | 123 if loc == -1: |
122 raise GLSLException('Undefined {} uniform.'.format(name)) | 124 raise GLSLException('Undefined {} uniform.'.format(name)) |
123 self.location_cache[name] = loc | 125 self.location_cache[name] = loc |