Class: Gl::Program
Instance Attribute Summary collapse
Instance Method Summary
collapse
#==, #__mark__, __marked_allocated__, #__unmark__, allocated, clear_all, delete_all, inherited, #marked?
Constructor Details
#initialize(name = nil) ⇒ Program
Returns a new instance of Program.
11
12
13
14
15
16
17
18
19
|
# File 'lib/opengl-core/aux/program.rb', line 11
def initialize(name = nil)
super()
@name = (name != 0 && name) || Gl.glCreateProgram()
@validate_status = nil
@link_status = nil
@uniform_locations = {}
__mark__
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
9
10
11
|
# File 'lib/opengl-core/aux/program.rb', line 9
def name
@name
end
|
Instance Method Details
41
42
43
44
45
46
|
# File 'lib/opengl-core/aux/program.rb', line 41
def __reload_uniforms__
@uniform_locations.keys.each {
|key|
@uniform_locations[key] = Gl.glGetUniformLocation(@name, key.to_s)
}
end
|
#attach_shader(shader) ⇒ Object
80
81
82
83
84
85
86
|
# File 'lib/opengl-core/aux/program.rb', line 80
def attach_shader(shader)
case shader
when ::Gl::Shader then Gl.glAttachShader(@name, shader.name)
else Gl.glAttachShader(@name, shader)
end
self
end
|
#binary ⇒ Object
28
29
30
|
# File 'lib/opengl-core/aux/program.rb', line 28
def binary
Gl.glGetProgramBinary(@name)
end
|
#bind_attrib_location(attrib_index, attrib_name) ⇒ Object
112
113
114
115
|
# File 'lib/opengl-core/aux/program.rb', line 112
def bind_attrib_location(attrib_index, attrib_name)
Gl.glBindAttribLocation(@name, attrib_index, attrib_name.to_s)
self
end
|
#bind_frag_data_location(color_number, frag_data_name) ⇒ Object
117
118
119
120
|
# File 'lib/opengl-core/aux/program.rb', line 117
def bind_frag_data_location(color_number, frag_data_name)
Gl.glBindFragDataLocation(@name, color_number, frag_data_name.to_s)
self
end
|
#delete ⇒ Object
32
33
34
35
36
37
38
39
|
# File 'lib/opengl-core/aux/program.rb', line 32
def delete
if @name != 0
Gl.glDeleteProgram(@name)
@name = 0
super
end
self
end
|
102
103
104
105
106
|
# File 'lib/opengl-core/aux/program.rb', line 102
def each_hinted_uniform(&block)
return @uniform_locations.each_key unless block_given?
@uniform_locations.each_key(&block)
self
end
|
88
89
90
91
92
|
# File 'lib/opengl-core/aux/program.rb', line 88
def hint_uniform(uniform_name)
uniform_name = uniform_name.to_sym
@uniform_locations[uniform_name] ||= -1
self
end
|
#info_log ⇒ Object
71
72
73
|
# File 'lib/opengl-core/aux/program.rb', line 71
def info_log
Gl.glGetProgramInfoLog(@name)
end
|
#link ⇒ Object
48
49
50
51
52
53
|
# File 'lib/opengl-core/aux/program.rb', line 48
def link
Gl.glLinkProgram(@name)
@link_status = nil
__reload_uniforms__ if (link_successful = linked?)
link_successful
end
|
#linked? ⇒ Boolean
55
56
57
58
|
# File 'lib/opengl-core/aux/program.rb', line 55
def linked?
@link_status = (!@link_status.nil? && @link_status) ||
Gl.glGetProgram(@name, Gl::GL_LINK_STATUS) == GL_TRUE
end
|
#load_binary(binary_format, binary_string) ⇒ Object
21
22
23
24
25
26
|
# File 'lib/opengl-core/aux/program.rb', line 21
def load_binary(binary_format, binary_string)
Gl.glProgramBinary(@name, binary_format, binary_string, binary_string.bytesize)
@link_status = nil
__reload_uniforms__ if (link_successful = linked?)
link_successful
end
|
108
109
110
|
# File 'lib/opengl-core/aux/program.rb', line 108
def subroutine_uniform_location(shader_kind, uniform_name)
Gl.glGetSubroutineUniformLocation(@name, shader_kind, uniform_name)
end
|
Implicitly hints that a uniform exists.
95
96
97
98
99
|
# File 'lib/opengl-core/aux/program.rb', line 95
def uniform_location(uniform_name)
uniform_sym = uniform_name.to_sym
@uniform_locations[uniform_sym] ||=
Gl.glGetUniformLocation(@name, uniform_name.to_s)
end
|
#use ⇒ Object
75
76
77
78
|
# File 'lib/opengl-core/aux/program.rb', line 75
def use
Gl.glUseProgram(@name)
self
end
|
#validate ⇒ Object
60
61
62
63
64
|
# File 'lib/opengl-core/aux/program.rb', line 60
def validate
Gl.glValidateProgram(@name)
@validate_status = nil
valid?
end
|