ruby-opengl 0.33.0 → 0.40.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 (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,41 @@
1
+ require "gl_prev"
2
+ require "glu_prev"
3
+ require "glut_prev"
4
+
5
+
6
+ display = Proc.new {
7
+ GL::Clear(GL::COLOR_BUFFER_BIT);
8
+ GL.LoadIdentity
9
+
10
+ GL::RasterPos2d(20,20)
11
+ "Hello Bitmap".each_byte { |x| GLUT.BitmapCharacter(GLUT::BITMAP_9_BY_15, x) }
12
+
13
+ GL.Translate(0, 50, 0)
14
+ GL.Scale(0.25, 0.25, 1)
15
+ "Hello Stroke".each_byte { |x| GLUT.StrokeCharacter(GLUT::STROKE_ROMAN, x) }
16
+
17
+ GL.Flush();
18
+ }
19
+
20
+ reshape = Proc.new {|w, h|
21
+ GL::Viewport(0, 0, w, h);
22
+ GL::MatrixMode(GL::PROJECTION);
23
+ GL::LoadIdentity();
24
+ GL::Ortho(0.0, w, 0.0, h, -1.0, 1.0);
25
+ GL::MatrixMode(GL::MODELVIEW);
26
+ }
27
+
28
+
29
+ # Main Loop
30
+ # Open window with initial window size, title bar,
31
+ # color index display mode, and handle input events.
32
+ #
33
+ GLUT.Init
34
+ GLUT.InitDisplayMode(GLUT::SINGLE | GLUT::RGB);
35
+ GLUT.InitWindowSize(200, 200);
36
+ GLUT.CreateWindow($0);
37
+
38
+ GLUT.ReshapeFunc(reshape);
39
+ GLUT.DisplayFunc(display);
40
+ GLUT.MainLoop
41
+
@@ -0,0 +1,158 @@
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
+ # * font.c
40
+ # *
41
+ # * Draws some text in a bitmapped font. Uses glBitmap()
42
+ # * and other pixel routines. Also demonstrates use of
43
+ # * display lists.
44
+ # */
45
+ require "gl_prev"
46
+ require "glu_prev"
47
+ require "glut_prev"
48
+
49
+
50
+ $space = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00];
51
+
52
+ $letters = [
53
+ [0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0x66, 0x3c, 0x18],
54
+ [0x00, 0x00, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe],
55
+ [0x00, 0x00, 0x7e, 0xe7, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xe7, 0x7e],
56
+ [0x00, 0x00, 0xfc, 0xce, 0xc7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc7, 0xce, 0xfc],
57
+ [0x00, 0x00, 0xff, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xc0, 0xc0, 0xc0, 0xc0, 0xff],
58
+ [0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xc0, 0xc0, 0xc0, 0xff],
59
+ [0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xcf, 0xc0, 0xc0, 0xc0, 0xc0, 0xe7, 0x7e],
60
+ [0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3],
61
+ [0x00, 0x00, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e],
62
+ [0x00, 0x00, 0x7c, 0xee, 0xc6, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06],
63
+ [0x00, 0x00, 0xc3, 0xc6, 0xcc, 0xd8, 0xf0, 0xe0, 0xf0, 0xd8, 0xcc, 0xc6, 0xc3],
64
+ [0x00, 0x00, 0xff, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0],
65
+ [0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xdb, 0xff, 0xff, 0xe7, 0xc3],
66
+ [0x00, 0x00, 0xc7, 0xc7, 0xcf, 0xcf, 0xdf, 0xdb, 0xfb, 0xf3, 0xf3, 0xe3, 0xe3],
67
+ [0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xe7, 0x7e],
68
+ [0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe],
69
+ [0x00, 0x00, 0x3f, 0x6e, 0xdf, 0xdb, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0x66, 0x3c],
70
+ [0x00, 0x00, 0xc3, 0xc6, 0xcc, 0xd8, 0xf0, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe],
71
+ [0x00, 0x00, 0x7e, 0xe7, 0x03, 0x03, 0x07, 0x7e, 0xe0, 0xc0, 0xc0, 0xe7, 0x7e],
72
+ [0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff],
73
+ [0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3],
74
+ [0x00, 0x00, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3],
75
+ [0x00, 0x00, 0xc3, 0xe7, 0xff, 0xff, 0xdb, 0xdb, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3],
76
+ [0x00, 0x00, 0xc3, 0x66, 0x66, 0x3c, 0x3c, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3],
77
+ [0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3],
78
+ [0x00, 0x00, 0xff, 0xc0, 0xc0, 0x60, 0x30, 0x7e, 0x0c, 0x06, 0x03, 0x03, 0xff]
79
+ ];
80
+
81
+ $fontOffset = 0;
82
+
83
+ def makeRasterFont
84
+ GL::PixelStorei(GL::UNPACK_ALIGNMENT, 1);
85
+
86
+ $fontOffset = GL::GenLists(128);
87
+ i = 0; j = ?A;
88
+ for i in 0...26
89
+ GL::NewList($fontOffset + j, GL::COMPILE);
90
+ GL::Bitmap(8, 13, 0.0, 2.0, 10.0, 0.0, $letters[i].pack("C*"));
91
+ GL::EndList();
92
+ j+=1
93
+ end
94
+ GL::NewList($fontOffset + ' '[0], GL::COMPILE);
95
+ GL::Bitmap(8, 13, 0.0, 2.0, 10.0, 0.0, $space.pack("C*"));
96
+ GL::EndList();
97
+ end
98
+
99
+ def init
100
+ GL::ShadeModel(GL::FLAT);
101
+ makeRasterFont();
102
+ end
103
+
104
+ def printString(s)
105
+ GL::PushAttrib(GL::LIST_BIT);
106
+ GL::ListBase($fontOffset);
107
+ GL::CallLists(s);
108
+ GL::PopAttrib();
109
+ end
110
+
111
+ #/* Everything above this line could be in a library
112
+ # * that defines a font. To make it work, you've got
113
+ # * to call makeRasterFont() before you start making
114
+ # * calls to printString().
115
+ # */
116
+ display = proc {
117
+ white = [ 1.0, 1.0, 1.0 ];
118
+
119
+ GL::Clear(GL::COLOR_BUFFER_BIT);
120
+ GL::Color(white);
121
+
122
+ GL::RasterPos(20, 60);
123
+ printString("THE QUICK BROWN FOX JUMPS");
124
+ GL::RasterPos(20, 40);
125
+ printString("OVER A LAZY DOG");
126
+ GL::Flush();
127
+ }
128
+
129
+ reshape = proc {|w, h|
130
+ GL::Viewport(0, 0, w, h);
131
+ GL::MatrixMode(GL::PROJECTION);
132
+ GL::LoadIdentity();
133
+ GL::Ortho(0.0, w, 0.0, h, -1.0, 1.0);
134
+ GL::MatrixMode(GL::MODELVIEW);
135
+ }
136
+
137
+ # /* ARGSUSED1 */
138
+ keyboard = proc {|key, x, y|
139
+ case (key)
140
+ when 27
141
+ exit(0);
142
+ end
143
+ }
144
+
145
+ #/* Main Loop
146
+ # * Open window with initial window size, title bar,
147
+ # * RGBA display mode, and handle input events.
148
+ # */
149
+ GLUT::Init();
150
+ GLUT::InitDisplayMode(GLUT::SINGLE | GLUT::RGB);
151
+ GLUT::InitWindowSize(300, 100);
152
+ GLUT::InitWindowPosition(100, 100);
153
+ GLUT::CreateWindow();
154
+ init();
155
+ GLUT::ReshapeFunc(reshape);
156
+ GLUT::KeyboardFunc(keyboard);
157
+ GLUT::DisplayFunc(display);
158
+ GLUT::MainLoop();
@@ -0,0 +1,75 @@
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
+ #hello.c
40
+ #This is a simple, introductory OpenGL program.
41
+ #
42
+ require "gl_prev"
43
+ require "glu_prev"
44
+ require "glut_prev"
45
+
46
+ display = Proc.new {
47
+ GL.Clear (GL::COLOR_BUFFER_BIT);
48
+
49
+ GL.Color(1.0, 1.0, 1.0);
50
+ GL.Begin(GL::POLYGON);
51
+ GL.Vertex(0.25, 0.25, 0.0);
52
+ GL.Vertex(0.75, 0.25, 0.0);
53
+ GL.Vertex(0.75, 0.75, 0.0);
54
+ GL.Vertex(0.25, 0.75, 0.0);
55
+ GL.End();
56
+
57
+ GL.Flush();
58
+ }
59
+
60
+ def init
61
+ GL.ClearColor(0.0, 0.0, 0.0, 0.0);
62
+
63
+ GL.MatrixMode(GL::PROJECTION);
64
+ GL.LoadIdentity();
65
+ GL.Ortho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
66
+ end
67
+
68
+ GLUT.Init
69
+ GLUT.InitDisplayMode(GLUT::SINGLE | GLUT::RGB);
70
+ GLUT.InitWindowSize(250, 250);
71
+ GLUT.InitWindowPosition(100, 100);
72
+ GLUT.CreateWindow("hello");
73
+ init();
74
+ GLUT.DisplayFunc(display);
75
+ GLUT.MainLoop();
@@ -0,0 +1,145 @@
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
+ #/* image.c
39
+ # * This program demonstrates drawing pixels and shows the effect
40
+ # * of glDrawPixels(), glCopyPixels(), and glPixelZoom().
41
+ # * Interaction: moving the mouse while pressing the mouse button
42
+ # * will copy the image in the lower-left corner of the window
43
+ # * to the mouse position, using the current pixel zoom factors.
44
+ # * There is no attempt to prevent you from drawing over the original
45
+ # * image. If you press the 'r' key, the original image and zoom
46
+ # * factors are reset. If you press the 'z' or 'Z' keys, you change
47
+ # * the zoom factors.
48
+ # */
49
+
50
+ require "gl_prev"
51
+ require "glu_prev"
52
+ require "glut_prev"
53
+ require "mathn"
54
+
55
+ # /* Create checkerboard image */
56
+ CheckImageWidth=64
57
+ CheckImageHeight=64
58
+ $checkImage=[]
59
+
60
+ $zoomFactor = 1.0;
61
+ $height = 0.0;
62
+
63
+ def makeCheckImage
64
+ for i in 0..CheckImageWidth-1
65
+ for j in 0..CheckImageHeight-1
66
+ c = if ((i&0x8==0) != (j&0x8==0)) then 255; else 0; end;
67
+ $checkImage[(i+CheckImageWidth*j)*3+0] = c;
68
+ $checkImage[(i+CheckImageWidth*j)*3+1] = c;
69
+ $checkImage[(i+CheckImageWidth*j)*3+2] = c;
70
+ end
71
+ end
72
+ end
73
+
74
+ def init
75
+ GL.ClearColor(0.0, 0.0, 0.0, 0.0);
76
+ GL.ShadeModel(GL::FLAT);
77
+ makeCheckImage();
78
+ GL.PixelStorei(GL::UNPACK_ALIGNMENT, 1);
79
+ end
80
+
81
+ display = Proc.new {
82
+ GL.Clear(GL::COLOR_BUFFER_BIT);
83
+ GL.RasterPos(0, 0);
84
+ GL.DrawPixels(CheckImageWidth, CheckImageHeight, GL::RGB, GL::UNSIGNED_BYTE, $checkImage.pack("C*"));
85
+ GL.Flush();
86
+ }
87
+
88
+ reshape = Proc.new {|w, h|
89
+ GL.Viewport(0, 0, w, h);
90
+ $height = h;
91
+ GL.MatrixMode(GL::PROJECTION);
92
+ GL.LoadIdentity();
93
+ GLU.Ortho2D(0.0, w, 0.0, h);
94
+ GL.MatrixMode(GL::MODELVIEW);
95
+ GL.LoadIdentity();
96
+ }
97
+
98
+ $screeny = 0.0
99
+ motion = Proc.new {|x, y|
100
+
101
+ $screeny = $height - y;
102
+ GL.RasterPos(x, $screeny);
103
+ GL.PixelZoom($zoomFactor, $zoomFactor);
104
+ GL.CopyPixels(0, 0, CheckImageWidth, CheckImageHeight, GL::COLOR);
105
+ GL.PixelZoom(1.0, 1.0);
106
+ GL.Flush();
107
+ }
108
+
109
+ # /* ARGSUSED1 */
110
+ keyboard = Proc.new {|key, x, y|
111
+ case (key)
112
+ when 'r'[0],'R'[0]
113
+ $zoomFactor = 1.0;
114
+ GLUT.PostRedisplay();
115
+ printf("zoomFactor reset to 1.0\n");
116
+ when 'z'[0]
117
+ $zoomFactor = $zoomFactor + 0.5;
118
+ if ($zoomFactor >= 3.0)
119
+ $zoomFactor = 3.0;
120
+ end
121
+ printf("zoomFactor is now %4.1f\n", $zoomFactor);
122
+ when 'Z'[0]
123
+ $zoomFactor = $zoomFactor - 0.5;
124
+ if ($zoomFactor <= 0.5)
125
+ $zoomFactor = 0.5;
126
+ end
127
+ printf("zoomFactor is now %4.1f\n", $zoomFactor);
128
+ when 27
129
+ exit(0);
130
+ end
131
+ }
132
+
133
+ #int main(int argc, char** argv)
134
+ #{
135
+ GLUT.Init
136
+ GLUT.InitDisplayMode(GLUT::SINGLE | GLUT::RGB);
137
+ GLUT.InitWindowSize(250, 250);
138
+ GLUT.InitWindowPosition(100, 100);
139
+ GLUT.CreateWindow($0);
140
+ init();
141
+ GLUT.DisplayFunc(display);
142
+ GLUT.ReshapeFunc(reshape);
143
+ GLUT.KeyboardFunc(keyboard);
144
+ GLUT.MotionFunc(motion);
145
+ GLUT.MainLoop();
@@ -0,0 +1,209 @@
1
+ #/*
2
+ # * (c) Copyright 1993, 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(TM) is a trademark of Silicon Graphics, Inc.
36
+ # */
37
+ #/*
38
+ #jitter.h
39
+ #
40
+ #This file contains jitter point arrays for 2,3,4,8,15,24 and 66 jitters.
41
+ #
42
+ #The arrays are named j2, j3, etc. Each element in the array has the form,
43
+ #for example, j8[0].x and j8[0].y
44
+ #
45
+ #Values are floating point in the range -.5 < x < .5, -.5 < y < .5, and
46
+ #have a gaussian distribution around the origin.
47
+ #
48
+ #Use these to do model jittering for scene anti-aliasing and view volume
49
+ #jittering for depth of field effects. Use in conjunction with the
50
+ #accwindow() routine.
51
+ #*/
52
+
53
+ MAX_SAMPLES=66
54
+
55
+
56
+ #/* 2 jitter points */
57
+ $j2 = [
58
+ [ 0.246490, 0.249999],
59
+ [-0.246490, -0.249999]
60
+ ];
61
+
62
+
63
+ # /* 3 jitter points */
64
+ $j3 = [
65
+ [-0.373411, -0.250550],
66
+ [ 0.256263, 0.368119],
67
+ [ 0.117148, -0.117570]
68
+ ];
69
+
70
+
71
+ # /* 4 jitter points */
72
+ $j4 = [
73
+ [-0.208147, 0.353730],
74
+ [ 0.203849, -0.353780],
75
+ [-0.292626, -0.149945],
76
+ [ 0.296924, 0.149994]
77
+ ];
78
+
79
+
80
+ # /* 8 jitter points */
81
+ $j8 = [
82
+ [-0.334818, 0.435331],
83
+ [ 0.286438, -0.393495],
84
+ [ 0.459462, 0.141540],
85
+ [-0.414498, -0.192829],
86
+ [-0.183790, 0.082102],
87
+ [-0.079263, -0.317383],
88
+ [ 0.102254, 0.299133],
89
+ [ 0.164216, -0.054399]
90
+ ];
91
+
92
+
93
+ # /* 15 jitter points */
94
+ $j15 = [
95
+ [ 0.285561, 0.188437],
96
+ [ 0.360176, -0.065688],
97
+ [-0.111751, 0.275019],
98
+ [-0.055918, -0.215197],
99
+ [-0.080231, -0.470965],
100
+ [ 0.138721, 0.409168],
101
+ [ 0.384120, 0.458500],
102
+ [-0.454968, 0.134088],
103
+ [ 0.179271, -0.331196],
104
+ [-0.307049, -0.364927],
105
+ [ 0.105354, -0.010099],
106
+ [-0.154180, 0.021794],
107
+ [-0.370135, -0.116425],
108
+ [ 0.451636, -0.300013],
109
+ [-0.370610, 0.387504]
110
+ ];
111
+
112
+ # /* 24 jitter points */
113
+ $j24 = [
114
+ [ 0.030245, 0.136384],
115
+ [ 0.018865, -0.348867],
116
+ [-0.350114, -0.472309],
117
+ [ 0.222181, 0.149524],
118
+ [-0.393670, -0.266873],
119
+ [ 0.404568, 0.230436],
120
+ [ 0.098381, 0.465337],
121
+ [ 0.462671, 0.442116],
122
+ [ 0.400373, -0.212720],
123
+ [-0.409988, 0.263345],
124
+ [-0.115878, -0.001981],
125
+ [ 0.348425, -0.009237],
126
+ [-0.464016, 0.066467],
127
+ [-0.138674, -0.468006],
128
+ [ 0.144932, -0.022780],
129
+ [-0.250195, 0.150161],
130
+ [-0.181400, -0.264219],
131
+ [ 0.196097, -0.234139],
132
+ [-0.311082, -0.078815],
133
+ [ 0.268379, 0.366778],
134
+ [-0.040601, 0.327109],
135
+ [-0.234392, 0.354659],
136
+ [-0.003102, -0.154402],
137
+ [ 0.297997, -0.417965]
138
+ ];
139
+
140
+
141
+ # /* 66 jitter points */
142
+ $j66 = [
143
+ [ 0.266377, -0.218171],
144
+ [-0.170919, -0.429368],
145
+ [ 0.047356, -0.387135],
146
+ [-0.430063, 0.363413],
147
+ [-0.221638, -0.313768],
148
+ [ 0.124758, -0.197109],
149
+ [-0.400021, 0.482195],
150
+ [ 0.247882, 0.152010],
151
+ [-0.286709, -0.470214],
152
+ [-0.426790, 0.004977],
153
+ [-0.361249, -0.104549],
154
+ [-0.040643, 0.123453],
155
+ [-0.189296, 0.438963],
156
+ [-0.453521, -0.299889],
157
+ [ 0.408216, -0.457699],
158
+ [ 0.328973, -0.101914],
159
+ [-0.055540, -0.477952],
160
+ [ 0.194421, 0.453510],
161
+ [ 0.404051, 0.224974],
162
+ [ 0.310136, 0.419700],
163
+ [-0.021743, 0.403898],
164
+ [-0.466210, 0.248839],
165
+ [ 0.341369, 0.081490],
166
+ [ 0.124156, -0.016859],
167
+ [-0.461321, -0.176661],
168
+ [ 0.013210, 0.234401],
169
+ [ 0.174258, -0.311854],
170
+ [ 0.294061, 0.263364],
171
+ [-0.114836, 0.328189],
172
+ [ 0.041206, -0.106205],
173
+ [ 0.079227, 0.345021],
174
+ [-0.109319, -0.242380],
175
+ [ 0.425005, -0.332397],
176
+ [ 0.009146, 0.015098],
177
+ [-0.339084, -0.355707],
178
+ [-0.224596, -0.189548],
179
+ [ 0.083475, 0.117028],
180
+ [ 0.295962, -0.334699],
181
+ [ 0.452998, 0.025397],
182
+ [ 0.206511, -0.104668],
183
+ [ 0.447544, -0.096004],
184
+ [-0.108006, -0.002471],
185
+ [-0.380810, 0.130036],
186
+ [-0.242440, 0.186934],
187
+ [-0.200363, 0.070863],
188
+ [-0.344844, -0.230814],
189
+ [ 0.408660, 0.345826],
190
+ [-0.233016, 0.305203],
191
+ [ 0.158475, -0.430762],
192
+ [ 0.486972, 0.139163],
193
+ [-0.301610, 0.009319],
194
+ [ 0.282245, -0.458671],
195
+ [ 0.482046, 0.443890],
196
+ [-0.121527, 0.210223],
197
+ [-0.477606, -0.424878],
198
+ [-0.083941, -0.121440],
199
+ [-0.345773, 0.253779],
200
+ [ 0.234646, 0.034549],
201
+ [ 0.394102, -0.210901],
202
+ [-0.312571, 0.397656],
203
+ [ 0.200906, 0.333293],
204
+ [ 0.018703, -0.261792],
205
+ [-0.209349, -0.065383],
206
+ [ 0.076248, 0.478538],
207
+ [-0.073036, -0.355064],
208
+ [ 0.145087, 0.221726]
209
+ ];