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,157 +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
- # texbind.c
39
- # This program demonstrates using glBindTexture() by
40
- # creating and managing two textures.
41
- #/
42
-
43
- #define checkImageWidth 64
44
- #define checkImageHeight 64
45
-
46
- require "gl_prev"
47
- require "glu_prev"
48
- require "glut_prev"
49
- require "mathn"
50
-
51
- CheckImageWidth = 64
52
- CheckImageHeight = 64
53
- #$checkImage = MDArray.new(CheckImageHeight, CheckImageWidth, 4)
54
- #$otherImage = MDArray.new(CheckImageHeight, CheckImageWidth, 4)
55
- $checkImage = []
56
- $otherImage = []
57
-
58
- $texName = [];
59
-
60
- def makeCheckImages
61
- for i in (0..CheckImageHeight-1)
62
- for j in (0..CheckImageWidth-1)
63
- if ((i&0x8==0)!=(j&0x8==0)) then tmp = 1; else tmp=0; end
64
- #c = ((((i&0x8)==0)^((j&0x8))==0))*255;
65
- c = tmp * 255;
66
- $checkImage[i*CheckImageWidth*4+j*4+0] = c;
67
- $checkImage[i*CheckImageWidth*4+j*4+1] = c;
68
- $checkImage[i*CheckImageWidth*4+j*4+2] = c;
69
- $checkImage[i*CheckImageWidth*4+j*4+3] = 255;
70
- #c = ((((i&0x10)==0)^((j&0x10))==0))*255;
71
- if ((i&0x10==0)!=(j&0x10==0)) then tmp = 1; else tmp=0; end
72
- c = tmp * 255;
73
- $otherImage[i*CheckImageWidth*4+j*4+0] = c;
74
- $otherImage[i*CheckImageWidth*4+j*4+1] = 0;
75
- $otherImage[i*CheckImageWidth*4+j*4+2] = 0;
76
- $otherImage[i*CheckImageWidth*4+j*4+3] = 255;
77
- end
78
- end
79
- end
80
-
81
- def init
82
- GL.ClearColor(0.0, 0.0, 0.0, 0.0);
83
- GL.ShadeModel(GL::FLAT);
84
- GL.Enable(GL::DEPTH_TEST);
85
-
86
- makeCheckImages();
87
- GL.PixelStorei(GL::UNPACK_ALIGNMENT, 1);
88
-
89
- $texName = GL.GenTextures(2);
90
- GL.BindTexture(GL::TEXTURE_2D, $texName[0]);
91
- GL.TexParameteri(GL::TEXTURE_2D, GL::TEXTURE_WRAP_S, GL::CLAMP);
92
- GL.TexParameteri(GL::TEXTURE_2D, GL::TEXTURE_WRAP_T, GL::CLAMP);
93
- GL.TexParameteri(GL::TEXTURE_2D, GL::TEXTURE_MAG_FILTER,GL::NEAREST);
94
- GL.TexParameteri(GL::TEXTURE_2D, GL::TEXTURE_MIN_FILTER,GL::NEAREST);
95
- GL.TexImage2D(GL::TEXTURE_2D, 0, GL::RGBA, CheckImageWidth,
96
- CheckImageHeight, 0, GL::RGBA, GL::UNSIGNED_BYTE,
97
- $checkImage.pack("C*"));
98
-
99
- GL.BindTexture(GL::TEXTURE_2D, $texName[1]);
100
- GL.TexParameteri(GL::TEXTURE_2D, GL::TEXTURE_WRAP_S, GL::CLAMP);
101
- GL.TexParameteri(GL::TEXTURE_2D, GL::TEXTURE_WRAP_T, GL::CLAMP);
102
- GL.TexParameteri(GL::TEXTURE_2D, GL::TEXTURE_MAG_FILTER, GL::NEAREST);
103
- GL.TexParameteri(GL::TEXTURE_2D, GL::TEXTURE_MIN_FILTER, GL::NEAREST);
104
- GL.TexEnvf(GL::TEXTURE_ENV, GL::TEXTURE_ENV_MODE, GL::DECAL);
105
- GL.TexImage2D(GL::TEXTURE_2D, 0, GL::RGBA, CheckImageWidth,
106
- CheckImageHeight, 0, GL::RGBA, GL::UNSIGNED_BYTE,
107
- $otherImage.pack("C*"));
108
- GL.Enable(GL::TEXTURE_2D);
109
- end
110
-
111
- display = Proc.new {
112
- GL.Clear(GL::COLOR_BUFFER_BIT | GL::DEPTH_BUFFER_BIT);
113
- GL.BindTexture(GL::TEXTURE_2D, $texName[0]);
114
- GL.Begin(GL::QUADS);
115
- GL.TexCoord(0.0, 0.0); GL.Vertex(-2.0, -1.0, 0.0);
116
- GL.TexCoord(0.0, 1.0); GL.Vertex(-2.0, 1.0, 0.0);
117
- GL.TexCoord(1.0, 1.0); GL.Vertex(0.0, 1.0, 0.0);
118
- GL.TexCoord(1.0, 0.0); GL.Vertex(0.0, -1.0, 0.0);
119
- GL.End();
120
- GL.BindTexture(GL::TEXTURE_2D, $texName[1]);
121
- GL.Begin(GL::QUADS);
122
- GL.TexCoord(0.0, 0.0); GL.Vertex(1.0, -1.0, 0.0);
123
- GL.TexCoord(0.0, 1.0); GL.Vertex(1.0, 1.0, 0.0);
124
- GL.TexCoord(1.0, 1.0); GL.Vertex(2.41421, 1.0, -1.41421);
125
- GL.TexCoord(1.0, 0.0); GL.Vertex(2.41421, -1.0, -1.41421);
126
- GL.End();
127
- GL.Flush();
128
- }
129
-
130
- reshape = Proc.new {|w, h|
131
- GL.Viewport(0, 0, w, h);
132
- GL.MatrixMode(GL::PROJECTION);
133
- GL.LoadIdentity();
134
- GLU.Perspective(60.0, w/h, 1.0, 30.0);
135
- GL.MatrixMode(GL::MODELVIEW);
136
- GL.LoadIdentity();
137
- GL.Translate(0.0, 0.0, -3.6);
138
- }
139
-
140
- #* ARGSUSED1 */
141
- keyboard = Proc.new {|key, x, y|
142
- case (key)
143
- when 27
144
- exit(0);
145
- end
146
- }
147
-
148
- GLUT.Init
149
- GLUT.InitDisplayMode(GLUT::SINGLE | GLUT::RGB | GLUT::DEPTH);
150
- GLUT.InitWindowSize(250, 250);
151
- GLUT.InitWindowPosition(100, 100);
152
- GLUT.CreateWindow($0);
153
- init();
154
- GLUT.ReshapeFunc(reshape);
155
- GLUT.DisplayFunc(display);
156
- GLUT.KeyboardFunc(keyboard);
157
- GLUT.MainLoop();
@@ -1,171 +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
- # texgen.c
39
- # This program draws a texture mapped teapot with
40
- # automatically generated texture coordinates. The
41
- # texture is rendered as stripes on the teapot.
42
- # Initially, the object is drawn with texture coordinates
43
- # based upon the object coordinates of the vertex
44
- # and distance from the plane x = 0. Pressing the 'e'
45
- # key changes the coordinate generation to eye coordinates
46
- # of the vertex. Pressing the 'o' key switches it back
47
- # to the object coordinates. Pressing the 's' key
48
- # changes the plane to a slanted one (x + y + z = 0).
49
- # Pressing the 'x' key switches it back to x = 0.
50
- #/
51
-
52
- require "gl_prev"
53
- require "glu_prev"
54
- require "glut_prev"
55
- require "mathn"
56
- StripeImageWidth = 32
57
- $stripeImage = []
58
-
59
- $texName;
60
-
61
- def makeStripeImage
62
- for j in (0..StripeImageWidth-1)
63
- $stripeImage[4*j] = if (j<=4) then 255; else 0; end;
64
- $stripeImage[4*j+1] = if (j>4) then 255 else 0; end;
65
- $stripeImage[4*j+2] = 0;
66
- $stripeImage[4*j+3] = 255;
67
- end
68
- end
69
-
70
- #* planes for texture coordinate generation */
71
- $xequalzero = [1.0, 0.0, 0.0, 0.0];
72
- $slanted = [1.0, 1.0, 1.0, 0.0];
73
- $currentCoeff = nil;
74
- $currentPlane = nil;
75
- $currentGenMode = nil;
76
-
77
- def init
78
- GL.ClearColor(0.0, 0.0, 0.0, 0.0);
79
- GL.Enable(GL::DEPTH_TEST);
80
- GL.ShadeModel(GL::SMOOTH);
81
-
82
- makeStripeImage();
83
- GL.PixelStorei(GL::UNPACK_ALIGNMENT, 1);
84
-
85
- $texName = GL.GenTextures(1);
86
- GL.BindTexture(GL::TEXTURE_2D, $texName[0]);
87
- GL.TexParameteri(GL::TEXTURE_2D, GL::TEXTURE_WRAP_S, GL::REPEAT);
88
- GL.TexParameteri(GL::TEXTURE_2D, GL::TEXTURE_MAG_FILTER, GL::LINEAR);
89
- GL.TexParameteri(GL::TEXTURE_2D, GL::TEXTURE_MIN_FILTER, GL::LINEAR);
90
- GL.TexImage2D(GL::TEXTURE_2D, 0, GL::RGBA, StripeImageWidth, 1, 0,
91
- GL::RGBA, GL::UNSIGNED_BYTE, $stripeImage.pack("C*"));
92
- GL.TexEnvf(GL::TEXTURE_ENV, GL::TEXTURE_ENV_MODE, GL::MODULATE);
93
- $currentCoeff = $xequalzero;
94
- $currentGenMode = GL::OBJECT_LINEAR;
95
- $currentPlane = GL::OBJECT_PLANE;
96
- GL.TexGen(GL::S, GL::TEXTURE_GEN_MODE, $currentGenMode);
97
- GL.TexGen(GL::S, $currentPlane, $currentCoeff);
98
-
99
- GL.Enable(GL::TEXTURE_GEN_S);
100
- GL.Enable(GL::TEXTURE_2D);
101
- GL.Enable(GL::CULL_FACE);
102
- GL.Enable(GL::LIGHTING);
103
- GL.Enable(GL::LIGHT0);
104
- GL.Enable(GL::AUTO_NORMAL);
105
- GL.Enable(GL::NORMALIZE);
106
- GL.FrontFace(GL::CW);
107
- GL.CullFace(GL::BACK);
108
- GL.Material(GL::FRONT, GL::SHININESS, 64.0);
109
- end
110
-
111
- display = Proc.new {
112
- GL.Clear(GL::COLOR_BUFFER_BIT | GL::DEPTH_BUFFER_BIT);
113
- GL.PushMatrix();
114
- GL.Rotate(45.0, 0.0, 0.0, 1.0);
115
- GL.BindTexture(GL::TEXTURE_2D, $texName[0]);
116
- GLUT.SolidTeapot(2.0);
117
- GL.PopMatrix();
118
- GL.Flush();
119
- }
120
-
121
- reshape = Proc.new {|w, h|
122
- GL.Viewport(0, 0, w, h);
123
- GL.MatrixMode(GL::PROJECTION);
124
- GL.LoadIdentity();
125
- if (w <= h)
126
- GL.Ortho(-3.5, 3.5, -3.5*h/w,3.5*h/w, -3.5, 3.5);
127
- else
128
- GL.Ortho(-3.5*w/h, 3.5*w/h, -3.5, 3.5, -3.5, 3.5);
129
- end
130
- GL.MatrixMode(GL::MODELVIEW);
131
- GL.LoadIdentity();
132
- }
133
-
134
- #* ARGSUSED1 */
135
- keyboard = Proc.new {|key, x, y|
136
- case (key)
137
- when 'e'[0],'E'[0]
138
- $currentGenMode = GL::EYE_LINEAR;
139
- $currentPlane = GL::EYE_PLANE;
140
- GL.TexGen(GL::S, GL::TEXTURE_GEN_MODE, $currentGenMode);
141
- GL.TexGen(GL::S, $currentPlane, $currentCoeff);
142
- GLUT.PostRedisplay();
143
- when 'o'[0], 'O'[0]
144
- $currentGenMode = GL::OBJECT_LINEAR;
145
- $currentPlane = GL::OBJECT_PLANE;
146
- GL.TexGen(GL::S, GL::TEXTURE_GEN_MODE, $currentGenMode);
147
- GL.TexGen(GL::S, $currentPlane, $currentCoeff);
148
- GLUT.PostRedisplay();
149
- when 's'[0],'S'[0]
150
- $currentCoeff = $slanted;
151
- GL.TexGen(GL::S, $currentPlane, $currentCoeff);
152
- GLUT.PostRedisplay();
153
- when 'x'[0],'X'[0]
154
- $currentCoeff = $xequalzero;
155
- GL.TexGen(GL::S, $currentPlane, $currentCoeff);
156
- GLUT.PostRedisplay();
157
- when 27
158
- exit(0);
159
- end
160
- }
161
-
162
- GLUT.Init
163
- GLUT.InitDisplayMode (GLUT::SINGLE | GLUT::RGB | GLUT::DEPTH);
164
- GLUT.InitWindowSize(256, 256);
165
- GLUT.InitWindowPosition(100, 100);
166
- GLUT.CreateWindow ($0);
167
- init();
168
- GLUT.DisplayFunc(display);
169
- GLUT.ReshapeFunc(reshape);
170
- GLUT.KeyboardFunc(keyboard);
171
- GLUT.MainLoop();
@@ -1,128 +0,0 @@
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
- #/* texturesurf.c
41
- # * This program uses evaluators to generate a curved
42
- # * surface and automatically generated texture coordinates.
43
- # */
44
- #
45
- require "gl_prev"
46
- require "glu_prev"
47
- require "glut_prev"
48
-
49
- $ctrlpoints = [
50
- [[ -1.5, -1.5, 4.0], [ -0.5, -1.5, 2.0],
51
- [0.5, -1.5, -1.0], [1.5, -1.5, 2.0]],
52
- [[ -1.5, -0.5, 1.0], [ -0.5, -0.5, 3.0],
53
- [0.5, -0.5, 0.0], [1.5, -0.5, -1.0]],
54
- [[ -1.5, 0.5, 4.0], [ -0.5, 0.5, 0.0],
55
- [0.5, 0.5, 3.0], [1.5, 0.5, 4.0]],
56
- [[ -1.5, 1.5, -2.0], [ -0.5, 1.5, -2.0],
57
- [0.5, 1.5, 0.0], [1.5, 1.5, -1.0]]
58
- ].flatten;
59
-
60
- $texpts = [[[0.0, 0.0], [0.0, 1.0]], [[1.0, 0.0], [1.0, 1.0]]].flatten;
61
-
62
- display = proc {
63
- GL::Clear(GL::COLOR_BUFFER_BIT | GL::DEPTH_BUFFER_BIT);
64
- GL::Color(1.0, 1.0, 1.0);
65
- GL::EvalMesh2(GL::FILL, 0, 20, 0, 20);
66
- GL::Flush();
67
- }
68
-
69
- ImageWidth=64
70
- ImageHeight=64
71
- $image = []
72
-
73
- def makeImage
74
- for i in 0...ImageWidth
75
- ti = 2.0*3.14159265*i/ImageWidth.to_f;
76
- for j in 0...ImageHeight
77
- tj = 2.0*3.14159265*j/ImageHeight.to_f;
78
-
79
- $image[3*(ImageHeight*i+j)] = 127*(1.0+Math::sin(ti));
80
- $image[3*(ImageHeight*i+j)+1] = 127*(1.0+Math::cos(2*tj));
81
- $image[3*(ImageHeight*i+j)+2] = 127*(1.0+Math::cos(ti+tj));
82
- end
83
- end
84
- end
85
-
86
- def myinit
87
- GL::Map2d(GL::MAP2_VERTEX_3, 0, 1, 3, 4,
88
- 0, 1, 12, 4, $ctrlpoints);
89
- GL::Map2d(GL::MAP2_TEXTURE_COORD_2, 0, 1, 2, 2,
90
- 0, 1, 4, 2, $texpts);
91
- GL::Enable(GL::MAP2_TEXTURE_COORD_2);
92
- GL::Enable(GL::MAP2_VERTEX_3);
93
- GL::MapGrid2d(20, 0.0, 1.0, 20, 0.0, 1.0);
94
- makeImage();
95
- GL::TexEnv(GL::TEXTURE_ENV, GL::TEXTURE_ENV_MODE, GL::DECAL);
96
- GL::TexParameter(GL::TEXTURE_2D, GL::TEXTURE_WRAP_S, GL::REPEAT);
97
- GL::TexParameter(GL::TEXTURE_2D, GL::TEXTURE_WRAP_T, GL::REPEAT);
98
- GL::TexParameter(GL::TEXTURE_2D, GL::TEXTURE_MAG_FILTER, GL::NEAREST);
99
- GL::TexParameter(GL::TEXTURE_2D, GL::TEXTURE_MIN_FILTER, GL::NEAREST);
100
- GL::TexImage2D(GL::TEXTURE_2D, 0, 3, ImageWidth, ImageHeight, 0,
101
- GL::RGB, GL::UNSIGNED_BYTE, $image.pack("C*"));
102
- GL::Enable(GL::TEXTURE_2D);
103
- GL::Enable(GL::DEPTH_TEST);
104
- GL::Enable(GL::NORMALIZE);
105
- GL::ShadeModel(GL::FLAT);
106
- end
107
-
108
- myReshape = proc {|w, h|
109
- GL::Viewport(0, 0, w, h);
110
- GL::MatrixMode(GL::PROJECTION);
111
- GL::LoadIdentity();
112
- if (w <= h)
113
- GL::Ortho(-4.0, 4.0, -4.0*h.to_f/w, 4.0*h.to_f/w, -4.0, 4.0);
114
- else
115
- GL::Ortho(-4.0*w.to_f/h, 4.0*w.to_f/h, -4.0, 4.0, -4.0, 4.0);
116
- end
117
- GL::MatrixMode(GL::MODELVIEW);
118
- GL::LoadIdentity();
119
- GL::Rotate(85.0, 1.0, 1.0, 1.0);
120
- }
121
-
122
- GLUT::Init();
123
- GLUT::InitDisplayMode(GLUT::SINGLE | GLUT::RGB | GLUT::DEPTH);
124
- GLUT::CreateWindow();
125
- myinit();
126
- GLUT::ReshapeFunc(myReshape);
127
- GLUT::DisplayFunc(display);
128
- GLUT::MainLoop();