opengl 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +1 -0
  3. data.tar.gz.sig +0 -0
  4. data/.gitignore +2 -1
  5. data/.travis.yml +19 -0
  6. data/History.rdoc +26 -0
  7. data/Manifest.txt +3 -23
  8. data/README.rdoc +43 -37
  9. data/Rakefile +6 -62
  10. data/examples/NeHe/nehe_lesson02.rb +3 -2
  11. data/examples/NeHe/nehe_lesson03.rb +3 -2
  12. data/examples/NeHe/nehe_lesson04.rb +3 -1
  13. data/examples/NeHe/nehe_lesson05.rb +4 -1
  14. data/examples/NeHe/nehe_lesson06.rb +9 -6
  15. data/examples/NeHe/nehe_lesson07.rb +9 -6
  16. data/examples/NeHe/nehe_lesson08.rb +9 -6
  17. data/examples/NeHe/nehe_lesson09.rb +10 -6
  18. data/examples/NeHe/nehe_lesson11.rb +9 -6
  19. data/examples/NeHe/nehe_lesson12.rb +9 -6
  20. data/examples/NeHe/nehe_lesson16.rb +50 -47
  21. data/examples/NeHe/nehe_lesson19.rb +10 -7
  22. data/examples/NeHe/nehe_lesson36.rb +234 -229
  23. data/examples/OrangeBook/brick.rb +227 -225
  24. data/examples/OrangeBook/particle.rb +233 -231
  25. data/examples/RedBook/aapoly.rb +71 -70
  26. data/examples/RedBook/aargb.rb +54 -52
  27. data/examples/RedBook/accanti.rb +96 -94
  28. data/examples/RedBook/accpersp.rb +106 -104
  29. data/examples/RedBook/alpha.rb +54 -52
  30. data/examples/RedBook/alpha3D.rb +90 -88
  31. data/examples/RedBook/bezcurve.rb +48 -46
  32. data/examples/RedBook/bezmesh.rb +71 -69
  33. data/examples/RedBook/checker.rb +57 -55
  34. data/examples/RedBook/clip.rb +41 -39
  35. data/examples/RedBook/colormat.rb +72 -70
  36. data/examples/RedBook/cube.rb +39 -37
  37. data/examples/RedBook/depthcue.rb +37 -35
  38. data/examples/RedBook/dof.rb +110 -109
  39. data/examples/RedBook/double.rb +40 -38
  40. data/examples/RedBook/drawf.rb +30 -28
  41. data/examples/RedBook/feedback.rb +79 -77
  42. data/examples/RedBook/fog.rb +90 -89
  43. data/examples/RedBook/font.rb +78 -76
  44. data/examples/RedBook/hello.rb +29 -27
  45. data/examples/RedBook/image.rb +57 -55
  46. data/examples/RedBook/jitter.rb +131 -131
  47. data/examples/RedBook/light.rb +2 -1
  48. data/examples/RedBook/lines.rb +70 -68
  49. data/examples/RedBook/list.rb +48 -46
  50. data/examples/RedBook/material.rb +200 -199
  51. data/examples/RedBook/mipmap.rb +84 -82
  52. data/examples/RedBook/model.rb +55 -53
  53. data/examples/RedBook/movelight.rb +52 -50
  54. data/examples/RedBook/pickdepth.rb +103 -101
  55. data/examples/RedBook/planet.rb +46 -44
  56. data/examples/RedBook/quadric.rb +97 -95
  57. data/examples/RedBook/robot.rb +55 -53
  58. data/examples/RedBook/select.rb +118 -116
  59. data/examples/RedBook/smooth.rb +35 -33
  60. data/examples/RedBook/stencil.rb +96 -94
  61. data/examples/RedBook/stroke.rb +75 -73
  62. data/examples/RedBook/surface.rb +93 -91
  63. data/examples/RedBook/teaambient.rb +71 -69
  64. data/examples/RedBook/teapots.rb +105 -103
  65. data/examples/RedBook/tess.rb +96 -94
  66. data/examples/RedBook/texbind.rb +79 -77
  67. data/examples/RedBook/texgen.rb +88 -86
  68. data/examples/RedBook/texturesurf.rb +57 -55
  69. data/examples/RedBook/varray.rb +85 -83
  70. data/examples/RedBook/wrap.rb +76 -74
  71. data/examples/misc/OGLBench.rb +114 -113
  72. data/examples/misc/anisotropic.rb +154 -152
  73. data/examples/misc/fbo_test.rb +37 -36
  74. data/examples/misc/font-glut.rb +47 -46
  75. data/examples/misc/glfwtest.rb +16 -16
  76. data/examples/misc/plane.rb +13 -13
  77. data/examples/misc/readpixel.rb +66 -65
  78. data/examples/misc/sdltest.rb +21 -19
  79. data/examples/misc/trislam.rb +548 -547
  80. data/ext/opengl/common.h +16 -38
  81. data/ext/opengl/conv.h +39 -41
  82. data/ext/opengl/extconf.rb +4 -31
  83. data/ext/opengl/funcdef.h +126 -124
  84. data/ext/opengl/gl-1.0-1.1.c +1917 -1917
  85. data/ext/opengl/gl-1.2.c +4 -667
  86. data/ext/opengl/gl-1.3.c +9 -9
  87. data/ext/opengl/gl-1.4.c +8 -8
  88. data/ext/opengl/gl-1.5.c +1 -1
  89. data/ext/opengl/gl-2.0.c +392 -388
  90. data/ext/opengl/gl-3.0.c +493 -0
  91. data/ext/opengl/gl-enums.c +1523 -5
  92. data/ext/opengl/gl-enums.h +4679 -122
  93. data/ext/opengl/gl-error.c +7 -7
  94. data/ext/opengl/gl-error.h +4 -4
  95. data/ext/opengl/gl-ext-arb.c +468 -464
  96. data/ext/opengl/gl-ext-ext.c +18 -18
  97. data/ext/opengl/gl-ext-nv.c +15 -15
  98. data/ext/opengl/gl.c +2 -0
  99. data/ext/opengl/gl_buffer.c +92 -92
  100. data/ext/opengl/opengl.c +1 -7
  101. data/lib/opengl.rb +23 -59
  102. data/lib/opengl/test_case.rb +1 -2
  103. data/test/dummy.xorg.conf +140 -0
  104. data/test/test_gl.rb +18 -22
  105. data/test/test_gl_10_11.rb +220 -220
  106. data/test/test_gl_12.rb +11 -122
  107. data/test/test_gl_13.rb +202 -210
  108. data/test/test_gl_14.rb +16 -19
  109. data/test/test_gl_15.rb +2 -4
  110. data/test/test_gl_20.rb +45 -58
  111. data/test/test_gl_21.rb +46 -163
  112. data/test/test_gl_ext_arb.rb +54 -72
  113. data/test/test_gl_ext_ati.rb +0 -2
  114. data/test/test_gl_ext_ext.rb +66 -66
  115. data/test/test_gl_ext_gremedy.rb +8 -15
  116. data/test/test_gl_ext_nv.rb +109 -112
  117. data/test/test_opengl_buffer.rb +8 -25
  118. data/utils/README +0 -5
  119. data/utils/enumgen.rb +72 -76
  120. data/utils/extlistgen.rb +55 -55
  121. metadata +87 -66
  122. metadata.gz.sig +2 -0
  123. data/Rakefile.cross +0 -107
  124. data/docs/build_install.txt +0 -119
  125. data/docs/extensions.txt.in +0 -348
  126. data/docs/history.txt +0 -66
  127. data/docs/requirements_and_design.txt +0 -117
  128. data/docs/roadmap.txt +0 -28
  129. data/docs/scientific_use.txt +0 -35
  130. data/docs/supplies/page_template.html +0 -71
  131. data/docs/thanks.txt +0 -29
  132. data/docs/tutorial.txt +0 -469
  133. data/ext/opengl/glu-enums.c +0 -164
  134. data/ext/opengl/glu-enums.h +0 -463
  135. data/ext/opengl/glu.c +0 -1534
  136. data/ext/opengl/glut.c +0 -1145
  137. data/ext/opengl/glut_callbacks.c +0 -845
  138. data/lib/glu.rb +0 -1
  139. data/lib/glut.rb +0 -1
  140. data/test/test_glu.rb +0 -309
  141. data/utils/mkdn2html.rb +0 -59
  142. data/utils/post-mkdn2html.rb +0 -91
  143. data/website/images/ogl.jpg +0 -0
  144. data/website/images/tab_bottom.gif +0 -0
  145. data/website/style.css +0 -198
@@ -36,6 +36,8 @@
36
36
  # .vert are vertex shaders, and files ending in .frag are fragment shaders.
37
37
 
38
38
  require 'opengl'
39
+ require 'glu'
40
+ require 'glut'
39
41
  include Gl,Glu,Glut
40
42
 
41
43
  $rotl = 1 * Math::PI / 180
@@ -68,33 +70,33 @@ $gleModel = [:cube, :teapot,:torus,:sphere]
68
70
  $clearColor = [[0,0,0,1], [0.2,0.2,0.3,1], [0.7,0.7,0.7,1]]
69
71
 
70
72
  def drawCube
71
- size = 1.0
72
- scale = 0.2
73
- delta = 0.1
74
-
75
- v = [
76
- [ size, size, size * scale + delta ],
77
- [ size, size, -size * scale + delta ],
78
- [ size, -size, -size * scale ],
79
- [ size, -size, size * scale ],
80
- [-size, size, size * scale + delta ],
81
- [-size, size, -size * scale + delta ],
82
- [-size, -size, -size * scale ],
83
- [-size, -size, size * scale ]
84
- ]
85
-
86
- cube = [
87
- [ [1,0,0], v[3],v[2],v[1],v[0] ], # normal, vertices
88
- [ [-1,0,0], v[6],v[7],v[4],v[5] ],
89
- [ [0,0,-1], v[2],v[6],v[5],v[1] ],
90
- [ [0,0,1], v[7],v[3],v[0],v[4] ],
91
- [ [0,1,0], v[4],v[0],v[1],v[5] ],
92
- [ [0,-1,0], v[6],v[2],v[3],v[7] ]
93
- ]
94
-
95
- glBegin(GL_QUADS)
96
- cube.each do |side|
97
- glNormal3fv(side[0])
73
+ size = 1.0
74
+ scale = 0.2
75
+ delta = 0.1
76
+
77
+ v = [
78
+ [ size, size, size * scale + delta ],
79
+ [ size, size, -size * scale + delta ],
80
+ [ size, -size, -size * scale ],
81
+ [ size, -size, size * scale ],
82
+ [-size, size, size * scale + delta ],
83
+ [-size, size, -size * scale + delta ],
84
+ [-size, -size, -size * scale ],
85
+ [-size, -size, size * scale ]
86
+ ]
87
+
88
+ cube = [
89
+ [ [1,0,0], v[3],v[2],v[1],v[0] ], # normal, vertices
90
+ [ [-1,0,0], v[6],v[7],v[4],v[5] ],
91
+ [ [0,0,-1], v[2],v[6],v[5],v[1] ],
92
+ [ [0,0,1], v[7],v[3],v[0],v[4] ],
93
+ [ [0,1,0], v[4],v[0],v[1],v[5] ],
94
+ [ [0,-1,0], v[6],v[2],v[3],v[7] ]
95
+ ]
96
+
97
+ glBegin(GL_QUADS)
98
+ cube.each do |side|
99
+ glNormal3fv(side[0])
98
100
 
99
101
  glTexCoord2f(1,1)
100
102
  glVertex3fv(side[1])
@@ -104,240 +106,240 @@ def drawCube
104
106
  glVertex3fv(side[3])
105
107
  glTexCoord2f(1,0)
106
108
  glVertex3fv(side[4])
107
- end
108
- glEnd()
109
+ end
110
+ glEnd()
109
111
  end
110
112
 
111
113
  def nextClearColor
112
- glClearColor($clearColor[0][0],
113
- $clearColor[0][1],
114
- $clearColor[0][2],
115
- $clearColor[0][3])
116
- $clearColor << $clearColor.shift # rotate
114
+ glClearColor($clearColor[0][0],
115
+ $clearColor[0][1],
116
+ $clearColor[0][2],
117
+ $clearColor[0][3])
118
+ $clearColor << $clearColor.shift # rotate
117
119
  end
118
120
 
119
121
 
120
122
  play = lambda do
121
- this_time = glutGet(GLUT_ELAPSED_TIME)
123
+ this_time = glutGet(GLUT_ELAPSED_TIME)
122
124
 
123
- $rotl+=(this_time - $last_time) * -0.001
124
- $last_time = this_time
125
+ $rotl+=(this_time - $last_time) * -0.001
126
+ $last_time = this_time
125
127
 
126
- glutPostRedisplay()
128
+ glutPostRedisplay()
127
129
  end
128
130
 
129
131
  display = lambda do
130
- glLoadIdentity()
131
- glTranslatef(0.0, 0.0, -5.0)
132
-
133
- glRotatef($fYDiff, 1,0,0)
134
- glRotatef($fXDiff, 0,1,0)
135
- glRotatef($fZDiff, 0,0,1)
136
-
137
- glScalef($fScale, $fScale, $fScale)
138
-
139
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
140
-
141
- case $gleModel[0]
142
- when :teapot :
143
- glutSolidTeapot(0.6)
144
- when :torus :
145
- glutSolidTorus(0.2, 0.6, 64, 64)
146
- when :sphere :
147
- glutSolidSphere(0.6, 64, 64)
148
- when :cube :
149
- drawCube()
150
- end
151
- glFlush()
152
- glutSwapBuffers()
132
+ glLoadIdentity()
133
+ glTranslatef(0.0, 0.0, -5.0)
134
+
135
+ glRotatef($fYDiff, 1,0,0)
136
+ glRotatef($fXDiff, 0,1,0)
137
+ glRotatef($fZDiff, 0,0,1)
138
+
139
+ glScalef($fScale, $fScale, $fScale)
140
+
141
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
142
+
143
+ case $gleModel[0]
144
+ when :teapot
145
+ glutSolidTeapot(0.6)
146
+ when :torus
147
+ glutSolidTorus(0.2, 0.6, 64, 64)
148
+ when :sphere
149
+ glutSolidSphere(0.6, 64, 64)
150
+ when :cube
151
+ drawCube()
152
+ end
153
+ glFlush()
154
+ glutSwapBuffers()
153
155
  end
154
156
 
155
157
  key = lambda do |key,x,y|
156
- case(key)
157
- when ?b
158
- nextClearColor()
159
- when ?q, ?\e # esc
160
- exit(0)
161
- when ?t
162
- $gleModel << $gleModel.shift # rotate the array
163
- when ?\s # space
164
- $rotate = !$rotate
165
-
166
- if ($rotate==false)
167
- $fXInertiaOld = $fXInertia
168
- $fYInertiaOld = $fYInertia
169
- else
170
- $fXInertia = $fXInertiaOld
171
- $fYInertia = $fYInertiaOld
158
+ case(key)
159
+ when ?b
160
+ nextClearColor()
161
+ when ?q, ?\e # esc
162
+ exit(0)
163
+ when ?t
164
+ $gleModel << $gleModel.shift # rotate the array
165
+ when ?\s # space
166
+ $rotate = !$rotate
167
+
168
+ if ($rotate==false)
169
+ $fXInertiaOld = $fXInertia
170
+ $fYInertiaOld = $fYInertia
171
+ else
172
+ $fXInertia = $fXInertiaOld
173
+ $fYInertia = $fYInertiaOld
172
174
 
173
175
  # To prevent confusion, force some rotation
174
- if ($fXInertia == 0 && $fYInertia == 0)
175
- $fXInertia = -0.5
176
- end
177
- end
178
- when ?+
179
- $fScale += SCALE_INCREMENT
180
- when ?-
181
- $fScale -= SCALE_INCREMENT
182
- else
183
- puts "Keyboard commands:\n"
184
- puts "b - Toggle among background clear colors"
185
- puts "q, <esc> - Quit"
186
- puts "t - Toggle among models to render"
187
- puts "? - Help"
188
- puts "<home> - reset zoom and rotation"
189
- puts "<space> or <click> - stop rotation"
190
- puts "<+>, <-> or <ctrl + drag> - zoom model"
191
- puts "<arrow keys> or <drag> - rotate model\n"
192
- end
176
+ if ($fXInertia == 0 && $fYInertia == 0)
177
+ $fXInertia = -0.5
178
+ end
179
+ end
180
+ when ?+
181
+ $fScale += SCALE_INCREMENT
182
+ when ?-
183
+ $fScale -= SCALE_INCREMENT
184
+ else
185
+ puts "Keyboard commands:\n"
186
+ puts "b - Toggle among background clear colors"
187
+ puts "q, <esc> - Quit"
188
+ puts "t - Toggle among models to render"
189
+ puts "? - Help"
190
+ puts "<home> - reset zoom and rotation"
191
+ puts "<space> or <click> - stop rotation"
192
+ puts "<+>, <-> or <ctrl + drag> - zoom model"
193
+ puts "<arrow keys> or <drag> - rotate model\n"
194
+ end
193
195
  end
194
196
 
195
197
  reshape = lambda do |w,h|
196
- vp = 0.8
197
- aspect = w.to_f/h.to_f
198
-
199
- glViewport(0, 0, w, h)
200
- glMatrixMode(GL_PROJECTION)
201
- glLoadIdentity()
202
-
203
- glFrustum(-vp, vp, -vp / aspect, vp / aspect, 3, 10)
204
-
205
- glMatrixMode(GL_MODELVIEW)
206
- glLoadIdentity()
207
- glTranslatef(0.0, 0.0, -5.0)
198
+ vp = 0.8
199
+ aspect = w.to_f/h.to_f
200
+
201
+ glViewport(0, 0, w, h)
202
+ glMatrixMode(GL_PROJECTION)
203
+ glLoadIdentity()
204
+
205
+ glFrustum(-vp, vp, -vp / aspect, vp / aspect, 3, 10)
206
+
207
+ glMatrixMode(GL_MODELVIEW)
208
+ glLoadIdentity()
209
+ glTranslatef(0.0, 0.0, -5.0)
208
210
  end
209
211
 
210
212
  motion = lambda do |x,y|
211
- if ($xLast != -1 || $yLast != -1)
212
- $xLastIncr = x - $xLast
213
- $yLastIncr = y - $yLast
214
- if ($bmModifiers & GLUT_ACTIVE_CTRL != 0)
215
- if ($xLast != -1)
216
- $fZDiff += $xLastIncr
217
- $fScale += $yLastIncr*SCALE_FACTOR
218
- end
219
- else
220
- if ($xLast != -1)
221
- $fXDiff += $xLastIncr
222
- $fYDiff += $yLastIncr
223
- end
224
- end
225
- end
226
- $xLast = x
227
- $yLast = y
213
+ if ($xLast != -1 || $yLast != -1)
214
+ $xLastIncr = x - $xLast
215
+ $yLastIncr = y - $yLast
216
+ if ($bmModifiers & GLUT_ACTIVE_CTRL != 0)
217
+ if ($xLast != -1)
218
+ $fZDiff += $xLastIncr
219
+ $fScale += $yLastIncr*SCALE_FACTOR
220
+ end
221
+ else
222
+ if ($xLast != -1)
223
+ $fXDiff += $xLastIncr
224
+ $fYDiff += $yLastIncr
225
+ end
226
+ end
227
+ end
228
+ $xLast = x
229
+ $yLast = y
228
230
  end
229
231
 
230
232
  mouse = lambda do |button,state,x,y|
231
- $bmModifiers = glutGetModifiers()
232
- if (button == GLUT_LEFT_BUTTON)
233
- if (state == GLUT_UP)
234
- $xLast = -1
235
- $yLast = -1
236
- if $xLastIncr > INERTIA_THRESHOLD
237
- $fXInertia = ($xLastIncr - INERTIA_THRESHOLD)*INERTIA_FACTOR
238
- end
239
- if -$xLastIncr > INERTIA_THRESHOLD
240
- $fXInertia = ($xLastIncr + INERTIA_THRESHOLD)*INERTIA_FACTOR
241
- end
242
-
243
- if $yLastIncr > INERTIA_THRESHOLD
244
- $fYInertia = ($yLastIncr - INERTIA_THRESHOLD)*INERTIA_FACTOR
245
- end
246
- if -$yLastIncr > INERTIA_THRESHOLD
247
- $fYInertia = ($yLastIncr + INERTIA_THRESHOLD)*INERTIA_FACTOR
248
- end
249
- else
250
- $fXInertia = 0
251
- $fYInertia = 0
252
- end
253
- $xLastIncr = 0
254
- $yLastIncr = 0
255
- end
233
+ $bmModifiers = glutGetModifiers()
234
+ if (button == GLUT_LEFT_BUTTON)
235
+ if (state == GLUT_UP)
236
+ $xLast = -1
237
+ $yLast = -1
238
+ if $xLastIncr > INERTIA_THRESHOLD
239
+ $fXInertia = ($xLastIncr - INERTIA_THRESHOLD)*INERTIA_FACTOR
240
+ end
241
+ if -$xLastIncr > INERTIA_THRESHOLD
242
+ $fXInertia = ($xLastIncr + INERTIA_THRESHOLD)*INERTIA_FACTOR
243
+ end
244
+
245
+ if $yLastIncr > INERTIA_THRESHOLD
246
+ $fYInertia = ($yLastIncr - INERTIA_THRESHOLD)*INERTIA_FACTOR
247
+ end
248
+ if -$yLastIncr > INERTIA_THRESHOLD
249
+ $fYInertia = ($yLastIncr + INERTIA_THRESHOLD)*INERTIA_FACTOR
250
+ end
251
+ else
252
+ $fXInertia = 0
253
+ $fYInertia = 0
254
+ end
255
+ $xLastIncr = 0
256
+ $yLastIncr = 0
257
+ end
256
258
  end
257
259
 
258
260
  special = lambda do |key,x,y|
259
- case key
260
- when GLUT_KEY_HOME:
261
- $fXDiff = 0
262
- $fYDiff = 35
263
- $fZDiff = 0
264
- $xLastIncr = 0
265
- $yLastIncr = 0
266
- $fXInertia = -0.5
267
- $fYInertia = 0
268
- $fScale = 1.0
269
- when GLUT_KEY_LEFT:
270
- $fXDiff -= 1
271
- when GLUT_KEY_RIGHT:
272
- $fXDiff += 1
273
- when GLUT_KEY_UP:
274
- $fYDiff -= 1
275
- when GLUT_KEY_DOWN:
276
- $fYDiff += 1
277
- end
261
+ case key
262
+ when GLUT_KEY_HOME
263
+ $fXDiff = 0
264
+ $fYDiff = 35
265
+ $fZDiff = 0
266
+ $xLastIncr = 0
267
+ $yLastIncr = 0
268
+ $fXInertia = -0.5
269
+ $fYInertia = 0
270
+ $fScale = 1.0
271
+ when GLUT_KEY_LEFT
272
+ $fXDiff -= 1
273
+ when GLUT_KEY_RIGHT
274
+ $fXDiff += 1
275
+ when GLUT_KEY_UP
276
+ $fYDiff -= 1
277
+ when GLUT_KEY_DOWN
278
+ $fYDiff += 1
279
+ end
278
280
  end
279
281
 
280
282
  timer = lambda do |value|
281
- $ftime += 0.01
282
- if $rotate
283
- $fXDiff += $fXInertia
284
- $fYDiff += $fYInertia
285
- end
286
- glutTimerFunc(TIMER_FREQUENCY_MILLIS , timer, 0)
283
+ $ftime += 0.01
284
+ if $rotate
285
+ $fXDiff += $fXInertia
286
+ $fYDiff += $fYInertia
287
+ end
288
+ glutTimerFunc(TIMER_FREQUENCY_MILLIS , timer, 0)
287
289
  end
288
290
 
289
291
  def getUniLoc(program, name)
290
- loc = glGetUniformLocation(program, name)
291
-
292
- if (loc == -1)
293
- puts "No such uniform named #{name}"
294
- end
295
- return loc
292
+ loc = glGetUniformLocation(program, name)
293
+
294
+ if (loc == -1)
295
+ puts "No such uniform named #{name}"
296
+ end
297
+ return loc
296
298
  end
297
299
 
298
300
  def installBrickShaders(vs_fname,fs_fname)
299
- # Create a vertex shader object and a fragment shader object
300
- brickVS = glCreateShader(GL_VERTEX_SHADER)
301
- brickFS = glCreateShader(GL_FRAGMENT_SHADER)
301
+ # Create a vertex shader object and a fragment shader object
302
+ brickVS = glCreateShader(GL_VERTEX_SHADER)
303
+ brickFS = glCreateShader(GL_FRAGMENT_SHADER)
302
304
 
303
- # Load source code strings into shaders
304
- glShaderSource(brickVS, File.read(vs_fname))
305
- glShaderSource(brickFS, File.read(fs_fname))
305
+ # Load source code strings into shaders
306
+ glShaderSource(brickVS, File.read(vs_fname))
307
+ glShaderSource(brickFS, File.read(fs_fname))
306
308
 
307
- # Compile the brick vertex shader, and print out
308
- # the compiler log file.
309
- glCompileShader(brickVS)
309
+ # Compile the brick vertex shader, and print out
310
+ # the compiler log file.
311
+ glCompileShader(brickVS)
310
312
  vertCompiled = glGetShaderiv(brickVS, GL_COMPILE_STATUS)
311
- puts "Shader InfoLog:\n#{glGetShaderInfoLog(brickVS)}\n"
312
-
313
- # Compile the brick fragment shader, and print out
314
- # the compiler log file.
315
- glCompileShader(brickFS)
313
+ puts "Shader InfoLog:\n#{glGetShaderInfoLog(brickVS)}\n"
314
+
315
+ # Compile the brick fragment shader, and print out
316
+ # the compiler log file.
317
+ glCompileShader(brickFS)
316
318
  fragCompiled = glGetShaderiv(brickFS, GL_COMPILE_STATUS)
317
- puts "Shader InfoLog:\n#{glGetShaderInfoLog(brickFS)}\n"
318
-
319
- return false if (vertCompiled == 0 || fragCompiled == 0)
320
- # Create a program object and attach the two compiled shaders
321
- brickProg = glCreateProgram()
322
- glAttachShader(brickProg,brickVS)
323
- glAttachShader(brickProg,brickFS)
324
- # Link the program object and print out the info log
325
- glLinkProgram(brickProg)
326
- linked = glGetProgramiv(brickProg,GL_LINK_STATUS)
327
- puts "Program InfoLog:\n#{glGetProgramInfoLog(brickProg)}\n"
328
- return false if linked==0
329
-
330
- # Install program object as part of current state
331
- glUseProgram(brickProg)
332
-
333
- # Set up initial uniform values
334
- glUniform3f(getUniLoc(brickProg, "BrickColor"), 1.0, 0.3, 0.2)
335
- glUniform3f(getUniLoc(brickProg, "MortarColor"), 0.85, 0.86, 0.84)
336
- glUniform2f(getUniLoc(brickProg, "BrickSize"), 0.30, 0.15)
337
- glUniform2f(getUniLoc(brickProg, "BrickPct"), 0.90, 0.85)
338
- glUniform3f(getUniLoc(brickProg, "LightPosition"), 0.0, 0.0, 4.0)
339
-
340
- return true
319
+ puts "Shader InfoLog:\n#{glGetShaderInfoLog(brickFS)}\n"
320
+
321
+ return false if (vertCompiled == 0 || fragCompiled == 0)
322
+ # Create a program object and attach the two compiled shaders
323
+ brickProg = glCreateProgram()
324
+ glAttachShader(brickProg,brickVS)
325
+ glAttachShader(brickProg,brickFS)
326
+ # Link the program object and print out the info log
327
+ glLinkProgram(brickProg)
328
+ linked = glGetProgramiv(brickProg,GL_LINK_STATUS)
329
+ puts "Program InfoLog:\n#{glGetProgramInfoLog(brickProg)}\n"
330
+ return false if linked==0
331
+
332
+ # Install program object as part of current state
333
+ glUseProgram(brickProg)
334
+
335
+ # Set up initial uniform values
336
+ glUniform3f(getUniLoc(brickProg, "BrickColor"), 1.0, 0.3, 0.2)
337
+ glUniform3f(getUniLoc(brickProg, "MortarColor"), 0.85, 0.86, 0.84)
338
+ glUniform2f(getUniLoc(brickProg, "BrickSize"), 0.30, 0.15)
339
+ glUniform2f(getUniLoc(brickProg, "BrickPct"), 0.90, 0.85)
340
+ glUniform3f(getUniLoc(brickProg, "LightPosition"), 0.0, 0.0, 4.0)
341
+
342
+ return true
341
343
  end
342
344
 
343
345
  # Main
@@ -356,13 +358,13 @@ glutMotionFunc(motion)
356
358
  glutMouseFunc(mouse)
357
359
  glutSpecialFunc(special)
358
360
  glutTimerFunc(TIMER_FREQUENCY_MILLIS , timer, 0)
359
-
361
+
360
362
  # Make sure that OpenGL 2.0 is supported by the driver
361
363
  if Gl.is_available?(2.0)==false
362
- major,minor,*rest = glGetString(GL_VERSION).split(/\.| /)
363
- puts "GL_VERSION major=#{major} minor=#{minor}"
364
- puts "Support for OpenGL 2.0 is required for this demo...exiting"
365
- exit(1)
364
+ major,minor,*rest = glGetString(GL_VERSION).split(/\.| /)
365
+ puts "GL_VERSION major=#{major} minor=#{minor}"
366
+ puts "Support for OpenGL 2.0 is required for this demo...exiting"
367
+ exit(1)
366
368
  end
367
369
 
368
370
  glDepthFunc(GL_LESS)
@@ -371,6 +373,6 @@ glEnable(GL_DEPTH_TEST)
371
373
  nextClearColor()
372
374
 
373
375
  key.call('?', 0, 0)
374
-
376
+
375
377
  success = installBrickShaders("brick.vert","brick.frag")
376
378
  glutMainLoop() if success == true