opengl 0.7.0.pre1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. data/.gemtest +0 -0
  2. data/.gitignore +8 -0
  3. data/History.txt +36 -0
  4. data/MIT-LICENSE +18 -0
  5. data/Manifest.txt +140 -0
  6. data/README.rdoc +51 -0
  7. data/Rakefile +129 -0
  8. data/Rakefile.cross +104 -0
  9. data/doc/build_install.txt +119 -0
  10. data/doc/extensions.txt.in +348 -0
  11. data/doc/history.txt +66 -0
  12. data/doc/requirements_and_design.txt +117 -0
  13. data/doc/roadmap.txt +28 -0
  14. data/doc/scientific_use.txt +35 -0
  15. data/doc/supplies/page_template.html +71 -0
  16. data/doc/thanks.txt +29 -0
  17. data/doc/tutorial.txt +469 -0
  18. data/examples/NeHe/nehe_lesson02.rb +117 -0
  19. data/examples/NeHe/nehe_lesson03.rb +122 -0
  20. data/examples/NeHe/nehe_lesson04.rb +133 -0
  21. data/examples/NeHe/nehe_lesson05.rb +186 -0
  22. data/examples/NeHe/nehe_lesson36.rb +303 -0
  23. data/examples/OrangeBook/3Dlabs-License.txt +33 -0
  24. data/examples/OrangeBook/brick.frag +36 -0
  25. data/examples/OrangeBook/brick.rb +376 -0
  26. data/examples/OrangeBook/brick.vert +41 -0
  27. data/examples/OrangeBook/particle.frag +17 -0
  28. data/examples/OrangeBook/particle.rb +406 -0
  29. data/examples/OrangeBook/particle.vert +38 -0
  30. data/examples/README +16 -0
  31. data/examples/RedBook/aapoly.rb +142 -0
  32. data/examples/RedBook/aargb.rb +119 -0
  33. data/examples/RedBook/accanti.rb +162 -0
  34. data/examples/RedBook/accpersp.rb +215 -0
  35. data/examples/RedBook/alpha.rb +123 -0
  36. data/examples/RedBook/alpha3D.rb +158 -0
  37. data/examples/RedBook/bezcurve.rb +105 -0
  38. data/examples/RedBook/bezmesh.rb +137 -0
  39. data/examples/RedBook/checker.rb +124 -0
  40. data/examples/RedBook/clip.rb +95 -0
  41. data/examples/RedBook/colormat.rb +135 -0
  42. data/examples/RedBook/cube.rb +69 -0
  43. data/examples/RedBook/depthcue.rb +99 -0
  44. data/examples/RedBook/dof.rb +205 -0
  45. data/examples/RedBook/double.rb +105 -0
  46. data/examples/RedBook/drawf.rb +91 -0
  47. data/examples/RedBook/feedback.rb +145 -0
  48. data/examples/RedBook/fog.rb +167 -0
  49. data/examples/RedBook/font.rb +151 -0
  50. data/examples/RedBook/hello.rb +79 -0
  51. data/examples/RedBook/image.rb +137 -0
  52. data/examples/RedBook/jitter.rb +207 -0
  53. data/examples/RedBook/lines.rb +128 -0
  54. data/examples/RedBook/list.rb +111 -0
  55. data/examples/RedBook/material.rb +275 -0
  56. data/examples/RedBook/mipmap.rb +156 -0
  57. data/examples/RedBook/model.rb +113 -0
  58. data/examples/RedBook/movelight.rb +132 -0
  59. data/examples/RedBook/pickdepth.rb +179 -0
  60. data/examples/RedBook/planet.rb +108 -0
  61. data/examples/RedBook/quadric.rb +158 -0
  62. data/examples/RedBook/robot.rb +115 -0
  63. data/examples/RedBook/select.rb +196 -0
  64. data/examples/RedBook/smooth.rb +95 -0
  65. data/examples/RedBook/stencil.rb +163 -0
  66. data/examples/RedBook/stroke.rb +167 -0
  67. data/examples/RedBook/surface.rb +166 -0
  68. data/examples/RedBook/teaambient.rb +132 -0
  69. data/examples/RedBook/teapots.rb +182 -0
  70. data/examples/RedBook/tess.rb +183 -0
  71. data/examples/RedBook/texbind.rb +147 -0
  72. data/examples/RedBook/texgen.rb +169 -0
  73. data/examples/RedBook/texturesurf.rb +128 -0
  74. data/examples/RedBook/varray.rb +159 -0
  75. data/examples/RedBook/wrap.rb +148 -0
  76. data/examples/misc/OGLBench.rb +337 -0
  77. data/examples/misc/anisotropic.rb +194 -0
  78. data/examples/misc/fbo_test.rb +356 -0
  79. data/examples/misc/font-glut.rb +46 -0
  80. data/examples/misc/glfwtest.rb +30 -0
  81. data/examples/misc/plane.rb +161 -0
  82. data/examples/misc/readpixel.rb +65 -0
  83. data/examples/misc/sdltest.rb +34 -0
  84. data/examples/misc/trislam.rb +828 -0
  85. data/ext/common/common.h +448 -0
  86. data/ext/common/conv.h +234 -0
  87. data/ext/common/funcdef.h +280 -0
  88. data/ext/common/gl-enums.h +10031 -0
  89. data/ext/common/gl-error.h +23 -0
  90. data/ext/common/gl-types.h +67 -0
  91. data/ext/common/glu-enums.h +463 -0
  92. data/ext/gl/extconf.rb +43 -0
  93. data/ext/gl/gl-1.0-1.1.c +2811 -0
  94. data/ext/gl/gl-1.2.c +814 -0
  95. data/ext/gl/gl-1.3.c +443 -0
  96. data/ext/gl/gl-1.4.c +348 -0
  97. data/ext/gl/gl-1.5.c +225 -0
  98. data/ext/gl/gl-2.0.c +657 -0
  99. data/ext/gl/gl-2.1.c +57 -0
  100. data/ext/gl/gl-enums.c +3354 -0
  101. data/ext/gl/gl-error.c +104 -0
  102. data/ext/gl/gl-ext-3dfx.c +27 -0
  103. data/ext/gl/gl-ext-arb.c +866 -0
  104. data/ext/gl/gl-ext-ati.c +41 -0
  105. data/ext/gl/gl-ext-ext.c +889 -0
  106. data/ext/gl/gl-ext-gremedy.c +41 -0
  107. data/ext/gl/gl-ext-nv.c +679 -0
  108. data/ext/gl/gl.c +216 -0
  109. data/ext/glu/extconf.rb +51 -0
  110. data/ext/glu/glu-enums.c +164 -0
  111. data/ext/glu/glu.c +1530 -0
  112. data/ext/glut/extconf.rb +67 -0
  113. data/ext/glut/glut.c +1624 -0
  114. data/lib/opengl.rb +89 -0
  115. data/test/README +10 -0
  116. data/test/tc_common.rb +98 -0
  117. data/test/tc_ext_arb.rb +467 -0
  118. data/test/tc_ext_ati.rb +33 -0
  119. data/test/tc_ext_ext.rb +551 -0
  120. data/test/tc_ext_gremedy.rb +36 -0
  121. data/test/tc_ext_nv.rb +357 -0
  122. data/test/tc_func_10_11.rb +1281 -0
  123. data/test/tc_func_12.rb +186 -0
  124. data/test/tc_func_13.rb +229 -0
  125. data/test/tc_func_14.rb +197 -0
  126. data/test/tc_func_15.rb +270 -0
  127. data/test/tc_func_20.rb +346 -0
  128. data/test/tc_func_21.rb +541 -0
  129. data/test/tc_glu.rb +310 -0
  130. data/test/tc_include_gl.rb +35 -0
  131. data/test/tc_misc.rb +54 -0
  132. data/test/tc_require_gl.rb +34 -0
  133. data/utils/README +11 -0
  134. data/utils/enumgen.rb +112 -0
  135. data/utils/extlistgen.rb +90 -0
  136. data/utils/mkdn2html.rb +59 -0
  137. data/utils/post-mkdn2html.rb +91 -0
  138. data/website/images/ogl.jpg +0 -0
  139. data/website/images/tab_bottom.gif +0 -0
  140. data/website/style.css +198 -0
  141. metadata +274 -0
@@ -0,0 +1,132 @@
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
+ # teaambient.c
40
+ # This program renders three lighted, shaded teapots, with
41
+ # different ambient values.
42
+ require 'opengl'
43
+ include Gl,Glu,Glut
44
+
45
+ # Initialize light source and lighting model.
46
+ def myinit
47
+ light_ambient = [0.0, 0.0, 0.0, 1.0]
48
+ light_diffuse = [1.0, 1.0, 1.0, 1.0]
49
+ light_specular = [1.0, 1.0, 1.0, 1.0]
50
+ # light_position is NOT default value
51
+ light_position = [1.0, 0.0, 0.0, 0.0]
52
+ global_ambient = [0.75, 0.75, 0.75, 1.0]
53
+
54
+ glLight(GL_LIGHT0, GL_AMBIENT, light_ambient)
55
+ glLight(GL_LIGHT0, GL_DIFFUSE, light_diffuse)
56
+ glLight(GL_LIGHT0, GL_SPECULAR, light_specular)
57
+ glLight(GL_LIGHT0, GL_POSITION, light_position)
58
+
59
+ glLightModel(GL_LIGHT_MODEL_AMBIENT, global_ambient)
60
+
61
+ glFrontFace(GL_CW)
62
+ glEnable(GL_LIGHTING)
63
+ glEnable(GL_LIGHT0)
64
+ glEnable(GL_AUTO_NORMAL)
65
+ glEnable(GL_NORMALIZE)
66
+ glDepthFunc(GL_LESS)
67
+ glEnable(GL_DEPTH_TEST)
68
+ end
69
+
70
+ display = proc do
71
+ low_ambient = [0.1, 0.1, 0.1, 1.0]
72
+ more_ambient = [0.4, 0.4, 0.4, 1.0]
73
+ most_ambient = [1.0, 1.0, 1.0, 1.0]
74
+
75
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
76
+
77
+ # material has small ambient reflection
78
+ glMaterial(GL_FRONT, GL_AMBIENT, low_ambient)
79
+ glMaterial(GL_FRONT, GL_SHININESS, 40.0)
80
+ glPushMatrix()
81
+ glTranslate(0.0, 2.0, 0.0)
82
+ glutSolidTeapot(1.0)
83
+ glPopMatrix()
84
+
85
+ # material has moderate ambient reflection
86
+ glMaterial(GL_FRONT, GL_AMBIENT, more_ambient)
87
+ glPushMatrix()
88
+ glTranslate(0.0, 0.0, 0.0)
89
+ glutSolidTeapot(1.0)
90
+ glPopMatrix()
91
+
92
+ # material has large ambient reflection
93
+ glMaterial(GL_FRONT, GL_AMBIENT, most_ambient)
94
+ glPushMatrix()
95
+ glTranslate(0.0, -2.0, 0.0)
96
+ glutSolidTeapot(1.0)
97
+ glPopMatrix()
98
+ glFlush()
99
+ end
100
+
101
+ myReshape = proc do |w, h|
102
+ glViewport(0, 0, w, h)
103
+ glMatrixMode(GL_PROJECTION)
104
+ glLoadIdentity()
105
+ if (w <= h)
106
+ glOrtho(-4.0, 4.0, -4.0 * h / w, 4.0 * h / w, -10.0, 10.0)
107
+ else
108
+ glOrtho(-4.0 * w / h, 4.0 * w / h, -4.0, 4.0, -10.0, 10.0)
109
+ end
110
+ glMatrixMode(GL_MODELVIEW)
111
+ end
112
+
113
+ keyboard = Proc.new do |key, x, y|
114
+ case (key)
115
+ when ?\e
116
+ exit(0);
117
+ end
118
+ end
119
+
120
+ # Main Loop
121
+ # Open window with initial window size, title bar,
122
+ # RGBA display mode, and handle input events.
123
+ glutInit()
124
+ glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH)
125
+ glutInitWindowSize(500, 500)
126
+ glutInitWindowPosition(100, 100)
127
+ glutCreateWindow()
128
+ myinit()
129
+ glutReshapeFunc(myReshape)
130
+ glutDisplayFunc(display)
131
+ glutKeyboardFunc(keyboard)
132
+ glutMainLoop()
@@ -0,0 +1,182 @@
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
+ # teapots.c
40
+ # This program demonstrates lots of material properties.
41
+ # A single light source illuminates the objects.
42
+ require 'opengl'
43
+ include Gl,Glu,Glut
44
+
45
+ # Initialize depth buffer, projection matrix, light source, and lighting
46
+ # model. Do not specify a material property here.
47
+ def myinit
48
+ ambient = [0.0, 0.0, 0.0, 1.0]
49
+ diffuse = [1.0, 1.0, 1.0, 1.0]
50
+ position = [0.0, 3.0, 3.0, 0.0]
51
+
52
+ lmodel_ambient = [0.2, 0.2, 0.2, 1.0]
53
+ local_view = [0.0]
54
+
55
+ glLight(GL_LIGHT0, GL_AMBIENT, ambient)
56
+ glLight(GL_LIGHT0, GL_DIFFUSE, diffuse)
57
+ glLight(GL_LIGHT0, GL_POSITION, position)
58
+ glLightModel(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient)
59
+ glLightModel(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view)
60
+
61
+ glFrontFace(GL_CW)
62
+ glEnable(GL_LIGHTING)
63
+ glEnable(GL_LIGHT0)
64
+ glEnable(GL_AUTO_NORMAL)
65
+ glEnable(GL_NORMALIZE)
66
+ glEnable(GL_DEPTH_TEST)
67
+ glDepthFunc(GL_LESS)
68
+ end
69
+
70
+ # Move object into position. Use 3rd through 12th parameters to specify the
71
+ # material property. Draw a teapot.
72
+ def renderTeapot(x, y, ambr, ambg, ambb, difr, difg, difb, specr, specg, specb, shine)
73
+ mat = []
74
+ glPushMatrix()
75
+ glTranslate(x, y, 0.0)
76
+ mat[0] = ambr
77
+ mat[1] = ambg
78
+ mat[2] = ambb
79
+ mat[3] = 1.0
80
+ glMaterial(GL_FRONT, GL_AMBIENT, mat)
81
+ mat[0] = difr
82
+ mat[1] = difg
83
+ mat[2] = difb
84
+ glMaterial(GL_FRONT, GL_DIFFUSE, mat)
85
+ mat[0] = specr
86
+ mat[1] = specg
87
+ mat[2] = specb
88
+ glMaterial(GL_FRONT, GL_SPECULAR, mat)
89
+ glMaterial(GL_FRONT, GL_SHININESS, shine * 128.0)
90
+ glutSolidTeapot(1.0)
91
+ glPopMatrix()
92
+ end
93
+
94
+ # First column: emerald, jade, obsidian, pearl, ruby, turquoise
95
+ # 2nd column: brass, bronze, chrome, copper, gold, silver
96
+ # 3rd column: black, cyan, green, red, white, yellow plastic
97
+ # 4th column: black, cyan, green, red, white, yellow rubber
98
+ display = proc do
99
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
100
+ renderTeapot(2.0, 17.0, 0.0215, 0.1745, 0.0215,
101
+ 0.07568, 0.61424, 0.07568, 0.633, 0.727811, 0.633, 0.6)
102
+ renderTeapot(2.0, 14.0, 0.135, 0.2225, 0.1575,
103
+ 0.54, 0.89, 0.63, 0.316228, 0.316228, 0.316228, 0.1)
104
+ renderTeapot(2.0, 11.0, 0.05375, 0.05, 0.06625,
105
+ 0.18275, 0.17, 0.22525, 0.332741, 0.328634, 0.346435, 0.3)
106
+ renderTeapot(2.0, 8.0, 0.25, 0.20725, 0.20725,
107
+ 1, 0.829, 0.829, 0.296648, 0.296648, 0.296648, 0.088)
108
+ renderTeapot(2.0, 5.0, 0.1745, 0.01175, 0.01175,
109
+ 0.61424, 0.04136, 0.04136, 0.727811, 0.626959, 0.626959, 0.6)
110
+ renderTeapot(2.0, 2.0, 0.1, 0.18725, 0.1745,
111
+ 0.396, 0.74151, 0.69102, 0.297254, 0.30829, 0.306678, 0.1)
112
+ renderTeapot(6.0, 17.0, 0.329412, 0.223529, 0.027451,
113
+ 0.780392, 0.568627, 0.113725, 0.992157, 0.941176, 0.807843,
114
+ 0.21794872)
115
+ renderTeapot(6.0, 14.0, 0.2125, 0.1275, 0.054,
116
+ 0.714, 0.4284, 0.18144, 0.393548, 0.271906, 0.166721, 0.2)
117
+ renderTeapot(6.0, 11.0, 0.25, 0.25, 0.25,
118
+ 0.4, 0.4, 0.4, 0.774597, 0.774597, 0.774597, 0.6)
119
+ renderTeapot(6.0, 8.0, 0.19125, 0.0735, 0.0225,
120
+ 0.7038, 0.27048, 0.0828, 0.256777, 0.137622, 0.086014, 0.1)
121
+ renderTeapot(6.0, 5.0, 0.24725, 0.1995, 0.0745,
122
+ 0.75164, 0.60648, 0.22648, 0.628281, 0.555802, 0.366065, 0.4)
123
+ renderTeapot(6.0, 2.0, 0.19225, 0.19225, 0.19225,
124
+ 0.50754, 0.50754, 0.50754, 0.508273, 0.508273, 0.508273, 0.4)
125
+ renderTeapot(10.0, 17.0, 0.0, 0.0, 0.0, 0.01, 0.01, 0.01,
126
+ 0.50, 0.50, 0.50, 0.25)
127
+ renderTeapot(10.0, 14.0, 0.0, 0.1, 0.06, 0.0, 0.50980392, 0.50980392,
128
+ 0.50196078, 0.50196078, 0.50196078, 0.25)
129
+ renderTeapot(10.0, 11.0, 0.0, 0.0, 0.0,
130
+ 0.1, 0.35, 0.1, 0.45, 0.55, 0.45, 0.25)
131
+ renderTeapot(10.0, 8.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0,
132
+ 0.7, 0.6, 0.6, 0.25)
133
+ renderTeapot(10.0, 5.0, 0.0, 0.0, 0.0, 0.55, 0.55, 0.55,
134
+ 0.70, 0.70, 0.70, 0.25)
135
+ renderTeapot(10.0, 2.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.0,
136
+ 0.60, 0.60, 0.50, 0.25)
137
+ renderTeapot(14.0, 17.0, 0.02, 0.02, 0.02, 0.01, 0.01, 0.01,
138
+ 0.4, 0.4, 0.4, 0.078125)
139
+ renderTeapot(14.0, 14.0, 0.0, 0.05, 0.05, 0.4, 0.5, 0.5,
140
+ 0.04, 0.7, 0.7, 0.078125)
141
+ renderTeapot(14.0, 11.0, 0.0, 0.05, 0.0, 0.4, 0.5, 0.4,
142
+ 0.04, 0.7, 0.04, 0.078125)
143
+ renderTeapot(14.0, 8.0, 0.05, 0.0, 0.0, 0.5, 0.4, 0.4,
144
+ 0.7, 0.04, 0.04, 0.078125)
145
+ renderTeapot(14.0, 5.0, 0.05, 0.05, 0.05, 0.5, 0.5, 0.5,
146
+ 0.7, 0.7, 0.7, 0.078125)
147
+ renderTeapot(14.0, 2.0, 0.05, 0.05, 0.0, 0.5, 0.5, 0.4,
148
+ 0.7, 0.7, 0.04, 0.078125)
149
+ glutSwapBuffers()
150
+ end
151
+
152
+ myReshape = proc do |w, h|
153
+ glViewport(0, 0, w, h)
154
+ glMatrixMode(GL_PROJECTION)
155
+ glLoadIdentity()
156
+ if (w <= h)
157
+ glOrtho(0.0, 16.0, 0.0, 16.0 * h.to_f / w, -10.0, 10.0)
158
+ else
159
+ glOrtho(0.0, 16.0 * w.to_f / h, 0.0, 16.0,-10.0, 10.0)
160
+ end
161
+ glMatrixMode(GL_MODELVIEW)
162
+ end
163
+
164
+ keyboard = Proc.new do |key, x, y|
165
+ case (key)
166
+ when ?\e
167
+ exit(0);
168
+ end
169
+ end
170
+
171
+ # Main Loop Open window with initial window size, title bar, RGBA display
172
+ # mode, and handle input events.
173
+ glutInit()
174
+ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH)
175
+ glutInitWindowSize(500, 500)
176
+ glutInitWindowPosition(100, 100)
177
+ glutCreateWindow()
178
+ myinit()
179
+ glutReshapeFunc(myReshape)
180
+ glutDisplayFunc(display)
181
+ glutKeyboardFunc(keyboard)
182
+ glutMainLoop()
@@ -0,0 +1,183 @@
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
+ # tess.c
38
+ # This program demonstrates polygon tessellation.
39
+ # Two tesselated objects are drawn. The first is a
40
+ # rectangle with a triangular hole. The second is a
41
+ # smooth shaded, self-intersecting star.
42
+ #
43
+ # Note the exterior rectangle is drawn with its vertices
44
+ # in counter-clockwise order, but its interior clockwise.
45
+ # Note the combineCallback is needed for the self-intersecting
46
+ # star. Also note that removing the TessProperty for the
47
+ # star will make the interior unshaded (WINDING_ODD).
48
+ require 'opengl'
49
+ include Gl,Glu,Glut
50
+
51
+ $startList = nil
52
+
53
+ display = proc do
54
+ glClear(GL_COLOR_BUFFER_BIT)
55
+ glColor(1.0, 1.0, 1.0)
56
+ glCallList($startList)
57
+ glCallList($startList + 1)
58
+ glutSwapBuffers()
59
+ end
60
+
61
+ $beginCallback = proc do |which|
62
+ glBegin(which)
63
+ end
64
+
65
+ $errorCallback = proc do |errorCode|
66
+ print "Tessellation Error: #{gluErrorString(errorCode)}"
67
+ exit(0)
68
+ end
69
+
70
+ $endCallback = proc do
71
+ glEnd()
72
+ end
73
+
74
+ $vertexCallback = proc do |vertex|
75
+ glColor(vertex[3], vertex[4], vertex[5])
76
+ glVertex(vertex[0], vertex[1], vertex[2])
77
+ end
78
+
79
+ # combineCallback is used to create a new vertex when edges
80
+ # intersect. coordinate location is trivial to calculate,
81
+ # but weight[4] may be used to average color, normal, or texture
82
+ # coordinate data. In this program, color is weighted.
83
+ $combineCallback = proc do |coords, vertex_data, weight|
84
+ vertex = []
85
+ vertex[0] = coords[0]
86
+ vertex[1] = coords[1]
87
+ vertex[2] = coords[2]
88
+ for i in 3...6
89
+ vertex[i] = weight[0] * vertex_data[0][i] + weight[1] * vertex_data[1][i] + weight[2] * vertex_data[2][i] + weight[3] * vertex_data[3][i]
90
+ end
91
+ vertex
92
+ end
93
+
94
+ def init
95
+ rect = [[50.0, 50.0, 0.0],
96
+ [200.0, 50.0, 0.0],
97
+ [200.0, 200.0, 0.0],
98
+ [50.0, 200.0, 0.0]]
99
+ tri = [[75.0, 75.0, 0.0],
100
+ [125.0, 175.0, 0.0],
101
+ [175.0, 75.0, 0.0]]
102
+ star= [[250.0, 50.0, 0.0, 1.0, 0.0, 1.0],
103
+ [325.0, 200.0, 0.0, 1.0, 1.0, 0.0],
104
+ [400.0, 50.0, 0.0, 0.0, 1.0, 1.0],
105
+ [250.0, 150.0, 0.0, 1.0, 0.0, 0.0],
106
+ [400.0, 150.0, 0.0, 0.0, 1.0, 0.0]]
107
+
108
+ glClearColor(0.0, 0.0, 0.0, 0.0)
109
+
110
+ $startList = glGenLists(2)
111
+
112
+ tobj = gluNewTess()
113
+ gluTessCallback(tobj, GLU_TESS_VERTEX, proc do |v| glVertex(v) end )
114
+ gluTessCallback(tobj, GLU_TESS_BEGIN, $beginCallback)
115
+ gluTessCallback(tobj, GLU_TESS_END, $endCallback)
116
+ gluTessCallback(tobj, GLU_TESS_ERROR, $errorCallback)
117
+
118
+ # rectangle with triangular hole inside
119
+ glNewList($startList, GL_COMPILE)
120
+ glShadeModel(GL_FLAT)
121
+ gluTessBeginPolygon(tobj, nil)
122
+ gluTessBeginContour(tobj)
123
+ gluTessVertex(tobj, rect[0], rect[0])
124
+ gluTessVertex(tobj, rect[1], rect[1])
125
+ gluTessVertex(tobj, rect[2], rect[2])
126
+ gluTessVertex(tobj, rect[3], rect[3])
127
+ gluTessEndContour(tobj)
128
+ gluTessBeginContour(tobj)
129
+ gluTessVertex(tobj, tri[0], tri[0])
130
+ gluTessVertex(tobj, tri[1], tri[1])
131
+ gluTessVertex(tobj, tri[2], tri[2])
132
+ gluTessEndContour(tobj)
133
+ gluTessEndPolygon(tobj)
134
+ glEndList()
135
+
136
+ gluTessCallback(tobj, GLU_TESS_VERTEX, $vertexCallback)
137
+ gluTessCallback(tobj, GLU_TESS_BEGIN, $beginCallback)
138
+ gluTessCallback(tobj, GLU_TESS_END, $endCallback)
139
+ gluTessCallback(tobj, GLU_TESS_ERROR, $errorCallback)
140
+ gluTessCallback(tobj, GLU_TESS_COMBINE, $combineCallback)
141
+
142
+
143
+ # smooth shaded, self-intersecting star
144
+ glNewList($startList + 1, GL_COMPILE)
145
+ glShadeModel(GL_SMOOTH)
146
+ gluTessProperty(tobj, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_POSITIVE)
147
+ gluTessBeginPolygon(tobj, nil)
148
+ gluTessBeginContour(tobj)
149
+ gluTessVertex(tobj, star[0], star[0])
150
+ gluTessVertex(tobj, star[1], star[1])
151
+ gluTessVertex(tobj, star[2], star[2])
152
+ gluTessVertex(tobj, star[3], star[3])
153
+ gluTessVertex(tobj, star[4], star[4])
154
+ gluTessEndContour(tobj)
155
+ gluTessEndPolygon(tobj)
156
+ glEndList()
157
+ gluDeleteTess(tobj)
158
+ end
159
+
160
+ reshape = proc do |w, h|
161
+ glViewport(0, 0, w, h)
162
+ glMatrixMode(GL_PROJECTION)
163
+ glLoadIdentity()
164
+ gluOrtho2D(0.0, w, 0.0, h)
165
+ end
166
+
167
+ keyboard = proc do |key, x, y|
168
+ case (key)
169
+ when ?\e
170
+ exit(0)
171
+ end
172
+ end
173
+
174
+ glutInit()
175
+ glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
176
+ glutInitWindowSize(500, 500)
177
+ glutInitWindowPosition(100, 100)
178
+ glutCreateWindow()
179
+ init()
180
+ glutDisplayFunc(display)
181
+ glutReshapeFunc(reshape)
182
+ glutKeyboardFunc(keyboard)
183
+ glutMainLoop()