ruby-opengl 0.60.1 → 0.61.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. metadata +36 -186
  2. data/Rakefile +0 -168
  3. data/doc/build_install.txt +0 -122
  4. data/doc/extensions.txt +0 -556
  5. data/doc/extensions.txt.in +0 -348
  6. data/doc/history.txt +0 -66
  7. data/doc/requirements_and_design.txt +0 -117
  8. data/doc/roadmap.txt +0 -28
  9. data/doc/scientific_use.txt +0 -35
  10. data/doc/supplies/page_template.html +0 -71
  11. data/doc/thanks.txt +0 -29
  12. data/doc/tutorial.txt +0 -469
  13. data/examples/NeHe/nehe_lesson02.rb +0 -117
  14. data/examples/NeHe/nehe_lesson03.rb +0 -122
  15. data/examples/NeHe/nehe_lesson04.rb +0 -133
  16. data/examples/NeHe/nehe_lesson05.rb +0 -186
  17. data/examples/NeHe/nehe_lesson36.rb +0 -303
  18. data/examples/OrangeBook/3Dlabs-License.txt +0 -33
  19. data/examples/OrangeBook/brick.frag +0 -36
  20. data/examples/OrangeBook/brick.rb +0 -376
  21. data/examples/OrangeBook/brick.vert +0 -41
  22. data/examples/OrangeBook/particle.frag +0 -17
  23. data/examples/OrangeBook/particle.rb +0 -406
  24. data/examples/OrangeBook/particle.vert +0 -38
  25. data/examples/README +0 -16
  26. data/examples/RedBook/aapoly.rb +0 -142
  27. data/examples/RedBook/aargb.rb +0 -119
  28. data/examples/RedBook/accanti.rb +0 -162
  29. data/examples/RedBook/accpersp.rb +0 -215
  30. data/examples/RedBook/alpha.rb +0 -123
  31. data/examples/RedBook/alpha3D.rb +0 -158
  32. data/examples/RedBook/bezcurve.rb +0 -105
  33. data/examples/RedBook/bezmesh.rb +0 -137
  34. data/examples/RedBook/checker.rb +0 -124
  35. data/examples/RedBook/clip.rb +0 -95
  36. data/examples/RedBook/colormat.rb +0 -135
  37. data/examples/RedBook/cube.rb +0 -69
  38. data/examples/RedBook/depthcue.rb +0 -99
  39. data/examples/RedBook/dof.rb +0 -205
  40. data/examples/RedBook/double.rb +0 -105
  41. data/examples/RedBook/drawf.rb +0 -91
  42. data/examples/RedBook/feedback.rb +0 -145
  43. data/examples/RedBook/fog.rb +0 -167
  44. data/examples/RedBook/font.rb +0 -151
  45. data/examples/RedBook/hello.rb +0 -79
  46. data/examples/RedBook/image.rb +0 -137
  47. data/examples/RedBook/jitter.rb +0 -207
  48. data/examples/RedBook/lines.rb +0 -128
  49. data/examples/RedBook/list.rb +0 -111
  50. data/examples/RedBook/material.rb +0 -275
  51. data/examples/RedBook/mipmap.rb +0 -156
  52. data/examples/RedBook/model.rb +0 -113
  53. data/examples/RedBook/movelight.rb +0 -132
  54. data/examples/RedBook/pickdepth.rb +0 -179
  55. data/examples/RedBook/planet.rb +0 -108
  56. data/examples/RedBook/quadric.rb +0 -158
  57. data/examples/RedBook/robot.rb +0 -115
  58. data/examples/RedBook/select.rb +0 -196
  59. data/examples/RedBook/smooth.rb +0 -95
  60. data/examples/RedBook/stencil.rb +0 -163
  61. data/examples/RedBook/stroke.rb +0 -167
  62. data/examples/RedBook/surface.rb +0 -166
  63. data/examples/RedBook/teaambient.rb +0 -132
  64. data/examples/RedBook/teapots.rb +0 -182
  65. data/examples/RedBook/tess.rb +0 -183
  66. data/examples/RedBook/texbind.rb +0 -147
  67. data/examples/RedBook/texgen.rb +0 -169
  68. data/examples/RedBook/texturesurf.rb +0 -128
  69. data/examples/RedBook/varray.rb +0 -159
  70. data/examples/RedBook/wrap.rb +0 -148
  71. data/examples/misc/OGLBench.rb +0 -337
  72. data/examples/misc/anisotropic.rb +0 -194
  73. data/examples/misc/fbo_test.rb +0 -356
  74. data/examples/misc/font-glut.rb +0 -46
  75. data/examples/misc/glfwtest.rb +0 -30
  76. data/examples/misc/plane.rb +0 -161
  77. data/examples/misc/readpixel.rb +0 -65
  78. data/examples/misc/sdltest.rb +0 -34
  79. data/examples/misc/trislam.rb +0 -828
  80. data/ext/common/common.h +0 -423
  81. data/ext/common/conv.h +0 -244
  82. data/ext/common/funcdef.h +0 -280
  83. data/ext/common/gl-enums.h +0 -10031
  84. data/ext/common/gl-error.h +0 -23
  85. data/ext/common/gl-types.h +0 -61
  86. data/ext/common/glu-enums.h +0 -463
  87. data/ext/gl/gl-1.0-1.1.c +0 -2817
  88. data/ext/gl/gl-1.2.c +0 -814
  89. data/ext/gl/gl-1.3.c +0 -444
  90. data/ext/gl/gl-1.4.c +0 -349
  91. data/ext/gl/gl-1.5.c +0 -225
  92. data/ext/gl/gl-2.0.c +0 -657
  93. data/ext/gl/gl-2.1.c +0 -57
  94. data/ext/gl/gl-enums.c +0 -3354
  95. data/ext/gl/gl-error.c +0 -104
  96. data/ext/gl/gl-ext-3dfx.c +0 -27
  97. data/ext/gl/gl-ext-arb.c +0 -866
  98. data/ext/gl/gl-ext-ati.c +0 -41
  99. data/ext/gl/gl-ext-ext.c +0 -890
  100. data/ext/gl/gl-ext-gremedy.c +0 -41
  101. data/ext/gl/gl-ext-nv.c +0 -679
  102. data/ext/gl/gl.c +0 -214
  103. data/ext/gl/mkrf_conf.rb +0 -34
  104. data/ext/glu/glu-enums.c +0 -164
  105. data/ext/glu/glu.c +0 -1530
  106. data/ext/glu/mkrf_conf.rb +0 -35
  107. data/ext/glut/glut.c +0 -1623
  108. data/ext/glut/mkrf_conf.rb +0 -37
  109. data/lib/opengl.rb +0 -84
  110. data/test/README +0 -10
  111. data/test/tc_common.rb +0 -98
  112. data/test/tc_ext_arb.rb +0 -467
  113. data/test/tc_ext_ati.rb +0 -33
  114. data/test/tc_ext_ext.rb +0 -551
  115. data/test/tc_ext_gremedy.rb +0 -36
  116. data/test/tc_ext_nv.rb +0 -357
  117. data/test/tc_func_10_11.rb +0 -1281
  118. data/test/tc_func_12.rb +0 -186
  119. data/test/tc_func_13.rb +0 -229
  120. data/test/tc_func_14.rb +0 -197
  121. data/test/tc_func_15.rb +0 -270
  122. data/test/tc_func_20.rb +0 -346
  123. data/test/tc_func_21.rb +0 -541
  124. data/test/tc_glu.rb +0 -310
  125. data/test/tc_include_gl.rb +0 -35
  126. data/test/tc_misc.rb +0 -54
  127. data/test/tc_require_gl.rb +0 -34
@@ -1,194 +0,0 @@
1
- #
2
- # Copyright (C) 2007 Jan Dvorak <jan.dvorak@kraxnet.cz>
3
- #
4
- # This program is distributed under the terms of the MIT license.
5
- # See the included MIT-LICENSE file for the terms of this license.
6
- #
7
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
8
- # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
9
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
10
- # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
11
- # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
12
- # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
13
- # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14
- #
15
-
16
- #
17
- # Showcase for anisotropic texture filtering
18
- #
19
-
20
- require 'opengl'
21
- include Gl,Glu,Glut
22
-
23
- # extend Array class with new function
24
- class Array
25
- def rotate!
26
- self << self.shift
27
- end
28
- end
29
-
30
- class App
31
- @@filters = [[GL_NEAREST,"None"],[GL_LINEAR_MIPMAP_NEAREST,"Bilinear"],[GL_LINEAR_MIPMAP_LINEAR,"Trilinear"]]
32
- @@anisotropy = [1,2,4,8,16,32]
33
- @@color_tint = ["Off","On"]
34
-
35
- def checker_texture(size,divide,color_a,color_b)
36
- strip_a = color_a * (size/divide)
37
- strip_b = color_b * (size/divide)
38
- line_strip_a = (strip_a + strip_b) * (size/2)
39
- line_strip_b = (strip_b + strip_a) * (size/2)
40
- (line_strip_a + line_strip_b) * (divide/2)
41
- end
42
-
43
- def printGlutBitmapFont(string, font, x,y, r,g,b)
44
- glDisable(GL_TEXTURE_2D)
45
- glColor3f(r, g, b)
46
- glRasterPos2i(x, y)
47
- string.each_byte do |x|
48
- glutBitmapCharacter(font, x)
49
- end
50
- end
51
-
52
- def ortho(w,h)
53
- glMatrixMode(GL_PROJECTION)
54
- glLoadIdentity()
55
- gluOrtho2D(0,w,0,h)
56
- glScalef(1,-1,1)
57
- glTranslatef(0,-h,0)
58
-
59
- glMatrixMode(GL_MODELVIEW)
60
- glLoadIdentity()
61
- end
62
-
63
- def persp(w,h)
64
- glMatrixMode(GL_PROJECTION)
65
- glLoadIdentity
66
- gluPerspective(90,w.to_f/h.to_f,1,100)
67
-
68
- glMatrixMode(GL_MODELVIEW)
69
- glLoadIdentity
70
- end
71
-
72
- def reshape(w,h)
73
- @@w,@@h = w,h
74
- glViewport(0, 0, w, h)
75
- persp(w,h)
76
- end
77
-
78
- def initialize
79
- if (not Gl.is_available?("GL_EXT_texture_filter_anisotropic"))
80
- puts "This program needs GL_EXT_texture_filter_anisotropic extension"
81
- exit
82
- end
83
- @@w,@@h = glutGet(GLUT_WINDOW_WIDTH),glutGet(GLUT_WINDOW_HEIGHT)
84
-
85
- @t = glGenTextures(2)
86
-
87
- # default checkerboard texture
88
- glBindTexture(GL_TEXTURE_2D,@t[0])
89
- data = checker_texture(64,4,[1,1,1],[0,0,0])
90
- gluBuild2DMipmaps(GL_TEXTURE_2D,GL_RGBA,64,64,GL_RGB,GL_FLOAT,data.pack("f*"))
91
-
92
- # second texture with color tinted mipmaps
93
- glBindTexture(GL_TEXTURE_2D,@t[1])
94
- data = checker_texture(64,4,[1,1,1],[0,0,0])
95
- glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,64,64,0,GL_RGB,GL_FLOAT,data.pack("f*"))
96
- data = checker_texture(32,4,[1,0,0],[0,0,0])
97
- glTexImage2D(GL_TEXTURE_2D,1,GL_RGBA,32,32,0,GL_RGB,GL_FLOAT,data.pack("f*"))
98
- data = checker_texture(16,4,[0,1,0],[0,0,0])
99
- glTexImage2D(GL_TEXTURE_2D,2,GL_RGBA,16,16,0,GL_RGB,GL_FLOAT,data.pack("f*"))
100
- data = checker_texture(8,4,[0,0,1],[0,0,0])
101
- glTexImage2D(GL_TEXTURE_2D,3,GL_RGBA,8,8,0,GL_RGB,GL_FLOAT,data.pack("f*"))
102
- data = checker_texture(4,4,[1,1,0],[0,0,0])
103
- glTexImage2D(GL_TEXTURE_2D,4,GL_RGBA,4,4,0,GL_RGB,GL_FLOAT,data.pack("f*"))
104
- data = checker_texture(2,2,[1,0,1],[0,0,0])
105
- glTexImage2D(GL_TEXTURE_2D,5,GL_RGBA,2,2,0,GL_RGB,GL_FLOAT,data.pack("f*"))
106
- data = [0.5,0.5,0.5] # single pixel texture, just average it
107
- glTexImage2D(GL_TEXTURE_2D,6,GL_RGBA,1,1,0,GL_RGB,GL_FLOAT,data.pack("f*"))
108
- end
109
-
110
- def display_text
111
- ortho(@@w,@@h)
112
- printGlutBitmapFont("Texture Filtering ('f'): #{@@filters[0][1]}", GLUT_BITMAP_9_BY_15, 20, 20, 1.0, 1.0, 1.0)
113
- printGlutBitmapFont("Anisotropy factor ('a'): #{@@anisotropy[0]}x", GLUT_BITMAP_9_BY_15, 20, 40, 1.0, 1.0, 1.0)
114
- printGlutBitmapFont("Colored Mipmaps ('c'): #{@@color_tint[0]}", GLUT_BITMAP_9_BY_15, 20, 60, 1.0, 1.0, 1.0)
115
- persp(@@w,@@h)
116
- end
117
-
118
- def display_plane()
119
- glEnable(GL_TEXTURE_2D)
120
- t_repeat = 16
121
- # x,y,z,u,v
122
- quad = [[-4,-1,1, 0,t_repeat],[4,-1,1, t_repeat,t_repeat],[4,1,-8, t_repeat,0],[-4,1,-8, 0,0]]
123
- glBegin(GL_QUADS)
124
- quad.each do |v|
125
- glTexCoord2f(v[3],v[4])
126
- glVertex3f(v[0],v[1],v[2])
127
- end
128
- glEnd()
129
- glDisable(GL_TEXTURE_2D)
130
- end
131
-
132
- def display
133
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
134
-
135
- persp(@@w,@@h)
136
-
137
- # move back from scene
138
- glTranslatef(0,0,-2)
139
-
140
- # set anisotropy
141
- glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAX_ANISOTROPY_EXT,@@anisotropy[0])
142
-
143
- # set color tint
144
- if (@@color_tint[0] == "On")
145
- glBindTexture(GL_TEXTURE_2D,@t[1])
146
- else
147
- glBindTexture(GL_TEXTURE_2D,@t[0])
148
- end
149
-
150
- # set filters
151
- f = @@filters[0][0]
152
- glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,f)
153
-
154
- # draw scene
155
- display_plane()
156
- display_text()
157
-
158
- sleep(0.001) # microsleep to avoid consuming all CPU time
159
- glutSwapBuffers()
160
- end
161
-
162
- def idle
163
- glutPostRedisplay()
164
- end
165
-
166
- def keyboard(key,x,y)
167
- case (key)
168
- when ?f
169
- @@filters.rotate!
170
- when ?a
171
- max_anisotropy = glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT)
172
- begin @@anisotropy.rotate! end until @@anisotropy[0]<=max_anisotropy
173
- when ?c
174
- @@color_tint.rotate!
175
- when ?\e # Escape
176
- exit(0)
177
- end
178
- glutPostRedisplay()
179
- end
180
- end
181
-
182
- # main
183
- glutInit()
184
- glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE )
185
- glutInitWindowPosition(150,50)
186
- glutInitWindowSize(500,500)
187
- glutCreateWindow($0)
188
-
189
- app = App.new
190
- glutReshapeFunc(app.method(:reshape).to_proc)
191
- glutDisplayFunc(app.method(:display).to_proc)
192
- glutIdleFunc(app.method(:idle).to_proc)
193
- glutKeyboardFunc(app.method(:keyboard).to_proc)
194
- glutMainLoop()
@@ -1,356 +0,0 @@
1
- # ogl_bench v1.0 - Copyright 2007 - Graphcomp
2
- # Bob Free bfree@graphcomp.com
3
- # http://graphcomp.com/opengl
4
-
5
- # This program is freely distributable without licensing fees
6
- # and is provided without guarantee or warrantee expressed or
7
- # implied. This program is -not- in the public domain.
8
- #
9
- # Conversion to ruby by Jan Dvorak <jan.dvorak@kraxnet.cz>
10
-
11
- # Set up standard libs
12
- require 'opengl'
13
- include Gl,Glut
14
-
15
- # Set up constants
16
- PROGRAM = "OpenGL Benchmark - Ruby Bindings"
17
- CYCLES = 1000
18
-
19
- # Setup OpenGL Extensions
20
- # (Not needed)
21
-
22
- # Set up types
23
- class Bench
24
- attr_accessor :start,:secs
25
- def initialize
26
- @start = 0
27
- @secs = 0
28
- end
29
- end
30
-
31
- # Set up globals
32
- $appBench = Bench.new
33
- $frameBench = Bench.new
34
- $textureBench = Bench.new
35
- $teapotBench = Bench.new
36
- $now = 0
37
- $frames = 0
38
-
39
- $idWindow = 0
40
-
41
- $windowWidth = 512
42
- $windowHeight = 512
43
-
44
- $textureWidth = 128
45
- $textureHeight = 128
46
-
47
- $rotTeapotX = 0
48
- $rotTeapotY = 0
49
-
50
- $idTexture = 0
51
- $idFrameBuffer = 0
52
- $idRenderBuffer = 0
53
- $idVertexProg = 0
54
- $idFragProg = 0
55
-
56
- $incY = 0.5
57
- $rotY = 0.0
58
-
59
- # Start benchmark
60
- def startBench(pBench)
61
- pBench.start = Time.now
62
- # pBench.secs = 0.0
63
- end
64
-
65
- # Accumulate benchmark
66
- def endBench(pBench)
67
- $now = Time.now
68
- pBench.secs += $now - pBench.start
69
- end
70
-
71
- # Print benchmark
72
- def printBench
73
- if ($frames==0 || $appBench.secs==0 || $frameBench.secs==0 ||
74
- $textureBench.secs==0 || $teapotBench.secs==0)
75
- puts "No measurable time has elapsed"
76
- return
77
- end
78
-
79
- puts "FBO Texture Rendering FPS: #{$frames / $textureBench.secs}"
80
- puts "Teapot Shader FPS: #{$frames / $teapotBench.secs}"
81
-
82
- overhead = $frameBench.secs - ($textureBench.secs + $teapotBench.secs)
83
- puts "Frame overhead secs/frame: #{overhead / $frames}"
84
-
85
- overhead = $appBench.secs - $frameBench.secs
86
- puts "OS/GLUT overhead secs/frame: #{overhead / $frames}"
87
-
88
- puts "Overall FPS: #{$frames / $appBench.secs}"
89
- puts ""
90
- end
91
-
92
- # Error handling
93
- def error(errTitle, errMsg)
94
- puts "#{errTitle}: #{errMsg}"
95
- exit(0)
96
- end
97
-
98
- # Check OpenGL Version
99
- def checkVersion
100
- version = glGetString(GL_VERSION)
101
- vendor = glGetString(GL_VENDOR)
102
- renderer = glGetString(GL_RENDERER)
103
- exts = glGetString(GL_EXTENSIONS)
104
-
105
- puts PROGRAM
106
- puts ""
107
- puts "OpenGL: #{version}"
108
- puts "Vendor: #{vendor}"
109
- puts "Renderer: #{renderer}"
110
- puts ""
111
-
112
- if Gl.is_available?("GL_EXT_framebuffer_object") == false
113
- error("Extension not available","EXT_framebuffer_object")
114
- end
115
- end
116
-
117
- # Load Extension Procs
118
- def initExtensions
119
- # (Not needed)
120
- end
121
-
122
- # Initialize Vertex/Fragment Programs
123
- def initProgs
124
- # NOP Vertex shader
125
- $vertexProg = <<-END_OF_PROGRAM
126
- !!ARBvp1.0
127
- TEMP vertexClip;
128
- DP4 vertexClip.x, state.matrix.mvp.row[0], vertex.position;
129
- DP4 vertexClip.y, state.matrix.mvp.row[1], vertex.position;
130
- DP4 vertexClip.z, state.matrix.mvp.row[2], vertex.position;
131
- DP4 vertexClip.w, state.matrix.mvp.row[3], vertex.position;
132
- MOV result.position, vertexClip;
133
- MOV result.color, vertex.color;
134
- MOV result.texcoord[0], vertex.texcoord;
135
- MOV result.texcoord[1], vertex.normal;
136
- END
137
- END_OF_PROGRAM
138
-
139
- # Black Light Fragment shader
140
- $fragProg = <<-END_OF_PROGRAM
141
- !!ARBfp1.0
142
- TEMP decal,color;
143
- TEX decal, fragment.texcoord[0], texture[0], 2D;
144
- MUL result.color, decal, fragment.texcoord[1];
145
- END
146
- END_OF_PROGRAM
147
-
148
- $idVertexProg,$idFragProg = glGenProgramsARB(2)
149
-
150
- glBindProgramARB(GL_VERTEX_PROGRAM_ARB, $idVertexProg)
151
- glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, $vertexProg)
152
-
153
- glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, $idFragProg)
154
- glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, $fragProg)
155
- end
156
-
157
- # Terminate Vertex/Fragment Programs
158
- def termProgs
159
- glBindProgramARB(GL_VERTEX_PROGRAM_ARB, 0)
160
- glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0)
161
-
162
- glDeleteProgramsARB([$idVertexProg,$idFragProg])
163
- end
164
-
165
- # FBO Status handler
166
- def statusFBO
167
- stat = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT)
168
- return if (stat==0 || stat == GL_FRAMEBUFFER_COMPLETE_EXT)
169
- printf("FBO status: %04X\n", stat)
170
- exit(0)
171
- end
172
-
173
- # Initialize Framebuffers
174
- def initFBO
175
- $idTexture = glGenTextures(1)[0]
176
- $idFrameBuffer = glGenFramebuffersEXT(1)[0]
177
- $idRenderBuffer = glGenRenderbuffersEXT(1)[0]
178
-
179
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, $idFrameBuffer)
180
- glBindTexture(GL_TEXTURE_2D, $idTexture)
181
-
182
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, $textureWidth, $textureHeight,
183
- 0, GL_RGBA, GL_UNSIGNED_BYTE, nil)
184
-
185
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
186
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
187
-
188
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
189
- GL_TEXTURE_2D, $idTexture, 0)
190
-
191
- glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, $idRenderBuffer)
192
-
193
- glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24,
194
- $textureWidth, $textureHeight)
195
-
196
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
197
- GL_RENDERBUFFER_EXT, $idRenderBuffer)
198
-
199
- statusFBO()
200
- end
201
-
202
- # FBO texture renderer
203
- def renderFBO
204
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, $idFrameBuffer)
205
-
206
- glLoadIdentity()
207
- glTranslated(-0.75, -0.85, -2.5)
208
-
209
- glRotated($rotTeapotX, 1.0, 0.0, 0.0)
210
- $rotTeapotX += 0.5
211
-
212
- glRotated($rotTeapotY, 0.0, 1.0, 0.0)
213
- $rotTeapotY += 1.0
214
-
215
- glClearColor(0, 0, 0, 0)
216
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
217
- glColor3d(1.0, 1.0, 1.0)
218
-
219
- glutWireTeapot(0.125)
220
-
221
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0)
222
- end
223
-
224
- # Terminate FBO objects
225
- def termFBO
226
- glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0)
227
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0)
228
- glBindTexture(GL_TEXTURE_2D, 0)
229
-
230
- glDeleteRenderbuffersEXT($idRenderBuffer)
231
- glDeleteFramebuffersEXT($idFrameBuffer)
232
- glDeleteTextures($idTexture)
233
- end
234
-
235
- # Resize Window
236
- def resizeScene(width,height)
237
- if (height==0)
238
- height = 1
239
- end
240
-
241
- glViewport(0, 0, width, height)
242
-
243
- glMatrixMode(GL_PROJECTION)
244
- glLoadIdentity()
245
- gluPerspective(45.0,width.to_f/height.to_f,0.1,100.0)
246
-
247
- glMatrixMode(GL_MODELVIEW)
248
-
249
- $windowWidth = width
250
- $windowHeight = height
251
- end
252
-
253
- # Initialize OpenGL Environment
254
- def init
255
- checkVersion
256
- initExtensions
257
-
258
- resizeScene($windowWidth, $windowHeight)
259
-
260
- initFBO
261
- initProgs
262
- end
263
-
264
- # Terminate OpenGL Environment
265
- def term
266
- # Display benchmark
267
- endBench($appBench)
268
- printBench()
269
-
270
- # Disable app
271
- glutHideWindow()
272
- glutKeyboardFunc(nil)
273
- glutSpecialFunc(nil)
274
- glutIdleFunc(nil)
275
- glutReshapeFunc(nil)
276
-
277
- # Release Framebuffers
278
- termProgs()
279
- termFBO()
280
-
281
- # Now we can destroy window
282
- glutDestroyWindow($idWindow)
283
- exit(0)
284
- end
285
-
286
- # Frame handler
287
- display = lambda do
288
- # Run benchmark CYCLES times
289
- $frames += 1
290
- term() if ($frames > CYCLES)
291
- startBench($frameBench)
292
-
293
- # Render animated texture
294
- startBench($textureBench)
295
- renderFBO()
296
- endBench($textureBench)
297
-
298
- # Set up ModelView
299
- glMatrixMode(GL_MODELVIEW)
300
- glLoadIdentity()
301
- glTranslatef(0.0,0.0,-5.0)
302
- glRotated(0.0,1.0,0.0,0.0)
303
- glRotated($rotY,0.0,1.0,0.0)
304
- $rotY += $incY
305
-
306
- # Set attributes
307
- glEnable(GL_TEXTURE_2D)
308
- glEnable(GL_DEPTH_TEST)
309
- glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_DECAL)
310
-
311
- # Clear render buffer and set teapot color
312
- glClearColor(0.2, 0.2, 0.2, 1.0)
313
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
314
- glColor3d(0.9, 0.45, 0.0)
315
-
316
- # Render the teapot using our shader
317
- startBench($teapotBench)
318
- glEnable(GL_VERTEX_PROGRAM_ARB)
319
- glEnable(GL_FRAGMENT_PROGRAM_ARB)
320
-
321
- glutSolidTeapot(1.0)
322
-
323
- glDisable(GL_FRAGMENT_PROGRAM_ARB)
324
- glDisable(GL_VERTEX_PROGRAM_ARB)
325
- endBench($teapotBench)
326
-
327
- # Double-buffer and done
328
- glutSwapBuffers()
329
- endBench($frameBench)
330
- end
331
-
332
- # Keyboard handler
333
- keyPressed = lambda do |key,x,y|
334
- term()
335
- end
336
-
337
-
338
-
339
- # Main app
340
-
341
- glutInit()
342
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_ALPHA)
343
- glutInitWindowSize($windowWidth,$windowHeight)
344
-
345
- $idWindow = glutCreateWindow(PROGRAM)
346
-
347
- glutDisplayFunc(display)
348
- glutIdleFunc(display)
349
- #glutReshapeFunc(resizeScene)
350
- glutKeyboardFunc(keyPressed)
351
-
352
- init()
353
- startBench($appBench)
354
- glutMainLoop()
355
- exit(0)
356
-