Class: Hate::Graphics::Shader::Base
- Inherits:
-
Object
- Object
- Hate::Graphics::Shader::Base
- Defined in:
- lib/hate/graphics/shader.rb
Instance Attribute Summary collapse
-
#shader ⇒ Object
readonly
Returns the value of attribute shader.
Instance Method Summary collapse
-
#initialize(file) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(file) ⇒ Base
Returns a new instance of Base.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/hate/graphics/shader.rb', line 31 def initialize(file) source = [] source << MemoryPointer.from_string(File.open(file).read) arg = MemoryPointer.new(:pointer, source.length) source.each_with_index do |p, i| arg[i].put_pointer(0, p) end if self.class == Hate::Graphics::Shader::Vertex @shader = glCreateShader(GL_VERTEX_SHADER) elsif self.class == Hate::Graphics::Shader::Fragment @shader = glCreateShader(GL_FRAGMENT_SHADER) end glShaderSource(@shader, source.size, arg, nil) glCompileShader(@shader) end |
Instance Attribute Details
#shader ⇒ Object (readonly)
Returns the value of attribute shader.
29 30 31 |
# File 'lib/hate/graphics/shader.rb', line 29 def shader @shader end |