Class: Mittsu::OpenGLShader

Inherits:
Object
  • Object
show all
Defined in:
lib/mittsu/renderers/opengl/opengl_shader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, string) ⇒ OpenGLShader

Returns a new instance of OpenGLShader.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/mittsu/renderers/opengl/opengl_shader.rb', line 7

def initialize(type, string)
  @shader = glCreateShader(type)
  # filename = type == GL_VERTEX_SHADER ? 'vertex.glsl' : 'fragment.glsl'
  # File.write filename, string

  string_pointer = Fiddle::Pointer[string]
  string_length = Fiddle::Pointer[string.length]

  glShaderSource(@shader, 1, string_pointer.ref, string_length.ref)
  glCompileShader(@shader)

  if !compile_status
    puts "ERROR: Mittsu::OpenGLShader: Shader couldn't compile"
  end

  log_info = shader_info_log
  if !log_info.empty?
    puts "WARNING: Mittsu::OpenGLShader: glGetShaderInfoLog, #{log_info}"
    puts add_line_numbers(string)
  end
end

Instance Attribute Details

#shaderObject (readonly)

Returns the value of attribute shader.



5
6
7
# File 'lib/mittsu/renderers/opengl/opengl_shader.rb', line 5

def shader
  @shader
end