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,149 @@
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
+ require 'opengl'
42
+ require 'glu'
43
+ require 'glut'
44
+ require 'mathn'
45
+ include Gl,Glu,Glut
46
+
47
+ CheckImageWidth = 64
48
+ CheckImageHeight = 64
49
+ $checkImage = []
50
+ $otherImage = []
51
+
52
+ $texName = []
53
+
54
+ def makeCheckImages
55
+ for i in (0..CheckImageHeight-1)
56
+ for j in (0..CheckImageWidth-1)
57
+ if ((i&0x8==0)!=(j&0x8==0)) then tmp = 1 else tmp=0 end
58
+ #c = ((((i&0x8)==0)^((j&0x8))==0))*255
59
+ c = tmp * 255
60
+ $checkImage[i*CheckImageWidth*4+j*4+0] = c
61
+ $checkImage[i*CheckImageWidth*4+j*4+1] = c
62
+ $checkImage[i*CheckImageWidth*4+j*4+2] = c
63
+ $checkImage[i*CheckImageWidth*4+j*4+3] = 255
64
+ #c = ((((i&0x10)==0)^((j&0x10))==0))*255
65
+ if ((i&0x10==0)!=(j&0x10==0)) then tmp = 1 else tmp=0 end
66
+ c = tmp * 255
67
+ $otherImage[i*CheckImageWidth*4+j*4+0] = c
68
+ $otherImage[i*CheckImageWidth*4+j*4+1] = 0
69
+ $otherImage[i*CheckImageWidth*4+j*4+2] = 0
70
+ $otherImage[i*CheckImageWidth*4+j*4+3] = 255
71
+ end
72
+ end
73
+ end
74
+
75
+ def init
76
+ glClearColor(0.0, 0.0, 0.0, 0.0)
77
+ glShadeModel(GL_FLAT)
78
+ glEnable(GL_DEPTH_TEST)
79
+
80
+ makeCheckImages()
81
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
82
+
83
+ $texName = glGenTextures(2)
84
+ glBindTexture(GL_TEXTURE_2D, $texName[0])
85
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP)
86
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP)
87
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,GL_NEAREST)
88
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_NEAREST)
89
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, CheckImageWidth,
90
+ CheckImageHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, $checkImage.pack("C*"))
91
+
92
+ glBindTexture(GL_TEXTURE_2D, $texName[1])
93
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP)
94
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP)
95
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
96
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
97
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL)
98
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, CheckImageWidth, CheckImageHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE,
99
+ $otherImage.pack("C*"))
100
+ glEnable(GL_TEXTURE_2D)
101
+ end
102
+
103
+ display = Proc.new do
104
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
105
+ glBindTexture(GL_TEXTURE_2D, $texName[0])
106
+ glBegin(GL_QUADS)
107
+ glTexCoord(0.0, 0.0); glVertex(-2.0, -1.0, 0.0)
108
+ glTexCoord(0.0, 1.0); glVertex(-2.0, 1.0, 0.0)
109
+ glTexCoord(1.0, 1.0); glVertex(0.0, 1.0, 0.0)
110
+ glTexCoord(1.0, 0.0); glVertex(0.0, -1.0, 0.0)
111
+ glEnd()
112
+ glBindTexture(GL_TEXTURE_2D, $texName[1])
113
+ glBegin(GL_QUADS)
114
+ glTexCoord(0.0, 0.0); glVertex(1.0, -1.0, 0.0)
115
+ glTexCoord(0.0, 1.0); glVertex(1.0, 1.0, 0.0)
116
+ glTexCoord(1.0, 1.0); glVertex(2.41421, 1.0, -1.41421)
117
+ glTexCoord(1.0, 0.0); glVertex(2.41421, -1.0, -1.41421)
118
+ glEnd()
119
+ glutSwapBuffers()
120
+ end
121
+
122
+ reshape = Proc.new do |w, h|
123
+ glViewport(0, 0, w, h)
124
+ glMatrixMode(GL_PROJECTION)
125
+ glLoadIdentity()
126
+ gluPerspective(60.0, w/h, 1.0, 30.0)
127
+ glMatrixMode(GL_MODELVIEW)
128
+ glLoadIdentity()
129
+ glTranslate(0.0, 0.0, -3.6)
130
+ end
131
+
132
+ keyboard = Proc.new do |key, x, y|
133
+ case (key)
134
+ when ?\e
135
+ exit(0)
136
+ end
137
+ end
138
+
139
+ # main
140
+ glutInit
141
+ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
142
+ glutInitWindowSize(500, 500)
143
+ glutInitWindowPosition(100, 100)
144
+ glutCreateWindow($0)
145
+ init()
146
+ glutReshapeFunc(reshape)
147
+ glutDisplayFunc(display)
148
+ glutKeyboardFunc(keyboard)
149
+ glutMainLoop()
@@ -0,0 +1,171 @@
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
+ # texgen.c
38
+ # This program draws a texture mapped teapot with
39
+ # automatically generated texture coordinates. The
40
+ # texture is rendered as stripes on the teapot.
41
+ # Initially, the object is drawn with texture coordinates
42
+ # based upon the object coordinates of the vertex
43
+ # and distance from the plane x = 0. Pressing the 'e'
44
+ # key changes the coordinate generation to eye coordinates
45
+ # of the vertex. Pressing the 'o' key switches it back
46
+ # to the object coordinates. Pressing the 's' key
47
+ # changes the plane to a slanted one (x + y + z = 0).
48
+ # Pressing the 'x' key switches it back to x = 0.
49
+
50
+ require 'opengl'
51
+ require 'glu'
52
+ require 'glut'
53
+ require 'mathn'
54
+ include Gl,Glu,Glut
55
+
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
+ glClearColor(0.0, 0.0, 0.0, 0.0)
79
+ glEnable(GL_DEPTH_TEST)
80
+ glShadeModel(GL_SMOOTH)
81
+
82
+ makeStripeImage()
83
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
84
+
85
+ $texName = glGenTextures(1)
86
+ glBindTexture(GL_TEXTURE_2D, $texName[0])
87
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
88
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
89
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
90
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, StripeImageWidth, 1, 0,
91
+ GL_RGBA, GL_UNSIGNED_BYTE, $stripeImage.pack("C*"))
92
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE)
93
+ $currentCoeff = $xequalzero
94
+ $currentGenMode = GL_OBJECT_LINEAR
95
+ $currentPlane = GL_OBJECT_PLANE
96
+ glTexGen(GL_S, GL_TEXTURE_GEN_MODE, $currentGenMode)
97
+ glTexGen(GL_S, $currentPlane, $currentCoeff)
98
+
99
+ glEnable(GL_TEXTURE_GEN_S)
100
+ glEnable(GL_TEXTURE_2D)
101
+ glEnable(GL_CULL_FACE)
102
+ glEnable(GL_LIGHTING)
103
+ glEnable(GL_LIGHT0)
104
+ glEnable(GL_AUTO_NORMAL)
105
+ glEnable(GL_NORMALIZE)
106
+ glFrontFace(GL_CW)
107
+ glCullFace(GL_BACK)
108
+ glMaterial(GL_FRONT, GL_SHININESS, 64.0)
109
+ end
110
+
111
+ display = Proc.new do
112
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
113
+ glPushMatrix()
114
+ glRotate(45.0, 0.0, 0.0, 1.0)
115
+ glBindTexture(GL_TEXTURE_2D, $texName[0])
116
+ glutSolidTeapot(2.0)
117
+ glPopMatrix()
118
+ glutSwapBuffers()
119
+ end
120
+
121
+ reshape = Proc.new do |w, h|
122
+ glViewport(0, 0, w, h)
123
+ glMatrixMode(GL_PROJECTION)
124
+ glLoadIdentity()
125
+ if (w <= h)
126
+ glOrtho(-3.5, 3.5, -3.5*h/w,3.5*h/w, -3.5, 3.5)
127
+ else
128
+ glOrtho(-3.5*w/h, 3.5*w/h, -3.5, 3.5, -3.5, 3.5)
129
+ end
130
+ glMatrixMode(GL_MODELVIEW)
131
+ glLoadIdentity()
132
+ end
133
+
134
+ keyboard = Proc.new do |key, x, y|
135
+ case (key)
136
+ when ?e,?E
137
+ $currentGenMode = GL_EYE_LINEAR
138
+ $currentPlane = GL_EYE_PLANE
139
+ glTexGen(GL_S, GL_TEXTURE_GEN_MODE, $currentGenMode)
140
+ glTexGen(GL_S, $currentPlane, $currentCoeff)
141
+ glutPostRedisplay()
142
+ when ?o, ?O
143
+ $currentGenMode = GL_OBJECT_LINEAR
144
+ $currentPlane = GL_OBJECT_PLANE
145
+ glTexGen(GL_S, GL_TEXTURE_GEN_MODE, $currentGenMode)
146
+ glTexGen(GL_S, $currentPlane, $currentCoeff)
147
+ glutPostRedisplay()
148
+ when ?s,?S
149
+ $currentCoeff = $slanted
150
+ glTexGen(GL_S, $currentPlane, $currentCoeff)
151
+ glutPostRedisplay()
152
+ when ?x,?X
153
+ $currentCoeff = $xequalzero
154
+ glTexGen(GL_S, $currentPlane, $currentCoeff)
155
+ glutPostRedisplay()
156
+ when ?\e
157
+ exit(0)
158
+ end
159
+ end
160
+
161
+ # main
162
+ glutInit
163
+ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
164
+ glutInitWindowSize(500, 500)
165
+ glutInitWindowPosition(100, 100)
166
+ glutCreateWindow($0)
167
+ init()
168
+ glutDisplayFunc(display)
169
+ glutReshapeFunc(reshape)
170
+ glutKeyboardFunc(keyboard)
171
+ glutMainLoop()
@@ -0,0 +1,130 @@
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
+ # texturesurf.c
40
+ # This program uses evaluators to generate a curved
41
+ # surface and automatically generated texture coordinates.
42
+ require 'opengl'
43
+ require 'glu'
44
+ require 'glut'
45
+ include Gl,Glu,Glut
46
+
47
+ $ctrlpoints = [
48
+ [[ -1.5, -1.5, 4.0], [ -0.5, -1.5, 2.0], [0.5, -1.5, -1.0], [1.5, -1.5, 2.0]],
49
+ [[ -1.5, -0.5, 1.0], [ -0.5, -0.5, 3.0], [0.5, -0.5, 0.0], [1.5, -0.5, -1.0]],
50
+ [[ -1.5, 0.5, 4.0], [ -0.5, 0.5, 0.0], [0.5, 0.5, 3.0], [1.5, 0.5, 4.0]],
51
+ [[ -1.5, 1.5, -2.0], [ -0.5, 1.5, -2.0], [0.5, 1.5, 0.0], [1.5, 1.5, -1.0]]
52
+ ].flatten
53
+
54
+ $texpts = [[[0.0, 0.0], [0.0, 1.0]], [[1.0, 0.0], [1.0, 1.0]]].flatten
55
+
56
+ display = proc do
57
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
58
+ glColor(1.0, 1.0, 1.0)
59
+ glEvalMesh2(GL_FILL, 0, 20, 0, 20)
60
+ glutSwapBuffers()
61
+ end
62
+
63
+ ImageWidth=64
64
+ ImageHeight=64
65
+ $image = []
66
+
67
+ def makeImage
68
+ for i in 0...ImageWidth
69
+ ti = 2.0*Math::PI*i/ImageWidth.to_f
70
+ for j in 0...ImageHeight
71
+ tj = 2.0*Math::PI*j/ImageHeight.to_f
72
+
73
+ $image[3*(ImageHeight*i+j)] = 127*(1.0+Math::sin(ti))
74
+ $image[3*(ImageHeight*i+j)+1] = 127*(1.0+Math::cos(2*tj))
75
+ $image[3*(ImageHeight*i+j)+2] = 127*(1.0+Math::cos(ti+tj))
76
+ end
77
+ end
78
+ end
79
+
80
+ def myinit
81
+ glMap2d(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, $ctrlpoints)
82
+ glMap2d(GL_MAP2_TEXTURE_COORD_2, 0, 1, 2, 2, 0, 1, 4, 2, $texpts)
83
+ glEnable(GL_MAP2_TEXTURE_COORD_2)
84
+ glEnable(GL_MAP2_VERTEX_3)
85
+ glMapGrid2d(20, 0.0, 1.0, 20, 0.0, 1.0)
86
+ makeImage()
87
+ glTexEnv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL)
88
+ glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
89
+ glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
90
+ glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
91
+ glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
92
+ glTexImage2D(GL_TEXTURE_2D, 0, 3, ImageWidth, ImageHeight, 0,
93
+ GL_RGB, GL_UNSIGNED_BYTE, $image.pack("C*"))
94
+ glEnable(GL_TEXTURE_2D)
95
+ glEnable(GL_DEPTH_TEST)
96
+ glEnable(GL_NORMALIZE)
97
+ glShadeModel(GL_FLAT)
98
+ end
99
+
100
+ myReshape = proc do|w, h|
101
+ glViewport(0, 0, w, h)
102
+ glMatrixMode(GL_PROJECTION)
103
+ glLoadIdentity()
104
+ if (w <= h)
105
+ glOrtho(-4.0, 4.0, -4.0*h.to_f/w, 4.0*h.to_f/w, -4.0, 4.0)
106
+ else
107
+ glOrtho(-4.0*w.to_f/h, 4.0*w.to_f/h, -4.0, 4.0, -4.0, 4.0)
108
+ end
109
+ glMatrixMode(GL_MODELVIEW)
110
+ glLoadIdentity()
111
+ glRotate(85.0, 1.0, 1.0, 1.0)
112
+ end
113
+
114
+ keyboard = Proc.new do |key, x, y|
115
+ case (key)
116
+ when ?\e
117
+ exit(0);
118
+ end
119
+ end
120
+
121
+ glutInit()
122
+ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
123
+ glutInitWindowSize(500, 500)
124
+ glutInitWindowPosition(100, 100)
125
+ glutCreateWindow()
126
+ myinit()
127
+ glutReshapeFunc(myReshape)
128
+ glutDisplayFunc(display)
129
+ glutKeyboardFunc(keyboard)
130
+ glutMainLoop()