ruby-opengl 0.40.1 → 0.50.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. data/Rakefile +2 -2
  2. data/doc/build_install.txt +48 -28
  3. data/doc/extensions.txt +361 -0
  4. data/doc/history.txt +8 -2
  5. data/doc/requirements_and_design.txt +0 -13
  6. data/doc/roadmap.txt +11 -13
  7. data/doc/supplies/page_template.html +11 -5
  8. data/doc/thanks.txt +2 -4
  9. data/doc/tutorial.txt +1 -4
  10. data/examples/{nehe_lesson02.rb → NeHe/nehe_lesson02.rb} +0 -0
  11. data/examples/{nehe_lesson03.rb → NeHe/nehe_lesson03.rb} +0 -0
  12. data/examples/{nehe_lesson04.rb → NeHe/nehe_lesson04.rb} +0 -0
  13. data/examples/{nehe_lesson05.rb → NeHe/nehe_lesson05.rb} +0 -0
  14. data/examples/NeHe/nehe_lesson36.rb +303 -0
  15. data/examples/OrangeBook/3Dlabs-License.txt +33 -0
  16. data/examples/OrangeBook/brick.frag +36 -0
  17. data/examples/OrangeBook/brick.rb +388 -0
  18. data/examples/OrangeBook/brick.vert +41 -0
  19. data/examples/OrangeBook/particle.frag +17 -0
  20. data/examples/OrangeBook/particle.rb +424 -0
  21. data/examples/OrangeBook/particle.vert +38 -0
  22. data/examples/README +13 -83
  23. data/examples/RedBook/aaindex.rb +97 -0
  24. data/examples/RedBook/aapoly.rb +142 -0
  25. data/examples/RedBook/aargb.rb +119 -0
  26. data/examples/RedBook/accanti.rb +162 -0
  27. data/examples/RedBook/accpersp.rb +215 -0
  28. data/examples/RedBook/alpha.rb +123 -0
  29. data/examples/RedBook/alpha3D.rb +158 -0
  30. data/examples/RedBook/bezcurve.rb +105 -0
  31. data/examples/RedBook/bezmesh.rb +137 -0
  32. data/examples/RedBook/checker.rb +124 -0
  33. data/examples/RedBook/clip.rb +95 -0
  34. data/examples/RedBook/colormat.rb +135 -0
  35. data/examples/RedBook/cube.rb +69 -0
  36. data/examples/RedBook/depthcue.rb +99 -0
  37. data/examples/RedBook/dof.rb +205 -0
  38. data/examples/{legacy → RedBook}/double.rb +59 -58
  39. data/examples/{legacy → RedBook}/drawf.rb +47 -54
  40. data/examples/RedBook/feedback.rb +145 -0
  41. data/examples/RedBook/fog.rb +167 -0
  42. data/examples/RedBook/font.rb +151 -0
  43. data/examples/RedBook/hello.rb +79 -0
  44. data/examples/RedBook/image.rb +137 -0
  45. data/examples/{legacy → RedBook}/jitter.rb +60 -62
  46. data/examples/RedBook/lines.rb +128 -0
  47. data/examples/RedBook/list.rb +111 -0
  48. data/examples/RedBook/material.rb +275 -0
  49. data/examples/RedBook/mipmap.rb +156 -0
  50. data/examples/{legacy → RedBook}/model.rb +66 -72
  51. data/examples/{legacy → RedBook}/movelight.rb +67 -75
  52. data/examples/RedBook/pickdepth.rb +179 -0
  53. data/examples/{legacy → RedBook}/planet.rb +62 -66
  54. data/examples/RedBook/quadric.rb +158 -0
  55. data/examples/RedBook/robot.rb +115 -0
  56. data/examples/RedBook/select.rb +196 -0
  57. data/examples/RedBook/smooth.rb +95 -0
  58. data/examples/RedBook/stencil.rb +163 -0
  59. data/examples/RedBook/stroke.rb +167 -0
  60. data/examples/RedBook/surface.rb +166 -0
  61. data/examples/RedBook/teaambient.rb +132 -0
  62. data/examples/RedBook/teapots.rb +182 -0
  63. data/examples/RedBook/tess.rb +183 -0
  64. data/examples/RedBook/texbind.rb +147 -0
  65. data/examples/RedBook/texgen.rb +169 -0
  66. data/examples/RedBook/texturesurf.rb +128 -0
  67. data/examples/RedBook/varray.rb +159 -0
  68. data/examples/RedBook/wrap.rb +148 -0
  69. data/examples/misc/anisotropic.rb +194 -0
  70. data/examples/misc/font-glut.rb +46 -0
  71. data/examples/{plane.rb → misc/plane.rb} +0 -0
  72. data/examples/misc/readpixel.rb +65 -0
  73. data/examples/{smooth.rb → misc/smooth.rb} +0 -0
  74. data/examples/{test.rb → misc/test.rb} +0 -0
  75. data/ext/common/common.h +252 -70
  76. data/ext/common/gl-enums.h +6102 -7334
  77. data/ext/common/gl-types.h +47 -0
  78. data/ext/common/glu-enums.h +469 -0
  79. data/ext/gl/gl-1.0-1.1.c +842 -2464
  80. data/ext/gl/gl-1.2.c +217 -281
  81. data/ext/gl/gl-1.3.c +113 -133
  82. data/ext/gl/gl-1.4.c +98 -334
  83. data/ext/gl/gl-1.5.c +28 -34
  84. data/ext/gl/gl-2.0.c +26 -235
  85. data/ext/gl/gl-2.1.c +31 -124
  86. data/ext/gl/gl-enums.c +786 -631
  87. data/ext/gl/gl-ext-arb.c +66 -0
  88. data/ext/gl/gl-ext-ext.c +218 -0
  89. data/ext/gl/gl.c +138 -31
  90. data/ext/gl/mkrf_conf.rb +1 -0
  91. data/ext/glu/glu-enums.c +163 -0
  92. data/ext/glu/glu.c +1003 -1205
  93. data/ext/glu/mkrf_conf.rb +1 -0
  94. data/ext/glut/glut.c +1056 -1175
  95. data/lib/opengl.rb +90 -3
  96. data/test/tc_common.rb +26 -13
  97. data/test/tc_ext_arb.rb +73 -0
  98. data/test/tc_ext_ext.rb +74 -0
  99. data/test/tc_func_12.rb +8 -8
  100. data/test/tc_func_13.rb +17 -11
  101. data/test/tc_func_14.rb +8 -8
  102. data/test/tc_func_15.rb +190 -2
  103. data/test/tc_func_20.rb +36 -10
  104. data/test/tc_func_21.rb +445 -2
  105. data/test/tc_glu.rb +305 -0
  106. data/test/tc_misc.rb +1 -0
  107. metadata +84 -68
  108. data/doc/screenshots.txt +0 -23
  109. data/examples/legacy/COPYRIGHT +0 -8
  110. data/examples/legacy/aaindex.rb +0 -98
  111. data/examples/legacy/aapoly.rb +0 -153
  112. data/examples/legacy/aargb.rb +0 -139
  113. data/examples/legacy/accanti.rb +0 -159
  114. data/examples/legacy/accpersp.rb +0 -216
  115. data/examples/legacy/alpha.rb +0 -133
  116. data/examples/legacy/alpha3D.rb +0 -165
  117. data/examples/legacy/bezcurve.rb +0 -107
  118. data/examples/legacy/bezmesh.rb +0 -131
  119. data/examples/legacy/checker.rb +0 -121
  120. data/examples/legacy/clip.rb +0 -104
  121. data/examples/legacy/colormat.rb +0 -145
  122. data/examples/legacy/cube.rb +0 -73
  123. data/examples/legacy/depthcue.rb +0 -101
  124. data/examples/legacy/dof.rb +0 -212
  125. data/examples/legacy/feedback.rb +0 -152
  126. data/examples/legacy/fog.rb +0 -172
  127. data/examples/legacy/font-glut.rb +0 -41
  128. data/examples/legacy/font.rb +0 -158
  129. data/examples/legacy/hello.rb +0 -75
  130. data/examples/legacy/image.rb +0 -145
  131. data/examples/legacy/lines.rb +0 -135
  132. data/examples/legacy/list.rb +0 -120
  133. data/examples/legacy/material.rb +0 -290
  134. data/examples/legacy/mipmap.rb +0 -159
  135. data/examples/legacy/pickdepth.rb +0 -180
  136. data/examples/legacy/quadric.rb +0 -180
  137. data/examples/legacy/readpixel.rb +0 -59
  138. data/examples/legacy/robot.rb +0 -120
  139. data/examples/legacy/select.rb +0 -207
  140. data/examples/legacy/smooth.rb +0 -41
  141. data/examples/legacy/stencil.rb +0 -154
  142. data/examples/legacy/stroke.rb +0 -170
  143. data/examples/legacy/surface.rb +0 -170
  144. data/examples/legacy/teaambient.rb +0 -132
  145. data/examples/legacy/teapots.rb +0 -188
  146. data/examples/legacy/tess.rb +0 -222
  147. data/examples/legacy/texbind.rb +0 -157
  148. data/examples/legacy/texgen.rb +0 -171
  149. data/examples/legacy/texturesurf.rb +0 -128
  150. data/examples/legacy/varray.rb +0 -167
  151. data/examples/legacy/wrap.rb +0 -158
  152. data/lib/gl_prev.rb +0 -46
  153. data/lib/glu_prev.rb +0 -46
  154. data/lib/glut_prev.rb +0 -45
@@ -1,180 +0,0 @@
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
- #
38
- #/*
39
- # * quadric.c
40
- # * This program demonstrates the use of some of the gluQuadric*
41
- # * routines. Quadric objects are created with some quadric
42
- # * properties and the callback routine to handle errors.
43
- # * Note that the cylinder has no top or bottom and the circle
44
- # * has a hole in it.
45
- # */
46
- require "gl_prev"
47
- require "glu_prev"
48
- require "glut_prev"
49
- require "mathn"
50
-
51
- $startList = nil;
52
-
53
- #void CALLBACK errorCallback(GLenum errorCode)
54
- #{
55
- # const GLubyte *estring;
56
- #
57
- # estring = gluErrorString(errorCode);
58
- # fprintf(stderr, "Quadric Error: %s\n", estring);
59
- # exit(0);
60
- #}
61
-
62
- def init
63
- mat_ambient = [ 0.5, 0.5, 0.5, 1.0 ];
64
- mat_specular = [ 1.0, 1.0, 1.0, 1.0 ];
65
- mat_shininess = [ 50.0 ];
66
- light_position = [ 1.0, 1.0, 1.0, 0.0 ];
67
- model_ambient = [ 0.5, 0.5, 0.5, 1.0 ];
68
-
69
- GL.ClearColor(0.0, 0.0, 0.0, 0.0);
70
-
71
- GL.Material(GL::FRONT, GL::AMBIENT, mat_ambient);
72
- GL.Material(GL::FRONT, GL::SPECULAR, mat_specular);
73
- GL.Material(GL::FRONT, GL::SHININESS, mat_shininess);
74
- GL.Light(GL::LIGHT0, GL::POSITION, light_position);
75
- GL.LightModel(GL::LIGHT_MODEL_AMBIENT, model_ambient);
76
-
77
- GL.Enable(GL::LIGHTING);
78
- GL.Enable(GL::LIGHT0);
79
- GL.Enable(GL::DEPTH_TEST);
80
-
81
- #/* Create 4 display lists, each with a different quadric object.
82
- # * Different drawing styles and surface normal specifications
83
- # * are demonstrated.
84
- # */
85
- $startList = GL.GenLists(4);
86
- qobj = GLU.NewQuadric();
87
- # gluQuadricCallback(qobj, GLU_ERROR,
88
- # (GLvoid (CALLBACK*) ()) errorCallback);
89
-
90
- GLU.QuadricDrawStyle(qobj, GLU::FILL); #/* smooth shaded */
91
- GLU.QuadricNormals(qobj, GLU::SMOOTH);
92
- GL.NewList($startList, GL::COMPILE);
93
- GLU.Sphere(qobj, 0.75, 15, 10);
94
- GL.EndList();
95
-
96
- GLU.QuadricDrawStyle(qobj, GLU::FILL); #/* flat shaded */
97
- GLU.QuadricNormals(qobj, GLU::FLAT);
98
- GL.NewList($startList+1, GL::COMPILE);
99
- GLU.Cylinder(qobj, 0.5, 0.3, 1.0, 15, 5);
100
- GL.EndList();
101
-
102
- GLU.QuadricDrawStyle(qobj, GLU::LINE); #/* all polygons wireframe */
103
- GLU.QuadricNormals(qobj, GLU::NONE);
104
- GL.NewList($startList+2, GL::COMPILE);
105
- GLU.Disk(qobj, 0.25, 1.0, 20, 4);
106
- GL.EndList();
107
-
108
- GLU.QuadricDrawStyle(qobj, GLU::SILHOUETTE); #/* boundary only */
109
- GLU.QuadricNormals(qobj, GLU::NONE);
110
- GL.NewList($startList+3, GL::COMPILE);
111
- GLU.PartialDisk(qobj, 0.0, 1.0, 20, 4, 0.0, 225.0);
112
- GL.EndList();
113
- end
114
-
115
- display = Proc.new {
116
- GL.Clear(GL::COLOR_BUFFER_BIT | GL::DEPTH_BUFFER_BIT);
117
- GL.PushMatrix();
118
-
119
- GL.Enable(GL::LIGHTING);
120
- GL.ShadeModel(GL::SMOOTH);
121
- GL.Translate(-1.0, -1.0, 0.0);
122
- GL.CallList($startList);
123
-
124
- GL.ShadeModel(GL::FLAT);
125
- GL.Translate(0.0, 2.0, 0.0);
126
- GL.PushMatrix();
127
- GL.Rotate(300.0, 1.0, 0.0, 0.0);
128
- GL.CallList($startList+1);
129
- GL.PopMatrix();
130
-
131
- GL.Disable(GL::LIGHTING);
132
- GL.Color(0.0, 1.0, 1.0);
133
- GL.Translate(2.0, -2.0, 0.0);
134
- GL.CallList($startList+2);
135
-
136
- GL.Color(1.0, 1.0, 0.0);
137
- GL.Translate(0.0, 2.0, 0.0);
138
- GL.CallList($startList+3);
139
-
140
- GL.PopMatrix();
141
- GL.Flush();
142
- }
143
-
144
- reshape = Proc.new {|w, h|
145
- GL.Viewport(0, 0, w, h);
146
- GL.MatrixMode(GL::PROJECTION);
147
- GL.LoadIdentity();
148
- if (w <= h)
149
- GL.Ortho(-2.5, 2.5, -2.5*h/w,
150
- 2.5*h/w, -10.0, 10.0);
151
- else
152
- GL.Ortho(-2.5*w/h,
153
- 2.5*w/h, -2.5, 2.5, -10.0, 10.0);
154
- end
155
- GL.MatrixMode(GL::MODELVIEW);
156
- GL.LoadIdentity();
157
- }
158
-
159
- #/* ARGSUSED1 */
160
- keyboard = Proc.new {|key, x, y|
161
- case (key)
162
- when 27
163
- exit(0);
164
- end
165
- }
166
-
167
- #int main(int argc, char** argv)
168
- #{
169
- GLUT.Init
170
- GLUT.InitDisplayMode(GLUT::SINGLE | GLUT::RGB | GLUT::DEPTH);
171
- GLUT.InitWindowSize(500, 500);
172
- GLUT.InitWindowPosition(100, 100);
173
- GLUT.CreateWindow($0);
174
- init();
175
- GLUT.DisplayFunc(display);
176
- GLUT.ReshapeFunc(reshape);
177
- GLUT.KeyboardFunc(keyboard);
178
- GLUT.MainLoop();
179
- # return 0;
180
- #}
@@ -1,59 +0,0 @@
1
- require "gl_prev"
2
- require "glu_prev"
3
- require "glut_prev"
4
-
5
- begin
6
- require "RMagick"
7
- rescue Exception
8
- print "This sample needs RMagick Module.\n"
9
- exit
10
- end
11
-
12
- WIDTH = 200
13
- HEIGHT = 200
14
-
15
- display = Proc.new {
16
- GL.Clear(GL::COLOR_BUFFER_BIT);
17
-
18
- GL.Begin(GL::LINES);
19
- GL.Vertex(0.5, 0.5);
20
- GL.Vertex(-0.5, -0.5);
21
- GL.End
22
-
23
- GL.Flush();
24
-
25
- pixel_str = GL.ReadPixels(0, 0, WIDTH, HEIGHT, GL::RGBA, GL::SHORT)
26
- pixels = pixel_str.unpack("s*")
27
-
28
- image = Magick::Image.new(WIDTH, HEIGHT)
29
- image.import_pixels(0, 0, WIDTH, HEIGHT, "RGBA", pixels)
30
- image.flip!
31
- # image.write("opengl_window.gif")
32
- }
33
-
34
- reshape = Proc.new {|w, h|
35
- GL.Viewport(0, 0, w, h);
36
- GL.MatrixMode(GL::PROJECTION);
37
- GL.LoadIdentity();
38
- if (w <= h)
39
- GLU.Ortho2D(-1.0, 1.0, -h.to_f/w.to_f, h.to_f/w.to_f);
40
- else
41
- GLU.Ortho2D(w.to_f/h.to_f, w.to_f/h.to_f, -1.0, 1.0);
42
- end
43
- GL.MatrixMode(GL::MODELVIEW);
44
- GL.LoadIdentity();
45
- }
46
-
47
-
48
- # Main Loop
49
- # Open window with initial window size, title bar,
50
- # color index display mode, and handle input events.
51
- #
52
- GLUT.Init
53
- GLUT.InitDisplayMode(GLUT::SINGLE | GLUT::RGB | GLUT::ALPHA);
54
- GLUT.InitWindowSize(WIDTH, HEIGHT);
55
- GLUT.CreateWindow($0);
56
- GLUT.ReshapeFunc(reshape);
57
- GLUT.DisplayFunc(display);
58
- GLUT.MainLoop
59
-
@@ -1,120 +0,0 @@
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
- #
38
- #/*
39
- # * robot.c
40
- # * This program shows how to composite modeling transformations
41
- # * to draw translated and rotated hierarchical models.
42
- # * Interaction: pressing the s and e keys (shoulder and elbow)
43
- # * alters the rotation of the robot arm.
44
- # */
45
- require "gl_prev"
46
- require "glu_prev"
47
- require "glut_prev"
48
- require "mathn"
49
-
50
- $shoulder = 0;
51
- $elbow = 0;
52
-
53
- def init
54
- GL.ClearColor(0.0, 0.0, 0.0, 0.0);
55
- GL.ShadeModel(GL::FLAT);
56
- end
57
-
58
- display = Proc.new {
59
- GL.Clear(GL::COLOR_BUFFER_BIT);
60
- GL.PushMatrix();
61
- GL.Translate(-1.0, 0.0, 0.0);
62
- GL.Rotate($shoulder, 0.0, 0.0, 1.0);
63
- GL.Translate(1.0, 0.0, 0.0);
64
- GL.PushMatrix();
65
- GL.Scale(2.0, 0.4, 1.0);
66
- GLUT.WireCube (1.0);
67
- GL.PopMatrix();
68
-
69
- GL.Translate(1.0, 0.0, 0.0);
70
- GL.Rotate($elbow, 0.0, 0.0, 1.0);
71
- GL.Translate(1.0, 0.0, 0.0);
72
- GL.PushMatrix();
73
- GL.Scale(2.0, 0.4, 1.0);
74
- GLUT.WireCube(1.0);
75
- GL.PopMatrix();
76
-
77
- GL.PopMatrix();
78
- GLUT.SwapBuffers();
79
- }
80
-
81
- reshape = Proc.new {|w, h|
82
- GL.Viewport(0, 0, w, h);
83
- GL.MatrixMode(GL::PROJECTION);
84
- GL.LoadIdentity();
85
- GLU.Perspective(65.0, w/ h, 1.0, 20.0);
86
- GL.MatrixMode(GL::MODELVIEW);
87
- GL.LoadIdentity();
88
- GL.Translate(0.0, 0.0, -5.0);
89
- }
90
-
91
- #/* ARGSUSED1 */
92
- keyboard = Proc.new {|key, x, y|
93
- case (key)
94
- when 's'[0]
95
- $shoulder = ($shoulder + 5) % 360;
96
- GLUT.PostRedisplay();
97
- when 'S'[0]
98
- $shoulder = ($shoulder - 5) % 360;
99
- GLUT.PostRedisplay();
100
- when 'e'[0]
101
- $elbow = ($elbow + 5) % 360;
102
- GLUT.PostRedisplay();
103
- when 'E'[0]
104
- $elbow = ($elbow - 5) % 360;
105
- GLUT.PostRedisplay();
106
- when 27
107
- exit(0);
108
- end
109
- }
110
-
111
- GLUT.Init
112
- GLUT.InitDisplayMode(GLUT::DOUBLE | GLUT::RGB);
113
- GLUT.InitWindowSize(500, 500);
114
- GLUT.InitWindowPosition(100, 100);
115
- GLUT.CreateWindow($0);
116
- init();
117
- GLUT.DisplayFunc(display);
118
- GLUT.ReshapeFunc(reshape);
119
- GLUT.KeyboardFunc(keyboard);
120
- GLUT.MainLoop();
@@ -1,207 +0,0 @@
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
- #
38
- #/*
39
- # * select.c
40
- # * This is an illustration of the selection mode and
41
- # * name stack, which detects whether objects which collide
42
- # * with a viewing volume. First, four triangles and a
43
- # * rectangular box representing a viewing volume are drawn
44
- # * (drawScene routine). The green triangle and yellow
45
- # * triangles appear to lie within the viewing volume, but
46
- # * the red triangle appears to lie outside it. Then the
47
- # * selection mode is entered (selectObjects routine).
48
- # * Drawing to the screen ceases. To see if any collisions
49
- # * occur, the four triangles are called. In this example,
50
- # * the green triangle causes one hit with the name 1, and
51
- # * the yellow triangles cause one hit with the name 3.
52
- # */
53
-
54
- require "gl_prev"
55
- require "glu_prev"
56
- require "glut_prev"
57
-
58
-
59
- #/* draw a triangle with vertices at (x1, y1), (x2, y2)
60
- # * and (x3, y3) at z units away from the origin.
61
- # */
62
- def drawTriangle(x1, y1, x2, y2, x3, y3, z)
63
- GL::Begin(GL::TRIANGLES);
64
- GL::Vertex(x1, y1, z);
65
- GL::Vertex(x2, y2, z);
66
- GL::Vertex(x3, y3, z);
67
- GL::End();
68
- end
69
-
70
- #/* draw a rectangular box with these outer x, y, and z values */
71
- def drawViewVolume(x1, x2, y1, y2, z1, z2)
72
- GL::Color(1.0, 1.0, 1.0);
73
- GL::Begin(GL::LINE_LOOP);
74
- GL::Vertex(x1, y1, -z1);
75
- GL::Vertex(x2, y1, -z1);
76
- GL::Vertex(x2, y2, -z1);
77
- GL::Vertex(x1, y2, -z1);
78
- GL::End();
79
-
80
- GL::Begin(GL::LINE_LOOP);
81
- GL::Vertex(x1, y1, -z2);
82
- GL::Vertex(x2, y1, -z2);
83
- GL::Vertex(x2, y2, -z2);
84
- GL::Vertex(x1, y2, -z2);
85
- GL::End();
86
-
87
- GL::Begin(GL::LINES);# /* 4 lines */
88
- GL::Vertex(x1, y1, -z1);
89
- GL::Vertex(x1, y1, -z2);
90
- GL::Vertex(x1, y2, -z1);
91
- GL::Vertex(x1, y2, -z2);
92
- GL::Vertex(x2, y1, -z1);
93
- GL::Vertex(x2, y1, -z2);
94
- GL::Vertex(x2, y2, -z1);
95
- GL::Vertex(x2, y2, -z2);
96
- GL::End();
97
- end
98
-
99
- #/* drawScene draws 4 triangles and a wire frame
100
- # * which represents the viewing volume.
101
- # */
102
- def drawScene()
103
- GL::MatrixMode(GL::PROJECTION);
104
- GL::LoadIdentity();
105
- GLU::Perspective(40.0, 4.0/3.0, 1.0, 100.0);
106
-
107
- GL::MatrixMode(GL::MODELVIEW);
108
- GL::LoadIdentity();
109
- GLU::LookAt(7.5, 7.5, 12.5, 2.5, 2.5, -5.0, 0.0, 1.0, 0.0);
110
- GL::Color(0.0, 1.0, 0.0);# /* green triangle */
111
- drawTriangle(2.0, 2.0, 3.0, 2.0, 2.5, 3.0, -5.0);
112
- GL::Color(1.0, 0.0, 0.0);# /* red triangle */
113
- drawTriangle(2.0, 7.0, 3.0, 7.0, 2.5, 8.0, -5.0);
114
- GL::Color(1.0, 1.0, 0.0);# /* yellow triangles */
115
- drawTriangle(2.0, 2.0, 3.0, 2.0, 2.5, 3.0, 0.0);
116
- drawTriangle(2.0, 2.0, 3.0, 2.0, 2.5, 3.0, -10.0);
117
- drawViewVolume(0.0, 5.0, 0.0, 5.0, 0.0, 10.0);
118
- end
119
-
120
- #/* processHits prints out the contents of the selection array
121
- # */
122
- def processHits(hits, buffer)
123
- printf("hits = %d\n", hits);
124
- ptr = buffer.unpack("I*")
125
- p = 0
126
- for i in 0...hits #/* for each hit */
127
- names = ptr[p]
128
- printf(" number of names for hit = %d\n", names); p+=1;
129
- printf(" z1 is %g;", ptr[p].to_f/0xffffffff); p+=1;
130
- printf(" z2 is %g\n", ptr[p].to_f/0xffffffff); p+=1;
131
- printf(" the name is ");
132
- for j in 0...names # /* for each name */
133
- printf("%d ", ptr[p]); p+=1
134
- end
135
- printf("\n");
136
- end
137
- end
138
-
139
- #/* selectObjects "draws" the triangles in selection mode,
140
- # * assigning names for the triangles. Note that the third
141
- # * and fourth triangles share one name, so that if either
142
- # * or both triangles intersects the viewing/clipping volume,
143
- # * only one hit will be registered.
144
- # */
145
-
146
- BUFSIZE=512
147
-
148
- def selectObjects
149
-
150
- selectBuf = GL::SelectBuffer(BUFSIZE);
151
- GL::RenderMode(GL::SELECT);
152
-
153
- GL::InitNames();
154
- GL::PushName(0);
155
-
156
- GL::PushMatrix();
157
- GL::MatrixMode(GL::PROJECTION);
158
- GL::LoadIdentity();
159
- GL::Ortho(0.0, 5.0, 0.0, 5.0, 0.0, 10.0);
160
- GL::MatrixMode(GL::MODELVIEW);
161
- GL::LoadIdentity();
162
- GL::LoadName(1);
163
- drawTriangle(2.0, 2.0, 3.0, 2.0, 2.5, 3.0, -5.0);
164
- GL::LoadName(2);
165
- drawTriangle(2.0, 7.0, 3.0, 7.0, 2.5, 8.0, -5.0);
166
- GL::LoadName(3);
167
- drawTriangle(2.0, 2.0, 3.0, 2.0, 2.5, 3.0, 0.0);
168
- drawTriangle(2.0, 2.0, 3.0, 2.0, 2.5, 3.0, -10.0);
169
- GL::PopMatrix();
170
- GL::Flush();
171
-
172
- hits = GL::RenderMode(GL::RENDER);
173
- processHits(hits, selectBuf);
174
- end
175
-
176
- def init
177
- GL::Enable(GL::DEPTH_TEST);
178
- GL::ShadeModel(GL::FLAT);
179
- end
180
-
181
- display = proc {
182
- GL::ClearColor(0.0, 0.0, 0.0, 0.0);
183
- GL::Clear(GL::COLOR_BUFFER_BIT | GL::DEPTH_BUFFER_BIT);
184
- drawScene();
185
- selectObjects();
186
- GL::Flush();
187
- }
188
-
189
- #/* ARGSUSED1 */
190
- keyboard = proc {|key, x, y|
191
- case (key)
192
- when 27
193
- exit(0);
194
- end
195
- }
196
-
197
- #/* Main Loop */
198
-
199
- GLUT.Init
200
- GLUT::InitDisplayMode(GLUT::SINGLE | GLUT::RGB | GLUT::DEPTH);
201
- GLUT::InitWindowSize(200, 200);
202
- GLUT::InitWindowPosition(100, 100);
203
- GLUT::CreateWindow $0
204
- init();
205
- GLUT::DisplayFunc(display);
206
- GLUT::KeyboardFunc(keyboard);
207
- GLUT::MainLoop();