Class: Rugl::State::Depth

Inherits:
Object
  • Object
show all
Defined in:
lib/rugl/state/depth.rb

Class Method Summary collapse

Class Method Details

.apply(gl:, params:) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rugl/state/depth.rb', line 7

def apply(gl:, params:)
  state = default.merge(params || {})

  if state[:enable]
    Util.gl_call(gl, :Enable, Util.gl_const(:DEPTH_TEST, gl: gl))
  else
    Util.gl_call(gl, :Disable, Util.gl_const(:DEPTH_TEST, gl: gl))
  end

  Util.gl_call(gl, :DepthMask, state[:mask] ? Util.gl_const(:TRUE, gl: gl) : Util.gl_const(:FALSE, gl: gl))
  Util.gl_call(gl, :DepthFunc, Util.to_gl_depth_func(state[:func], gl: gl))
  range = Array(state[:range])
  Util.gl_call(gl, :DepthRange, range[0].to_f, range[1].to_f)
end

.defaultObject



22
23
24
25
26
27
28
29
# File 'lib/rugl/state/depth.rb', line 22

def default
  {
    enable: false,
    mask: true,
    func: :less,
    range: [0.0, 1.0]
  }
end