Class: Budgie::CheckerTexture

Inherits:
Object
  • Object
show all
Includes:
GL
Defined in:
lib/budgie/checker_texture.rb

Instance Method Summary collapse

Constructor Details

#initializeCheckerTexture

Returns a new instance of CheckerTexture.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/budgie/checker_texture.rb', line 6

def initialize
  @id = (glGenTextures 1).first
  bind

  data = [
    [0xee, 0xee, 0xee], [0xee, 0xee, 0xee], [0xff, 0xff, 0xff], [0xff, 0xff, 0xff],
    [0xee, 0xee, 0xee], [0xee, 0xee, 0xee], [0xff, 0xff, 0xff], [0xff, 0xff, 0xff],
    [0xff, 0xff, 0xff], [0xff, 0xff, 0xff], [0xee, 0xee, 0xee], [0xee, 0xee, 0xee],
    [0xff, 0xff, 0xff], [0xff, 0xff, 0xff], [0xee, 0xee, 0xee], [0xee, 0xee, 0xee]
  ]

  data = data.flatten.pack 'C*'

  glTexImage2D GL_TEXTURE_2D,
    level = 0,
    internal_format = 3,
    width = 4,
    height = 4,
    border = 0,
    format = GL_RGB,
    type = GL_UNSIGNED_BYTE,
    data

  glTexParameteri GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST
  glTexParameteri GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST

  unbind
end

Instance Method Details

#bindObject



35
36
37
# File 'lib/budgie/checker_texture.rb', line 35

def bind
  glBindTexture GL_TEXTURE_2D, @id
end

#unbindObject



39
40
41
# File 'lib/budgie/checker_texture.rb', line 39

def unbind
  glBindTexture GL_TEXTURE_2D, 0
end