Class: GL::Shader

Inherits:
Object
  • Object
show all
Defined in:
lib/opengl-aux/program.rb,
lib/opengl-aux/shader.rb

Overview

Declare it just for type checking

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(kind, name = nil) {|_self| ... } ⇒ Shader

Returns a new instance of Shader.

Yields:

  • (_self)

Yield Parameters:

  • _self (GL::Shader)

    the object that the method was called on


18
19
20
21
22
23
24
25
26
27
28
# File 'lib/opengl-aux/shader.rb', line 18

def initialize(kind, name = nil)
  if name
    @name = name
  else
    @name = GL.glCreateShader(kind)
    raise GL::GLCreateError, "Unable to allocate shader" if @name == 0
  end

  @kind = kind
  yield self if block_given?
end

Instance Attribute Details

#kindObject (readonly)

Returns the value of attribute kind


16
17
18
# File 'lib/opengl-aux/shader.rb', line 16

def kind
  @kind
end

#nameObject (readonly)

Returns the value of attribute name


15
16
17
# File 'lib/opengl-aux/shader.rb', line 15

def name
  @name
end

Instance Method Details

#compileObject


51
52
53
54
# File 'lib/opengl-aux/shader.rb', line 51

def compile
  GL.glCompileShader(@name)
  compiled?
end

#compiled?Boolean

Returns:

  • (Boolean)

56
57
58
# File 'lib/opengl-aux/shader.rb', line 56

def compiled?
  GL.glGetShader(@name, GL::GL_COMPILE_STATUS) != GL::GL_FALSE
end

#deleteObject


30
31
32
33
34
35
36
# File 'lib/opengl-aux/shader.rb', line 30

def delete
  if @name != 0
    GL.glDeleteShader(@name)
    @name = 0
  end
  self
end

#info_logObject


60
61
62
# File 'lib/opengl-aux/shader.rb', line 60

def info_log
  GL.glGetShaderInfoLog(@name)
end

#is_shader?Boolean

Returns:

  • (Boolean)

38
39
40
# File 'lib/opengl-aux/shader.rb', line 38

def is_shader?
  GL::glIsShader(@name) != GL::GL_FALSE
end

#sourceObject


47
48
49
# File 'lib/opengl-aux/shader.rb', line 47

def source
  GL.glGetShaderSource(@name)
end

#source=(sources) ⇒ Object


42
43
44
45
# File 'lib/opengl-aux/shader.rb', line 42

def source=(sources)
  GL.glShaderSource(@name, sources)
  sources
end