def link(self): LinkProgram(self._object) _check_errors() self._attribs = ProgramAttributes(self) self._uniforms = ProgramUniforms(self) return self.link_status
def image(self, image): with PreserveTextureBinding(self): self._bind() _check_errors() self._image = image self._image.submit(self._binding) _check_errors()
def __init__(self): self._texture = _gen_texture() _check_errors() self._unit = None self._image = None self.filter = Filter(self) self.wrap = WrapMode(self)
def __set__(self, instance, value): texture = self._get_texture(instance) with PreserveTextureBinding(texture) as binding: binding.state = texture._texture #FIXME: binding.state ? clean enough? TexParameter(texture._binding, self._parameter, value.value) #FIXME: what if it's not a GLenum? _check_errors()
def sources(self, sources): #FIXME: looking at that for a second time, that is UGLY c_str_array = (c_str * len(sources))(*[ c_str(''.join(source)) if hasattr(source, 'read') else c_str(source ) for source in sources ]) ShaderSource(self._object, len(sources), c_str_array, cast(NULL, POINTER(GLuint))) _check_errors()
def sources(self, sources): #FIXME: looking at that for a second time, that is UGLY c_str_array = (c_str * len(sources))(*[ c_str(''.join(source)) if hasattr(source, 'read') else c_str(source) for source in sources ]) ShaderSource(self._object, len(sources), c_str_array, cast(NULL, POINTER(GLuint)) ) _check_errors()
def compile(self): CompileShader(self._object) _check_errors() return self.compile_status
def use(self): UseProgram(self._object) _check_errors()
def _set_unit(self): ActiveTexture(self.unit) _check_errors()
def _get_integer(flag): value = GLint(0) GetInteger(flag, value) _check_errors() return value.value
def enable(self): self._set_unit() _check_errors() Enable(self._binding) _check_errors() #FIXME: check after everything?
def disable(self): self._set_unit() _check_errors() Disable(self._binding) _check_errors()
def __get__(self, instance, owner): texture = GLint(0) #FIXME: textures are GLuints... but GetInteger is integers only GetInteger(_query_from_binding(self._get_binding(instance)), texture) _check_errors() return texture.value
def append(self, shader): self._shaders.append(shader) AttachShader(self._program._object, shader._object) _check_errors()
def __get__(self, instance, owner): texture = GLint( 0) #FIXME: textures are GLuints... but GetInteger is integers only GetInteger(_query_from_binding(self._get_binding(instance)), texture) _check_errors() return texture.value
def __set__(self, instance, value): BindTexture(self._get_binding(instance), value) _check_errors()
def remove(self, shader): DetachShader(self._program._object, shader._object) _check_errors()