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
@@ -1,13 +1,13 @@
1
1
  #
2
2
  # Copyright (c) 1993-1997, Silicon Graphics, Inc.
3
- # ALL RIGHTS RESERVED
4
- # Permission to use, copy, modify, and distribute this software for
3
+ # ALL RIGHTS RESERVED
4
+ # Permission to use, copy, modify, and distribute this software for
5
5
  # any purpose and without fee is hereby granted, provided that the above
6
6
  # copyright notice appear in all copies and that both the copyright notice
7
- # and this permission notice appear in supporting documentation, and that
7
+ # and this permission notice appear in supporting documentation, and that
8
8
  # the name of Silicon Graphics, Inc. not be used in advertising
9
9
  # or publicity pertaining to distribution of the software without specific,
10
- # written prior permission.
10
+ # written prior permission.
11
11
  #
12
12
  # THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
13
13
  # AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
@@ -21,8 +21,8 @@
21
21
  # ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
22
22
  # ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
23
23
  # POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
24
- #
25
- # US Government Users Restricted Rights
24
+ #
25
+ # US Government Users Restricted Rights
26
26
  # Use, duplication, or disclosure by the Government is subject to
27
27
  # restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
28
28
  # (c)(1)(ii) of the Rights in Technical Data and Computer Software
@@ -43,37 +43,39 @@
43
43
  # Note the exterior rectangle is drawn with its vertices
44
44
  # in counter-clockwise order, but its interior clockwise.
45
45
  # Note the combineCallback is needed for the self-intersecting
46
- # star. Also note that removing the TessProperty for the
46
+ # star. Also note that removing the TessProperty for the
47
47
  # star will make the interior unshaded (WINDING_ODD).
48
48
  require 'opengl'
49
+ require 'glu'
50
+ require 'glut'
49
51
  include Gl,Glu,Glut
50
52
 
51
53
  $startList = nil
52
54
 
53
55
  display = proc do
54
- glClear(GL_COLOR_BUFFER_BIT)
55
- glColor(1.0, 1.0, 1.0)
56
- glCallList($startList)
57
- glCallList($startList + 1)
58
- glutSwapBuffers()
56
+ glClear(GL_COLOR_BUFFER_BIT)
57
+ glColor(1.0, 1.0, 1.0)
58
+ glCallList($startList)
59
+ glCallList($startList + 1)
60
+ glutSwapBuffers()
59
61
  end
60
62
 
61
63
  $beginCallback = proc do |which|
62
- glBegin(which)
64
+ glBegin(which)
63
65
  end
64
66
 
65
67
  $errorCallback = proc do |errorCode|
66
- print "Tessellation Error: #{gluErrorString(errorCode)}"
67
- exit(0)
68
+ print "Tessellation Error: #{gluErrorString(errorCode)}"
69
+ exit(0)
68
70
  end
69
71
 
70
72
  $endCallback = proc do
71
- glEnd()
73
+ glEnd()
72
74
  end
73
75
 
74
76
  $vertexCallback = proc do |vertex|
75
- glColor(vertex[3], vertex[4], vertex[5])
76
- glVertex(vertex[0], vertex[1], vertex[2])
77
+ glColor(vertex[3], vertex[4], vertex[5])
78
+ glVertex(vertex[0], vertex[1], vertex[2])
77
79
  end
78
80
 
79
81
  # combineCallback is used to create a new vertex when edges
@@ -81,94 +83,94 @@ end
81
83
  # but weight[4] may be used to average color, normal, or texture
82
84
  # coordinate data. In this program, color is weighted.
83
85
  $combineCallback = proc do |coords, vertex_data, weight|
84
- vertex = []
85
- vertex[0] = coords[0]
86
- vertex[1] = coords[1]
87
- vertex[2] = coords[2]
88
- for i in 3...6
89
- vertex[i] = weight[0] * vertex_data[0][i] + weight[1] * vertex_data[1][i] + weight[2] * vertex_data[2][i] + weight[3] * vertex_data[3][i]
90
- end
91
- vertex
86
+ vertex = []
87
+ vertex[0] = coords[0]
88
+ vertex[1] = coords[1]
89
+ vertex[2] = coords[2]
90
+ for i in 3...6
91
+ vertex[i] = weight[0] * vertex_data[0][i] + weight[1] * vertex_data[1][i] + weight[2] * vertex_data[2][i] + weight[3] * vertex_data[3][i]
92
+ end
93
+ vertex
92
94
  end
93
95
 
94
96
  def init
95
- rect = [[50.0, 50.0, 0.0],
96
- [200.0, 50.0, 0.0],
97
- [200.0, 200.0, 0.0],
98
- [50.0, 200.0, 0.0]]
99
- tri = [[75.0, 75.0, 0.0],
100
- [125.0, 175.0, 0.0],
101
- [175.0, 75.0, 0.0]]
102
- star= [[250.0, 50.0, 0.0, 1.0, 0.0, 1.0],
103
- [325.0, 200.0, 0.0, 1.0, 1.0, 0.0],
104
- [400.0, 50.0, 0.0, 0.0, 1.0, 1.0],
105
- [250.0, 150.0, 0.0, 1.0, 0.0, 0.0],
106
- [400.0, 150.0, 0.0, 0.0, 1.0, 0.0]]
107
-
108
- glClearColor(0.0, 0.0, 0.0, 0.0)
109
-
110
- $startList = glGenLists(2)
111
-
112
- tobj = gluNewTess()
113
- gluTessCallback(tobj, GLU_TESS_VERTEX, proc do |v| glVertex(v) end )
114
- gluTessCallback(tobj, GLU_TESS_BEGIN, $beginCallback)
115
- gluTessCallback(tobj, GLU_TESS_END, $endCallback)
116
- gluTessCallback(tobj, GLU_TESS_ERROR, $errorCallback)
117
-
118
- # rectangle with triangular hole inside
119
- glNewList($startList, GL_COMPILE)
120
- glShadeModel(GL_FLAT)
121
- gluTessBeginPolygon(tobj, nil)
122
- gluTessBeginContour(tobj)
123
- gluTessVertex(tobj, rect[0], rect[0])
124
- gluTessVertex(tobj, rect[1], rect[1])
125
- gluTessVertex(tobj, rect[2], rect[2])
126
- gluTessVertex(tobj, rect[3], rect[3])
127
- gluTessEndContour(tobj)
128
- gluTessBeginContour(tobj)
129
- gluTessVertex(tobj, tri[0], tri[0])
130
- gluTessVertex(tobj, tri[1], tri[1])
131
- gluTessVertex(tobj, tri[2], tri[2])
132
- gluTessEndContour(tobj)
133
- gluTessEndPolygon(tobj)
134
- glEndList()
135
-
136
- gluTessCallback(tobj, GLU_TESS_VERTEX, $vertexCallback)
137
- gluTessCallback(tobj, GLU_TESS_BEGIN, $beginCallback)
138
- gluTessCallback(tobj, GLU_TESS_END, $endCallback)
139
- gluTessCallback(tobj, GLU_TESS_ERROR, $errorCallback)
140
- gluTessCallback(tobj, GLU_TESS_COMBINE, $combineCallback)
97
+ rect = [[50.0, 50.0, 0.0],
98
+ [200.0, 50.0, 0.0],
99
+ [200.0, 200.0, 0.0],
100
+ [50.0, 200.0, 0.0]]
101
+ tri = [[75.0, 75.0, 0.0],
102
+ [125.0, 175.0, 0.0],
103
+ [175.0, 75.0, 0.0]]
104
+ star= [[250.0, 50.0, 0.0, 1.0, 0.0, 1.0],
105
+ [325.0, 200.0, 0.0, 1.0, 1.0, 0.0],
106
+ [400.0, 50.0, 0.0, 0.0, 1.0, 1.0],
107
+ [250.0, 150.0, 0.0, 1.0, 0.0, 0.0],
108
+ [400.0, 150.0, 0.0, 0.0, 1.0, 0.0]]
109
+
110
+ glClearColor(0.0, 0.0, 0.0, 0.0)
111
+
112
+ $startList = glGenLists(2)
113
+
114
+ tobj = gluNewTess()
115
+ gluTessCallback(tobj, GLU_TESS_VERTEX, proc do |v| glVertex(v) end )
116
+ gluTessCallback(tobj, GLU_TESS_BEGIN, $beginCallback)
117
+ gluTessCallback(tobj, GLU_TESS_END, $endCallback)
118
+ gluTessCallback(tobj, GLU_TESS_ERROR, $errorCallback)
119
+
120
+ # rectangle with triangular hole inside
121
+ glNewList($startList, GL_COMPILE)
122
+ glShadeModel(GL_FLAT)
123
+ gluTessBeginPolygon(tobj, nil)
124
+ gluTessBeginContour(tobj)
125
+ gluTessVertex(tobj, rect[0], rect[0])
126
+ gluTessVertex(tobj, rect[1], rect[1])
127
+ gluTessVertex(tobj, rect[2], rect[2])
128
+ gluTessVertex(tobj, rect[3], rect[3])
129
+ gluTessEndContour(tobj)
130
+ gluTessBeginContour(tobj)
131
+ gluTessVertex(tobj, tri[0], tri[0])
132
+ gluTessVertex(tobj, tri[1], tri[1])
133
+ gluTessVertex(tobj, tri[2], tri[2])
134
+ gluTessEndContour(tobj)
135
+ gluTessEndPolygon(tobj)
136
+ glEndList()
137
+
138
+ gluTessCallback(tobj, GLU_TESS_VERTEX, $vertexCallback)
139
+ gluTessCallback(tobj, GLU_TESS_BEGIN, $beginCallback)
140
+ gluTessCallback(tobj, GLU_TESS_END, $endCallback)
141
+ gluTessCallback(tobj, GLU_TESS_ERROR, $errorCallback)
142
+ gluTessCallback(tobj, GLU_TESS_COMBINE, $combineCallback)
141
143
 
142
144
 
143
145
  # smooth shaded, self-intersecting star
144
- glNewList($startList + 1, GL_COMPILE)
145
- glShadeModel(GL_SMOOTH)
146
- gluTessProperty(tobj, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_POSITIVE)
147
- gluTessBeginPolygon(tobj, nil)
148
- gluTessBeginContour(tobj)
149
- gluTessVertex(tobj, star[0], star[0])
150
- gluTessVertex(tobj, star[1], star[1])
151
- gluTessVertex(tobj, star[2], star[2])
152
- gluTessVertex(tobj, star[3], star[3])
153
- gluTessVertex(tobj, star[4], star[4])
154
- gluTessEndContour(tobj)
155
- gluTessEndPolygon(tobj)
156
- glEndList()
157
- gluDeleteTess(tobj)
146
+ glNewList($startList + 1, GL_COMPILE)
147
+ glShadeModel(GL_SMOOTH)
148
+ gluTessProperty(tobj, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_POSITIVE)
149
+ gluTessBeginPolygon(tobj, nil)
150
+ gluTessBeginContour(tobj)
151
+ gluTessVertex(tobj, star[0], star[0])
152
+ gluTessVertex(tobj, star[1], star[1])
153
+ gluTessVertex(tobj, star[2], star[2])
154
+ gluTessVertex(tobj, star[3], star[3])
155
+ gluTessVertex(tobj, star[4], star[4])
156
+ gluTessEndContour(tobj)
157
+ gluTessEndPolygon(tobj)
158
+ glEndList()
159
+ gluDeleteTess(tobj)
158
160
  end
159
161
 
160
162
  reshape = proc do |w, h|
161
- glViewport(0, 0, w, h)
162
- glMatrixMode(GL_PROJECTION)
163
- glLoadIdentity()
164
- gluOrtho2D(0.0, w, 0.0, h)
163
+ glViewport(0, 0, w, h)
164
+ glMatrixMode(GL_PROJECTION)
165
+ glLoadIdentity()
166
+ gluOrtho2D(0.0, w, 0.0, h)
165
167
  end
166
168
 
167
169
  keyboard = proc do |key, x, y|
168
- case (key)
169
- when ?\e
170
- exit(0)
171
- end
170
+ case (key)
171
+ when ?\e
172
+ exit(0)
173
+ end
172
174
  end
173
175
 
174
176
  glutInit()
@@ -1,13 +1,13 @@
1
1
  #
2
2
  # Copyright (c) 1993-1997, Silicon Graphics, Inc.
3
- # ALL RIGHTS RESERVED
4
- # Permission to use, copy, modify, and distribute this software for
3
+ # ALL RIGHTS RESERVED
4
+ # Permission to use, copy, modify, and distribute this software for
5
5
  # any purpose and without fee is hereby granted, provided that the above
6
6
  # copyright notice appear in all copies and that both the copyright notice
7
- # and this permission notice appear in supporting documentation, and that
7
+ # and this permission notice appear in supporting documentation, and that
8
8
  # the name of Silicon Graphics, Inc. not be used in advertising
9
9
  # or publicity pertaining to distribution of the software without specific,
10
- # written prior permission.
10
+ # written prior permission.
11
11
  #
12
12
  # THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
13
13
  # AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
@@ -21,8 +21,8 @@
21
21
  # ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
22
22
  # ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
23
23
  # POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
24
- #
25
- # US Government Users Restricted Rights
24
+ #
25
+ # US Government Users Restricted Rights
26
26
  # Use, duplication, or disclosure by the Government is subject to
27
27
  # restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
28
28
  # (c)(1)(ii) of the Rights in Technical Data and Computer Software
@@ -36,9 +36,11 @@
36
36
  #
37
37
 
38
38
  # texbind.c
39
- # This program demonstrates using glBindTexture() by
39
+ # This program demonstrates using glBindTexture() by
40
40
  # creating and managing two textures.
41
41
  require 'opengl'
42
+ require 'glu'
43
+ require 'glut'
42
44
  require 'mathn'
43
45
  include Gl,Glu,Glut
44
46
 
@@ -50,88 +52,88 @@ $otherImage = []
50
52
  $texName = []
51
53
 
52
54
  def makeCheckImages
53
- for i in (0..CheckImageHeight-1)
54
- for j in (0..CheckImageWidth-1)
55
- if ((i&0x8==0)!=(j&0x8==0)) then tmp = 1 else tmp=0 end
56
- #c = ((((i&0x8)==0)^((j&0x8))==0))*255
57
- c = tmp * 255
58
- $checkImage[i*CheckImageWidth*4+j*4+0] = c
59
- $checkImage[i*CheckImageWidth*4+j*4+1] = c
60
- $checkImage[i*CheckImageWidth*4+j*4+2] = c
61
- $checkImage[i*CheckImageWidth*4+j*4+3] = 255
62
- #c = ((((i&0x10)==0)^((j&0x10))==0))*255
63
- if ((i&0x10==0)!=(j&0x10==0)) then tmp = 1 else tmp=0 end
64
- c = tmp * 255
65
- $otherImage[i*CheckImageWidth*4+j*4+0] = c
66
- $otherImage[i*CheckImageWidth*4+j*4+1] = 0
67
- $otherImage[i*CheckImageWidth*4+j*4+2] = 0
68
- $otherImage[i*CheckImageWidth*4+j*4+3] = 255
69
- end
70
- end
55
+ for i in (0..CheckImageHeight-1)
56
+ for j in (0..CheckImageWidth-1)
57
+ if ((i&0x8==0)!=(j&0x8==0)) then tmp = 1 else tmp=0 end
58
+ #c = ((((i&0x8)==0)^((j&0x8))==0))*255
59
+ c = tmp * 255
60
+ $checkImage[i*CheckImageWidth*4+j*4+0] = c
61
+ $checkImage[i*CheckImageWidth*4+j*4+1] = c
62
+ $checkImage[i*CheckImageWidth*4+j*4+2] = c
63
+ $checkImage[i*CheckImageWidth*4+j*4+3] = 255
64
+ #c = ((((i&0x10)==0)^((j&0x10))==0))*255
65
+ if ((i&0x10==0)!=(j&0x10==0)) then tmp = 1 else tmp=0 end
66
+ c = tmp * 255
67
+ $otherImage[i*CheckImageWidth*4+j*4+0] = c
68
+ $otherImage[i*CheckImageWidth*4+j*4+1] = 0
69
+ $otherImage[i*CheckImageWidth*4+j*4+2] = 0
70
+ $otherImage[i*CheckImageWidth*4+j*4+3] = 255
71
+ end
72
+ end
71
73
  end
72
74
 
73
75
  def init
74
- glClearColor(0.0, 0.0, 0.0, 0.0)
75
- glShadeModel(GL_FLAT)
76
- glEnable(GL_DEPTH_TEST)
77
-
78
- makeCheckImages()
79
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
80
-
81
- $texName = glGenTextures(2)
82
- glBindTexture(GL_TEXTURE_2D, $texName[0])
83
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP)
84
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP)
85
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,GL_NEAREST)
86
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_NEAREST)
87
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, CheckImageWidth,
88
- CheckImageHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, $checkImage.pack("C*"))
89
-
90
- glBindTexture(GL_TEXTURE_2D, $texName[1])
91
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP)
92
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP)
93
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
94
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
95
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL)
96
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, CheckImageWidth, CheckImageHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE,
97
- $otherImage.pack("C*"))
98
- glEnable(GL_TEXTURE_2D)
76
+ glClearColor(0.0, 0.0, 0.0, 0.0)
77
+ glShadeModel(GL_FLAT)
78
+ glEnable(GL_DEPTH_TEST)
79
+
80
+ makeCheckImages()
81
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
82
+
83
+ $texName = glGenTextures(2)
84
+ glBindTexture(GL_TEXTURE_2D, $texName[0])
85
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP)
86
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP)
87
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,GL_NEAREST)
88
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_NEAREST)
89
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, CheckImageWidth,
90
+ CheckImageHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, $checkImage.pack("C*"))
91
+
92
+ glBindTexture(GL_TEXTURE_2D, $texName[1])
93
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP)
94
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP)
95
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
96
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
97
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL)
98
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, CheckImageWidth, CheckImageHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE,
99
+ $otherImage.pack("C*"))
100
+ glEnable(GL_TEXTURE_2D)
99
101
  end
100
102
 
101
103
  display = Proc.new do
102
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
103
- glBindTexture(GL_TEXTURE_2D, $texName[0])
104
- glBegin(GL_QUADS)
105
- glTexCoord(0.0, 0.0); glVertex(-2.0, -1.0, 0.0)
106
- glTexCoord(0.0, 1.0); glVertex(-2.0, 1.0, 0.0)
107
- glTexCoord(1.0, 1.0); glVertex(0.0, 1.0, 0.0)
108
- glTexCoord(1.0, 0.0); glVertex(0.0, -1.0, 0.0)
109
- glEnd()
110
- glBindTexture(GL_TEXTURE_2D, $texName[1])
111
- glBegin(GL_QUADS)
112
- glTexCoord(0.0, 0.0); glVertex(1.0, -1.0, 0.0)
113
- glTexCoord(0.0, 1.0); glVertex(1.0, 1.0, 0.0)
114
- glTexCoord(1.0, 1.0); glVertex(2.41421, 1.0, -1.41421)
115
- glTexCoord(1.0, 0.0); glVertex(2.41421, -1.0, -1.41421)
116
- glEnd()
117
- glutSwapBuffers()
104
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
105
+ glBindTexture(GL_TEXTURE_2D, $texName[0])
106
+ glBegin(GL_QUADS)
107
+ glTexCoord(0.0, 0.0); glVertex(-2.0, -1.0, 0.0)
108
+ glTexCoord(0.0, 1.0); glVertex(-2.0, 1.0, 0.0)
109
+ glTexCoord(1.0, 1.0); glVertex(0.0, 1.0, 0.0)
110
+ glTexCoord(1.0, 0.0); glVertex(0.0, -1.0, 0.0)
111
+ glEnd()
112
+ glBindTexture(GL_TEXTURE_2D, $texName[1])
113
+ glBegin(GL_QUADS)
114
+ glTexCoord(0.0, 0.0); glVertex(1.0, -1.0, 0.0)
115
+ glTexCoord(0.0, 1.0); glVertex(1.0, 1.0, 0.0)
116
+ glTexCoord(1.0, 1.0); glVertex(2.41421, 1.0, -1.41421)
117
+ glTexCoord(1.0, 0.0); glVertex(2.41421, -1.0, -1.41421)
118
+ glEnd()
119
+ glutSwapBuffers()
118
120
  end
119
121
 
120
122
  reshape = Proc.new do |w, h|
121
- glViewport(0, 0, w, h)
122
- glMatrixMode(GL_PROJECTION)
123
- glLoadIdentity()
124
- gluPerspective(60.0, w/h, 1.0, 30.0)
125
- glMatrixMode(GL_MODELVIEW)
126
- glLoadIdentity()
127
- glTranslate(0.0, 0.0, -3.6)
123
+ glViewport(0, 0, w, h)
124
+ glMatrixMode(GL_PROJECTION)
125
+ glLoadIdentity()
126
+ gluPerspective(60.0, w/h, 1.0, 30.0)
127
+ glMatrixMode(GL_MODELVIEW)
128
+ glLoadIdentity()
129
+ glTranslate(0.0, 0.0, -3.6)
128
130
  end
129
131
 
130
132
  keyboard = Proc.new do |key, x, y|
131
- case (key)
132
- when ?\e
133
- exit(0)
134
- end
133
+ case (key)
134
+ when ?\e
135
+ exit(0)
136
+ end
135
137
  end
136
138
 
137
139
  # main
@@ -1,13 +1,13 @@
1
1
  #
2
2
  # Copyright (c) 1993-1997, Silicon Graphics, Inc.
3
- # ALL RIGHTS RESERVED
4
- # Permission to use, copy, modify, and distribute this software for
3
+ # ALL RIGHTS RESERVED
4
+ # Permission to use, copy, modify, and distribute this software for
5
5
  # any purpose and without fee is hereby granted, provided that the above
6
6
  # copyright notice appear in all copies and that both the copyright notice
7
- # and this permission notice appear in supporting documentation, and that
7
+ # and this permission notice appear in supporting documentation, and that
8
8
  # the name of Silicon Graphics, Inc. not be used in advertising
9
9
  # or publicity pertaining to distribution of the software without specific,
10
- # written prior permission.
10
+ # written prior permission.
11
11
  #
12
12
  # THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
13
13
  # AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
@@ -21,8 +21,8 @@
21
21
  # ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
22
22
  # ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
23
23
  # POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
24
- #
25
- # US Government Users Restricted Rights
24
+ #
25
+ # US Government Users Restricted Rights
26
26
  # Use, duplication, or disclosure by the Government is subject to
27
27
  # restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
28
28
  # (c)(1)(ii) of the Rights in Technical Data and Computer Software
@@ -35,7 +35,7 @@
35
35
  # OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
36
36
  #
37
37
  # texgen.c
38
- # This program draws a texture mapped teapot with
38
+ # This program draws a texture mapped teapot with
39
39
  # automatically generated texture coordinates. The
40
40
  # texture is rendered as stripes on the teapot.
41
41
  # Initially, the object is drawn with texture coordinates
@@ -43,11 +43,13 @@
43
43
  # and distance from the plane x = 0. Pressing the 'e'
44
44
  # key changes the coordinate generation to eye coordinates
45
45
  # of the vertex. Pressing the 'o' key switches it back
46
- # to the object coordinates. Pressing the 's' key
46
+ # to the object coordinates. Pressing the 's' key
47
47
  # changes the plane to a slanted one (x + y + z = 0).
48
48
  # Pressing the 'x' key switches it back to x = 0.
49
49
 
50
50
  require 'opengl'
51
+ require 'glu'
52
+ require 'glut'
51
53
  require 'mathn'
52
54
  include Gl,Glu,Glut
53
55
 
@@ -57,12 +59,12 @@ $stripeImage = []
57
59
  $texName
58
60
 
59
61
  def makeStripeImage
60
- for j in (0..StripeImageWidth-1)
61
- $stripeImage[4*j] = if (j<=4) then 255 else 0 end
62
- $stripeImage[4*j+1] = if (j>4) then 255 else 0 end
63
- $stripeImage[4*j+2] = 0
64
- $stripeImage[4*j+3] = 255
65
- end
62
+ for j in (0..StripeImageWidth-1)
63
+ $stripeImage[4*j] = if (j<=4) then 255 else 0 end
64
+ $stripeImage[4*j+1] = if (j>4) then 255 else 0 end
65
+ $stripeImage[4*j+2] = 0
66
+ $stripeImage[4*j+3] = 255
67
+ end
66
68
  end
67
69
 
68
70
  # planes for texture coordinate generation
@@ -73,87 +75,87 @@ $currentPlane = nil
73
75
  $currentGenMode = nil
74
76
 
75
77
  def init
76
- glClearColor(0.0, 0.0, 0.0, 0.0)
77
- glEnable(GL_DEPTH_TEST)
78
- glShadeModel(GL_SMOOTH)
79
-
80
- makeStripeImage()
81
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
82
-
83
- $texName = glGenTextures(1)
84
- glBindTexture(GL_TEXTURE_2D, $texName[0])
85
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
86
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
87
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
88
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, StripeImageWidth, 1, 0,
89
- GL_RGBA, GL_UNSIGNED_BYTE, $stripeImage.pack("C*"))
90
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE)
91
- $currentCoeff = $xequalzero
92
- $currentGenMode = GL_OBJECT_LINEAR
93
- $currentPlane = GL_OBJECT_PLANE
94
- glTexGen(GL_S, GL_TEXTURE_GEN_MODE, $currentGenMode)
95
- glTexGen(GL_S, $currentPlane, $currentCoeff)
96
-
97
- glEnable(GL_TEXTURE_GEN_S)
98
- glEnable(GL_TEXTURE_2D)
99
- glEnable(GL_CULL_FACE)
100
- glEnable(GL_LIGHTING)
101
- glEnable(GL_LIGHT0)
102
- glEnable(GL_AUTO_NORMAL)
103
- glEnable(GL_NORMALIZE)
104
- glFrontFace(GL_CW)
105
- glCullFace(GL_BACK)
106
- glMaterial(GL_FRONT, GL_SHININESS, 64.0)
78
+ glClearColor(0.0, 0.0, 0.0, 0.0)
79
+ glEnable(GL_DEPTH_TEST)
80
+ glShadeModel(GL_SMOOTH)
81
+
82
+ makeStripeImage()
83
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
84
+
85
+ $texName = glGenTextures(1)
86
+ glBindTexture(GL_TEXTURE_2D, $texName[0])
87
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
88
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
89
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
90
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, StripeImageWidth, 1, 0,
91
+ GL_RGBA, GL_UNSIGNED_BYTE, $stripeImage.pack("C*"))
92
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE)
93
+ $currentCoeff = $xequalzero
94
+ $currentGenMode = GL_OBJECT_LINEAR
95
+ $currentPlane = GL_OBJECT_PLANE
96
+ glTexGen(GL_S, GL_TEXTURE_GEN_MODE, $currentGenMode)
97
+ glTexGen(GL_S, $currentPlane, $currentCoeff)
98
+
99
+ glEnable(GL_TEXTURE_GEN_S)
100
+ glEnable(GL_TEXTURE_2D)
101
+ glEnable(GL_CULL_FACE)
102
+ glEnable(GL_LIGHTING)
103
+ glEnable(GL_LIGHT0)
104
+ glEnable(GL_AUTO_NORMAL)
105
+ glEnable(GL_NORMALIZE)
106
+ glFrontFace(GL_CW)
107
+ glCullFace(GL_BACK)
108
+ glMaterial(GL_FRONT, GL_SHININESS, 64.0)
107
109
  end
108
110
 
109
111
  display = Proc.new do
110
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
111
- glPushMatrix()
112
- glRotate(45.0, 0.0, 0.0, 1.0)
113
- glBindTexture(GL_TEXTURE_2D, $texName[0])
114
- glutSolidTeapot(2.0)
115
- glPopMatrix()
116
- glutSwapBuffers()
112
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
113
+ glPushMatrix()
114
+ glRotate(45.0, 0.0, 0.0, 1.0)
115
+ glBindTexture(GL_TEXTURE_2D, $texName[0])
116
+ glutSolidTeapot(2.0)
117
+ glPopMatrix()
118
+ glutSwapBuffers()
117
119
  end
118
120
 
119
121
  reshape = Proc.new do |w, h|
120
- glViewport(0, 0, w, h)
121
- glMatrixMode(GL_PROJECTION)
122
- glLoadIdentity()
123
- if (w <= h)
124
- glOrtho(-3.5, 3.5, -3.5*h/w,3.5*h/w, -3.5, 3.5)
125
- else
126
- glOrtho(-3.5*w/h, 3.5*w/h, -3.5, 3.5, -3.5, 3.5)
127
- end
128
- glMatrixMode(GL_MODELVIEW)
129
- glLoadIdentity()
122
+ glViewport(0, 0, w, h)
123
+ glMatrixMode(GL_PROJECTION)
124
+ glLoadIdentity()
125
+ if (w <= h)
126
+ glOrtho(-3.5, 3.5, -3.5*h/w,3.5*h/w, -3.5, 3.5)
127
+ else
128
+ glOrtho(-3.5*w/h, 3.5*w/h, -3.5, 3.5, -3.5, 3.5)
129
+ end
130
+ glMatrixMode(GL_MODELVIEW)
131
+ glLoadIdentity()
130
132
  end
131
133
 
132
134
  keyboard = Proc.new do |key, x, y|
133
- case (key)
134
- when ?e,?E
135
- $currentGenMode = GL_EYE_LINEAR
136
- $currentPlane = GL_EYE_PLANE
137
- glTexGen(GL_S, GL_TEXTURE_GEN_MODE, $currentGenMode)
138
- glTexGen(GL_S, $currentPlane, $currentCoeff)
139
- glutPostRedisplay()
140
- when ?o, ?O
141
- $currentGenMode = GL_OBJECT_LINEAR
142
- $currentPlane = GL_OBJECT_PLANE
143
- glTexGen(GL_S, GL_TEXTURE_GEN_MODE, $currentGenMode)
144
- glTexGen(GL_S, $currentPlane, $currentCoeff)
145
- glutPostRedisplay()
146
- when ?s,?S
147
- $currentCoeff = $slanted
148
- glTexGen(GL_S, $currentPlane, $currentCoeff)
149
- glutPostRedisplay()
150
- when ?x,?X
151
- $currentCoeff = $xequalzero
152
- glTexGen(GL_S, $currentPlane, $currentCoeff)
153
- glutPostRedisplay()
154
- when ?\e
155
- exit(0)
156
- end
135
+ case (key)
136
+ when ?e,?E
137
+ $currentGenMode = GL_EYE_LINEAR
138
+ $currentPlane = GL_EYE_PLANE
139
+ glTexGen(GL_S, GL_TEXTURE_GEN_MODE, $currentGenMode)
140
+ glTexGen(GL_S, $currentPlane, $currentCoeff)
141
+ glutPostRedisplay()
142
+ when ?o, ?O
143
+ $currentGenMode = GL_OBJECT_LINEAR
144
+ $currentPlane = GL_OBJECT_PLANE
145
+ glTexGen(GL_S, GL_TEXTURE_GEN_MODE, $currentGenMode)
146
+ glTexGen(GL_S, $currentPlane, $currentCoeff)
147
+ glutPostRedisplay()
148
+ when ?s,?S
149
+ $currentCoeff = $slanted
150
+ glTexGen(GL_S, $currentPlane, $currentCoeff)
151
+ glutPostRedisplay()
152
+ when ?x,?X
153
+ $currentCoeff = $xequalzero
154
+ glTexGen(GL_S, $currentPlane, $currentCoeff)
155
+ glutPostRedisplay()
156
+ when ?\e
157
+ exit(0)
158
+ end
157
159
  end
158
160
 
159
161
  # main