opengl 0.8.0-x86-mingw32 → 0.9.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +1 -0
  3. data.tar.gz.sig +2 -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/1.9/opengl.so +0 -0
  103. data/lib/opengl/2.0/opengl.so +0 -0
  104. data/lib/opengl/2.1/opengl.so +0 -0
  105. data/lib/opengl/test_case.rb +1 -2
  106. data/test/dummy.xorg.conf +140 -0
  107. data/test/test_gl.rb +18 -22
  108. data/test/test_gl_10_11.rb +220 -220
  109. data/test/test_gl_12.rb +11 -122
  110. data/test/test_gl_13.rb +202 -210
  111. data/test/test_gl_14.rb +16 -19
  112. data/test/test_gl_15.rb +2 -4
  113. data/test/test_gl_20.rb +45 -58
  114. data/test/test_gl_21.rb +46 -163
  115. data/test/test_gl_ext_arb.rb +54 -72
  116. data/test/test_gl_ext_ati.rb +0 -2
  117. data/test/test_gl_ext_ext.rb +66 -66
  118. data/test/test_gl_ext_gremedy.rb +8 -15
  119. data/test/test_gl_ext_nv.rb +109 -112
  120. data/test/test_opengl_buffer.rb +8 -25
  121. data/utils/README +0 -5
  122. data/utils/enumgen.rb +72 -76
  123. data/utils/extlistgen.rb +55 -55
  124. metadata +90 -67
  125. metadata.gz.sig +0 -0
  126. data/Rakefile.cross +0 -107
  127. data/docs/build_install.txt +0 -119
  128. data/docs/extensions.txt.in +0 -348
  129. data/docs/history.txt +0 -66
  130. data/docs/requirements_and_design.txt +0 -117
  131. data/docs/roadmap.txt +0 -28
  132. data/docs/scientific_use.txt +0 -35
  133. data/docs/supplies/page_template.html +0 -71
  134. data/docs/thanks.txt +0 -29
  135. data/docs/tutorial.txt +0 -469
  136. data/ext/opengl/glu-enums.c +0 -164
  137. data/ext/opengl/glu-enums.h +0 -463
  138. data/ext/opengl/glu.c +0 -1534
  139. data/ext/opengl/glut.c +0 -1145
  140. data/ext/opengl/glut_callbacks.c +0 -845
  141. data/lib/glu.rb +0 -1
  142. data/lib/glut.rb +0 -1
  143. data/lib/opengl/opengl.so +0 -0
  144. data/test/test_glu.rb +0 -309
  145. data/utils/mkdn2html.rb +0 -59
  146. data/utils/post-mkdn2html.rb +0 -91
  147. data/website/images/ogl.jpg +0 -0
  148. data/website/images/tab_bottom.gif +0 -0
  149. 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
@@ -37,101 +37,103 @@
37
37
  # feedback.c
38
38
  # This program demonstrates use of OpenGL feedback. First,
39
39
  # a lighting environment is set up and a few lines are drawn.
40
- # Then feedback mode is entered, and the same lines are
40
+ # Then feedback mode is entered, and the same lines are
41
41
  # drawn. The results in the feedback buffer are printed.
42
42
  require 'opengl'
43
+ require 'glu'
44
+ require 'glut'
43
45
  include Gl,Glu,Glut
44
46
 
45
47
  # Initialize lighting.
46
48
  def init
47
- glEnable(GL_LIGHTING)
48
- glEnable(GL_LIGHT0)
49
+ glEnable(GL_LIGHTING)
50
+ glEnable(GL_LIGHT0)
49
51
  end
50
52
 
51
- # Draw a few lines and two points, one of which will
52
- # be clipped. If in feedback mode, a passthrough token
53
+ # Draw a few lines and two points, one of which will
54
+ # be clipped. If in feedback mode, a passthrough token
53
55
  # is issued between the each primitive.
54
56
  def drawGeometry(mode)
55
- glBegin(GL_LINE_STRIP)
56
- glNormal(0.0, 0.0, 1.0)
57
- glVertex(30.0, 30.0, 0.0)
58
- glVertex(50.0, 60.0, 0.0)
59
- glVertex(70.0, 40.0, 0.0)
60
- glEnd()
61
- if (mode == GL_FEEDBACK)
62
- glPassThrough(1.0)
63
- end
64
- glBegin(GL_POINTS)
65
- glVertex(-100.0, -100.0, -100.0) # will be clipped
66
- glEnd()
67
- if (mode == GL_FEEDBACK)
68
- glPassThrough(2.0)
69
- end
70
- glBegin(GL_POINTS)
71
- glNormal(0.0, 0.0, 1.0)
72
- glVertex(50.0, 50.0, 0.0)
73
- glEnd()
57
+ glBegin(GL_LINE_STRIP)
58
+ glNormal(0.0, 0.0, 1.0)
59
+ glVertex(30.0, 30.0, 0.0)
60
+ glVertex(50.0, 60.0, 0.0)
61
+ glVertex(70.0, 40.0, 0.0)
62
+ glEnd()
63
+ if (mode == GL_FEEDBACK)
64
+ glPassThrough(1.0)
65
+ end
66
+ glBegin(GL_POINTS)
67
+ glVertex(-100.0, -100.0, -100.0) # will be clipped
68
+ glEnd()
69
+ if (mode == GL_FEEDBACK)
70
+ glPassThrough(2.0)
71
+ end
72
+ glBegin(GL_POINTS)
73
+ glNormal(0.0, 0.0, 1.0)
74
+ glVertex(50.0, 50.0, 0.0)
75
+ glEnd()
74
76
  end
75
77
 
76
78
  # Write contents of one vertex to stdout.
77
79
  def print3DcolorVertex(size, count, buffer)
78
- printf(" ")
79
- for i in 0...7
80
- printf("%4.2f ", buffer[size-count])
81
- count -= 1
82
- end
83
- printf("\n")
84
- return count
80
+ printf(" ")
81
+ for i in 0...7
82
+ printf("%4.2f ", buffer[size-count])
83
+ count -= 1
84
+ end
85
+ printf("\n")
86
+ return count
85
87
  end
86
88
 
87
89
  # Write contents of entire buffer. (Parse tokens!)
88
90
  def printBuffer(size, buffer)
89
- count = size
90
- while (count!=0)
91
- token = buffer[size-count]
92
- count-=1
93
- if (token == GL_PASS_THROUGH_TOKEN)
94
- printf("GL_PASS_THROUGH_TOKEN\n")
95
- printf(" %4.2f\n", buffer[size-count])
96
- count-=1
97
- elsif (token == GL_POINT_TOKEN)
98
- printf("GL_POINT_TOKEN\n")
99
- count = print3DcolorVertex(size, count, buffer)
100
- elsif (token == GL_LINE_TOKEN)
101
- printf("GL_LINE_TOKEN\n")
102
- count = print3DcolorVertex(size, count, buffer)
103
- count = print3DcolorVertex(size, count, buffer)
104
- elsif (token == GL_LINE_RESET_TOKEN)
105
- printf("GL_LINE_RESET_TOKEN\n")
106
- count = print3DcolorVertex(size, count, buffer)
107
- count = print3DcolorVertex(size, count, buffer)
108
- end
109
- end
91
+ count = size
92
+ while (count!=0)
93
+ token = buffer[size-count]
94
+ count-=1
95
+ if (token == GL_PASS_THROUGH_TOKEN)
96
+ printf("GL_PASS_THROUGH_TOKEN\n")
97
+ printf(" %4.2f\n", buffer[size-count])
98
+ count-=1
99
+ elsif (token == GL_POINT_TOKEN)
100
+ printf("GL_POINT_TOKEN\n")
101
+ count = print3DcolorVertex(size, count, buffer)
102
+ elsif (token == GL_LINE_TOKEN)
103
+ printf("GL_LINE_TOKEN\n")
104
+ count = print3DcolorVertex(size, count, buffer)
105
+ count = print3DcolorVertex(size, count, buffer)
106
+ elsif (token == GL_LINE_RESET_TOKEN)
107
+ printf("GL_LINE_RESET_TOKEN\n")
108
+ count = print3DcolorVertex(size, count, buffer)
109
+ count = print3DcolorVertex(size, count, buffer)
110
+ end
111
+ end
110
112
  end
111
113
 
112
114
  display = proc do
113
- glMatrixMode(GL_PROJECTION)
114
- glLoadIdentity()
115
- glOrtho(0.0, 100.0, 0.0, 100.0, 0.0, 1.0)
116
-
117
- glClearColor(0.0, 0.0, 0.0, 0.0)
118
- glClear(GL_COLOR_BUFFER_BIT)
119
- drawGeometry(GL_RENDER)
120
-
121
- feedBuffer = glFeedbackBuffer(1024, GL_3D_COLOR)
122
- glRenderMode(GL_FEEDBACK)
123
- drawGeometry(GL_FEEDBACK)
124
-
125
- size = glRenderMode(GL_RENDER)
126
- printBuffer(size, feedBuffer.unpack("f#{size}"))
127
- glutSwapBuffers()
115
+ glMatrixMode(GL_PROJECTION)
116
+ glLoadIdentity()
117
+ glOrtho(0.0, 100.0, 0.0, 100.0, 0.0, 1.0)
118
+
119
+ glClearColor(0.0, 0.0, 0.0, 0.0)
120
+ glClear(GL_COLOR_BUFFER_BIT)
121
+ drawGeometry(GL_RENDER)
122
+
123
+ feedBuffer = glFeedbackBuffer(1024, GL_3D_COLOR)
124
+ glRenderMode(GL_FEEDBACK)
125
+ drawGeometry(GL_FEEDBACK)
126
+
127
+ size = glRenderMode(GL_RENDER)
128
+ printBuffer(size, feedBuffer.unpack("f#{size}"))
129
+ glutSwapBuffers()
128
130
  end
129
131
 
130
132
  keyboard = proc 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
  glutInit()
@@ -2,14 +2,14 @@
2
2
  # Copyright (c) Mark J. Kilgard, 1994.
3
3
  #
4
4
  # (c) Copyright 1993, Silicon Graphics, Inc.
5
- # ALL RIGHTS RESERVED
6
- # Permission to use, copy, modify, and distribute this software for
5
+ # ALL RIGHTS RESERVED
6
+ # Permission to use, copy, modify, and distribute this software for
7
7
  # any purpose and without fee is hereby granted, provided that the above
8
8
  # copyright notice appear in all copies and that both the copyright notice
9
- # and this permission notice appear in supporting documentation, and that
9
+ # and this permission notice appear in supporting documentation, and that
10
10
  # the name of Silicon Graphics, Inc. not be used in advertising
11
11
  # or publicity pertaining to distribution of the software without specific,
12
- # written prior permission.
12
+ # written prior permission.
13
13
  #
14
14
  # THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
15
15
  # AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
@@ -23,8 +23,8 @@
23
23
  # ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
24
24
  # ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
25
25
  # POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
26
- #
27
- # US Government Users Restricted Rights
26
+ #
27
+ # US Government Users Restricted Rights
28
28
  # Use, duplication, or disclosure by the Government is subject to
29
29
  # restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
30
30
  # (c)(1)(ii) of the Rights in Technical Data and Computer Software
@@ -37,116 +37,118 @@
37
37
  # OpenGL(TM) is a trademark of Silicon Graphics, Inc.
38
38
  #
39
39
  # fog.c
40
- # This program draws 5 red teapots, each at a different
41
- # z distance from the eye, in different types of fog.
42
- # Pressing the left mouse button chooses between 3 types of
43
- # fog: exponential, exponential squared, and linear.
44
- # In this program, there is a fixed density value, as well
40
+ # This program draws 5 red teapots, each at a different
41
+ # z distance from the eye, in different types of fog.
42
+ # Pressing the left mouse button chooses between 3 types of
43
+ # fog: exponential, exponential squared, and linear.
44
+ # In this program, there is a fixed density value, as well
45
45
  # as fixed start and end values for the linear fog.
46
46
  require 'opengl'
47
+ require 'glu'
48
+ require 'glut'
47
49
  require 'mathn'
48
50
  include Gl,Glu,Glut
49
51
 
50
52
  $fogMode = 0
51
53
 
52
54
  selectFog = Proc.new do |mode|
53
- if (mode == GL_LINEAR)
54
- glFog(GL_FOG_START, 1.0)
55
- glFog(GL_FOG_END, 5.0)
56
- # falls through
57
- glFog(GL_FOG_MODE, mode)
58
- glutPostRedisplay()
59
- end
60
- if (mode == GL_EXP2 || mode == GL_EXP)
61
- glFog(GL_FOG_MODE, mode)
62
- glutPostRedisplay()
63
- end
64
- exit(0) if (mode == 0)
55
+ if (mode == GL_LINEAR)
56
+ glFog(GL_FOG_START, 1.0)
57
+ glFog(GL_FOG_END, 5.0)
58
+ # falls through
59
+ glFog(GL_FOG_MODE, mode)
60
+ glutPostRedisplay()
61
+ end
62
+ if (mode == GL_EXP2 || mode == GL_EXP)
63
+ glFog(GL_FOG_MODE, mode)
64
+ glutPostRedisplay()
65
+ end
66
+ exit(0) if (mode == 0)
65
67
  end
66
68
 
67
- # Initialize z-buffer, projection matrix, light source,
69
+ # Initialize z-buffer, projection matrix, light source,
68
70
  # and lighting model. Do not specify a material property here.
69
71
  def myinit
70
- position = [0.0, 3.0, 3.0, 0.0]
71
- local_view = [0.0]
72
-
73
- glEnable(GL_DEPTH_TEST)
74
- glDepthFunc(GL_LESS)
75
-
76
- glLight(GL_LIGHT0, GL_POSITION, position)
77
- glLightModel(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view)
78
-
79
- glFrontFace(GL_CW)
80
- glEnable(GL_LIGHTING)
81
- glEnable(GL_LIGHT0)
82
- glEnable(GL_AUTO_NORMAL)
83
- glEnable(GL_NORMALIZE)
84
- glEnable(GL_FOG)
85
- fogColor = [0.5, 0.5, 0.5, 1.0]
86
-
87
- fogMode = GL_EXP
88
- glFog(GL_FOG_MODE, fogMode)
89
- glFog(GL_FOG_COLOR, fogColor)
90
- glFog(GL_FOG_DENSITY, 0.35)
91
- glHint(GL_FOG_HINT, GL_DONT_CARE)
92
- glClearColor(0.5, 0.5, 0.5, 1.0)
72
+ position = [0.0, 3.0, 3.0, 0.0]
73
+ local_view = [0.0]
74
+
75
+ glEnable(GL_DEPTH_TEST)
76
+ glDepthFunc(GL_LESS)
77
+
78
+ glLight(GL_LIGHT0, GL_POSITION, position)
79
+ glLightModel(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view)
80
+
81
+ glFrontFace(GL_CW)
82
+ glEnable(GL_LIGHTING)
83
+ glEnable(GL_LIGHT0)
84
+ glEnable(GL_AUTO_NORMAL)
85
+ glEnable(GL_NORMALIZE)
86
+ glEnable(GL_FOG)
87
+ fogColor = [0.5, 0.5, 0.5, 1.0]
88
+
89
+ fogMode = GL_EXP
90
+ glFog(GL_FOG_MODE, fogMode)
91
+ glFog(GL_FOG_COLOR, fogColor)
92
+ glFog(GL_FOG_DENSITY, 0.35)
93
+ glHint(GL_FOG_HINT, GL_DONT_CARE)
94
+ glClearColor(0.5, 0.5, 0.5, 1.0)
93
95
  end
94
96
 
95
97
  def renderRedTeapot(x, y, z)
96
- mat = []
97
- glPushMatrix()
98
- glTranslate(x, y, z)
99
- mat[0] = 0.1745
100
- mat[1] = 0.01175
101
- mat[2] = 0.01175
102
- mat[3] = 1.0
103
- glMaterial(GL_FRONT, GL_AMBIENT, mat)
104
- mat[0] = 0.61424
105
- mat[1] = 0.04136
106
- mat[2] = 0.04136
107
- glMaterial(GL_FRONT, GL_DIFFUSE, mat)
108
- mat[0] = 0.727811
109
- mat[1] = 0.626959
110
- mat[2] = 0.626959
111
- glMaterial(GL_FRONT, GL_SPECULAR, mat)
112
- glMaterial(GL_FRONT, GL_SHININESS, 0.6 * 128.0)
113
- glutSolidTeapot(1.0)
114
- glPopMatrix()
98
+ mat = []
99
+ glPushMatrix()
100
+ glTranslate(x, y, z)
101
+ mat[0] = 0.1745
102
+ mat[1] = 0.01175
103
+ mat[2] = 0.01175
104
+ mat[3] = 1.0
105
+ glMaterial(GL_FRONT, GL_AMBIENT, mat)
106
+ mat[0] = 0.61424
107
+ mat[1] = 0.04136
108
+ mat[2] = 0.04136
109
+ glMaterial(GL_FRONT, GL_DIFFUSE, mat)
110
+ mat[0] = 0.727811
111
+ mat[1] = 0.626959
112
+ mat[2] = 0.626959
113
+ glMaterial(GL_FRONT, GL_SPECULAR, mat)
114
+ glMaterial(GL_FRONT, GL_SHININESS, mat)
115
+ glutSolidTeapot(1.0)
116
+ glPopMatrix()
115
117
  end
116
118
 
117
119
  # display() draws 5 teapots at different z positions.
118
120
  display = Proc.new do
119
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
120
- renderRedTeapot(-4.0, -0.5, -1.0)
121
- renderRedTeapot(-2.0, -0.5, -2.0)
122
- renderRedTeapot(0.0, -0.5, -3.0)
123
- renderRedTeapot(2.0, -0.5, -4.0)
124
- renderRedTeapot(4.0, -0.5, -5.0)
125
- glFlush()
121
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
122
+ renderRedTeapot(-4.0, -0.5, -1.0)
123
+ renderRedTeapot(-2.0, -0.5, -2.0)
124
+ renderRedTeapot(0.0, -0.5, -3.0)
125
+ renderRedTeapot(2.0, -0.5, -4.0)
126
+ renderRedTeapot(4.0, -0.5, -5.0)
127
+ glFlush()
126
128
  end
127
129
 
128
130
  myReshape = Proc.new do |w, h|
129
- glViewport(0, 0, w, h)
130
- glMatrixMode(GL_PROJECTION)
131
- glLoadIdentity()
132
- if (w <= (h * 3))
133
- glOrtho(-6.0, 6.0, -2.0 * h * 3 / w, 2.0 * h * 3 / w, 0.0, 10.0)
134
- elsif
135
- glOrtho(-6.0 * w / h * 3, 6.0 * w / h * 3, -2.0, 2.0, 0.0, 10.0)
136
- end
137
- glMatrixMode(GL_MODELVIEW)
138
- glLoadIdentity()
131
+ glViewport(0, 0, w, h)
132
+ glMatrixMode(GL_PROJECTION)
133
+ glLoadIdentity()
134
+ if (w <= (h * 3))
135
+ glOrtho(-6.0, 6.0, -2.0 * h * 3 / w, 2.0 * h * 3 / w, 0.0, 10.0)
136
+ elsif
137
+ glOrtho(-6.0 * w / h * 3, 6.0 * w / h * 3, -2.0, 2.0, 0.0, 10.0)
138
+ end
139
+ glMatrixMode(GL_MODELVIEW)
140
+ glLoadIdentity()
139
141
  end
140
142
 
141
143
  keyboard = Proc.new do |key, x, y|
142
- case (key)
143
- when ?\e
144
- exit(0)
145
- end
144
+ case (key)
145
+ when ?\e
146
+ exit(0)
147
+ end
146
148
  end
147
149
 
148
150
  # Main Loop
149
- # Open window with initial window size, title bar,
151
+ # Open window with initial window size, title bar,
150
152
  # RGBA display mode, depth buffer, and handle input events.
151
153
  glutInit
152
154
  glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH)
@@ -164,4 +166,3 @@ glutAddMenuEntry("Fog LINEAR", GL_LINEAR)
164
166
  glutAddMenuEntry("Quit", 0)
165
167
  glutAttachMenu(GLUT_RIGHT_BUTTON)
166
168
  glutMainLoop()
167
-
@@ -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,108 +36,110 @@
36
36
  #
37
37
  # font.c
38
38
  #
39
- # Draws some text in a bitmapped font. Uses glBitmap()
40
- # and other pixel routines. Also demonstrates use of
39
+ # Draws some text in a bitmapped font. Uses glBitmap()
40
+ # and other pixel routines. Also demonstrates use of
41
41
  # display lists.
42
42
  require 'opengl'
43
+ require 'glu'
44
+ require 'glut'
43
45
  include Gl,Glu,Glut
44
46
 
45
47
  $space = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
46
48
 
47
49
  $letters = [
48
- [0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0x66, 0x3c, 0x18],
49
- [0x00, 0x00, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe],
50
- [0x00, 0x00, 0x7e, 0xe7, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xe7, 0x7e],
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 0xcc, 0xd8, 0xf0, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe],
68
+ [0x00, 0x00, 0x7e, 0xe7, 0x03, 0x03, 0x07, 0x7e, 0xe0, 0xc0, 0xc0, 0xe7, 0x7e],
69
+ [0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff],
70
+ [0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3],
71
+ [0x00, 0x00, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3],
72
+ [0x00, 0x00, 0xc3, 0xe7, 0xff, 0xff, 0xdb, 0xdb, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3],
73
+ [0x00, 0x00, 0xc3, 0x66, 0x66, 0x3c, 0x3c, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3],
74
+ [0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3],
73
75
  [0x00, 0x00, 0xff, 0xc0, 0xc0, 0x60, 0x30, 0x7e, 0x0c, 0x06, 0x03, 0x03, 0xff]
74
76
  ]
75
77
 
76
78
  $fontOffset = 0
77
79
 
78
80
  def makeRasterFont
79
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
80
-
81
- $fontOffset = glGenLists(128)
82
- i = 0
83
- j = ?A
84
- for i in 0...26
85
- glNewList($fontOffset + j, GL_COMPILE)
86
- glBitmap(8, 13, 0.0, 2.0, 10.0, 0.0, $letters[i].pack("C*"))
87
- glEndList()
88
- j+=1
89
- end
90
- glNewList($fontOffset + ' '[0], GL_COMPILE)
91
- glBitmap(8, 13, 0.0, 2.0, 10.0, 0.0, $space.pack("C*"))
92
- glEndList()
81
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
82
+
83
+ $fontOffset = glGenLists(128)
84
+ i = 0
85
+ j = ?A
86
+ for i in 0...26
87
+ glNewList($fontOffset + j, GL_COMPILE)
88
+ glBitmap(8, 13, 0.0, 2.0, 10.0, 0.0, $letters[i].pack("C*"))
89
+ glEndList()
90
+ j+=1
91
+ end
92
+ glNewList($fontOffset + ' '[0], GL_COMPILE)
93
+ glBitmap(8, 13, 0.0, 2.0, 10.0, 0.0, $space.pack("C*"))
94
+ glEndList()
93
95
  end
94
96
 
95
97
  def init
96
- glShadeModel(GL_FLAT)
97
- makeRasterFont()
98
+ glShadeModel(GL_FLAT)
99
+ makeRasterFont()
98
100
  end
99
101
 
100
102
  def printString(s)
101
- glPushAttrib(GL_LIST_BIT)
102
- glListBase($fontOffset)
103
- glCallLists(GL_BYTE,s)
104
- glPopAttrib()
103
+ glPushAttrib(GL_LIST_BIT)
104
+ glListBase($fontOffset)
105
+ glCallLists(GL_BYTE,s)
106
+ glPopAttrib()
105
107
  end
106
108
 
107
- # Everything above this line could be in a library
108
- # that defines a font. To make it work, you've got
109
- # to call makeRasterFont() before you start making
109
+ # Everything above this line could be in a library
110
+ # that defines a font. To make it work, you've got
111
+ # to call makeRasterFont() before you start making
110
112
  # calls to printString().
111
113
  display = proc do
112
- white = [ 1.0, 1.0, 1.0 ]
113
-
114
- glClear(GL_COLOR_BUFFER_BIT)
115
- glColor(white)
116
-
117
- glRasterPos(20, 60)
118
- printString("THE QUICK BROWN FOX JUMPS")
119
- glRasterPos(20, 40)
120
- printString("OVER A LAZY DOG")
121
- glutSwapBuffers()
114
+ white = [ 1.0, 1.0, 1.0 ]
115
+
116
+ glClear(GL_COLOR_BUFFER_BIT)
117
+ glColor(white)
118
+
119
+ glRasterPos(20, 60)
120
+ printString("THE QUICK BROWN FOX JUMPS")
121
+ glRasterPos(20, 40)
122
+ printString("OVER A LAZY DOG")
123
+ glutSwapBuffers()
122
124
  end
123
125
 
124
126
  reshape = proc do |w, h|
125
- glViewport(0, 0, w, h)
126
- glMatrixMode(GL_PROJECTION)
127
- glLoadIdentity()
128
- glOrtho(0.0, w, 0.0, h, -1.0, 1.0)
129
- glMatrixMode(GL_MODELVIEW)
127
+ glViewport(0, 0, w, h)
128
+ glMatrixMode(GL_PROJECTION)
129
+ glLoadIdentity()
130
+ glOrtho(0.0, w, 0.0, h, -1.0, 1.0)
131
+ glMatrixMode(GL_MODELVIEW)
130
132
  end
131
133
 
132
134
  keyboard = proc do |key, x, y|
133
- case (key)
134
- when ?\e
135
- exit(0)
136
- end
135
+ case (key)
136
+ when ?\e
137
+ exit(0)
138
+ end
137
139
  end
138
140
 
139
141
  # Main Loop
140
- # Open window with initial window size, title bar,
142
+ # Open window with initial window size, title bar,
141
143
  # RGBA display mode, and handle input events.
142
144
  glutInit()
143
145
  glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)