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
|