22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/ext/shader.rb', line 22
def apply
@window.gl do
glBindTexture(GL_TEXTURE_2D, @@canvas_texture_id)
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 0, 0, @window.width, @window.height, 0)
glUseProgram(@program_id)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glColor4f(1.0, 1.0, 1.0, 1.0)
glMatrixMode(GL_PROJECTION)
glPushMatrix
glLoadIdentity
glViewport(0, 0, @window.width, @window.height)
glOrtho(0, @window.width, @window.height, 0, -1, 1)
glBindTexture(GL_TEXTURE_2D, @@canvas_texture_id)
glBegin(GL_QUADS)
glTexCoord2f(0.0, 1.0); glVertex2f(0.0, 0.0)
glTexCoord2f(1.0, 1.0); glVertex2f(@window.width, 0.0)
glTexCoord2f(1.0, 0.0); glVertex2f(@window.width, @window.height)
glTexCoord2f(0.0, 0.0); glVertex2f(0.0, @window.height)
glEnd
glUseProgram(0)
glPopMatrix
end
end
|