コード例 #1
0
ファイル: SampleForm.cs プロジェクト: stjeong/OpenGL.Net
        private SceneObjectGeometry CreateCubeGeometry()
        {
            SceneObjectGeometry cubeGeometry = new SceneObjectGeometry("Cube");

            #region State

            cubeGeometry.ObjectState.DefineState(new CullFaceState(FrontFaceDirection.Ccw, CullFaceMode.Back));
            cubeGeometry.ObjectState.DefineState(new TransformState());

            MaterialState cubeMaterialState = new MaterialState();
            cubeMaterialState.FrontMaterial           = new MaterialState.Material(ColorRGBAF.ColorWhite * 0.5f);
            cubeMaterialState.FrontMaterial.Ambient   = ColorRGBAF.ColorBlack;
            cubeMaterialState.FrontMaterial.Diffuse   = ColorRGBAF.ColorWhite * 0.5f;
            cubeMaterialState.FrontMaterial.Specular  = ColorRGBAF.ColorWhite * 0.5f;
            cubeMaterialState.FrontMaterial.Shininess = 10.0f;
            cubeGeometry.ObjectState.DefineState(cubeMaterialState);

            #endregion

            #region Vertex Arrays

            if (_CubeArrayPosition == null)
            {
                _CubeArrayPosition = new ArrayBuffer <Vertex3f>();
                _CubeArrayPosition.Create(ArrayPosition);
            }

            if (_CubeArrayColor == null)
            {
                _CubeArrayColor = new ArrayBuffer <ColorRGBF>();
                _CubeArrayColor.Create(ArrayColors);
            }

            if (_CubeArrayNormal == null)
            {
                _CubeArrayNormal = new ArrayBuffer <Vertex3f>();
                _CubeArrayNormal.Create(ArrayNormals);
            }

            if (_CubeArrays == null)
            {
                _CubeArrays = new VertexArrays();
                _CubeArrays.SetArray(_CubeArrayPosition, VertexArraySemantic.Position);
                _CubeArrays.SetArray(_CubeArrayColor, VertexArraySemantic.Color);
                _CubeArrays.SetArray(_CubeArrayNormal, VertexArraySemantic.Normal);
                _CubeArrays.SetElementArray(PrimitiveType.Triangles);
            }

            cubeGeometry.VertexArray = _CubeArrays;

            #endregion

            #region Program

            cubeGeometry.BoundingVolume = new BoundingBox(-Vertex3f.One * _CubeSize, Vertex3f.One * _CubeSize);

            #endregion

            return(cubeGeometry);
        }
コード例 #2
0
        private SceneObjectGeometry CreateSphere(string material)
        {
            SceneObjectGeometry sphereGeometry = new SceneObjectGeometry("Sphere");

            sphereGeometry.ObjectState.DefineState(new DepthTestState(DepthFunction.Less));
            sphereGeometry.ObjectState.DefineState(new CullFaceState(FrontFaceDirection.Ccw, CullFaceMode.Back));
            sphereGeometry.ObjectState.DefineState(new TransformState());

            sphereGeometry.VertexArray = VertexArrayObject.CreateSphere(4.0f, 32, 32);

            ArrayBufferObject <Vertex2f> texCoordBuffer = new ArrayBufferObject <Vertex2f>(BufferObjectHint.StaticCpuDraw);

            texCoordBuffer.Create(sphereGeometry.VertexArray.ArrayLength);
            sphereGeometry.VertexArray.SetArray(texCoordBuffer, VertexArraySemantic.TexCoord);

            ArrayBufferObject <Vertex3f> tanCoordBuffer = new ArrayBufferObject <Vertex3f>(BufferObjectHint.StaticCpuDraw);

            tanCoordBuffer.Create(sphereGeometry.VertexArray.ArrayLength);
            sphereGeometry.VertexArray.SetArray(tanCoordBuffer, VertexArraySemantic.Tangent);

            ArrayBufferObject <Vertex3f> bitanCoordBuffer = new ArrayBufferObject <Vertex3f>(BufferObjectHint.StaticCpuDraw);

            bitanCoordBuffer.Create(sphereGeometry.VertexArray.ArrayLength);
            sphereGeometry.VertexArray.SetArray(bitanCoordBuffer, VertexArraySemantic.Bitangent);

            sphereGeometry.VertexArray.GenerateTexCoords(new VertexArrayTexGen.Sphere());
            sphereGeometry.VertexArray.GenerateTangents();

            sphereGeometry.ProgramTag = ShadersLibrary.Instance.CreateProgramTag("OpenGL.Standard+PhongFragment");

            SetSphereMaterial(sphereGeometry, material);

            return(sphereGeometry);
        }
コード例 #3
0
        private SceneObjectGeometry CreateSphere(string material)
        {
            SceneObjectGeometry sphereGeometry = new SceneObjectGeometry("Sphere");

            sphereGeometry.ObjectState.DefineState(new CullFaceState(FrontFaceDirection.Ccw, CullFaceMode.Back));
            sphereGeometry.ObjectState.DefineState(new TransformState());
            sphereGeometry.LocalModelView = Matrix4x4f.Translated(0.0f, 4.0f, 0.0f);

            sphereGeometry.VertexArray = VertexArrays.CreateSphere(4.0f, 32, 32);

            ArrayBuffer <Vertex2f> texCoordBuffer = new ArrayBuffer <Vertex2f>();

            texCoordBuffer.Create(sphereGeometry.VertexArray.ArrayLength);
            sphereGeometry.VertexArray.SetArray(texCoordBuffer, VertexArraySemantic.TexCoord);

            ArrayBuffer <Vertex3f> tanCoordBuffer = new ArrayBuffer <Vertex3f>();

            tanCoordBuffer.Create(sphereGeometry.VertexArray.ArrayLength);
            sphereGeometry.VertexArray.SetArray(tanCoordBuffer, VertexArraySemantic.Tangent);

            ArrayBuffer <Vertex3f> bitanCoordBuffer = new ArrayBuffer <Vertex3f>();

            bitanCoordBuffer.Create(sphereGeometry.VertexArray.ArrayLength);
            sphereGeometry.VertexArray.SetArray(bitanCoordBuffer, VertexArraySemantic.Bitangent);

            //sphereGeometry.VertexArray.GenerateTexCoords(ctx, new VertexArrayTexGen.Sphere());
            //sphereGeometry.VertexArray.GenerateTangents();

            sphereGeometry.ProgramTag = ShadersLibrary.Instance.CreateProgramTag("OpenGL.Standard+PhongFragment");

            SetSphereMaterial(sphereGeometry, material);

            return(sphereGeometry);
        }
コード例 #4
0
ファイル: SampleForm.cs プロジェクト: stjeong/OpenGL.Net
        private SceneObjectGeometry CreatePlane()
        {
            SceneObjectGeometry geometry = new SceneObjectGeometry("Plane");

            geometry.VertexArray = VertexArrays.CreatePlane(1.0f, 1.0f, -1.0f, 1, 1);
            // geometry.ObjectState.DefineState(new CullFaceState(FrontFaceDirection.Ccw, CullFaceMode.Back) { Culling = false });
            geometry.ProgramTag = ShadersLibrary.Instance.CreateProgramTag("OpenGL.Standard");

            return(geometry);
        }
コード例 #5
0
        private SceneObjectGeometry CreatePlane()
        {
            SceneObjectGeometry geometry = new SceneObjectGeometry("Plane");

            geometry.VertexArray = VertexArrays.CreatePlane(50.0f, 50.0f, 0.0f, 1, 1);
            geometry.ObjectState.DefineState(new CullFaceState(FrontFaceDirection.Ccw, CullFaceMode.Back));
            geometry.ObjectState.DefineState(new TransformState());

            MaterialState cubeMaterialState = new MaterialState();

            cubeMaterialState.FrontMaterial          = new MaterialState.Material(ColorRGBAF.ColorWhite * 0.5f);
            cubeMaterialState.FrontMaterial.Ambient  = ColorRGBAF.ColorBlack;
            cubeMaterialState.FrontMaterial.Diffuse  = ColorRGBAF.ColorWhite * 0.5f;
            cubeMaterialState.FrontMaterial.Specular = ColorRGBAF.ColorBlack;
            geometry.ObjectState.DefineState(cubeMaterialState);

            geometry.LocalModel.RotateX(-90.0);

            geometry.ProgramTag = ShadersLibrary.Instance.CreateProgramTag("OpenGL.Standard+PhongFragment");

            return(geometry);
        }
コード例 #6
0
ファイル: MainActivity.cs プロジェクト: owenxuwei/OpenGL.Net
        private void GlSurface_ContextCreated(object sender, GLSurfaceViewEventArgs e)
        {
            // Wrap GL context with GraphicsContext
            _Context = new GraphicsContext(e.DeviceContext, e.RenderContext);

            _CubeScene           = new SceneGraph(SceneGraphFlags.None);
            _CubeScene.SceneRoot = new SceneObjectGeometry();
            _CubeScene.SceneRoot.ObjectState.DefineState(new DepthTestState(DepthFunction.Less));

            _CubeScene.CurrentView = new SceneObjectCamera();
            _CubeScene.SceneRoot.Link(_CubeScene.CurrentView);

            SceneObjectGeometry geometry = new SceneObjectGeometry();

            geometry.ProgramTag = ShadersLibrary.Instance.CreateProgramTag("OpenGL.Standard");
            geometry.AddGeometry(VertexArrays.CreateSphere(3.0f, 8, 8));

            _CubeScene.SceneRoot.Link(geometry);

            _CubeScene.Create(_Context);

            Gl.ClearColor(1.0f, 0.1f, 0.1f, 1.0f);
        }
コード例 #7
0
        /// <summary>
        /// Allocate resources for rendering.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ObjectsControl_ContextCreated(object sender, GlControlEventArgs e)
        {
            // Wrap GL context with GraphicsContext
            _Context = new GraphicsContext(e.DeviceContext, e.RenderContext);
            // Scene
            _CubeScene = new SceneGraph();
            _CubeScene.Link(new SceneObjectCamera());

            // Global lighting
            SceneObjectLightZone globalLightZone = new SceneObjectLightZone();

            _GlobalLightObject           = new SceneObjectLightDirectional();
            _GlobalLightObject.Direction = (-Vertex3f.UnitX + Vertex3f.UnitY - Vertex3f.UnitZ).Normalized;
            globalLightZone.Link(_GlobalLightObject);

            SceneObjectLightPoint localLightObject = new SceneObjectLightPoint();

            localLightObject.LocalModel.Translate(0.0, -5.0f, 0.0);
            localLightObject.AttenuationFactors.Y = 0.1f;
            //globalLightZone.AddChild(localLightObject);

            _CubeScene.Link(globalLightZone);

            // Cube
            float       Size       = (float)Math.Sqrt(0);
            const float Multiplier = 10.0f;

            int materialIndex = 0;

            for (float x = -Size / 2.0f * Multiplier; x < Size / 2.0f * Multiplier; x += Multiplier)
            {
                for (float y = -Size / 2.0f * Multiplier; y < Size / 2.0f * Multiplier; y += Multiplier, materialIndex++)
                {
                    SceneObjectGeometry cubeInstance = CreateCubeGeometry();

                    cubeInstance.LocalModel.Translate(x, 0.0f, y);
                    cubeInstance.LocalModel.Scale(0.25f);

                    // Enable/Disable blending
                    if ((materialIndex % 2) == 0)
                    {
                        cubeInstance.ObjectState.DefineState(new BlendState(BlendEquationModeEXT.FuncAdd, BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha));
                    }

                    // Enable/Disable blending
                    switch (materialIndex % 1)
                    {
                    case 0:
                        cubeInstance.ProgramTag = ShadersLibrary.Instance.CreateProgramTag("OpenGL.Standard+LambertVertex", new ShaderCompilerContext("GLO_COLOR_PER_VERTEX"));
                        break;

                    case 1:
                        cubeInstance.ProgramTag = ShadersLibrary.Instance.CreateProgramTag("OpenGL.Standard+Color");
                        break;

                    case 2:
                        cubeInstance.ProgramTag = ShadersLibrary.Instance.CreateProgramTag("OpenGL.Standard+PhongFragment");
                        break;
                    }

                    globalLightZone.Link(cubeInstance);
                }
            }

            //SceneObjectGeometry cubeLambert = CreateCubeGeometry();
            //cubeLambert.ProgramTag = ShadersLibrary.Instance.CreateProgramTag("OpenGL.Standard+LambertVertex", new ShaderCompilerContext("GLO_COLOR_PER_VERTEX"));
            //globalLightZone.Link(cubeLambert);

            //SceneObjectGeometry cubeBlinn = CreateCubeGeometry();
            //cubeBlinn.ProgramTag = ShadersLibrary.Instance.CreateProgramTag("OpenGL.Standard+PhongFragment", new ShaderCompilerContext("GLO_COLOR_PER_VERTEX"));
            //cubeBlinn.LocalModel.Translate(0.0f, 10.0f, 0.0f);
            //globalLightZone.Link(cubeBlinn);

            //SceneObjectGeometry cubeColored = CreateCubeGeometry();
            //cubeColored.ProgramTag = ShadersLibrary.Instance.CreateProgramTag("OpenGL.Standard+Color");
            //cubeColored.LocalModel.Translate(0.0f, 5.0f, 0.0f);
            //globalLightZone.Link(cubeColored);

            globalLightZone.Link(CreateBumbleBeeVH());
            globalLightZone.Link(CreateBumbleBeeRB());
            globalLightZone.Link(CreateSphere("squarebricks"));

            // Skybox
            //if ((sceneObject = CreateSkyBoxObject()) != null)
            //	_CubeScene.AddChild(sceneObject);

            _CubeScene.Create(_Context);

            Gl.ClearColor(0.1f, 0.1f, 0.1f, 0.0f);
        }
コード例 #8
0
        private SceneObject CreateSkyBoxObject()
        {
            if (!Gl.CurrentExtensions.TextureCubeMap_ARB)
            {
                return(null);
            }

            SceneObjectGeometry skyboxObject = new SceneObjectGeometry();

            #region Texture

            OpenGL.Objects.Image[] cubeMap = new OpenGL.Objects.Image[6];

            using (Stream imageStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("HelloObjects.Data.PiazzaDelPopolo.posx.jpg"))
                cubeMap[0] = ImageCodec.Instance.Load(imageStream, ImageFormat.Jpeg);
            using (Stream imageStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("HelloObjects.Data.PiazzaDelPopolo.negx.jpg"))
                cubeMap[1] = ImageCodec.Instance.Load(imageStream, ImageFormat.Jpeg);
            using (Stream imageStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("HelloObjects.Data.PiazzaDelPopolo.posy.jpg"))
                cubeMap[2] = ImageCodec.Instance.Load(imageStream, ImageFormat.Jpeg);
            using (Stream imageStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("HelloObjects.Data.PiazzaDelPopolo.negy.jpg"))
                cubeMap[3] = ImageCodec.Instance.Load(imageStream, ImageFormat.Jpeg);
            using (Stream imageStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("HelloObjects.Data.PiazzaDelPopolo.posz.jpg"))
                cubeMap[4] = ImageCodec.Instance.Load(imageStream, ImageFormat.Jpeg);
            using (Stream imageStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("HelloObjects.Data.PiazzaDelPopolo.negz.jpg"))
                cubeMap[5] = ImageCodec.Instance.Load(imageStream, ImageFormat.Jpeg);

            foreach (OpenGL.Objects.Image image in cubeMap)
            {
                image.FlipVertically();
            }

            TextureCube cubeMapTexture = new TextureCube();
            cubeMapTexture.Create(PixelLayout.RGB24, cubeMap);

            #endregion

            #region State

            skyboxObject.LocalModel.Scale(170.0f);

            skyboxObject.ObjectState.DefineState(new DepthTestState(DepthFunction.Less));
            skyboxObject.ObjectState.DefineState(new CullFaceState(FrontFaceDirection.Cw, CullFaceMode.Back));

            ShaderUniformState skyboxUniformState = new ShaderUniformState("OpenGL.Skybox");
            skyboxUniformState.SetUniformState("glo_CubeMapTexture", cubeMapTexture);
            skyboxObject.ObjectState.DefineState(skyboxUniformState);

            #endregion

            #region Program

            skyboxObject.ProgramTag = ShadersLibrary.Instance.CreateProgramTag("OpenGL.Skybox");
            skyboxObject.Program.Create(_Context);

            #endregion

            #region Vertex Array

            // Define vertex arrays
            skyboxObject.VertexArray = new VertexArrayObject();
            skyboxObject.VertexArray.SetArray(_CubeArrayPosition, VertexArraySemantic.Position);
            skyboxObject.VertexArray.SetElementArray(PrimitiveType.Triangles);
            skyboxObject.VertexArray.Create(_Context);

            #endregion

            return(skyboxObject);
        }
コード例 #9
0
        private void SetSphereMaterial(SceneObjectGeometry sphere, string material)
        {
            MaterialState sphereMaterial = new MaterialState();

            sphereMaterial.FrontMaterial           = new MaterialState.Material(ColorRGBAF.ColorWhite);
            sphereMaterial.FrontMaterial.Ambient   = ColorRGBAF.ColorWhite * 0.2f;
            sphereMaterial.FrontMaterial.Diffuse   = ColorRGBAF.ColorWhite * 0.8f;
            sphereMaterial.FrontMaterial.Specular  = ColorRGBAF.ColorWhite * 1.0f;
            sphereMaterial.FrontMaterial.Shininess = 32.0f;

            sphere.ObjectState.DefineState(sphereMaterial);

            if (material == null)
            {
                return;
            }

            string basePath = Path.Combine("Data", "PhotosculptTextures");
            string textureFilename, texturePath;

            textureFilename = String.Format("photosculpt-{0}-{1}.jpg", material, "diffuse");
            texturePath     = Path.Combine(basePath, textureFilename);
            if (File.Exists(texturePath))
            {
                try {
                    Image     textureImage = ImageCodec.Instance.Load(texturePath);
                    Texture2d texture      = new Texture2d();

                    texture.RequestMipmapsCreation();
                    texture.WrapCoordR = Texture.Wrap.MirroredRepeat;
                    texture.WrapCoordS = Texture.Wrap.MirroredRepeat;
                    texture.Create(textureImage);

                    sphereMaterial.FrontMaterialDiffuseTexture  = texture;
                    sphereMaterial.FrontMaterialDiffuseTexCoord = 0;
                } catch (Exception exception) {
                    throw new InvalidOperationException(String.Format("unable to load texture {0}", texturePath), exception);
                }
            }

            textureFilename = String.Format("photosculpt-{0}-{1}.jpg", material, "normal");
            texturePath     = Path.Combine(basePath, textureFilename);
            if (File.Exists(texturePath))
            {
                try {
                    Image     textureImage = ImageCodec.Instance.Load(texturePath);
                    Texture2d texture      = new Texture2d();

                    texture.RequestMipmapsCreation();
                    texture.WrapCoordR = Texture.Wrap.MirroredRepeat;
                    texture.WrapCoordS = Texture.Wrap.MirroredRepeat;
                    texture.Create(textureImage);

                    sphereMaterial.FrontMaterialNormalTexture  = texture;
                    sphereMaterial.FrontMaterialNormalTexCoord = 0;
                } catch (Exception exception) {
                    throw new InvalidOperationException(String.Format("unable to load texture {0}", texturePath), exception);
                }
            }

            textureFilename = String.Format("photosculpt-{0}-{1}.jpg", material, "specular");
            texturePath     = Path.Combine(basePath, textureFilename);
            if (File.Exists(texturePath))
            {
                try {
                    Image     textureImage = ImageCodec.Instance.Load(texturePath);
                    Texture2d texture      = new Texture2d();

                    texture.RequestMipmapsCreation();
                    texture.WrapCoordR = Texture.Wrap.MirroredRepeat;
                    texture.WrapCoordS = Texture.Wrap.MirroredRepeat;
                    texture.Create(textureImage);

                    sphereMaterial.FrontMaterialSpecularTexture  = texture;
                    sphereMaterial.FrontMaterialSpecularTexCoord = 0;
                } catch (Exception exception) {
                    throw new InvalidOperationException(String.Format("unable to load texture {0}", texturePath), exception);
                }
            }

            textureFilename = String.Format("photosculpt-{0}-{1}.jpg", material, "ambientocclusion");
            texturePath     = Path.Combine(basePath, textureFilename);
            if (File.Exists(texturePath))
            {
                try {
                    Image     textureImage = ImageCodec.Instance.Load(texturePath);
                    Texture2d texture      = new Texture2d();

                    texture.RequestMipmapsCreation();
                    texture.WrapCoordR = Texture.Wrap.MirroredRepeat;
                    texture.WrapCoordS = Texture.Wrap.MirroredRepeat;
                    texture.Create(textureImage);

                    sphereMaterial.FrontMaterialAmbientTexture  = texture;
                    sphereMaterial.FrontMaterialAmbientTexCoord = 0;
                } catch (Exception exception) {
                    throw new InvalidOperationException(String.Format("unable to load texture {0}", texturePath), exception);
                }
            }

            textureFilename = String.Format("photosculpt-{0}-{1}.jpg", material, "displace");
            texturePath     = Path.Combine(basePath, textureFilename);
            if (File.Exists(texturePath))
            {
                try {
                    Image     textureImage = ImageCodec.Instance.Load(texturePath);
                    Texture2d texture      = new Texture2d();

                    // texture.RequestMipmapsCreation();
                    texture.WrapCoordR     = Texture.Wrap.Repeat;
                    texture.WrapCoordS     = Texture.Wrap.Repeat;
                    texture.MinFilter      = Texture.Filter.Nearest;
                    texture.MagFilter      = Texture.Filter.Nearest;
                    texture.MipmapMaxLevel = 0;
                    texture.Create(textureImage);

                    sphereMaterial.FrontMaterialDisplacementTexture = texture;
                    // sphereMaterial.FrontMaterialDisplacementTexCoord = 0;
                    sphereMaterial.FrontMaterialDisplacementFactor = 0.2f;
                } catch (Exception exception) {
                    throw new InvalidOperationException(String.Format("unable to load texture {0}", texturePath), exception);
                }
            }
        }
コード例 #10
0
        /// <summary>
        /// Allocate resources for rendering.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ObjectsControl_ContextCreated(object sender, GlControlEventArgs e)
        {
            // Wrap GL context with GraphicsContext
            _Context = new GraphicsContext(e.DeviceContext, e.RenderContext);
            // Scene
            _CubeScene = new SceneGraph(
                SceneGraphFlags.CullingViewFrustum | SceneGraphFlags.StateSorting | SceneGraphFlags.Lighting | SceneGraphFlags.ShadowMaps
                //| SceneGraphFlags.BoundingVolumes
                );
            _CubeScene.SceneRoot = new SceneObjectGeometry();
            _CubeScene.SceneRoot.ObjectState.DefineState(new DepthTestState(DepthFunction.Less));

            _CubeScene.CurrentView = new SceneObjectCamera();
            _CubeScene.SceneRoot.Link(_CubeScene.CurrentView);

            fontTitle = FontFactory.CreateFont(System.Drawing.FontFamily.GenericSerif, 24, System.Drawing.FontStyle.Regular, FontFactory.FontType.Textured, new FontFxShadow());
            fontTitle.Create(_Context);

            fontTitleV = FontFactory.CreateFont(System.Drawing.FontFamily.GenericSerif, 24, System.Drawing.FontStyle.Regular, FontFactory.FontType.Vector, new FontFxShadow());
            fontTitleV.Create(_Context);

            fontPatch = FontFactory.CreateFont(System.Drawing.FontFamily.GenericMonospace, 16, System.Drawing.FontStyle.Regular, FontFactory.FontType.Vector);
            fontPatch.Create(_Context);

            // Global lighting
            SceneObjectLightZone globalLightZone = new SceneObjectLightZone();

            _GlobalLightObject           = new SceneObjectLightDirectional();
            _GlobalLightObject.Direction = (-Vertex3f.UnitX + Vertex3f.UnitY - Vertex3f.UnitZ).Normalized;
            //globalLightZone.Link(_GlobalLightObject);

            spotLight = new SceneObjectLightSpot();
            spotLight.LocalModel.Translate(0.0f, 35.0f, 0.0f);
            spotLight.Direction       = -Vertex3f.UnitY;
            spotLight.FalloffAngle    = 10.5f;
            spotLight.FalloffExponent = 0.0f;
            globalLightZone.Link(spotLight);

            SceneObjectLightPoint localLightObject = new SceneObjectLightPoint();

            localLightObject.LocalModel.Translate(0.0, -5.0f, 0.0);
            localLightObject.AttenuationFactors.Y = 0.1f;
            //globalLightZone.AddChild(localLightObject);

            _CubeScene.SceneRoot.Link(globalLightZone);

            // Horizontal plane
            globalLightZone.Link(CreatePlane());

            // Cube
            float       Size       = (float)Math.Sqrt(1);
            const float Multiplier = 10.0f;

            int materialIndex = 0;

            for (float x = -Size / 2.0f * Multiplier; x < Size / 2.0f * Multiplier; x += Multiplier)
            {
                for (float y = -Size / 2.0f * Multiplier; y < Size / 2.0f * Multiplier; y += Multiplier, materialIndex++)
                {
                    SceneObjectGeometry cubeInstance = CreateCubeGeometry();

                    cubeInstance.LocalModel.Translate(x, 0.0f, y);
                    cubeInstance.LocalModel.Scale(0.25f);

                    // materialIndex = 1;

                    // Enable/Disable blending
                    if ((materialIndex % 2) == 0)
                    {
                        cubeInstance.ObjectState.DefineState(new BlendState(BlendEquationMode.FuncAdd, BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha));
                    }

                    // Enable/Disable blending
                    switch (materialIndex % 3)
                    {
                    case 0:
                        cubeInstance.ProgramTag = ShadersLibrary.Instance.CreateProgramTag("OpenGL.Standard+Color");
                        break;

                    case 1:
                        cubeInstance.ProgramTag = ShadersLibrary.Instance.CreateProgramTag("OpenGL.Standard+LambertVertex", new ShaderCompilerContext("GLO_COLOR_PER_VERTEX"));
                        break;

                    case 2:
                        cubeInstance.ProgramTag = ShadersLibrary.Instance.CreateProgramTag("OpenGL.Standard+PhongFragment");
                        break;
                    }

                    globalLightZone.Link(cubeInstance);
                }
            }

            //SceneObjectGeometry cubeLambert = CreateCubeGeometry();
            //cubeLambert.ProgramTag = ShadersLibrary.Instance.CreateProgramTag("OpenGL.Standard+LambertVertex", new ShaderCompilerContext("GLO_COLOR_PER_VERTEX"));
            //globalLightZone.Link(cubeLambert);

            //SceneObjectGeometry cubeBlinn = CreateCubeGeometry();
            //cubeBlinn.ProgramTag = ShadersLibrary.Instance.CreateProgramTag("OpenGL.Standard+PhongFragment", new ShaderCompilerContext("GLO_COLOR_PER_VERTEX"));
            //cubeBlinn.LocalModel.Translate(0.0f, 10.0f, 0.0f);
            //globalLightZone.Link(cubeBlinn);

            //SceneObjectGeometry cubeColored = CreateCubeGeometry();
            //cubeColored.ProgramTag = ShadersLibrary.Instance.CreateProgramTag("OpenGL.Standard+Color");
            //cubeColored.LocalModel.Translate(0.0f, 5.0f, 0.0f);
            //globalLightZone.Link(cubeColored);

            globalLightZone.Link(CreateBumbleBeeVH());
            globalLightZone.Link(CreateBumbleBeeRB());
            // globalLightZone.Link(CreateSphere("squarebricks"));

            // Skybox
            //if ((sceneObject = CreateSkyBoxObject()) != null)
            //	_CubeScene.AddChild(sceneObject);

            _CubeScene.Create(_Context);

            Gl.ClearColor(0.1f, 0.1f, 0.1f, 0.0f);

            Gl.Enable(EnableCap.Multisample);
        }