opengl 0.9.0-x64-mingw32

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 +3 -0
  3. data.tar.gz.sig +0 -0
  4. data/.autotest +29 -0
  5. data/.gemtest +0 -0
  6. data/.gitignore +6 -0
  7. data/.travis.yml +19 -0
  8. data/History.rdoc +77 -0
  9. data/MIT-LICENSE +18 -0
  10. data/Manifest.txt +138 -0
  11. data/README.rdoc +102 -0
  12. data/Rakefile +60 -0
  13. data/examples/NeHe/NeHe.png +0 -0
  14. data/examples/NeHe/crate.png +0 -0
  15. data/examples/NeHe/glass.png +0 -0
  16. data/examples/NeHe/nehe_lesson02.rb +117 -0
  17. data/examples/NeHe/nehe_lesson03.rb +123 -0
  18. data/examples/NeHe/nehe_lesson04.rb +132 -0
  19. data/examples/NeHe/nehe_lesson05.rb +182 -0
  20. data/examples/NeHe/nehe_lesson06.rb +186 -0
  21. data/examples/NeHe/nehe_lesson07.rb +240 -0
  22. data/examples/NeHe/nehe_lesson08.rb +255 -0
  23. data/examples/NeHe/nehe_lesson09.rb +203 -0
  24. data/examples/NeHe/nehe_lesson11.rb +176 -0
  25. data/examples/NeHe/nehe_lesson12.rb +203 -0
  26. data/examples/NeHe/nehe_lesson16.rb +211 -0
  27. data/examples/NeHe/nehe_lesson19.rb +209 -0
  28. data/examples/NeHe/nehe_lesson36.rb +308 -0
  29. data/examples/NeHe/particle.png +0 -0
  30. data/examples/NeHe/star.png +0 -0
  31. data/examples/NeHe/tim.png +0 -0
  32. data/examples/OrangeBook/3Dlabs-License.txt +33 -0
  33. data/examples/OrangeBook/brick.frag +36 -0
  34. data/examples/OrangeBook/brick.rb +378 -0
  35. data/examples/OrangeBook/brick.vert +41 -0
  36. data/examples/OrangeBook/particle.frag +17 -0
  37. data/examples/OrangeBook/particle.rb +408 -0
  38. data/examples/OrangeBook/particle.vert +38 -0
  39. data/examples/README +16 -0
  40. data/examples/RedBook/aapoly.rb +143 -0
  41. data/examples/RedBook/aargb.rb +121 -0
  42. data/examples/RedBook/accanti.rb +164 -0
  43. data/examples/RedBook/accpersp.rb +217 -0
  44. data/examples/RedBook/alpha.rb +125 -0
  45. data/examples/RedBook/alpha3D.rb +160 -0
  46. data/examples/RedBook/bezcurve.rb +107 -0
  47. data/examples/RedBook/bezmesh.rb +139 -0
  48. data/examples/RedBook/checker.rb +126 -0
  49. data/examples/RedBook/clip.rb +97 -0
  50. data/examples/RedBook/colormat.rb +137 -0
  51. data/examples/RedBook/cube.rb +71 -0
  52. data/examples/RedBook/depthcue.rb +101 -0
  53. data/examples/RedBook/dof.rb +206 -0
  54. data/examples/RedBook/double.rb +107 -0
  55. data/examples/RedBook/drawf.rb +93 -0
  56. data/examples/RedBook/feedback.rb +147 -0
  57. data/examples/RedBook/fog.rb +168 -0
  58. data/examples/RedBook/font.rb +153 -0
  59. data/examples/RedBook/hello.rb +81 -0
  60. data/examples/RedBook/image.rb +139 -0
  61. data/examples/RedBook/jitter.rb +207 -0
  62. data/examples/RedBook/light.rb +155 -0
  63. data/examples/RedBook/lines.rb +130 -0
  64. data/examples/RedBook/list.rb +113 -0
  65. data/examples/RedBook/material.rb +276 -0
  66. data/examples/RedBook/mipmap.rb +158 -0
  67. data/examples/RedBook/model.rb +115 -0
  68. data/examples/RedBook/movelight.rb +134 -0
  69. data/examples/RedBook/pickdepth.rb +181 -0
  70. data/examples/RedBook/planet.rb +110 -0
  71. data/examples/RedBook/quadric.rb +160 -0
  72. data/examples/RedBook/robot.rb +117 -0
  73. data/examples/RedBook/select.rb +198 -0
  74. data/examples/RedBook/smooth.rb +97 -0
  75. data/examples/RedBook/stencil.rb +165 -0
  76. data/examples/RedBook/stroke.rb +169 -0
  77. data/examples/RedBook/surface.rb +168 -0
  78. data/examples/RedBook/teaambient.rb +134 -0
  79. data/examples/RedBook/teapots.rb +184 -0
  80. data/examples/RedBook/tess.rb +185 -0
  81. data/examples/RedBook/texbind.rb +149 -0
  82. data/examples/RedBook/texgen.rb +171 -0
  83. data/examples/RedBook/texturesurf.rb +130 -0
  84. data/examples/RedBook/varray.rb +161 -0
  85. data/examples/RedBook/wrap.rb +150 -0
  86. data/examples/misc/OGLBench.rb +338 -0
  87. data/examples/misc/anisotropic.rb +196 -0
  88. data/examples/misc/fbo_test.rb +357 -0
  89. data/examples/misc/font-glut.rb +47 -0
  90. data/examples/misc/glfwtest.rb +30 -0
  91. data/examples/misc/plane.rb +161 -0
  92. data/examples/misc/readpixel.rb +66 -0
  93. data/examples/misc/sdltest.rb +36 -0
  94. data/examples/misc/trislam.rb +829 -0
  95. data/ext/opengl/common.h +428 -0
  96. data/ext/opengl/conv.h +244 -0
  97. data/ext/opengl/extconf.rb +47 -0
  98. data/ext/opengl/funcdef.h +313 -0
  99. data/ext/opengl/gl-1.0-1.1.c +3075 -0
  100. data/ext/opengl/gl-1.2.c +155 -0
  101. data/ext/opengl/gl-1.3.c +443 -0
  102. data/ext/opengl/gl-1.4.c +348 -0
  103. data/ext/opengl/gl-1.5.c +224 -0
  104. data/ext/opengl/gl-2.0.c +667 -0
  105. data/ext/opengl/gl-2.1.c +57 -0
  106. data/ext/opengl/gl-3.0.c +493 -0
  107. data/ext/opengl/gl-enums.c +4873 -0
  108. data/ext/opengl/gl-enums.h +14588 -0
  109. data/ext/opengl/gl-error.c +112 -0
  110. data/ext/opengl/gl-error.h +28 -0
  111. data/ext/opengl/gl-ext-3dfx.c +27 -0
  112. data/ext/opengl/gl-ext-arb.c +875 -0
  113. data/ext/opengl/gl-ext-ati.c +41 -0
  114. data/ext/opengl/gl-ext-ext.c +889 -0
  115. data/ext/opengl/gl-ext-gremedy.c +41 -0
  116. data/ext/opengl/gl-ext-nv.c +680 -0
  117. data/ext/opengl/gl-types.h +67 -0
  118. data/ext/opengl/gl.c +220 -0
  119. data/ext/opengl/gl_buffer.c +177 -0
  120. data/ext/opengl/opengl.c +7 -0
  121. data/lib/gl.rb +1 -0
  122. data/lib/opengl.rb +53 -0
  123. data/lib/opengl/2.0/opengl.so +0 -0
  124. data/lib/opengl/2.1/opengl.so +0 -0
  125. data/lib/opengl/test_case.rb +86 -0
  126. data/test/dummy.xorg.conf +140 -0
  127. data/test/test_gl.rb +38 -0
  128. data/test/test_gl_10_11.rb +1363 -0
  129. data/test/test_gl_12.rb +71 -0
  130. data/test/test_gl_13.rb +221 -0
  131. data/test/test_gl_14.rb +218 -0
  132. data/test/test_gl_15.rb +258 -0
  133. data/test/test_gl_20.rb +417 -0
  134. data/test/test_gl_21.rb +436 -0
  135. data/test/test_gl_ext_arb.rb +508 -0
  136. data/test/test_gl_ext_ati.rb +28 -0
  137. data/test/test_gl_ext_ext.rb +608 -0
  138. data/test/test_gl_ext_gremedy.rb +29 -0
  139. data/test/test_gl_ext_nv.rb +349 -0
  140. data/test/test_opengl_buffer.rb +120 -0
  141. data/utils/README +6 -0
  142. data/utils/enumgen.rb +108 -0
  143. data/utils/extlistgen.rb +90 -0
  144. metadata +319 -0
  145. metadata.gz.sig +1 -0
@@ -0,0 +1,97 @@
1
+ #
2
+ # Copyright (c) 1993-1997, Silicon Graphics, Inc.
3
+ # ALL RIGHTS RESERVED
4
+ # Permission to use, copy, modify, and distribute this software for
5
+ # any purpose and without fee is hereby granted, provided that the above
6
+ # copyright notice appear in all copies and that both the copyright notice
7
+ # and this permission notice appear in supporting documentation, and that
8
+ # the name of Silicon Graphics, Inc. not be used in advertising
9
+ # or publicity pertaining to distribution of the software without specific,
10
+ # written prior permission.
11
+ #
12
+ # THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
13
+ # AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
14
+ # INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
15
+ # FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
16
+ # GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
17
+ # SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
18
+ # KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
19
+ # LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
20
+ # THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
21
+ # ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
22
+ # ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
23
+ # POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
24
+ #
25
+ # US Government Users Restricted Rights
26
+ # Use, duplication, or disclosure by the Government is subject to
27
+ # restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
28
+ # (c)(1)(ii) of the Rights in Technical Data and Computer Software
29
+ # clause at DFARS 252.227-7013 and/or in similar or successor
30
+ # clauses in the FAR or the DOD or NASA FAR Supplement.
31
+ # Unpublished-- rights reserved under the copyright laws of the
32
+ # United States. Contractor/manufacturer is Silicon Graphics,
33
+ # Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
34
+ #
35
+ # OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
36
+ #
37
+ # smooth.c
38
+ # This program demonstrates smooth shading.
39
+ # A smooth shaded polygon is drawn in a 2-D projection.
40
+
41
+ require 'opengl'
42
+ require 'glu'
43
+ require 'glut'
44
+ include Gl,Glu,Glut
45
+
46
+ def init
47
+ glClearColor(0,0,0,0)
48
+ glShadeModel(GL_SMOOTH)
49
+ end
50
+
51
+ def triangle
52
+ glBegin(GL_TRIANGLES)
53
+ glColor3f(1.0, 0.0, 0.0)
54
+ glVertex2f(5, 5)
55
+ glColor3f(0.0, 1.0, 0.0)
56
+ glVertex2f(25, 5)
57
+ glColor3f(0.0, 0.0, 1.0)
58
+ glVertex2f(5, 25)
59
+ glEnd()
60
+ end
61
+
62
+
63
+ display = Proc.new do
64
+ glClear(GL_COLOR_BUFFER_BIT)
65
+ triangle
66
+ glutSwapBuffers()
67
+ end
68
+
69
+ reshape = Proc.new do |w, h|
70
+ glViewport(0, 0, w, h)
71
+ glMatrixMode(GL_PROJECTION)
72
+ glLoadIdentity
73
+ if w<=h
74
+ gluOrtho2D(0,30,0, 30 * h/w)
75
+ else
76
+ gluOrtho2D(0,30 * w/h, 0,30)
77
+ end
78
+ glMatrixMode(GL_MODELVIEW)
79
+ end
80
+
81
+ keyboard = lambda do |key, x, y|
82
+ case(key)
83
+ when ?\e
84
+ exit(0)
85
+ end
86
+ end
87
+
88
+ glutInit()
89
+ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
90
+ glutInitWindowSize(500, 500)
91
+ glutInitWindowPosition(100, 100)
92
+ glutCreateWindow($0)
93
+ init()
94
+ glutDisplayFunc(display)
95
+ glutReshapeFunc(reshape)
96
+ glutKeyboardFunc(keyboard)
97
+ glutMainLoop()
@@ -0,0 +1,165 @@
1
+ #
2
+ # Copyright (c) Mark J. Kilgard, 1994.
3
+ #
4
+ # (c) Copyright 1993, Silicon Graphics, Inc.
5
+ # ALL RIGHTS RESERVED
6
+ # Permission to use, copy, modify, and distribute this software for
7
+ # any purpose and without fee is hereby granted, provided that the above
8
+ # copyright notice appear in all copies and that both the copyright notice
9
+ # and this permission notice appear in supporting documentation, and that
10
+ # the name of Silicon Graphics, Inc. not be used in advertising
11
+ # or publicity pertaining to distribution of the software without specific,
12
+ # written prior permission.
13
+ #
14
+ # THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
15
+ # AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
16
+ # INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
17
+ # FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
18
+ # GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
19
+ # SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
20
+ # KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
21
+ # LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
22
+ # THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
23
+ # ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
24
+ # ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
25
+ # POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
26
+ #
27
+ # US Government Users Restricted Rights
28
+ # Use, duplication, or disclosure by the Government is subject to
29
+ # restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
30
+ # (c)(1)(ii) of the Rights in Technical Data and Computer Software
31
+ # clause at DFARS 252.227-7013 and/or in similar or successor
32
+ # clauses in the FAR or the DOD or NASA FAR Supplement.
33
+ # Unpublished-- rights reserved under the copyright laws of the
34
+ # United States. Contractor/manufacturer is Silicon Graphics,
35
+ # Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
36
+ #
37
+ # OpenGL(TM) is a trademark of Silicon Graphics, Inc.
38
+ #
39
+ # stencil.c
40
+ # This program draws two rotated tori in a window.
41
+ # A diamond in the center of the window masks out part
42
+ # of the scene. Within this mask, a different model
43
+ # (a sphere) is drawn in a different color.
44
+ #
45
+ require 'opengl'
46
+ require 'glu'
47
+ require 'glut'
48
+ require 'rational'
49
+ include Gl,Glu,Glut
50
+
51
+ YELLOWMAT=1
52
+ BLUEMAT=2
53
+
54
+ def myinit
55
+ yellow_diffuse = [ 0.7, 0.7, 0.0, 1.0 ]
56
+ yellow_specular = [ 1.0, 1.0, 1.0, 1.0 ]
57
+
58
+ blue_diffuse = [ 0.1, 0.1, 0.7, 1.0 ]
59
+ blue_specular = [ 0.1, 1.0, 1.0, 1.0 ]
60
+
61
+ position_one = [ 1.0, 1.0, 1.0, 0.0 ]
62
+
63
+ glNewList(YELLOWMAT, GL_COMPILE)
64
+ glMaterial(GL_FRONT, GL_DIFFUSE, yellow_diffuse)
65
+ glMaterial(GL_FRONT, GL_SPECULAR, yellow_specular)
66
+ glMaterial(GL_FRONT, GL_SHININESS, 64.0)
67
+ glEndList()
68
+
69
+ glNewList(BLUEMAT, GL_COMPILE)
70
+ glMaterial(GL_FRONT, GL_DIFFUSE, blue_diffuse)
71
+ glMaterial(GL_FRONT, GL_SPECULAR, blue_specular)
72
+ glMaterial(GL_FRONT, GL_SHININESS, 45.0)
73
+ glEndList()
74
+
75
+ glLight(GL_LIGHT0, GL_POSITION, position_one)
76
+
77
+ glEnable(GL_LIGHT0)
78
+ glEnable(GL_LIGHTING)
79
+ glEnable(GL_DEPTH_TEST)
80
+
81
+ glClearStencil(0x0)
82
+ glEnable(GL_STENCIL_TEST)
83
+ end
84
+
85
+ # Draw a sphere in a diamond-shaped section in the
86
+ # middle of a window with 2 tori.
87
+ display = Proc.new do
88
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
89
+
90
+ # draw blue sphere where the stencil is 1
91
+ glStencilFunc(GL_EQUAL, 0x1, 0x1)
92
+ glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP)
93
+ glCallList(BLUEMAT)
94
+ glutSolidSphere(0.5, 15, 15)
95
+
96
+ # draw the tori where the stencil is not 1
97
+ glStencilFunc(GL_NOTEQUAL, 0x1, 0x1)
98
+ glPushMatrix()
99
+ glRotate(45.0, 0.0, 0.0, 1.0)
100
+ glRotate(45.0, 0.0, 1.0, 0.0)
101
+ glCallList(YELLOWMAT)
102
+ glutSolidTorus(0.275, 0.85, 15, 15)
103
+ glPushMatrix()
104
+ glRotate(90.0, 1.0, 0.0, 0.0)
105
+ glutSolidTorus(0.275, 0.85, 15, 15)
106
+ glPopMatrix()
107
+ glPopMatrix()
108
+
109
+ glutSwapBuffers()
110
+ end
111
+
112
+ # Whenever the window is reshaped, redefine the
113
+ # coordinate system and redraw the stencil area.
114
+ myReshape = Proc.new do |w, h|
115
+ glViewport(0, 0, w, h)
116
+
117
+ # create a diamond shaped stencil area
118
+ glMatrixMode(GL_PROJECTION)
119
+ glLoadIdentity()
120
+ if w<=h
121
+ gluOrtho2D(-3.0, 3.0, -3.0*h/w, 3*h/w)
122
+ else
123
+ gluOrtho2D(-3.0*w/h, 3.0*w/h, -3.0, 3)
124
+ end
125
+ glMatrixMode(GL_MODELVIEW)
126
+ glLoadIdentity()
127
+
128
+ glClear(GL_STENCIL_BUFFER_BIT)
129
+ glStencilFunc(GL_ALWAYS, 0x1, 0x1)
130
+ glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE)
131
+ glBegin(GL_QUADS)
132
+ glVertex2f(-1.0, 0.0)
133
+ glVertex2f(0.0, 1.0)
134
+ glVertex2f(1.0, 0.0)
135
+ glVertex2f(0.0, -1.0)
136
+ glEnd()
137
+
138
+ glMatrixMode(GL_PROJECTION)
139
+ glLoadIdentity()
140
+ GLU.Perspective(45.0, w.to_f/h.to_f, 3.0, 7.0)
141
+ glMatrixMode(GL_MODELVIEW)
142
+ glLoadIdentity()
143
+ glTranslate(0.0, 0.0, -5.0)
144
+ end
145
+
146
+ keyboard = Proc.new do |key, x, y|
147
+ case (key)
148
+ when ?\e
149
+ exit(0);
150
+ end
151
+ end
152
+
153
+ # Main Loop
154
+ # Open window with initial window size, title bar,
155
+ # RGB display mode, and handle input events.
156
+ glutInit()
157
+ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_STENCIL)
158
+ glutInitWindowSize(500, 500)
159
+ glutInitWindowPosition(100, 100)
160
+ glutCreateWindow($0)
161
+ myinit
162
+ glutReshapeFunc(myReshape)
163
+ glutDisplayFunc(display)
164
+ glutKeyboardFunc(keyboard)
165
+ glutMainLoop()
@@ -0,0 +1,169 @@
1
+ #
2
+ # Copyright (c) Mark J. Kilgard, 1994.
3
+ #
4
+ # (c) Copyright 1993, Silicon Graphics, Inc.
5
+ # ALL RIGHTS RESERVED
6
+ # Permission to use, copy, modify, and distribute this software for
7
+ # any purpose and without fee is hereby granted, provided that the above
8
+ # copyright notice appear in all copies and that both the copyright notice
9
+ # and this permission notice appear in supporting documentation, and that
10
+ # the name of Silicon Graphics, Inc. not be used in advertising
11
+ # or publicity pertaining to distribution of the software without specific,
12
+ # written prior permission.
13
+ #
14
+ # THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
15
+ # AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
16
+ # INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
17
+ # FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
18
+ # GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
19
+ # SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
20
+ # KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
21
+ # LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
22
+ # THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
23
+ # ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
24
+ # ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
25
+ # POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
26
+ #
27
+ # US Government Users Restricted Rights
28
+ # Use, duplication, or disclosure by the Government is subject to
29
+ # restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
30
+ # (c)(1)(ii) of the Rights in Technical Data and Computer Software
31
+ # clause at DFARS 252.227-7013 and/or in similar or successor
32
+ # clauses in the FAR or the DOD or NASA FAR Supplement.
33
+ # Unpublished-- rights reserved under the copyright laws of the
34
+ # United States. Contractor/manufacturer is Silicon Graphics,
35
+ # Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
36
+ #
37
+ # OpenGL(TM) is a trademark of Silicon Graphics, Inc.
38
+ #
39
+ # stroke.c
40
+ # This program demonstrates some characters of a
41
+ # stroke (vector) font. The characters are represented
42
+ # by display lists, which are given numbers which
43
+ # correspond to the ASCII values of the characters.
44
+ # Use of glCallLists() is demonstrated.
45
+ require 'opengl'
46
+ require 'glu'
47
+ require 'glut'
48
+ require 'mathn'
49
+ include Gl,Glu,Glut
50
+
51
+ PT=1
52
+ STROKE=2
53
+ END_=3
54
+
55
+ Adata = [
56
+ [[0, 0], PT], [[0, 9], PT], [[1, 10], PT], [[4, 10], PT],
57
+ [[5, 9], PT], [[5, 0], STROKE], [[0, 5], PT], [[5, 5], END_]
58
+ ]
59
+
60
+ Edata = [
61
+ [[5, 0], PT], [[0, 0], PT], [[0, 10], PT], [[5, 10], STROKE],
62
+ [[0, 5], PT], [[4, 5], END_]
63
+ ]
64
+
65
+ Pdata = [
66
+ [[0, 0], PT], [[0, 10], PT], [[4, 10], PT], [[5, 9], PT], [[5, 6], PT],
67
+ [[4, 5], PT], [[0, 5], END_]
68
+ ]
69
+
70
+ Rdata = [
71
+ [[0, 0], PT], [[0, 10], PT], [[4, 10], PT], [[5, 9], PT], [[5, 6], PT],
72
+ [[4, 5], PT], [[0, 5], STROKE], [[3, 5], PT], [[5, 0], END_]
73
+ ]
74
+
75
+ Sdata = [
76
+ [[0, 1], PT], [[1, 0], PT], [[4, 0], PT], [[5, 1], PT], [[5, 4], PT],
77
+ [[4, 5], PT], [[1, 5], PT], [[0, 6], PT], [[0, 9], PT], [[1, 10], PT],
78
+ [[4, 10], PT], [[5, 9], END_]
79
+ ]
80
+
81
+ # drawLetter() interprets the instructions from the array
82
+ # for that letter and renders the letter with line segments.
83
+ def drawLetter(l)
84
+ i = 0
85
+ glBegin(GL_LINE_STRIP)
86
+ while true
87
+ case (l[i][1])
88
+ when PT
89
+ glVertex(l[i][0])
90
+ when STROKE
91
+ glVertex(l[i][0])
92
+ glEnd()
93
+ glBegin(GL_LINE_STRIP)
94
+ when END_
95
+ glVertex(l[i][0])
96
+ glEnd()
97
+ glTranslate(8.0, 0.0, 0.0)
98
+ return
99
+ end
100
+ i += 1
101
+ end
102
+ end
103
+
104
+ # Create a display list for each of 6 characters
105
+ def myinit
106
+ glShadeModel(GL_FLAT)
107
+
108
+ base = glGenLists(128)
109
+ glListBase(base)
110
+ glNewList(base+'A'[0], GL_COMPILE); drawLetter(Adata); glEndList()
111
+ glNewList(base+'E'[0], GL_COMPILE); drawLetter(Edata); glEndList()
112
+ glNewList(base+'P'[0], GL_COMPILE); drawLetter(Pdata); glEndList()
113
+ glNewList(base+'R'[0], GL_COMPILE); drawLetter(Rdata); glEndList()
114
+ glNewList(base+'S'[0], GL_COMPILE); drawLetter(Sdata); glEndList()
115
+ glNewList(base+' '[0], GL_COMPILE); glTranslate(8.0, 0.0, 0.0); glEndList()
116
+ end
117
+
118
+ $test1 = "A SPARE SERAPE APPEARS AS"
119
+ $test2 = "APES PREPARE RARE PEPPERS"
120
+
121
+ def printStrokedString(s)
122
+ glCallLists(GL_BYTE,s)
123
+ end
124
+
125
+ display = Proc.new do
126
+ glClear(GL_COLOR_BUFFER_BIT)
127
+ glColor(1.0, 1.0, 1.0)
128
+ glPushMatrix()
129
+ glScale(2.0, 2.0, 2.0)
130
+ glTranslate(10.0, 30.0, 0.0)
131
+ printStrokedString($test1)
132
+ glPopMatrix()
133
+ glPushMatrix()
134
+ glScale(2.0, 2.0, 2.0)
135
+ glTranslate(10.0, 13.0, 0.0)
136
+ printStrokedString($test2)
137
+ glPopMatrix()
138
+ glutSwapBuffers()
139
+ end
140
+
141
+ reshape = Proc.new do |w, h|
142
+ glViewport(0, 0, w, h)
143
+ glMatrixMode(GL_PROJECTION)
144
+ glLoadIdentity()
145
+ glOrtho(0.0, w, 0.0, h, -1.0, 1.0)
146
+ glMatrixMode(GL_MODELVIEW)
147
+ glLoadIdentity()
148
+ end
149
+
150
+ keyboard = Proc.new do |key, x, y|
151
+ case (key)
152
+ when ?\e
153
+ exit(0);
154
+ end
155
+ end
156
+
157
+ # Main Loop
158
+ # Open window with initial window size, title bar,
159
+ # RGBA display mode, and handle input events.
160
+ glutInit
161
+ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
162
+ glutInitWindowSize(440, 120)
163
+ glutInitWindowPosition(100, 100)
164
+ glutCreateWindow($0)
165
+ myinit()
166
+ glutDisplayFunc(display)
167
+ glutReshapeFunc(reshape)
168
+ glutKeyboardFunc(keyboard)
169
+ glutMainLoop()
@@ -0,0 +1,168 @@
1
+ #
2
+ # (c) Copyright 1993, Silicon Graphics, Inc.
3
+ # ALL RIGHTS RESERVED
4
+ # Permission to use, copy, modify, and distribute this software for
5
+ # any purpose and without fee is hereby granted, provided that the above
6
+ # copyright notice appear in all copies and that both the copyright notice
7
+ # and this permission notice appear in supporting documentation, and that
8
+ # the name of Silicon Graphics, Inc. not be used in advertising
9
+ # or publicity pertaining to distribution of the software without specific,
10
+ # written prior permission.
11
+ #
12
+ # THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
13
+ # AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
14
+ # INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
15
+ # FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
16
+ # GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
17
+ # SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
18
+ # KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
19
+ # LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
20
+ # THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
21
+ # ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
22
+ # ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
23
+ # POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
24
+ #
25
+ # US Government Users Restricted Rights
26
+ # Use, duplication, or disclosure by the Government is subject to
27
+ # restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
28
+ # (c)(1)(ii) of the Rights in Technical Data and Computer Software
29
+ # clause at DFARS 252.227-7013 and/or in similar or successor
30
+ # clauses in the FAR or the DOD or NASA FAR Supplement.
31
+ # Unpublished-- rights reserved under the copyright laws of the
32
+ # United States. Contractor/manufacturer is Silicon Graphics,
33
+ # Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
34
+ #
35
+ # OpenGL(TM) is a trademark of Silicon Graphics, Inc.
36
+ #
37
+ #
38
+ # surface.c
39
+ # This program draws a NURBS surface in the shape of a
40
+ # symmetrical hill.
41
+ #
42
+ require 'opengl'
43
+ require 'glu'
44
+ require 'glut'
45
+ include Gl,Glu,Glut
46
+
47
+ $ctlpoints = Array.new(4).collect { Array.new(4).collect { Array.new(3, nil) } } # 4*4*3 array
48
+ $showPoints = 0
49
+
50
+ $theNurb = nil
51
+
52
+ # Initializes the control points of the surface to a small hill.
53
+ # The control points range from -3 to +3 in x, y, and z
54
+ def init_surface
55
+ for u in 0..3
56
+ for v in 0..3
57
+ $ctlpoints[u][v][0] = 2.0*(u - 1.5)
58
+ $ctlpoints[u][v][1] = 2.0*(v - 1.5)
59
+
60
+ if ( (u == 1 || u == 2) && (v == 1 || v == 2))
61
+ $ctlpoints[u][v][2] = 3
62
+ else
63
+ $ctlpoints[u][v][2] = -3
64
+ end
65
+ end
66
+ end
67
+ end
68
+
69
+ # Initialize material property and depth buffer.
70
+ def myinit
71
+ mat_diffuse = [ 0.7, 0.7, 0.7, 1.0 ]
72
+ mat_specular = [ 1.0, 1.0, 1.0, 1.0 ]
73
+ mat_shininess = [ 100.0 ]
74
+
75
+ glClearColor(0.0, 0.0, 0.0, 1.0)
76
+ glMaterial(GL_FRONT, GL_DIFFUSE, mat_diffuse)
77
+ glMaterial(GL_FRONT, GL_SPECULAR, mat_specular)
78
+ glMaterial(GL_FRONT, GL_SHININESS, mat_shininess)
79
+
80
+ glEnable(GL_LIGHTING)
81
+ glEnable(GL_LIGHT0)
82
+ glDepthFunc(GL_LESS)
83
+ glEnable(GL_DEPTH_TEST)
84
+ glEnable(GL_AUTO_NORMAL)
85
+ glEnable(GL_NORMALIZE)
86
+
87
+ init_surface()
88
+
89
+ $theNurb = gluNewNurbsRenderer()
90
+ gluNurbsProperty($theNurb, GLU_SAMPLING_TOLERANCE, 25.0)
91
+ gluNurbsProperty($theNurb, GLU_DISPLAY_MODE, GLU_FILL)
92
+ end
93
+
94
+ display = Proc.new do
95
+ knots = [0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0]
96
+
97
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
98
+
99
+ glPushMatrix()
100
+ glRotate(330.0, 1.0,0.0,0.0)
101
+ glScale(0.5, 0.5, 0.5)
102
+
103
+ gluBeginSurface($theNurb)
104
+ gluNurbsSurface($theNurb,
105
+ 8, knots,
106
+ 8, knots,
107
+ 4 * 3,
108
+ 3,
109
+ $ctlpoints.flatten,
110
+ 4, 4,
111
+ GL_MAP2_VERTEX_3)
112
+ gluEndSurface($theNurb)
113
+
114
+ if($showPoints==1)
115
+ glPointSize(5.0)
116
+ glDisable(GL_LIGHTING)
117
+ glColor(1.0, 1.0, 0.0)
118
+ glBegin(GL_POINTS)
119
+ for i in 0..3
120
+ for j in 0..3
121
+ glVertex($ctlpoints[i][j][0], $ctlpoints[i][j][1], $ctlpoints[i][j][2])
122
+ end
123
+ end
124
+ glEnd()
125
+ glEnable(GL_LIGHTING)
126
+ end
127
+
128
+ glPopMatrix()
129
+ glutSwapBuffers()
130
+ end
131
+
132
+ reshape = Proc.new do |w, h|
133
+ glViewport(0, 0, w, h)
134
+ glMatrixMode(GL_PROJECTION)
135
+ glLoadIdentity()
136
+ gluPerspective(45.0, w/h, 3.0, 8.0)
137
+
138
+ glMatrixMode(GL_MODELVIEW)
139
+ glLoadIdentity()
140
+ glTranslate(0.0, 0.0, -5.0)
141
+ end
142
+
143
+ menu = Proc.new do |value|
144
+ $showPoints = value
145
+ glutPostRedisplay()
146
+ end
147
+
148
+ keyboard = Proc.new do |key, x, y|
149
+ case (key)
150
+ when ?\e
151
+ exit(0);
152
+ end
153
+ end
154
+
155
+ glutInit
156
+ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
157
+ glutInitWindowSize(500, 500)
158
+ glutInitWindowPosition(100, 100)
159
+ glutCreateWindow($0)
160
+ myinit()
161
+ glutReshapeFunc(reshape)
162
+ glutDisplayFunc(display)
163
+ glutKeyboardFunc(keyboard)
164
+ glutCreateMenu(menu)
165
+ glutAddMenuEntry("Show control points", 1)
166
+ glutAddMenuEntry("Hide control points", 0)
167
+ glutAttachMenu(GLUT_RIGHT_BUTTON)
168
+ glutMainLoop()