ruby-opengl 0.33.0 → 0.40.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. data/Rakefile +42 -15
  2. data/doc/build_install.txt +70 -25
  3. data/doc/history.txt +4 -0
  4. data/doc/requirements_and_design.txt +2 -3
  5. data/doc/roadmap.txt +15 -2
  6. data/doc/screenshots.txt +23 -0
  7. data/doc/supplies/page_template.html +2 -1
  8. data/doc/thanks.txt +3 -0
  9. data/doc/tutorial.txt +5 -3
  10. data/examples/README +57 -7
  11. data/examples/legacy/COPYRIGHT +8 -0
  12. data/examples/{aaindex.rb → legacy/aaindex.rb} +6 -5
  13. data/examples/legacy/aapoly.rb +153 -0
  14. data/examples/legacy/aargb.rb +139 -0
  15. data/examples/legacy/accanti.rb +159 -0
  16. data/examples/legacy/accpersp.rb +216 -0
  17. data/examples/legacy/alpha.rb +133 -0
  18. data/examples/legacy/alpha3D.rb +165 -0
  19. data/examples/legacy/bezcurve.rb +107 -0
  20. data/examples/legacy/bezmesh.rb +131 -0
  21. data/examples/legacy/checker.rb +121 -0
  22. data/examples/legacy/clip.rb +104 -0
  23. data/examples/legacy/colormat.rb +145 -0
  24. data/examples/legacy/cube.rb +73 -0
  25. data/examples/legacy/depthcue.rb +101 -0
  26. data/examples/legacy/dof.rb +212 -0
  27. data/examples/legacy/double.rb +104 -0
  28. data/examples/legacy/drawf.rb +98 -0
  29. data/examples/legacy/feedback.rb +152 -0
  30. data/examples/legacy/fog.rb +172 -0
  31. data/examples/legacy/font-glut.rb +41 -0
  32. data/examples/legacy/font.rb +158 -0
  33. data/examples/legacy/hello.rb +75 -0
  34. data/examples/legacy/image.rb +145 -0
  35. data/examples/legacy/jitter.rb +209 -0
  36. data/examples/legacy/lines.rb +135 -0
  37. data/examples/legacy/list.rb +120 -0
  38. data/examples/legacy/material.rb +290 -0
  39. data/examples/legacy/mipmap.rb +159 -0
  40. data/examples/legacy/model.rb +119 -0
  41. data/examples/legacy/movelight.rb +140 -0
  42. data/examples/legacy/pickdepth.rb +180 -0
  43. data/examples/legacy/planet.rb +112 -0
  44. data/examples/legacy/quadric.rb +180 -0
  45. data/examples/legacy/readpixel.rb +59 -0
  46. data/examples/legacy/robot.rb +120 -0
  47. data/examples/legacy/select.rb +207 -0
  48. data/examples/{smooth_prev.rb → legacy/smooth.rb} +3 -2
  49. data/examples/legacy/stencil.rb +154 -0
  50. data/examples/legacy/stroke.rb +170 -0
  51. data/examples/legacy/surface.rb +170 -0
  52. data/examples/legacy/teaambient.rb +132 -0
  53. data/examples/legacy/teapots.rb +188 -0
  54. data/examples/legacy/tess.rb +222 -0
  55. data/examples/legacy/texbind.rb +157 -0
  56. data/examples/legacy/texgen.rb +171 -0
  57. data/examples/legacy/texturesurf.rb +128 -0
  58. data/examples/legacy/varray.rb +167 -0
  59. data/examples/legacy/wrap.rb +158 -0
  60. data/examples/nehe_lesson02.rb +117 -0
  61. data/examples/nehe_lesson03.rb +122 -0
  62. data/examples/nehe_lesson04.rb +133 -0
  63. data/examples/nehe_lesson05.rb +186 -0
  64. data/examples/plane.rb +1 -1
  65. data/examples/smooth.rb +4 -2
  66. data/examples/test.rb +3 -2
  67. data/ext/common/{rbogl.c → common.h} +99 -32
  68. data/ext/common/gl-enums.h +39 -1
  69. data/ext/gl/gl-1.0-1.1.c +350 -305
  70. data/ext/gl/gl-1.2.c +933 -38
  71. data/ext/gl/gl-1.3.c +725 -0
  72. data/ext/gl/gl-1.4.c +647 -0
  73. data/ext/gl/gl-1.5.c +362 -0
  74. data/ext/gl/gl-2.0.c +1632 -0
  75. data/ext/gl/gl-2.1.c +154 -0
  76. data/ext/gl/gl-enums.c +1 -2
  77. data/ext/gl/gl.c +58 -2
  78. data/ext/gl/mkrf_conf.rb +4 -1
  79. data/ext/glu/glu.c +5 -4
  80. data/ext/glu/mkrf_conf.rb +4 -1
  81. data/ext/glut/glut.c +7 -1
  82. data/ext/glut/mkrf_conf.rb +5 -0
  83. data/lib/gl_prev.rb +4 -3
  84. data/lib/glu_prev.rb +4 -3
  85. data/lib/glut_prev.rb +3 -3
  86. data/{examples/all_tests.rb → lib/opengl.rb} +9 -12
  87. data/test/README +5 -18
  88. data/test/tc_common.rb +79 -0
  89. data/test/tc_func_10_11.rb +1255 -0
  90. data/test/tc_func_12.rb +186 -0
  91. data/test/tc_func_13.rb +203 -0
  92. data/test/tc_func_14.rb +197 -0
  93. data/test/tc_func_15.rb +82 -0
  94. data/test/tc_func_20.rb +320 -0
  95. data/test/tc_func_21.rb +67 -0
  96. data/test/tc_include_gl.rb +1 -1
  97. data/test/{tc_opengl_namespace.rb → tc_misc.rb} +20 -20
  98. data/test/tc_require_gl.rb +1 -1
  99. metadata +99 -27
  100. data/ext/common/Rakefile +0 -39
  101. data/ext/common/rbogl.h +0 -52
  102. data/test/runtests.sh +0 -7
  103. data/test/tc_gl_vertex.rb +0 -180
@@ -0,0 +1,207 @@
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();
@@ -1,5 +1,6 @@
1
- require "../lib/gl_prev"
2
- require "../lib/glut_prev"
1
+ #!/usr/bin/env ruby -rubygems
2
+ require "gl_prev"
3
+ require "glut_prev"
3
4
 
4
5
  STDOUT.sync=TRUE
5
6
  disp = Proc.new {
@@ -0,0 +1,154 @@
1
+
2
+ # Copyright (c) Mark J. Kilgard, 1994. */
3
+
4
+ #
5
+ # (c) Copyright 1993, Silicon Graphics, Inc.
6
+ # ALL RIGHTS RESERVED
7
+ # Permission to use, copy, modify, and distribute this software for
8
+ # any purpose and without fee is hereby granted, provided that the above
9
+ # copyright notice appear in all copies and that both the copyright notice
10
+ # and this permission notice appear in supporting documentation, and that
11
+ # the name of Silicon Graphics, Inc. not be used in advertising
12
+ # or publicity pertaining to distribution of the software without specific,
13
+ # written prior permission.
14
+ #
15
+ # THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
16
+ # AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
17
+ # INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
18
+ # FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
19
+ # GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
20
+ # SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
21
+ # KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
22
+ # LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
23
+ # THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
24
+ # ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
25
+ # ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
26
+ # POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
27
+ #
28
+ # US Government Users Restricted Rights
29
+ # Use, duplication, or disclosure by the Government is subject to
30
+ # restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
31
+ # (c)(1)(ii) of the Rights in Technical Data and Computer Software
32
+ # clause at DFARS 252.227-7013 and/or in similar or successor
33
+ # clauses in the FAR or the DOD or NASA FAR Supplement.
34
+ # Unpublished-- rights reserved under the copyright laws of the
35
+ # United States. Contractor/manufacturer is Silicon Graphics,
36
+ # Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
37
+ #
38
+ # OpenGL(TM) is a trademark of Silicon Graphics, Inc.
39
+ #/
40
+ # stencil.c
41
+ # This program draws two rotated tori in a window.
42
+ # A diamond in the center of the window masks out part
43
+ # of the scene. Within this mask, a different model
44
+ # (a sphere) is drawn in a different color.
45
+ #/
46
+ require "gl_prev"
47
+ require "glu_prev"
48
+ require "glut_prev"
49
+ require "rational"
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
+ GL.NewList(YELLOWMAT, GL::COMPILE);
64
+ GL.Material(GL::FRONT, GL::DIFFUSE, yellow_diffuse);
65
+ GL.Material(GL::FRONT, GL::SPECULAR, yellow_specular);
66
+ GL.Material(GL::FRONT, GL::SHININESS, 64.0);
67
+ GL.EndList();
68
+
69
+ GL.NewList(BLUEMAT, GL::COMPILE);
70
+ GL.Material(GL::FRONT, GL::DIFFUSE, blue_diffuse);
71
+ GL.Material(GL::FRONT, GL::SPECULAR, blue_specular);
72
+ GL.Material(GL::FRONT, GL::SHININESS, 45.0);
73
+ GL.EndList();
74
+
75
+ GL.Light(GL::LIGHT0, GL::POSITION, position_one);
76
+
77
+ GL.Enable(GL::LIGHT0);
78
+ GL.Enable(GL::LIGHTING);
79
+ GL.DepthFunc(GL::LESS);
80
+ GL.Enable(GL::DEPTH_TEST);
81
+
82
+ GL.ClearStencil(0x0);
83
+ GL.Enable(GL::STENCIL_TEST);
84
+ end
85
+
86
+ # Draw a sphere in a diamond-shaped section in the
87
+ # middle of a window with 2 tori.
88
+ #/
89
+ display = Proc.new {
90
+ GL.Clear(GL::COLOR_BUFFER_BIT | GL::DEPTH_BUFFER_BIT);
91
+
92
+ # draw blue sphere where the stencil is 1 */
93
+ GL.StencilFunc(GL::EQUAL, 0x1, 0x1);
94
+ GL.CallList(BLUEMAT);
95
+ GLUT.SolidSphere(0.5, 15, 15);
96
+
97
+ # draw the tori where the stencil is not 1 */
98
+ GL.StencilFunc(GL::NOTEQUAL, 0x1, 0x1);
99
+ GL.StencilOp(GL::KEEP, GL::KEEP, GL::KEEP);
100
+ GL.PushMatrix();
101
+ GL.Rotate(45.0, 0.0, 0.0, 1.0);
102
+ GL.Rotate(45.0, 0.0, 1.0, 0.0);
103
+ GL.CallList(YELLOWMAT);
104
+ GLUT.SolidTorus(0.275, 0.85, 15, 15);
105
+ GL.PushMatrix();
106
+ GL.Rotate(90.0, 1.0, 0.0, 0.0);
107
+ GLUT.SolidTorus(0.275, 0.85, 15, 15);
108
+ GL.PopMatrix();
109
+ GL.PopMatrix();
110
+ }
111
+
112
+ # Whenever the window is reshaped, redefine the
113
+ # coordinate system and redraw the stencil area.
114
+ #/
115
+ myReshape = Proc.new {|w, h|
116
+ GL.Viewport(0, 0, w, h);
117
+
118
+ GL.Clear(GL::STENCIL_BUFFER_BIT);
119
+ # create a diamond shaped stencil area */
120
+ GL.MatrixMode(GL::PROJECTION);
121
+ GL.LoadIdentity();
122
+ GL.Ortho(-3.0, 3.0, -3.0, 3.0, -1.0, 1.0);
123
+ GL.MatrixMode(GL::MODELVIEW);
124
+ GL.LoadIdentity();
125
+
126
+ GL.StencilFunc(GL::ALWAYS, 0x1, 0x1);
127
+ GL.StencilOp(GL::REPLACE, GL::REPLACE, GL::REPLACE);
128
+ GL.Begin(GL::QUADS);
129
+ GL.Vertex(-1.0, 0.0, 0.0);
130
+ GL.Vertex(0.0, 1.0, 0.0);
131
+ GL.Vertex(1.0, 0.0, 0.0);
132
+ GL.Vertex(0.0, -1.0, 0.0);
133
+ GL.End();
134
+
135
+ GL.MatrixMode(GL::PROJECTION);
136
+ GL.LoadIdentity();
137
+ GLU.Perspective(45.0, w.to_f/h.to_f, 3.0, 7.0);
138
+ GL.MatrixMode(GL::MODELVIEW);
139
+ GL.LoadIdentity();
140
+ GL.Translate(0.0, 0.0, -5.0);
141
+ }
142
+
143
+ # Main Loop
144
+ # Open window with initial window size, title bar,
145
+ # RGBA display mode, and handle input events.
146
+ #/
147
+ GLUT.Init()
148
+ GLUT.InitDisplayMode(GLUT::SINGLE | GLUT::RGB | GLUT::DEPTH | GLUT::STENCIL);
149
+ GLUT.InitWindowSize(400, 400);
150
+ GLUT.CreateWindow($0);
151
+ myinit
152
+ GLUT.ReshapeFunc(myReshape);
153
+ GLUT.DisplayFunc(display);
154
+ GLUT.MainLoop();
@@ -0,0 +1,170 @@
1
+ #
2
+ #/* Copyright (c) Mark J. Kilgard, 1994. */
3
+ #
4
+ #/*
5
+ # * (c) Copyright 1993, Silicon Graphics, Inc.
6
+ # * ALL RIGHTS RESERVED
7
+ # * Permission to use, copy, modify, and distribute this software for
8
+ # * any purpose and without fee is hereby granted, provided that the above
9
+ # * copyright notice appear in all copies and that both the copyright notice
10
+ # * and this permission notice appear in supporting documentation, and that
11
+ # * the name of Silicon Graphics, Inc. not be used in advertising
12
+ # * or publicity pertaining to distribution of the software without specific,
13
+ # * written prior permission.
14
+ # *
15
+ # * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
16
+ # * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
17
+ # * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
18
+ # * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
19
+ # * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
20
+ # * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
21
+ # * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
22
+ # * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
23
+ # * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
24
+ # * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
25
+ # * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
26
+ # * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
27
+ # *
28
+ # * US Government Users Restricted Rights
29
+ # * Use, duplication, or disclosure by the Government is subject to
30
+ # * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
31
+ # * (c)(1)(ii) of the Rights in Technical Data and Computer Software
32
+ # * clause at DFARS 252.227-7013 and/or in similar or successor
33
+ # * clauses in the FAR or the DOD or NASA FAR Supplement.
34
+ # * Unpublished-- rights reserved under the copyright laws of the
35
+ # * United States. Contractor/manufacturer is Silicon Graphics,
36
+ # * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
37
+ # *
38
+ # * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
39
+ # */
40
+ #/*
41
+ # * stroke.c
42
+ # * This program demonstrates some characters of a
43
+ # * stroke (vector) font. The characters are represented
44
+ # * by display lists, which are given numbers which
45
+ # * correspond to the ASCII values of the characters.
46
+ # * Use of glCallLists() is demonstrated.
47
+ # */
48
+
49
+ require "gl_prev"
50
+ require "glu_prev"
51
+ require "glut_prev"
52
+ require "mathn"
53
+
54
+ PT=1
55
+ STROKE=2
56
+ END_=3
57
+
58
+ Adata = [
59
+ [[0, 0], PT], [[0, 9], PT], [[1, 10], PT], [[4, 10], PT],
60
+ [[5, 9], PT], [[5, 0], STROKE], [[0, 5], PT], [[5, 5], END_]
61
+ ];
62
+
63
+ Edata = [
64
+ [[5, 0], PT], [[0, 0], PT], [[0, 10], PT], [[5, 10], STROKE],
65
+ [[0, 5], PT], [[4, 5], END_]
66
+ ];
67
+
68
+ Pdata = [
69
+ [[0, 0], PT], [[0, 10], PT], [[4, 10], PT], [[5, 9], PT], [[5, 6], PT],
70
+ [[4, 5], PT], [[0, 5], END_]
71
+ ];
72
+
73
+ Rdata = [
74
+ [[0, 0], PT], [[0, 10], PT], [[4, 10], PT], [[5, 9], PT], [[5, 6], PT],
75
+ [[4, 5], PT], [[0, 5], STROKE], [[3, 5], PT], [[5, 0], END_]
76
+ ];
77
+
78
+ Sdata = [
79
+ [[0, 1], PT], [[1, 0], PT], [[4, 0], PT], [[5, 1], PT], [[5, 4], PT],
80
+ [[4, 5], PT], [[1, 5], PT], [[0, 6], PT], [[0, 9], PT], [[1, 10], PT],
81
+ [[4, 10], PT], [[5, 9], END_]
82
+ ];
83
+
84
+ #/* drawLetter() interprets the instructions from the array
85
+ # * for that letter and renders the letter with line segments.
86
+ # */
87
+ def drawLetter(l)
88
+ i = 0
89
+ GL.Begin(GL::LINE_STRIP);
90
+ while (1)
91
+ case (l[i][1])
92
+ when PT
93
+ GL.Vertex(l[i][0]);
94
+ when STROKE
95
+ GL.Vertex(l[i][0]);
96
+ GL.End();
97
+ GL.Begin(GL::LINE_STRIP);
98
+ when END_
99
+ GL.Vertex(l[i][0]);
100
+ GL.End();
101
+ GL.Translate(8.0, 0.0, 0.0);
102
+ return
103
+ end
104
+ i = i + 1
105
+ end
106
+ end
107
+
108
+ # /* Create a display list for each of 6 characters */
109
+ def myinit
110
+ GL.ShadeModel (GL::FLAT);
111
+
112
+ base = GL.GenLists(128);
113
+ GL.ListBase(base);
114
+ GL.NewList(base+'A'[0], GL::COMPILE); drawLetter(Adata); GL.EndList();
115
+ GL.NewList(base+'E'[0], GL::COMPILE); drawLetter(Edata); GL.EndList();
116
+ GL.NewList(base+'P'[0], GL::COMPILE); drawLetter(Pdata); GL.EndList();
117
+ GL.NewList(base+'R'[0], GL::COMPILE); drawLetter(Rdata); GL.EndList();
118
+ GL.NewList(base+'S'[0], GL::COMPILE); drawLetter(Sdata); GL.EndList();
119
+ GL.NewList(base+' '[0], GL::COMPILE); GL.Translate(8.0, 0.0, 0.0); GL.EndList();
120
+ end
121
+
122
+ $test1 = "A SPARE SERAPE APPEARS AS";
123
+ $test2 = "APES PREPARE RARE PEPPERS";
124
+
125
+ def printStrokedString(s)
126
+ # GL.CallLists(s.size, GL::BYTE, s);
127
+ GL.CallLists( s);
128
+ end
129
+
130
+ display = Proc.new {
131
+ GL.Clear(GL::COLOR_BUFFER_BIT);
132
+ GL.Color(1.0, 1.0, 1.0);
133
+ GL.PushMatrix();
134
+ GL.Scale(2.0, 2.0, 2.0);
135
+ GL.Translate(10.0, 30.0, 0.0);
136
+ printStrokedString($test1);
137
+ GL.PopMatrix();
138
+ GL.PushMatrix();
139
+ GL.Scale(2.0, 2.0, 2.0);
140
+ GL.Translate(10.0, 13.0, 0.0);
141
+ printStrokedString($test2);
142
+ GL.PopMatrix();
143
+ GL.Flush();
144
+ }
145
+
146
+ reshape = Proc.new {|w, h|
147
+ GL.Viewport(0, 0, w, h);
148
+ GL.MatrixMode(GL::PROJECTION);
149
+ GL.LoadIdentity();
150
+ GL.Ortho(0.0, w, 0.0, h, -1.0, 1.0);
151
+ GL.MatrixMode(GL::MODELVIEW);
152
+ GL.LoadIdentity();
153
+ }
154
+
155
+ #/* Main Loop
156
+ # * Open window with initial window size, title bar,
157
+ # * RGBA display mode, and handle input events.
158
+ # */
159
+ #int main(int argc, char** argv)
160
+ #{
161
+ GLUT.Init
162
+ GLUT.InitDisplayMode(GLUT::SINGLE | GLUT::RGB);
163
+ GLUT.InitWindowSize(440, 120);
164
+ GLUT.CreateWindow($0);
165
+ myinit();
166
+ GLUT.DisplayFunc(display);
167
+ GLUT.ReshapeFunc(reshape);
168
+ GLUT.MainLoop();
169
+ # return 0; /* ANSI C requires main to return int. */
170
+ #}