1 """Shader classes.
2
3 @author: Stephan Wenger
4 @date: 2012-02-29
5 """
6
7 import glitter.raw as _gl
8 from glitter.utils import ManagedObject, ShaderCompileError
11 _generate_id = _gl.glCreateShader
12 _delete_id = _gl.glDeleteShader
13 _db = "shaders"
14
15 - def __init__(self, source=None, compile=None, context=None):
25
36
37 @property
39 with self._context:
40 _info_log_length = _gl.GLint()
41 _gl.glGetShaderiv(self._id, _gl.GL_INFO_LOG_LENGTH, _gl.pointer(_info_log_length))
42 _info_log = _gl.create_string_buffer(_info_log_length.value)
43 _gl.glGetShaderInfoLog(self._id, _info_log_length, _gl.POINTER(_gl.GLint)(), _info_log)
44 return _info_log.value
45
46 @property
48 with self._context:
49 _shader_source_length = _gl.GLint()
50 _gl.glGetShaderiv(self._id, _gl.GL_SHADER_SOURCE_LENGTH, _gl.pointer(_shader_source_length))
51 _source = _gl.create_string_buffer(_shader_source_length.value)
52 _gl.glGetShaderSource(self._id, _shader_source_length, _gl.POINTER(_gl.GLint)(), _source)
53 return _source.value
54
55 @source.setter
59
61 """Vertes shader.
62
63 @todo: wrap C{glGetShaderPrecisionFormat}.
64 """
65
66 _type = _gl.GL_VERTEX_SHADER
67
70
73
76
78 """Fragment shader.
79
80 @todo: wrap C{glGetShaderPrecisionFormat}.
81 """
82
83 _type = _gl.GL_FRAGMENT_SHADER
84
85 __all__ = [
86 "Shader",
87 "VertexShader",
88 "TesselationControlShader",
89 "TesselationEvaluationShader",
90 "GeometryShader",
91 "FragmentShader",
92 ]
93