Mercurial > touhou
comparison pytouhou/ui/opengl/shader.pyx @ 604:aca9551ee8b4
Fix compiling issues with Cython 0.20 ; don't pretend to concat shader sources
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Tue, 11 Nov 2014 15:46:31 +0100 |
parents | e15672733c93 |
children | 3c2f96f1d715 |
comparison
equal
deleted
inserted
replaced
603:e9300aae4b24 | 604:aca9551ee8b4 |
---|---|
25 class GLSLException(Exception): | 25 class GLSLException(Exception): |
26 pass | 26 pass |
27 | 27 |
28 | 28 |
29 cdef class Shader: | 29 cdef class Shader: |
30 # vert and frag take arrays of source strings the arrays will be | |
31 # concattenated into one string by OpenGL | |
32 def __init__(self, vert=None, frag=None): | 30 def __init__(self, vert=None, frag=None): |
33 if use_debug_group: | 31 if use_debug_group: |
34 glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "Program creation") | 32 glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "Program creation") |
35 | 33 |
36 # create the program handle | 34 # create the program handle |
40 | 38 |
41 # cache the uniforms location | 39 # cache the uniforms location |
42 self.location_cache = {} | 40 self.location_cache = {} |
43 | 41 |
44 # create the vertex shader | 42 # create the vertex shader |
45 self.create_shader(vert[0].encode(), GL_VERTEX_SHADER) | 43 vert_src = vert.encode() |
44 self.create_shader(vert_src, GL_VERTEX_SHADER) | |
45 | |
46 # create the fragment shader | 46 # create the fragment shader |
47 self.create_shader(frag[0].encode(), GL_FRAGMENT_SHADER) | 47 frag_src = frag.encode() |
48 self.create_shader(frag_src, GL_FRAGMENT_SHADER) | |
48 | 49 |
49 #TODO: put those elsewhere. | 50 #TODO: put those elsewhere. |
50 glBindAttribLocation(self.handle, 0, 'in_position') | 51 glBindAttribLocation(self.handle, 0, 'in_position') |
51 glBindAttribLocation(self.handle, 1, 'in_texcoord') | 52 glBindAttribLocation(self.handle, 1, 'in_texcoord') |
52 glBindAttribLocation(self.handle, 2, 'in_color') | 53 glBindAttribLocation(self.handle, 2, 'in_color') |