opengl 0.9.0-x64-mingw32
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.
- checksums.yaml +7 -0
 - checksums.yaml.gz.sig +3 -0
 - data.tar.gz.sig +0 -0
 - data/.autotest +29 -0
 - data/.gemtest +0 -0
 - data/.gitignore +6 -0
 - data/.travis.yml +19 -0
 - data/History.rdoc +77 -0
 - data/MIT-LICENSE +18 -0
 - data/Manifest.txt +138 -0
 - data/README.rdoc +102 -0
 - data/Rakefile +60 -0
 - data/examples/NeHe/NeHe.png +0 -0
 - data/examples/NeHe/crate.png +0 -0
 - data/examples/NeHe/glass.png +0 -0
 - data/examples/NeHe/nehe_lesson02.rb +117 -0
 - data/examples/NeHe/nehe_lesson03.rb +123 -0
 - data/examples/NeHe/nehe_lesson04.rb +132 -0
 - data/examples/NeHe/nehe_lesson05.rb +182 -0
 - data/examples/NeHe/nehe_lesson06.rb +186 -0
 - data/examples/NeHe/nehe_lesson07.rb +240 -0
 - data/examples/NeHe/nehe_lesson08.rb +255 -0
 - data/examples/NeHe/nehe_lesson09.rb +203 -0
 - data/examples/NeHe/nehe_lesson11.rb +176 -0
 - data/examples/NeHe/nehe_lesson12.rb +203 -0
 - data/examples/NeHe/nehe_lesson16.rb +211 -0
 - data/examples/NeHe/nehe_lesson19.rb +209 -0
 - data/examples/NeHe/nehe_lesson36.rb +308 -0
 - data/examples/NeHe/particle.png +0 -0
 - data/examples/NeHe/star.png +0 -0
 - data/examples/NeHe/tim.png +0 -0
 - data/examples/OrangeBook/3Dlabs-License.txt +33 -0
 - data/examples/OrangeBook/brick.frag +36 -0
 - data/examples/OrangeBook/brick.rb +378 -0
 - data/examples/OrangeBook/brick.vert +41 -0
 - data/examples/OrangeBook/particle.frag +17 -0
 - data/examples/OrangeBook/particle.rb +408 -0
 - data/examples/OrangeBook/particle.vert +38 -0
 - data/examples/README +16 -0
 - data/examples/RedBook/aapoly.rb +143 -0
 - data/examples/RedBook/aargb.rb +121 -0
 - data/examples/RedBook/accanti.rb +164 -0
 - data/examples/RedBook/accpersp.rb +217 -0
 - data/examples/RedBook/alpha.rb +125 -0
 - data/examples/RedBook/alpha3D.rb +160 -0
 - data/examples/RedBook/bezcurve.rb +107 -0
 - data/examples/RedBook/bezmesh.rb +139 -0
 - data/examples/RedBook/checker.rb +126 -0
 - data/examples/RedBook/clip.rb +97 -0
 - data/examples/RedBook/colormat.rb +137 -0
 - data/examples/RedBook/cube.rb +71 -0
 - data/examples/RedBook/depthcue.rb +101 -0
 - data/examples/RedBook/dof.rb +206 -0
 - data/examples/RedBook/double.rb +107 -0
 - data/examples/RedBook/drawf.rb +93 -0
 - data/examples/RedBook/feedback.rb +147 -0
 - data/examples/RedBook/fog.rb +168 -0
 - data/examples/RedBook/font.rb +153 -0
 - data/examples/RedBook/hello.rb +81 -0
 - data/examples/RedBook/image.rb +139 -0
 - data/examples/RedBook/jitter.rb +207 -0
 - data/examples/RedBook/light.rb +155 -0
 - data/examples/RedBook/lines.rb +130 -0
 - data/examples/RedBook/list.rb +113 -0
 - data/examples/RedBook/material.rb +276 -0
 - data/examples/RedBook/mipmap.rb +158 -0
 - data/examples/RedBook/model.rb +115 -0
 - data/examples/RedBook/movelight.rb +134 -0
 - data/examples/RedBook/pickdepth.rb +181 -0
 - data/examples/RedBook/planet.rb +110 -0
 - data/examples/RedBook/quadric.rb +160 -0
 - data/examples/RedBook/robot.rb +117 -0
 - data/examples/RedBook/select.rb +198 -0
 - data/examples/RedBook/smooth.rb +97 -0
 - data/examples/RedBook/stencil.rb +165 -0
 - data/examples/RedBook/stroke.rb +169 -0
 - data/examples/RedBook/surface.rb +168 -0
 - data/examples/RedBook/teaambient.rb +134 -0
 - data/examples/RedBook/teapots.rb +184 -0
 - data/examples/RedBook/tess.rb +185 -0
 - data/examples/RedBook/texbind.rb +149 -0
 - data/examples/RedBook/texgen.rb +171 -0
 - data/examples/RedBook/texturesurf.rb +130 -0
 - data/examples/RedBook/varray.rb +161 -0
 - data/examples/RedBook/wrap.rb +150 -0
 - data/examples/misc/OGLBench.rb +338 -0
 - data/examples/misc/anisotropic.rb +196 -0
 - data/examples/misc/fbo_test.rb +357 -0
 - data/examples/misc/font-glut.rb +47 -0
 - data/examples/misc/glfwtest.rb +30 -0
 - data/examples/misc/plane.rb +161 -0
 - data/examples/misc/readpixel.rb +66 -0
 - data/examples/misc/sdltest.rb +36 -0
 - data/examples/misc/trislam.rb +829 -0
 - data/ext/opengl/common.h +428 -0
 - data/ext/opengl/conv.h +244 -0
 - data/ext/opengl/extconf.rb +47 -0
 - data/ext/opengl/funcdef.h +313 -0
 - data/ext/opengl/gl-1.0-1.1.c +3075 -0
 - data/ext/opengl/gl-1.2.c +155 -0
 - data/ext/opengl/gl-1.3.c +443 -0
 - data/ext/opengl/gl-1.4.c +348 -0
 - data/ext/opengl/gl-1.5.c +224 -0
 - data/ext/opengl/gl-2.0.c +667 -0
 - data/ext/opengl/gl-2.1.c +57 -0
 - data/ext/opengl/gl-3.0.c +493 -0
 - data/ext/opengl/gl-enums.c +4873 -0
 - data/ext/opengl/gl-enums.h +14588 -0
 - data/ext/opengl/gl-error.c +112 -0
 - data/ext/opengl/gl-error.h +28 -0
 - data/ext/opengl/gl-ext-3dfx.c +27 -0
 - data/ext/opengl/gl-ext-arb.c +875 -0
 - data/ext/opengl/gl-ext-ati.c +41 -0
 - data/ext/opengl/gl-ext-ext.c +889 -0
 - data/ext/opengl/gl-ext-gremedy.c +41 -0
 - data/ext/opengl/gl-ext-nv.c +680 -0
 - data/ext/opengl/gl-types.h +67 -0
 - data/ext/opengl/gl.c +220 -0
 - data/ext/opengl/gl_buffer.c +177 -0
 - data/ext/opengl/opengl.c +7 -0
 - data/lib/gl.rb +1 -0
 - data/lib/opengl.rb +53 -0
 - data/lib/opengl/2.0/opengl.so +0 -0
 - data/lib/opengl/2.1/opengl.so +0 -0
 - data/lib/opengl/test_case.rb +86 -0
 - data/test/dummy.xorg.conf +140 -0
 - data/test/test_gl.rb +38 -0
 - data/test/test_gl_10_11.rb +1363 -0
 - data/test/test_gl_12.rb +71 -0
 - data/test/test_gl_13.rb +221 -0
 - data/test/test_gl_14.rb +218 -0
 - data/test/test_gl_15.rb +258 -0
 - data/test/test_gl_20.rb +417 -0
 - data/test/test_gl_21.rb +436 -0
 - data/test/test_gl_ext_arb.rb +508 -0
 - data/test/test_gl_ext_ati.rb +28 -0
 - data/test/test_gl_ext_ext.rb +608 -0
 - data/test/test_gl_ext_gremedy.rb +29 -0
 - data/test/test_gl_ext_nv.rb +349 -0
 - data/test/test_opengl_buffer.rb +120 -0
 - data/utils/README +6 -0
 - data/utils/enumgen.rb +108 -0
 - data/utils/extlistgen.rb +90 -0
 - metadata +319 -0
 - metadata.gz.sig +1 -0
 
| 
         Binary file 
     | 
| 
         Binary file 
     | 
| 
         Binary file 
     | 
| 
         @@ -0,0 +1,33 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Copyright (C) 2002-2005  3Dlabs Inc. Ltd.
         
     | 
| 
      
 2 
     | 
    
         
            +
            All rights reserved.
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            Redistribution and use in source and binary forms, with or without
         
     | 
| 
      
 5 
     | 
    
         
            +
            modification, are permitted provided that the following conditions
         
     | 
| 
      
 6 
     | 
    
         
            +
            are met:
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                Redistributions of source code must retain the above copyright
         
     | 
| 
      
 9 
     | 
    
         
            +
                notice, this list of conditions and the following disclaimer.
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                Redistributions in binary form must reproduce the above
         
     | 
| 
      
 12 
     | 
    
         
            +
                copyright notice, this list of conditions and the following
         
     | 
| 
      
 13 
     | 
    
         
            +
                disclaimer in the documentation and/or other materials provided
         
     | 
| 
      
 14 
     | 
    
         
            +
                with the distribution.
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                Neither the name of 3Dlabs Inc. Ltd. nor the names of its
         
     | 
| 
      
 17 
     | 
    
         
            +
                contributors may be used to endorse or promote products derived
         
     | 
| 
      
 18 
     | 
    
         
            +
                from this software without specific prior written permission.
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
         
     | 
| 
      
 21 
     | 
    
         
            +
            "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
         
     | 
| 
      
 22 
     | 
    
         
            +
            LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
         
     | 
| 
      
 23 
     | 
    
         
            +
            FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
         
     | 
| 
      
 24 
     | 
    
         
            +
            COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
         
     | 
| 
      
 25 
     | 
    
         
            +
            INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
         
     | 
| 
      
 26 
     | 
    
         
            +
            BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
         
     | 
| 
      
 27 
     | 
    
         
            +
            LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
         
     | 
| 
      
 28 
     | 
    
         
            +
            CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
         
     | 
| 
      
 29 
     | 
    
         
            +
            LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
         
     | 
| 
      
 30 
     | 
    
         
            +
            ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
         
     | 
| 
      
 31 
     | 
    
         
            +
            POSSIBILITY OF SUCH DAMAGE.
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,36 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            //
         
     | 
| 
      
 2 
     | 
    
         
            +
            // Fragment shader for procedural bricks
         
     | 
| 
      
 3 
     | 
    
         
            +
            //
         
     | 
| 
      
 4 
     | 
    
         
            +
            // Authors: Dave Baldwin, Steve Koren, Randi Rost
         
     | 
| 
      
 5 
     | 
    
         
            +
            //          based on a shader by Darwyn Peachey
         
     | 
| 
      
 6 
     | 
    
         
            +
            //
         
     | 
| 
      
 7 
     | 
    
         
            +
            // Copyright (c) 2002-2004 3Dlabs Inc. Ltd.
         
     | 
| 
      
 8 
     | 
    
         
            +
            //
         
     | 
| 
      
 9 
     | 
    
         
            +
            // See 3Dlabs-License.txt for license information
         
     | 
| 
      
 10 
     | 
    
         
            +
            //  
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            uniform vec3  BrickColor, MortarColor;
         
     | 
| 
      
 13 
     | 
    
         
            +
            uniform vec2  BrickSize;
         
     | 
| 
      
 14 
     | 
    
         
            +
            uniform vec2  BrickPct;
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            varying vec2  MCposition;
         
     | 
| 
      
 17 
     | 
    
         
            +
            varying float LightIntensity;
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            void main(void)
         
     | 
| 
      
 20 
     | 
    
         
            +
            {
         
     | 
| 
      
 21 
     | 
    
         
            +
                vec3  color;
         
     | 
| 
      
 22 
     | 
    
         
            +
                vec2  position, useBrick;
         
     | 
| 
      
 23 
     | 
    
         
            +
                
         
     | 
| 
      
 24 
     | 
    
         
            +
                position = MCposition / BrickSize;
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                if (fract(position.y * 0.5) > 0.5)
         
     | 
| 
      
 27 
     | 
    
         
            +
                    position.x += 0.5;
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                position = fract(position);
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                useBrick = step(position, BrickPct);
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                color  = mix(MortarColor, BrickColor, useBrick.x * useBrick.y);
         
     | 
| 
      
 34 
     | 
    
         
            +
                color *= LightIntensity;
         
     | 
| 
      
 35 
     | 
    
         
            +
                gl_FragColor = vec4 (color, 1.0);
         
     | 
| 
      
 36 
     | 
    
         
            +
            }
         
     | 
| 
         @@ -0,0 +1,378 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Copyright (C) 2002-2005  3Dlabs Inc. Ltd.
         
     | 
| 
      
 2 
     | 
    
         
            +
            # All rights reserved.
         
     | 
| 
      
 3 
     | 
    
         
            +
            #
         
     | 
| 
      
 4 
     | 
    
         
            +
            # Redistribution and use in source and binary forms, with or without
         
     | 
| 
      
 5 
     | 
    
         
            +
            # modification, are permitted provided that the following conditions
         
     | 
| 
      
 6 
     | 
    
         
            +
            # are met:
         
     | 
| 
      
 7 
     | 
    
         
            +
            #
         
     | 
| 
      
 8 
     | 
    
         
            +
            #    Redistributions of source code must retain the above copyright
         
     | 
| 
      
 9 
     | 
    
         
            +
            #    notice, this list of conditions and the following disclaimer.
         
     | 
| 
      
 10 
     | 
    
         
            +
            #
         
     | 
| 
      
 11 
     | 
    
         
            +
            #    Redistributions in binary form must reproduce the above
         
     | 
| 
      
 12 
     | 
    
         
            +
            #    copyright notice, this list of conditions and the following
         
     | 
| 
      
 13 
     | 
    
         
            +
            #    disclaimer in the documentation and/or other materials provided
         
     | 
| 
      
 14 
     | 
    
         
            +
            #    with the distribution.
         
     | 
| 
      
 15 
     | 
    
         
            +
            #
         
     | 
| 
      
 16 
     | 
    
         
            +
            #    Neither the name of 3Dlabs Inc. Ltd. nor the names of its
         
     | 
| 
      
 17 
     | 
    
         
            +
            #    contributors may be used to endorse or promote products derived
         
     | 
| 
      
 18 
     | 
    
         
            +
            #    from this software without specific prior written permission.
         
     | 
| 
      
 19 
     | 
    
         
            +
            #
         
     | 
| 
      
 20 
     | 
    
         
            +
            # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
         
     | 
| 
      
 21 
     | 
    
         
            +
            # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
         
     | 
| 
      
 22 
     | 
    
         
            +
            # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
         
     | 
| 
      
 23 
     | 
    
         
            +
            # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
         
     | 
| 
      
 24 
     | 
    
         
            +
            # COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
         
     | 
| 
      
 25 
     | 
    
         
            +
            # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
         
     | 
| 
      
 26 
     | 
    
         
            +
            # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
         
     | 
| 
      
 27 
     | 
    
         
            +
            # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
         
     | 
| 
      
 28 
     | 
    
         
            +
            # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
         
     | 
| 
      
 29 
     | 
    
         
            +
            # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
         
     | 
| 
      
 30 
     | 
    
         
            +
            # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
         
     | 
| 
      
 31 
     | 
    
         
            +
            # POSSIBILITY OF SUCH DAMAGE.
         
     | 
| 
      
 32 
     | 
    
         
            +
            # ===========================================================================
         
     | 
| 
      
 33 
     | 
    
         
            +
            #
         
     | 
| 
      
 34 
     | 
    
         
            +
            #
         
     | 
| 
      
 35 
     | 
    
         
            +
            # The source of the shaders itself are in plain text files. Files ending in
         
     | 
| 
      
 36 
     | 
    
         
            +
            # .vert are vertex shaders, and files ending in .frag are fragment shaders.
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
            require 'opengl'
         
     | 
| 
      
 39 
     | 
    
         
            +
            require 'glu'
         
     | 
| 
      
 40 
     | 
    
         
            +
            require 'glut'
         
     | 
| 
      
 41 
     | 
    
         
            +
            include Gl,Glu,Glut
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
            $rotl = 1 * Math::PI / 180
         
     | 
| 
      
 44 
     | 
    
         
            +
            $last_time = 0
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
            $fXDiff = 206
         
     | 
| 
      
 47 
     | 
    
         
            +
            $fYDiff = 16
         
     | 
| 
      
 48 
     | 
    
         
            +
            $fZDiff = 10
         
     | 
| 
      
 49 
     | 
    
         
            +
            $xLastIncr = 0
         
     | 
| 
      
 50 
     | 
    
         
            +
            $yLastIncr = 0
         
     | 
| 
      
 51 
     | 
    
         
            +
            $fXInertia = -0.5
         
     | 
| 
      
 52 
     | 
    
         
            +
            $fYInertia = 0
         
     | 
| 
      
 53 
     | 
    
         
            +
            $fXInertiaOld = 0
         
     | 
| 
      
 54 
     | 
    
         
            +
            $fYInertiaOld = 0
         
     | 
| 
      
 55 
     | 
    
         
            +
            $fScale = 1.0
         
     | 
| 
      
 56 
     | 
    
         
            +
            $ftime = 0
         
     | 
| 
      
 57 
     | 
    
         
            +
            $xLast = -1
         
     | 
| 
      
 58 
     | 
    
         
            +
            $yLast = -1
         
     | 
| 
      
 59 
     | 
    
         
            +
            $bmModifiers = 0
         
     | 
| 
      
 60 
     | 
    
         
            +
            $rotate = true
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
            INERTIA_THRESHOLD = 1.0
         
     | 
| 
      
 63 
     | 
    
         
            +
            INERTIA_FACTOR = 0.5
         
     | 
| 
      
 64 
     | 
    
         
            +
            SCALE_FACTOR = 0.01
         
     | 
| 
      
 65 
     | 
    
         
            +
            SCALE_INCREMENT = 0.5
         
     | 
| 
      
 66 
     | 
    
         
            +
            TIMER_FREQUENCY_MILLIS = 20
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
            $gleModel = [:cube, :teapot,:torus,:sphere]
         
     | 
| 
      
 70 
     | 
    
         
            +
            $clearColor = [[0,0,0,1], [0.2,0.2,0.3,1], [0.7,0.7,0.7,1]]
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
            def drawCube
         
     | 
| 
      
 73 
     | 
    
         
            +
              size = 1.0
         
     | 
| 
      
 74 
     | 
    
         
            +
              scale = 0.2
         
     | 
| 
      
 75 
     | 
    
         
            +
              delta = 0.1
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
              v = [
         
     | 
| 
      
 78 
     | 
    
         
            +
                [ size,  size,  size * scale + delta ],
         
     | 
| 
      
 79 
     | 
    
         
            +
                [ size,  size, -size * scale + delta ],
         
     | 
| 
      
 80 
     | 
    
         
            +
                [ size, -size, -size * scale ],
         
     | 
| 
      
 81 
     | 
    
         
            +
                [ size, -size,  size * scale ],
         
     | 
| 
      
 82 
     | 
    
         
            +
                [-size,  size,  size * scale + delta ],
         
     | 
| 
      
 83 
     | 
    
         
            +
                [-size,  size, -size * scale + delta ],
         
     | 
| 
      
 84 
     | 
    
         
            +
                [-size, -size, -size * scale ],
         
     | 
| 
      
 85 
     | 
    
         
            +
                [-size, -size,  size * scale ]
         
     | 
| 
      
 86 
     | 
    
         
            +
              ]
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
              cube = [
         
     | 
| 
      
 89 
     | 
    
         
            +
                [ [1,0,0], v[3],v[2],v[1],v[0] ], # normal, vertices
         
     | 
| 
      
 90 
     | 
    
         
            +
                [ [-1,0,0], v[6],v[7],v[4],v[5] ],
         
     | 
| 
      
 91 
     | 
    
         
            +
                [ [0,0,-1], v[2],v[6],v[5],v[1] ],
         
     | 
| 
      
 92 
     | 
    
         
            +
                [ [0,0,1], v[7],v[3],v[0],v[4] ],
         
     | 
| 
      
 93 
     | 
    
         
            +
                [ [0,1,0], v[4],v[0],v[1],v[5] ],
         
     | 
| 
      
 94 
     | 
    
         
            +
                [ [0,-1,0], v[6],v[2],v[3],v[7] ]
         
     | 
| 
      
 95 
     | 
    
         
            +
              ]
         
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
      
 97 
     | 
    
         
            +
              glBegin(GL_QUADS)
         
     | 
| 
      
 98 
     | 
    
         
            +
              cube.each do |side|
         
     | 
| 
      
 99 
     | 
    
         
            +
                glNormal3fv(side[0])
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
                glTexCoord2f(1,1)
         
     | 
| 
      
 102 
     | 
    
         
            +
                glVertex3fv(side[1])
         
     | 
| 
      
 103 
     | 
    
         
            +
                glTexCoord2f(0,1)
         
     | 
| 
      
 104 
     | 
    
         
            +
                glVertex3fv(side[2])
         
     | 
| 
      
 105 
     | 
    
         
            +
                glTexCoord2f(0,0)
         
     | 
| 
      
 106 
     | 
    
         
            +
                glVertex3fv(side[3])
         
     | 
| 
      
 107 
     | 
    
         
            +
                glTexCoord2f(1,0)
         
     | 
| 
      
 108 
     | 
    
         
            +
                glVertex3fv(side[4])
         
     | 
| 
      
 109 
     | 
    
         
            +
              end
         
     | 
| 
      
 110 
     | 
    
         
            +
              glEnd()
         
     | 
| 
      
 111 
     | 
    
         
            +
            end
         
     | 
| 
      
 112 
     | 
    
         
            +
             
     | 
| 
      
 113 
     | 
    
         
            +
            def nextClearColor
         
     | 
| 
      
 114 
     | 
    
         
            +
              glClearColor($clearColor[0][0],
         
     | 
| 
      
 115 
     | 
    
         
            +
                           $clearColor[0][1],
         
     | 
| 
      
 116 
     | 
    
         
            +
                           $clearColor[0][2],
         
     | 
| 
      
 117 
     | 
    
         
            +
                           $clearColor[0][3])
         
     | 
| 
      
 118 
     | 
    
         
            +
              $clearColor << $clearColor.shift # rotate
         
     | 
| 
      
 119 
     | 
    
         
            +
            end
         
     | 
| 
      
 120 
     | 
    
         
            +
             
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
            play = lambda do
         
     | 
| 
      
 123 
     | 
    
         
            +
              this_time = glutGet(GLUT_ELAPSED_TIME)
         
     | 
| 
      
 124 
     | 
    
         
            +
             
     | 
| 
      
 125 
     | 
    
         
            +
              $rotl+=(this_time - $last_time) * -0.001
         
     | 
| 
      
 126 
     | 
    
         
            +
              $last_time = this_time
         
     | 
| 
      
 127 
     | 
    
         
            +
             
     | 
| 
      
 128 
     | 
    
         
            +
              glutPostRedisplay()
         
     | 
| 
      
 129 
     | 
    
         
            +
            end
         
     | 
| 
      
 130 
     | 
    
         
            +
             
     | 
| 
      
 131 
     | 
    
         
            +
            display = lambda do
         
     | 
| 
      
 132 
     | 
    
         
            +
              glLoadIdentity()
         
     | 
| 
      
 133 
     | 
    
         
            +
              glTranslatef(0.0, 0.0, -5.0)
         
     | 
| 
      
 134 
     | 
    
         
            +
             
     | 
| 
      
 135 
     | 
    
         
            +
              glRotatef($fYDiff, 1,0,0)
         
     | 
| 
      
 136 
     | 
    
         
            +
              glRotatef($fXDiff, 0,1,0)
         
     | 
| 
      
 137 
     | 
    
         
            +
              glRotatef($fZDiff, 0,0,1)
         
     | 
| 
      
 138 
     | 
    
         
            +
             
     | 
| 
      
 139 
     | 
    
         
            +
              glScalef($fScale, $fScale, $fScale)
         
     | 
| 
      
 140 
     | 
    
         
            +
             
     | 
| 
      
 141 
     | 
    
         
            +
              glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
         
     | 
| 
      
 142 
     | 
    
         
            +
             
     | 
| 
      
 143 
     | 
    
         
            +
              case $gleModel[0]
         
     | 
| 
      
 144 
     | 
    
         
            +
                when :teapot
         
     | 
| 
      
 145 
     | 
    
         
            +
                  glutSolidTeapot(0.6)
         
     | 
| 
      
 146 
     | 
    
         
            +
                when :torus
         
     | 
| 
      
 147 
     | 
    
         
            +
                  glutSolidTorus(0.2, 0.6, 64, 64)
         
     | 
| 
      
 148 
     | 
    
         
            +
                when :sphere
         
     | 
| 
      
 149 
     | 
    
         
            +
                  glutSolidSphere(0.6, 64, 64)
         
     | 
| 
      
 150 
     | 
    
         
            +
                when :cube
         
     | 
| 
      
 151 
     | 
    
         
            +
                  drawCube()
         
     | 
| 
      
 152 
     | 
    
         
            +
              end
         
     | 
| 
      
 153 
     | 
    
         
            +
              glFlush()
         
     | 
| 
      
 154 
     | 
    
         
            +
              glutSwapBuffers()
         
     | 
| 
      
 155 
     | 
    
         
            +
            end
         
     | 
| 
      
 156 
     | 
    
         
            +
             
     | 
| 
      
 157 
     | 
    
         
            +
            key = lambda do |key,x,y|
         
     | 
| 
      
 158 
     | 
    
         
            +
              case(key)
         
     | 
| 
      
 159 
     | 
    
         
            +
              when ?b
         
     | 
| 
      
 160 
     | 
    
         
            +
                nextClearColor()
         
     | 
| 
      
 161 
     | 
    
         
            +
              when ?q, ?\e # esc
         
     | 
| 
      
 162 
     | 
    
         
            +
                exit(0)
         
     | 
| 
      
 163 
     | 
    
         
            +
              when ?t
         
     | 
| 
      
 164 
     | 
    
         
            +
                $gleModel << $gleModel.shift # rotate the array
         
     | 
| 
      
 165 
     | 
    
         
            +
              when ?\s # space
         
     | 
| 
      
 166 
     | 
    
         
            +
                $rotate = !$rotate
         
     | 
| 
      
 167 
     | 
    
         
            +
             
     | 
| 
      
 168 
     | 
    
         
            +
                if ($rotate==false)
         
     | 
| 
      
 169 
     | 
    
         
            +
                  $fXInertiaOld = $fXInertia
         
     | 
| 
      
 170 
     | 
    
         
            +
                  $fYInertiaOld = $fYInertia
         
     | 
| 
      
 171 
     | 
    
         
            +
                else
         
     | 
| 
      
 172 
     | 
    
         
            +
                  $fXInertia = $fXInertiaOld
         
     | 
| 
      
 173 
     | 
    
         
            +
                  $fYInertia = $fYInertiaOld
         
     | 
| 
      
 174 
     | 
    
         
            +
             
     | 
| 
      
 175 
     | 
    
         
            +
                  # To prevent confusion, force some rotation
         
     | 
| 
      
 176 
     | 
    
         
            +
                  if ($fXInertia == 0 && $fYInertia == 0)
         
     | 
| 
      
 177 
     | 
    
         
            +
                    $fXInertia = -0.5
         
     | 
| 
      
 178 
     | 
    
         
            +
                  end
         
     | 
| 
      
 179 
     | 
    
         
            +
                end
         
     | 
| 
      
 180 
     | 
    
         
            +
              when ?+
         
     | 
| 
      
 181 
     | 
    
         
            +
                $fScale += SCALE_INCREMENT
         
     | 
| 
      
 182 
     | 
    
         
            +
              when ?-
         
     | 
| 
      
 183 
     | 
    
         
            +
                $fScale -= SCALE_INCREMENT
         
     | 
| 
      
 184 
     | 
    
         
            +
              else
         
     | 
| 
      
 185 
     | 
    
         
            +
                puts "Keyboard commands:\n"
         
     | 
| 
      
 186 
     | 
    
         
            +
                puts "b - Toggle among background clear colors"
         
     | 
| 
      
 187 
     | 
    
         
            +
                puts "q, <esc> - Quit"
         
     | 
| 
      
 188 
     | 
    
         
            +
                puts "t - Toggle among models to render"
         
     | 
| 
      
 189 
     | 
    
         
            +
                puts "? - Help"
         
     | 
| 
      
 190 
     | 
    
         
            +
                puts "<home>     - reset zoom and rotation"
         
     | 
| 
      
 191 
     | 
    
         
            +
                puts "<space> or <click>        - stop rotation"
         
     | 
| 
      
 192 
     | 
    
         
            +
                puts "<+>, <-> or <ctrl + drag> - zoom model"
         
     | 
| 
      
 193 
     | 
    
         
            +
                puts "<arrow keys> or <drag>    - rotate model\n"
         
     | 
| 
      
 194 
     | 
    
         
            +
              end
         
     | 
| 
      
 195 
     | 
    
         
            +
            end
         
     | 
| 
      
 196 
     | 
    
         
            +
             
     | 
| 
      
 197 
     | 
    
         
            +
            reshape = lambda do |w,h|
         
     | 
| 
      
 198 
     | 
    
         
            +
              vp = 0.8
         
     | 
| 
      
 199 
     | 
    
         
            +
              aspect = w.to_f/h.to_f
         
     | 
| 
      
 200 
     | 
    
         
            +
             
     | 
| 
      
 201 
     | 
    
         
            +
              glViewport(0, 0, w, h)
         
     | 
| 
      
 202 
     | 
    
         
            +
              glMatrixMode(GL_PROJECTION)
         
     | 
| 
      
 203 
     | 
    
         
            +
              glLoadIdentity()
         
     | 
| 
      
 204 
     | 
    
         
            +
             
     | 
| 
      
 205 
     | 
    
         
            +
              glFrustum(-vp, vp, -vp / aspect, vp / aspect, 3, 10)
         
     | 
| 
      
 206 
     | 
    
         
            +
             
     | 
| 
      
 207 
     | 
    
         
            +
              glMatrixMode(GL_MODELVIEW)
         
     | 
| 
      
 208 
     | 
    
         
            +
              glLoadIdentity()
         
     | 
| 
      
 209 
     | 
    
         
            +
              glTranslatef(0.0, 0.0, -5.0)
         
     | 
| 
      
 210 
     | 
    
         
            +
            end
         
     | 
| 
      
 211 
     | 
    
         
            +
             
     | 
| 
      
 212 
     | 
    
         
            +
            motion = lambda do |x,y|
         
     | 
| 
      
 213 
     | 
    
         
            +
              if ($xLast != -1 || $yLast != -1)
         
     | 
| 
      
 214 
     | 
    
         
            +
                $xLastIncr = x - $xLast
         
     | 
| 
      
 215 
     | 
    
         
            +
                $yLastIncr = y - $yLast
         
     | 
| 
      
 216 
     | 
    
         
            +
                if ($bmModifiers & GLUT_ACTIVE_CTRL != 0)
         
     | 
| 
      
 217 
     | 
    
         
            +
                  if ($xLast != -1)
         
     | 
| 
      
 218 
     | 
    
         
            +
                    $fZDiff += $xLastIncr
         
     | 
| 
      
 219 
     | 
    
         
            +
                    $fScale += $yLastIncr*SCALE_FACTOR
         
     | 
| 
      
 220 
     | 
    
         
            +
                  end
         
     | 
| 
      
 221 
     | 
    
         
            +
                else
         
     | 
| 
      
 222 
     | 
    
         
            +
                  if ($xLast != -1)
         
     | 
| 
      
 223 
     | 
    
         
            +
                    $fXDiff += $xLastIncr
         
     | 
| 
      
 224 
     | 
    
         
            +
                    $fYDiff += $yLastIncr
         
     | 
| 
      
 225 
     | 
    
         
            +
                  end
         
     | 
| 
      
 226 
     | 
    
         
            +
                end
         
     | 
| 
      
 227 
     | 
    
         
            +
              end
         
     | 
| 
      
 228 
     | 
    
         
            +
              $xLast = x
         
     | 
| 
      
 229 
     | 
    
         
            +
              $yLast = y
         
     | 
| 
      
 230 
     | 
    
         
            +
            end
         
     | 
| 
      
 231 
     | 
    
         
            +
             
     | 
| 
      
 232 
     | 
    
         
            +
            mouse = lambda do |button,state,x,y|
         
     | 
| 
      
 233 
     | 
    
         
            +
              $bmModifiers = glutGetModifiers()
         
     | 
| 
      
 234 
     | 
    
         
            +
              if (button == GLUT_LEFT_BUTTON)
         
     | 
| 
      
 235 
     | 
    
         
            +
                if (state == GLUT_UP)
         
     | 
| 
      
 236 
     | 
    
         
            +
                  $xLast = -1
         
     | 
| 
      
 237 
     | 
    
         
            +
                  $yLast = -1
         
     | 
| 
      
 238 
     | 
    
         
            +
                  if $xLastIncr > INERTIA_THRESHOLD
         
     | 
| 
      
 239 
     | 
    
         
            +
                    $fXInertia = ($xLastIncr - INERTIA_THRESHOLD)*INERTIA_FACTOR
         
     | 
| 
      
 240 
     | 
    
         
            +
                  end
         
     | 
| 
      
 241 
     | 
    
         
            +
                  if -$xLastIncr > INERTIA_THRESHOLD
         
     | 
| 
      
 242 
     | 
    
         
            +
                    $fXInertia = ($xLastIncr + INERTIA_THRESHOLD)*INERTIA_FACTOR
         
     | 
| 
      
 243 
     | 
    
         
            +
                  end
         
     | 
| 
      
 244 
     | 
    
         
            +
             
     | 
| 
      
 245 
     | 
    
         
            +
                  if $yLastIncr > INERTIA_THRESHOLD
         
     | 
| 
      
 246 
     | 
    
         
            +
                    $fYInertia = ($yLastIncr - INERTIA_THRESHOLD)*INERTIA_FACTOR
         
     | 
| 
      
 247 
     | 
    
         
            +
                  end
         
     | 
| 
      
 248 
     | 
    
         
            +
                  if -$yLastIncr > INERTIA_THRESHOLD
         
     | 
| 
      
 249 
     | 
    
         
            +
                    $fYInertia = ($yLastIncr + INERTIA_THRESHOLD)*INERTIA_FACTOR
         
     | 
| 
      
 250 
     | 
    
         
            +
                  end
         
     | 
| 
      
 251 
     | 
    
         
            +
                else
         
     | 
| 
      
 252 
     | 
    
         
            +
                  $fXInertia = 0
         
     | 
| 
      
 253 
     | 
    
         
            +
                  $fYInertia = 0
         
     | 
| 
      
 254 
     | 
    
         
            +
                end
         
     | 
| 
      
 255 
     | 
    
         
            +
                $xLastIncr = 0
         
     | 
| 
      
 256 
     | 
    
         
            +
                $yLastIncr = 0
         
     | 
| 
      
 257 
     | 
    
         
            +
              end
         
     | 
| 
      
 258 
     | 
    
         
            +
            end
         
     | 
| 
      
 259 
     | 
    
         
            +
             
     | 
| 
      
 260 
     | 
    
         
            +
            special = lambda do |key,x,y|
         
     | 
| 
      
 261 
     | 
    
         
            +
              case key
         
     | 
| 
      
 262 
     | 
    
         
            +
              when GLUT_KEY_HOME
         
     | 
| 
      
 263 
     | 
    
         
            +
                $fXDiff = 0
         
     | 
| 
      
 264 
     | 
    
         
            +
                $fYDiff = 35
         
     | 
| 
      
 265 
     | 
    
         
            +
                $fZDiff = 0
         
     | 
| 
      
 266 
     | 
    
         
            +
                $xLastIncr = 0
         
     | 
| 
      
 267 
     | 
    
         
            +
                $yLastIncr = 0
         
     | 
| 
      
 268 
     | 
    
         
            +
                $fXInertia = -0.5
         
     | 
| 
      
 269 
     | 
    
         
            +
                $fYInertia = 0
         
     | 
| 
      
 270 
     | 
    
         
            +
                $fScale = 1.0
         
     | 
| 
      
 271 
     | 
    
         
            +
              when GLUT_KEY_LEFT
         
     | 
| 
      
 272 
     | 
    
         
            +
                $fXDiff -= 1
         
     | 
| 
      
 273 
     | 
    
         
            +
              when GLUT_KEY_RIGHT
         
     | 
| 
      
 274 
     | 
    
         
            +
                $fXDiff += 1
         
     | 
| 
      
 275 
     | 
    
         
            +
              when GLUT_KEY_UP
         
     | 
| 
      
 276 
     | 
    
         
            +
                $fYDiff -= 1
         
     | 
| 
      
 277 
     | 
    
         
            +
              when GLUT_KEY_DOWN
         
     | 
| 
      
 278 
     | 
    
         
            +
                $fYDiff += 1
         
     | 
| 
      
 279 
     | 
    
         
            +
              end
         
     | 
| 
      
 280 
     | 
    
         
            +
            end
         
     | 
| 
      
 281 
     | 
    
         
            +
             
     | 
| 
      
 282 
     | 
    
         
            +
            timer = lambda do |value|
         
     | 
| 
      
 283 
     | 
    
         
            +
              $ftime += 0.01
         
     | 
| 
      
 284 
     | 
    
         
            +
              if $rotate
         
     | 
| 
      
 285 
     | 
    
         
            +
                $fXDiff += $fXInertia
         
     | 
| 
      
 286 
     | 
    
         
            +
                $fYDiff += $fYInertia
         
     | 
| 
      
 287 
     | 
    
         
            +
              end
         
     | 
| 
      
 288 
     | 
    
         
            +
              glutTimerFunc(TIMER_FREQUENCY_MILLIS , timer, 0)
         
     | 
| 
      
 289 
     | 
    
         
            +
            end
         
     | 
| 
      
 290 
     | 
    
         
            +
             
     | 
| 
      
 291 
     | 
    
         
            +
            def getUniLoc(program, name)
         
     | 
| 
      
 292 
     | 
    
         
            +
              loc = glGetUniformLocation(program, name)
         
     | 
| 
      
 293 
     | 
    
         
            +
             
     | 
| 
      
 294 
     | 
    
         
            +
              if (loc == -1)
         
     | 
| 
      
 295 
     | 
    
         
            +
                puts "No such uniform named #{name}"
         
     | 
| 
      
 296 
     | 
    
         
            +
              end
         
     | 
| 
      
 297 
     | 
    
         
            +
              return loc
         
     | 
| 
      
 298 
     | 
    
         
            +
            end
         
     | 
| 
      
 299 
     | 
    
         
            +
             
     | 
| 
      
 300 
     | 
    
         
            +
            def installBrickShaders(vs_fname,fs_fname)
         
     | 
| 
      
 301 
     | 
    
         
            +
              # Create a vertex shader object and a fragment shader object
         
     | 
| 
      
 302 
     | 
    
         
            +
              brickVS = glCreateShader(GL_VERTEX_SHADER)
         
     | 
| 
      
 303 
     | 
    
         
            +
              brickFS = glCreateShader(GL_FRAGMENT_SHADER)
         
     | 
| 
      
 304 
     | 
    
         
            +
             
     | 
| 
      
 305 
     | 
    
         
            +
              # Load source code strings into shaders
         
     | 
| 
      
 306 
     | 
    
         
            +
              glShaderSource(brickVS, File.read(vs_fname))
         
     | 
| 
      
 307 
     | 
    
         
            +
              glShaderSource(brickFS, File.read(fs_fname))
         
     | 
| 
      
 308 
     | 
    
         
            +
             
     | 
| 
      
 309 
     | 
    
         
            +
              # Compile the brick vertex shader, and print out
         
     | 
| 
      
 310 
     | 
    
         
            +
              #  the compiler log file.
         
     | 
| 
      
 311 
     | 
    
         
            +
              glCompileShader(brickVS)
         
     | 
| 
      
 312 
     | 
    
         
            +
              vertCompiled = glGetShaderiv(brickVS, GL_COMPILE_STATUS)
         
     | 
| 
      
 313 
     | 
    
         
            +
              puts "Shader InfoLog:\n#{glGetShaderInfoLog(brickVS)}\n"
         
     | 
| 
      
 314 
     | 
    
         
            +
             
     | 
| 
      
 315 
     | 
    
         
            +
              # Compile the brick fragment shader, and print out
         
     | 
| 
      
 316 
     | 
    
         
            +
              # the compiler log file.
         
     | 
| 
      
 317 
     | 
    
         
            +
              glCompileShader(brickFS)
         
     | 
| 
      
 318 
     | 
    
         
            +
              fragCompiled = glGetShaderiv(brickFS, GL_COMPILE_STATUS)
         
     | 
| 
      
 319 
     | 
    
         
            +
              puts "Shader InfoLog:\n#{glGetShaderInfoLog(brickFS)}\n"
         
     | 
| 
      
 320 
     | 
    
         
            +
             
     | 
| 
      
 321 
     | 
    
         
            +
              return false if (vertCompiled == 0 || fragCompiled == 0)
         
     | 
| 
      
 322 
     | 
    
         
            +
              # Create a program object and attach the two compiled shaders
         
     | 
| 
      
 323 
     | 
    
         
            +
              brickProg = glCreateProgram()
         
     | 
| 
      
 324 
     | 
    
         
            +
              glAttachShader(brickProg,brickVS)
         
     | 
| 
      
 325 
     | 
    
         
            +
              glAttachShader(brickProg,brickFS)
         
     | 
| 
      
 326 
     | 
    
         
            +
              # Link the program object and print out the info log
         
     | 
| 
      
 327 
     | 
    
         
            +
              glLinkProgram(brickProg)
         
     | 
| 
      
 328 
     | 
    
         
            +
              linked = glGetProgramiv(brickProg,GL_LINK_STATUS)
         
     | 
| 
      
 329 
     | 
    
         
            +
              puts "Program InfoLog:\n#{glGetProgramInfoLog(brickProg)}\n"
         
     | 
| 
      
 330 
     | 
    
         
            +
              return false if linked==0
         
     | 
| 
      
 331 
     | 
    
         
            +
             
     | 
| 
      
 332 
     | 
    
         
            +
              # Install program object as part of current state
         
     | 
| 
      
 333 
     | 
    
         
            +
              glUseProgram(brickProg)
         
     | 
| 
      
 334 
     | 
    
         
            +
             
     | 
| 
      
 335 
     | 
    
         
            +
              # Set up initial uniform values
         
     | 
| 
      
 336 
     | 
    
         
            +
              glUniform3f(getUniLoc(brickProg, "BrickColor"), 1.0, 0.3, 0.2)
         
     | 
| 
      
 337 
     | 
    
         
            +
              glUniform3f(getUniLoc(brickProg, "MortarColor"), 0.85, 0.86, 0.84)
         
     | 
| 
      
 338 
     | 
    
         
            +
              glUniform2f(getUniLoc(brickProg, "BrickSize"), 0.30, 0.15)
         
     | 
| 
      
 339 
     | 
    
         
            +
              glUniform2f(getUniLoc(brickProg, "BrickPct"), 0.90, 0.85)
         
     | 
| 
      
 340 
     | 
    
         
            +
              glUniform3f(getUniLoc(brickProg, "LightPosition"), 0.0, 0.0, 4.0)
         
     | 
| 
      
 341 
     | 
    
         
            +
             
     | 
| 
      
 342 
     | 
    
         
            +
              return true
         
     | 
| 
      
 343 
     | 
    
         
            +
            end
         
     | 
| 
      
 344 
     | 
    
         
            +
             
     | 
| 
      
 345 
     | 
    
         
            +
            # Main
         
     | 
| 
      
 346 
     | 
    
         
            +
             
     | 
| 
      
 347 
     | 
    
         
            +
            glutInit()
         
     | 
| 
      
 348 
     | 
    
         
            +
            glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE)
         
     | 
| 
      
 349 
     | 
    
         
            +
            glutInitWindowPosition(100,100)
         
     | 
| 
      
 350 
     | 
    
         
            +
            glutInitWindowSize(500, 500)
         
     | 
| 
      
 351 
     | 
    
         
            +
            glutCreateWindow( "3Dlabs Brick Shader")
         
     | 
| 
      
 352 
     | 
    
         
            +
             
     | 
| 
      
 353 
     | 
    
         
            +
            glutIdleFunc(play)
         
     | 
| 
      
 354 
     | 
    
         
            +
            glutDisplayFunc(display)
         
     | 
| 
      
 355 
     | 
    
         
            +
            glutKeyboardFunc(key)
         
     | 
| 
      
 356 
     | 
    
         
            +
            glutReshapeFunc(reshape)
         
     | 
| 
      
 357 
     | 
    
         
            +
            glutMotionFunc(motion)
         
     | 
| 
      
 358 
     | 
    
         
            +
            glutMouseFunc(mouse)
         
     | 
| 
      
 359 
     | 
    
         
            +
            glutSpecialFunc(special)
         
     | 
| 
      
 360 
     | 
    
         
            +
            glutTimerFunc(TIMER_FREQUENCY_MILLIS , timer, 0)
         
     | 
| 
      
 361 
     | 
    
         
            +
             
     | 
| 
      
 362 
     | 
    
         
            +
            # Make sure that OpenGL 2.0 is supported by the driver
         
     | 
| 
      
 363 
     | 
    
         
            +
            if Gl.is_available?(2.0)==false
         
     | 
| 
      
 364 
     | 
    
         
            +
              major,minor,*rest = glGetString(GL_VERSION).split(/\.| /)
         
     | 
| 
      
 365 
     | 
    
         
            +
              puts "GL_VERSION major=#{major} minor=#{minor}"
         
     | 
| 
      
 366 
     | 
    
         
            +
              puts "Support for OpenGL 2.0 is required for this demo...exiting"
         
     | 
| 
      
 367 
     | 
    
         
            +
              exit(1)
         
     | 
| 
      
 368 
     | 
    
         
            +
            end
         
     | 
| 
      
 369 
     | 
    
         
            +
             
     | 
| 
      
 370 
     | 
    
         
            +
            glDepthFunc(GL_LESS)
         
     | 
| 
      
 371 
     | 
    
         
            +
            glEnable(GL_DEPTH_TEST)
         
     | 
| 
      
 372 
     | 
    
         
            +
             
     | 
| 
      
 373 
     | 
    
         
            +
            nextClearColor()
         
     | 
| 
      
 374 
     | 
    
         
            +
             
     | 
| 
      
 375 
     | 
    
         
            +
            key.call('?', 0, 0)
         
     | 
| 
      
 376 
     | 
    
         
            +
             
     | 
| 
      
 377 
     | 
    
         
            +
            success = installBrickShaders("brick.vert","brick.frag")
         
     | 
| 
      
 378 
     | 
    
         
            +
            glutMainLoop() if success == true
         
     |