Class: Rugl::State::Stencil

Inherits:
Object
  • Object
show all
Defined in:
lib/rugl/state/stencil.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
21
22
# File 'lib/rugl/state/stencil.rb', line 7

def apply(gl:, params:)
  state = normalize(params)

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

  Util.gl_call(gl, :StencilMask, state[:mask])

  apply_face_func(gl, :FRONT, state[:func_front])
  apply_face_func(gl, :BACK, state[:func_back])
  apply_face_op(gl, :FRONT, state[:op_front])
  apply_face_op(gl, :BACK, state[:op_back])
end

.defaultObject



24
25
26
27
28
29
30
31
32
33
# File 'lib/rugl/state/stencil.rb', line 24

def default
  {
    enable: false,
    mask: 0xFF,
    func_front: { cmp: :always, ref: 0, mask: 0xFF },
    func_back: { cmp: :always, ref: 0, mask: 0xFF },
    op_front: { fail: :keep, zfail: :keep, zpass: :keep },
    op_back: { fail: :keep, zfail: :keep, zpass: :keep }
  }
end