Exception: GL::GLStateError

Inherits:
GLError
  • Object
show all
Defined in:
lib/opengl-aux/error.rb

Overview

State error raised for errors returned by glGetError.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, msg = nil) ⇒ GLStateError


28
29
30
31
# File 'lib/opengl-aux/error.rb', line 28

def initialize(code, msg = nil)
  @code = code
  super(msg)
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code


22
23
24
# File 'lib/opengl-aux/error.rb', line 22

def code
  @code
end

Class Method Details

.exception(msg = nil, code = GL::GL_NO_ERROR) ⇒ Object


24
25
26
# File 'lib/opengl-aux/error.rb', line 24

def self.exception(msg = nil, code = GL::GL_NO_ERROR)
  new(code, msg)
end

Instance Method Details

#exception(msg = nil) ⇒ Object


33
34
35
36
37
38
39
# File 'lib/opengl-aux/error.rb', line 33

def exception(msg = nil)
  if msg
    self.class.exception(msg, code)
  else
    self
  end
end

#to_sObject


41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/opengl-aux/error.rb', line 41

def to_s
  code_str =
    case self.code
    when GL::GL_NO_ERROR                      then 'NO_ERROR'
    when GL::GL_INVALID_ENUM                  then 'INVALID_ENUM'
    when GL::GL_INVALID_VALUE                 then 'INVALID_VALUE'
    when GL::GL_INVALID_OPERATION             then 'INVALID_OPERATION'
    when GL::GL_INVALID_FRAMEBUFFER_OPERATION then 'INVALID_FRAMEBUFFER_OPERATION'
    when GL::GL_OUT_OF_MEMORY                 then 'OUT_OF_MEMORY'
    when GL::GL_STACK_UNDERFLOW               then 'STACK_UNDERFLOW'
    when GL::GL_STACK_OVERFLOW                then 'STACK_OVERFLOW'
    end
  "#{code_str}: #{super}"
end