Class: Gl::Shader

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

Overview

Needed even if the class isn’t actually used

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from GlInternalMarked

#==, #__mark__, __marked_allocated__, #__unmark__, allocated, clear_all, delete_all, inherited, #marked?

Constructor Details

#initialize(kind, name = nil) ⇒ Shader

Returns a new instance of Shader.



9
10
11
12
13
14
# File 'lib/opengl-core/aux/shader.rb', line 9

def initialize(kind, name = nil)
  super()
  @name = (name != 0 && name) || Gl.glCreateShader(kind)
  @kind = kind
  __mark__
end

Instance Attribute Details

#kindObject (readonly)

Returns the value of attribute kind.



7
8
9
# File 'lib/opengl-core/aux/shader.rb', line 7

def kind
  @kind
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/opengl-core/aux/shader.rb', line 6

def name
  @name
end

Instance Method Details

#compileObject



34
35
36
37
38
# File 'lib/opengl-core/aux/shader.rb', line 34

def compile
  Gl.glCompileShader(@name)
  @compile_status = nil
  compiled?
end

#compiled?Boolean

Returns:

  • (Boolean)


40
41
42
43
# File 'lib/opengl-core/aux/shader.rb', line 40

def compiled?
  @compile_status = (!@compile_status.nil? && @compile_status) ||
    Gl.glGetShader(@name, Gl::GL_COMPILE_STATUS) == GL_TRUE
end

#deleteObject



16
17
18
19
20
21
22
23
# File 'lib/opengl-core/aux/shader.rb', line 16

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

#info_logObject



45
46
47
# File 'lib/opengl-core/aux/shader.rb', line 45

def info_log
  Gl.glGetShaderInfoLog(@name)
end

#sourceObject



30
31
32
# File 'lib/opengl-core/aux/shader.rb', line 30

def source
  Gl.glGetShaderSource(@name)
end

#source=(sources) ⇒ Object



25
26
27
28
# File 'lib/opengl-core/aux/shader.rb', line 25

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