Mercurial > touhou
comparison pytouhou/ui/opengl/shader.pyx @ 617:a6af3ff86612
Change all “void except *” function into “bint except True”, to prevent PyErr_Occurred() from being called at each call.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sun, 29 Mar 2015 00:08:20 +0100 |
parents | 3c2f96f1d715 |
children |
comparison
equal
deleted
inserted
replaced
616:4ce3ef053a25 | 617:a6af3ff86612 |
---|---|
56 self.link() | 56 self.link() |
57 | 57 |
58 if use_debug_group: | 58 if use_debug_group: |
59 glPopDebugGroup() | 59 glPopDebugGroup() |
60 | 60 |
61 cdef void create_shader(self, const GLchar *string, GLenum_shader shader_type) except *: | 61 cdef bint create_shader(self, const GLchar *string, GLenum_shader shader_type) except True: |
62 cdef GLint temp | 62 cdef GLint temp |
63 cdef const GLchar *strings[2] | 63 cdef const GLchar *strings[2] |
64 strings[:] = [shader_header, string] | 64 strings[:] = [shader_header, string] |
65 | 65 |
66 # create the shader handle | 66 # create the shader handle |
89 raise GLSLException(buf) | 89 raise GLSLException(buf) |
90 else: | 90 else: |
91 # all is well, so attach the shader to the program | 91 # all is well, so attach the shader to the program |
92 glAttachShader(self.handle, shader) | 92 glAttachShader(self.handle, shader) |
93 | 93 |
94 cdef void link(self) except *: | 94 cdef bint link(self) except True: |
95 cdef GLint temp | 95 cdef GLint temp |
96 | 96 |
97 # link the program | 97 # link the program |
98 glLinkProgram(self.handle) | 98 glLinkProgram(self.handle) |
99 | 99 |
130 # bind the program | 130 # bind the program |
131 glUseProgram(self.handle) | 131 glUseProgram(self.handle) |
132 | 132 |
133 # upload a floating point uniform | 133 # upload a floating point uniform |
134 # this program must be currently bound | 134 # this program must be currently bound |
135 cdef void uniform_1(self, name, GLfloat val) except *: | 135 cdef bint uniform_1(self, name, GLfloat val) except True: |
136 glUniform1fv(self.get_uniform_location(name), 1, &val) | 136 glUniform1fv(self.get_uniform_location(name), 1, &val) |
137 | 137 |
138 # upload a vec4 uniform | 138 # upload a vec4 uniform |
139 cdef void uniform_4(self, name, GLfloat a, GLfloat b, GLfloat c, GLfloat d) except *: | 139 cdef bint uniform_4(self, name, GLfloat a, GLfloat b, GLfloat c, GLfloat d) except True: |
140 cdef GLfloat vals[4] | 140 cdef GLfloat vals[4] |
141 vals[0] = a | 141 vals[0] = a |
142 vals[1] = b | 142 vals[1] = b |
143 vals[2] = c | 143 vals[2] = c |
144 vals[3] = d | 144 vals[3] = d |
145 glUniform4fv(self.get_uniform_location(name), 1, vals) | 145 glUniform4fv(self.get_uniform_location(name), 1, vals) |
146 | 146 |
147 # upload a uniform matrix | 147 # upload a uniform matrix |
148 # works with matrices stored as lists, | 148 # works with matrices stored as lists, |
149 # as well as euclid matrices | 149 # as well as euclid matrices |
150 cdef void uniform_matrix(self, name, Matrix *mat) except *: | 150 cdef bint uniform_matrix(self, name, Matrix *mat) except True: |
151 # obtain the uniform location | 151 # obtain the uniform location |
152 loc = self.get_uniform_location(name) | 152 loc = self.get_uniform_location(name) |
153 # uplaod the 4x4 floating point matrix | 153 # uplaod the 4x4 floating point matrix |
154 glUniformMatrix4fv(loc, 1, False, <GLfloat*>mat) | 154 glUniformMatrix4fv(loc, 1, False, <GLfloat*>mat) |