void SetupGL()
        {
            EAGLContext.SetCurrentContext(context);

            LoadShaders();

            effect = new GLKBaseEffect();
            effect.Light0.Enabled      = true;
            effect.Light0.DiffuseColor = new Vector4(1.0f, 0.4f, 0.4f, 1.0f);

            GL.Enable(EnableCap.DepthTest);

            GL.Oes.GenVertexArrays(1, out vertexArray);
            GL.Oes.BindVertexArray(vertexArray);

            GL.GenBuffers(1, out vertexBuffer);
            GL.BindBuffer(BufferTarget.ArrayBuffer, vertexBuffer);
            GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(cubeVertexData.Length * sizeof(float)), cubeVertexData, BufferUsage.StaticDraw);

            GL.EnableVertexAttribArray((int)GLKVertexAttrib.Position);
            GL.VertexAttribPointer((int)GLKVertexAttrib.Position, 3, VertexAttribPointerType.Float, false, 24, new IntPtr(0));
            GL.EnableVertexAttribArray((int)GLKVertexAttrib.Normal);
            GL.VertexAttribPointer((int)GLKVertexAttrib.Normal, 3, VertexAttribPointerType.Float, false, 24, new IntPtr(12));

            GL.Oes.BindVertexArray(0);
        }
        public void Properties()
        {
            TestRuntime.AssertSystemVersion(ApplePlatform.MacOSX, 10, 8, throwIfOtherPlatform: false);

            var material = new GLKEffectPropertyMaterial();

#if NET
            Assert.That(material.AmbientColor.ToString(), Is.EqualTo("<0.2, 0.2, 0.2, 1>"), "AmbientColor");
            Assert.That(material.DiffuseColor.ToString(), Is.EqualTo("<0.8, 0.8, 0.8, 1>"), "DiffuseColor");
            Assert.That(material.SpecularColor.ToString(), Is.EqualTo("<0, 0, 0, 1>"), "SpecularColor");
            Assert.That(material.EmissiveColor.ToString(), Is.EqualTo("<0, 0, 0, 1>"), "EmissiveColor");
#else
            Assert.That(material.AmbientColor.ToString(), Is.EqualTo("(0.2, 0.2, 0.2, 1)"), "AmbientColor");
            Assert.That(material.DiffuseColor.ToString(), Is.EqualTo("(0.8, 0.8, 0.8, 1)"), "DiffuseColor");
            Assert.That(material.SpecularColor.ToString(), Is.EqualTo("(0, 0, 0, 1)"), "SpecularColor");
            Assert.That(material.EmissiveColor.ToString(), Is.EqualTo("(0, 0, 0, 1)"), "EmissiveColor");
#endif

            material = new GLKBaseEffect().Material;
#if NET
            Assert.That(material.AmbientColor.ToString(), Is.EqualTo("<0.2, 0.2, 0.2, 1>"), "AmbientColor");
            Assert.That(material.DiffuseColor.ToString(), Is.EqualTo("<0.8, 0.8, 0.8, 1>"), "DiffuseColor");
            Assert.That(material.SpecularColor.ToString(), Is.EqualTo("<0, 0, 0, 1>"), "SpecularColor");
            Assert.That(material.EmissiveColor.ToString(), Is.EqualTo("<0, 0, 0, 1>"), "EmissiveColor");
#else
            Assert.That(material.AmbientColor.ToString(), Is.EqualTo("(0.2, 0.2, 0.2, 1)"), "AmbientColor");
            Assert.That(material.DiffuseColor.ToString(), Is.EqualTo("(0.8, 0.8, 0.8, 1)"), "DiffuseColor");
            Assert.That(material.SpecularColor.ToString(), Is.EqualTo("(0, 0, 0, 1)"), "SpecularColor");
            Assert.That(material.EmissiveColor.ToString(), Is.EqualTo("(0, 0, 0, 1)"), "EmissiveColor");
#endif
        }
Exemple #3
0
        public void Properties()
        {
            TestRuntime.AssertSystemVersion(ApplePlatform.MacOSX, 10, 8, throwIfOtherPlatform: false);

            var light = new GLKEffectPropertyLight();

#if NET
            Assert.That(light.AmbientColor.ToString(), Is.EqualTo("<0, 0, 0, 0>"), "AmbientColor");
            Assert.That(light.DiffuseColor.ToString(), Is.EqualTo("<0, 0, 0, 0>"), "DiffuseColor");
            Assert.That(light.SpecularColor.ToString(), Is.EqualTo("<0, 0, 0, 0>"), "SpecularColor");
            Assert.That(light.Position.ToString(), Is.EqualTo("<0, 0, 0, 0>"), "Position");
#else
            Assert.That(light.AmbientColor.ToString(), Is.EqualTo("(0, 0, 0, 0)"), "AmbientColor");
            Assert.That(light.DiffuseColor.ToString(), Is.EqualTo("(0, 0, 0, 0)"), "DiffuseColor");
            Assert.That(light.SpecularColor.ToString(), Is.EqualTo("(0, 0, 0, 0)"), "SpecularColor");
            Assert.That(light.Position.ToString(), Is.EqualTo("(0, 0, 0, 0)"), "Position");
#endif

            light = new GLKBaseEffect().Light0;
#if NET
            Assert.That(light.AmbientColor.ToString(), Is.EqualTo("<0, 0, 0, 1>"), "AmbientColor");
            Assert.That(light.DiffuseColor.ToString(), Is.EqualTo("<1, 1, 1, 1>"), "DiffuseColor");
            Assert.That(light.SpecularColor.ToString(), Is.EqualTo("<1, 1, 1, 1>"), "SpecularColor");
            Assert.That(light.Position.ToString(), Is.EqualTo("<0, 0, 1, 0>"), "Position");
#else
            Assert.That(light.AmbientColor.ToString(), Is.EqualTo("(0, 0, 0, 1)"), "AmbientColor");
            Assert.That(light.DiffuseColor.ToString(), Is.EqualTo("(1, 1, 1, 1)"), "DiffuseColor");
            Assert.That(light.SpecularColor.ToString(), Is.EqualTo("(1, 1, 1, 1)"), "SpecularColor");
            Assert.That(light.Position.ToString(), Is.EqualTo("(0, 0, 1, 0)"), "Position");
#endif
        }
        public void Properties()
        {
            var effect = new GLKBaseEffect();

            Assert.That(effect.LightModelAmbientColor.ToString(), Is.EqualTo("(0.2, 0.2, 0.2, 1)"), "LightModelAmbientColor");
            Assert.That(effect.ConstantColor.ToString(), Is.EqualTo("(1, 1, 1, 1)"), "ConstantColor");
        }
Exemple #5
0
        private void TearDownGL()
        {
            EAGLContext.SetCurrentContext(this.context);
            GL.DeleteBuffers(1, ref vertexBuffer);
            GL.Oes.DeleteVertexArrays(1, ref vertexArray);

            this.effect = null;
        }
        public unsafe void Redraw(AudioPlotGlPoint[] points, GLKBaseEffect baseEffect, uint vbo, uint vab, bool interpolated, bool mirrored, float gain)
        {
            IntPtr pPoints;

            IntPtrHelper.ConvertToIntPtr <AudioPlotGlPoint> (points, out pPoints);
            _Redraw(pPoints, (uint)points.Length, baseEffect, vbo, vab, interpolated, mirrored, gain);
            Marshal.FreeHGlobal(pPoints);
        }
Exemple #7
0
        public void Properties()
        {
            var fog = new GLKEffectPropertyFog();

            Assert.That(fog.Color.ToString(), Is.EqualTo("(0, 0, 0, 0)"), "Color");

            fog = new GLKBaseEffect().Fog;
            Assert.That(fog.Color.ToString(), Is.EqualTo("(0, 0, 0, 0)"), "Color");
        }
        void setupGL()
        {
            EAGLContext.SetCurrentContext(context);

            effect = new GLKBaseEffect();
            effect.LightingType = GLKLightingType.PerPixel;

            effect.Light0.Enabled      = true;
            effect.Light0.DiffuseColor = new Vector4(1.0f, 0.4f, 0.4f, 1.0f);

            GL.Enable(EnableCap.DepthTest);

            GL.Oes.GenVertexArrays(1, out vertexArray);
            GL.Oes.BindVertexArray(vertexArray);

            GL.GenBuffers(1, out vertexBuffer);
            GL.BindBuffer(BufferTarget.ArrayBuffer, vertexBuffer);
            GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(Monkey.MeshVertexData.Length * sizeof(float)),
                          Monkey.MeshVertexData, BufferUsage.StaticDraw);

            GL.EnableVertexAttribArray((int)GLKVertexAttrib.Position);
            GL.VertexAttribPointer((int)GLKVertexAttrib.Position, 3, VertexAttribPointerType.Float,
                                   false, 8 * sizeof(float), 0);

            GL.EnableVertexAttribArray((int)GLKVertexAttrib.Normal);
            GL.VertexAttribPointer((int)GLKVertexAttrib.Normal, 3, VertexAttribPointerType.Float,
                                   false, 8 * sizeof(float), 12);

            GL.EnableVertexAttribArray((int)GLKVertexAttrib.TexCoord0);
            GL.VertexAttribPointer((int)GLKVertexAttrib.TexCoord0, 2, VertexAttribPointerType.Float,
                                   false, 8 * sizeof(float), 24);

            GL.ActiveTexture(TextureUnit.Texture0);
            string path = NSBundle.MainBundle.PathForResource("monkey", "png");

            NSError      error;
            NSDictionary options = NSDictionary.FromObjectAndKey(NSNumber.FromBoolean(true),
                                                                 GLKTextureLoader.OriginBottomLeft);

            texture = GLKTextureLoader.FromFile(path, options, out error);

            if (texture == null)
            {
                Console.WriteLine(String.Format("Error loading texture: {0}", error.LocalizedDescription));
            }

            GLKEffectPropertyTexture tex = new GLKEffectPropertyTexture();

            tex.Enabled = true;
            tex.EnvMode = GLKTextureEnvMode.Decal;
            tex.GLName  = texture.Name;

            effect.Texture2d0.GLName = tex.GLName;

            GL.Oes.BindVertexArray(0);
        }
Exemple #9
0
        public void Properties()
        {
            TestRuntime.AssertSystemVersion(PlatformName.MacOSX, 10, 8, throwIfOtherPlatform: false);

            var fog = new GLKEffectPropertyFog();

            Assert.That(fog.Color.ToString(), Is.EqualTo("(0, 0, 0, 0)"), "Color");

            fog = new GLKBaseEffect().Fog;
            Assert.That(fog.Color.ToString(), Is.EqualTo("(0, 0, 0, 0)"), "Color");
        }
Exemple #10
0
        public void Properties()
        {
            var effect = new GLKBaseEffect();

            Assert.That(effect.LightModelAmbientColor.ToString(), Is.EqualTo("(0.2, 0.2, 0.2, 1)"), "LightModelAmbientColor");
            Assert.That(effect.ConstantColor.ToString(), Is.EqualTo("(1, 1, 1, 1)"), "ConstantColor");

            effect.Light0.Enabled      = true;
            effect.Light0.DiffuseColor = new Vector4(1.0f, 0.4f, 0.4f, 1.0f);
            Assert.That(effect.Light0.DiffuseColor.ToString(), Is.EqualTo("(1, 0.4, 0.4, 1)"), "Light0");
        }
		void setupGL ()
		{
			EAGLContext.SetCurrentContext (context);

			effect = new GLKBaseEffect ();
			effect.LightingType = GLKLightingType.PerPixel;

			effect.Light0.Enabled = true;
			effect.Light0.DiffuseColor = new Vector4 (1.0f, 0.4f, 0.4f, 1.0f);

			GL.Enable (EnableCap.DepthTest);

			GL.Oes.GenVertexArrays (1, out vertexArray);
			GL.Oes.BindVertexArray (vertexArray);

			GL.GenBuffers (1, out vertexBuffer);
			GL.BindBuffer (BufferTarget.ArrayBuffer, vertexBuffer);
			GL.BufferData (BufferTarget.ArrayBuffer, (IntPtr) (Monkey.MeshVertexData.Length * sizeof (float)), 
			               Monkey.MeshVertexData, BufferUsage.StaticDraw);

			GL.EnableVertexAttribArray ((int) GLKVertexAttrib.Position);
			GL.VertexAttribPointer ((int) GLKVertexAttrib.Position, 3, VertexAttribPointerType.Float,
			                        false, 8 * sizeof (float), 0);

			GL.EnableVertexAttribArray ((int) GLKVertexAttrib.Normal);
			GL.VertexAttribPointer ((int) GLKVertexAttrib.Normal, 3, VertexAttribPointerType.Float,
			                        false, 8 * sizeof(float), 12);

			GL.EnableVertexAttribArray ((int) GLKVertexAttrib.TexCoord0);
			GL.VertexAttribPointer ((int) GLKVertexAttrib.TexCoord0, 2, VertexAttribPointerType.Float,
			                        false, 8 * sizeof(float), 24);

			GL.ActiveTexture (TextureUnit.Texture0);
			string path = NSBundle.MainBundle.PathForResource ("monkey", "png");

			NSError error;
			NSDictionary options = NSDictionary.FromObjectAndKey (NSNumber.FromBoolean (true),
			                                                      GLKTextureLoader.OriginBottomLeft);

			texture = GLKTextureLoader.FromFile (path, options, out error);

			if (texture == null)
				Console.WriteLine (String.Format("Error loading texture: {0}", error.LocalizedDescription));

			GLKEffectPropertyTexture tex = new GLKEffectPropertyTexture ();
			tex.Enabled = true;
			tex.EnvMode = GLKTextureEnvMode.Decal;
			tex.GLName = texture.Name;

			effect.Texture2d0.GLName = tex.GLName;

			GL.Oes.BindVertexArray (0);
		}
        public void Properties()
        {
            TestRuntime.AssertSystemVersion(PlatformName.MacOSX, 10, 8, throwIfOtherPlatform: false);

            var effect = new GLKBaseEffect();

            Assert.That(effect.LightModelAmbientColor.ToString(), Is.EqualTo("(0.2, 0.2, 0.2, 1)"), "LightModelAmbientColor");
            Assert.That(effect.ConstantColor.ToString(), Is.EqualTo("(1, 1, 1, 1)"), "ConstantColor");

            effect.Light0.Enabled      = true;
            effect.Light0.DiffuseColor = new Vector4(1.0f, 0.4f, 0.4f, 1.0f);
            Assert.That(effect.Light0.DiffuseColor.ToString(), Is.EqualTo("(1, 0.4, 0.4, 1)"), "Light0");
        }
Exemple #13
0
        public void Properties()
        {
            var transform = new GLKEffectPropertyTransform();

            Assert.That(transform.ModelViewMatrix.ToString(), Is.EqualTo("(1, 0, 0, 0)\n(0, 1, 0, 0)\n(0, 0, 1, 0)\n(0, 0, 0, 1)"), "ModelViewMatrix");
            Assert.That(transform.ProjectionMatrix.ToString(), Is.EqualTo("(1, 0, 0, 0)\n(0, 1, 0, 0)\n(0, 0, 1, 0)\n(0, 0, 0, 1)"), "ProjectionMatrix");
            // Is TextureMatrix supposed to be here? I can't find it in apple's docs, and it throws a selector not found exception
            // Assert.That (transform.TextureMatrix.ToString (), Is.EqualTo ("(0, 0, 0, 0)"), "TextureMatrix");

            transform = new GLKBaseEffect().Transform;
            Assert.That(transform.ModelViewMatrix.ToString(), Is.EqualTo("(1, 0, 0, 0)\n(0, 1, 0, 0)\n(0, 0, 1, 0)\n(0, 0, 0, 1)"), "ModelViewMatrix");
            Assert.That(transform.ProjectionMatrix.ToString(), Is.EqualTo("(1, 0, 0, 0)\n(0, 1, 0, 0)\n(0, 0, 1, 0)\n(0, 0, 0, 1)"), "ProjectionMatrix");
        }
        void TearDownGL()
        {
            EAGLContext.SetCurrentContext(context);
            GL.DeleteBuffers(1, ref vertexBuffer);
            GL.Oes.DeleteVertexArrays(1, ref vertexArray);

            effect = null;

            if (program > 0)
            {
                GL.DeleteProgram(program);
                program = 0;
            }
        }
Exemple #15
0
        // Setup and Teardown
        private void SetupGL()
        {
            // Context
            EAGLContext.SetCurrentContext(this.context);
            this.effect = new GLKBaseEffect();
            GL.Disable(EnableCap.DepthTest);

            // Signature lines
            GL.Oes.GenVertexArrays(1, out vertexArray);
            GL.Oes.BindVertexArray(vertexArray);

            GL.GenBuffers(1, out vertexBuffer);
            GL.BindBuffer(BufferTarget.ArrayBuffer, vertexBuffer);

            int s = Marshal.SizeOf(typeof(NICSignaturePoint)) * this.SignatureVertexData.Length;

            GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)s, this.SignatureVertexData, BufferUsage.DynamicDraw);
            this.BindShaderAttributes();

            // Signature dots
            GL.Oes.GenVertexArrays(1, out dotsArray);
            GL.Oes.BindVertexArray(dotsArray);

            GL.GenBuffers(1, out dotsBuffer);
            GL.BindBuffer(BufferTarget.ArrayBuffer, dotsBuffer);

            s = Marshal.SizeOf(typeof(NICSignaturePoint)) * this.SignatureDotsData.Length;
            GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)s, this.SignatureDotsData, BufferUsage.DynamicDraw);
            this.BindShaderAttributes();

            GL.Oes.BindVertexArray(0);

            // Perspective
            Matrix4 ortho = Matrix4.CreateOrthographic(2.0f, 2.0f, 0.1f, 2.0f);

            effect.Transform.ProjectionMatrix = ortho;
            Matrix4 modelViewMatrix = Matrix4.CreateTranslation(new Vector3 {
                X = 0.0f, Y = 0.0f, Z = -1.0f
            });

            effect.Transform.ModelViewMatrix = modelViewMatrix;

            vertexLength  = 0;
            dotsLength    = 0;
            penThickness  = 0.004f;
            previousPoint = new CGPoint {
                X = -100, Y = -100
            };
        }
        public void Properties()
        {
            TestRuntime.AssertSystemVersion(PlatformName.MacOSX, 10, 8, throwIfOtherPlatform: false);

            var transform = new GLKEffectPropertyTransform();

            Assert.That(transform.ModelViewMatrix.ToString(), Is.EqualTo("(1, 0, 0, 0)\n(0, 1, 0, 0)\n(0, 0, 1, 0)\n(0, 0, 0, 1)"), "ModelViewMatrix");
            Assert.That(transform.ProjectionMatrix.ToString(), Is.EqualTo("(1, 0, 0, 0)\n(0, 1, 0, 0)\n(0, 0, 1, 0)\n(0, 0, 0, 1)"), "ProjectionMatrix");
            // Is TextureMatrix supposed to be here? I can't find it in apple's docs, and it throws a selector not found exception
            // Assert.That (transform.TextureMatrix.ToString (), Is.EqualTo ("(0, 0, 0, 0)"), "TextureMatrix");

            transform = new GLKBaseEffect().Transform;
            Assert.That(transform.ModelViewMatrix.ToString(), Is.EqualTo("(1, 0, 0, 0)\n(0, 1, 0, 0)\n(0, 0, 1, 0)\n(0, 0, 0, 1)"), "ModelViewMatrix");
            Assert.That(transform.ProjectionMatrix.ToString(), Is.EqualTo("(1, 0, 0, 0)\n(0, 1, 0, 0)\n(0, 0, 1, 0)\n(0, 0, 0, 1)"), "ProjectionMatrix");
        }
Exemple #17
0
        public void Properties()
        {
            var light = new GLKEffectPropertyLight();

            Assert.That(light.AmbientColor.ToString(), Is.EqualTo("(0, 0, 0, 0)"), "AmbientColor");
            Assert.That(light.DiffuseColor.ToString(), Is.EqualTo("(0, 0, 0, 0)"), "DiffuseColor");
            Assert.That(light.SpecularColor.ToString(), Is.EqualTo("(0, 0, 0, 0)"), "SpecularColor");
            Assert.That(light.Position.ToString(), Is.EqualTo("(0, 0, 0, 0)"), "Position");

            light = new GLKBaseEffect().Light0;
            Assert.That(light.AmbientColor.ToString(), Is.EqualTo("(0, 0, 0, 1)"), "AmbientColor");
            Assert.That(light.DiffuseColor.ToString(), Is.EqualTo("(1, 1, 1, 1)"), "DiffuseColor");
            Assert.That(light.SpecularColor.ToString(), Is.EqualTo("(1, 1, 1, 1)"), "SpecularColor");
            Assert.That(light.Position.ToString(), Is.EqualTo("(0, 0, 1, 0)"), "Position");
        }
        public void Properties()
        {
            var material = new GLKEffectPropertyMaterial();

            Assert.That(material.AmbientColor.ToString(), Is.EqualTo("(0.2, 0.2, 0.2, 1)"), "AmbientColor");
            Assert.That(material.DiffuseColor.ToString(), Is.EqualTo("(0.8, 0.8, 0.8, 1)"), "DiffuseColor");
            Assert.That(material.SpecularColor.ToString(), Is.EqualTo("(0, 0, 0, 1)"), "SpecularColor");
            Assert.That(material.EmissiveColor.ToString(), Is.EqualTo("(0, 0, 0, 1)"), "EmissiveColor");

            material = new GLKBaseEffect().Material;
            Assert.That(material.AmbientColor.ToString(), Is.EqualTo("(0.2, 0.2, 0.2, 1)"), "AmbientColor");
            Assert.That(material.DiffuseColor.ToString(), Is.EqualTo("(0.8, 0.8, 0.8, 1)"), "DiffuseColor");
            Assert.That(material.SpecularColor.ToString(), Is.EqualTo("(0, 0, 0, 1)"), "SpecularColor");
            Assert.That(material.EmissiveColor.ToString(), Is.EqualTo("(0, 0, 0, 1)"), "EmissiveColor");
        }
        public void Properties()
        {
            TestRuntime.AssertSystemVersion(ApplePlatform.MacOSX, 10, 8, throwIfOtherPlatform: false);

            var fog = new GLKEffectPropertyFog();

#if NET
            Assert.That(fog.Color.ToString(), Is.EqualTo("<0, 0, 0, 0>"), "Color");
#else
            Assert.That(fog.Color.ToString(), Is.EqualTo("(0, 0, 0, 0)"), "Color");
#endif

            fog = new GLKBaseEffect().Fog;
#if NET
            Assert.That(fog.Color.ToString(), Is.EqualTo("<0, 0, 0, 0>"), "Color");
#else
            Assert.That(fog.Color.ToString(), Is.EqualTo("(0, 0, 0, 0)"), "Color");
#endif
        }
		void setupGL ()
		{
			EAGLContext.SetCurrentContext (context);

			effect = new GLKBaseEffect ();
			effect.LightingType = GLKLightingType.PerPixel;

			effect.Light0.Enabled = true;
			effect.Light0.DiffuseColor = new Vector4 (1.0f, 0.4f, 0.4f, 1.0f);
			effect.Light0.Position = new Vector4 (-5f, -5f, 10f, 1f);
			effect.Light0.SpecularColor = new Vector4 (1f, 0f, 0f, 1f);

			effect.Light1.Enabled = true;
			effect.Light1.DiffuseColor = new Vector4 (1f, 0.4f, 0.4f, 1f);
			effect.Light1.Position = new Vector4 (15f, 15f, 10f, 1f);
			effect.Light1.SpecularColor = new Vector4 (1f, 0f, 0f, 1f);

			effect.Material.DiffuseColor = new Vector4 (0f, 0.5f, 1f, 1f);
			effect.Material.AmbientColor = new Vector4 (0f, 0.5f, 0f, 1f);
			effect.Material.SpecularColor = new Vector4 (1f, 0f, 0f, 1f);
			effect.Material.Shininess = 20f;
			effect.Material.EmissiveColor = new Vector4 (0.2f, 0f, 0.2f, 1f);

			GL.Enable (EnableCap.DepthTest);

			GL.Oes.GenVertexArrays (1, out vertexArray);
			GL.Oes.BindVertexArray (vertexArray);

			GL.GenBuffers (1, out vertexBuffer);
			GL.BindBuffer (BufferTarget.ArrayBuffer, vertexBuffer);
			GL.BufferData (BufferTarget.ArrayBuffer, (IntPtr)(Monkey.MeshVertexData.Length * sizeof(float)),
			               Monkey.MeshVertexData, BufferUsage.StaticDraw);

			GL.EnableVertexAttribArray ((int) GLKVertexAttrib.Position);
			GL.VertexAttribPointer ((int) GLKVertexAttrib.Position, 3, VertexAttribPointerType.Float,
			                        false, 6 * sizeof(float), 0);

			GL.EnableVertexAttribArray ((int) GLKVertexAttrib.Normal);
			GL.VertexAttribPointer ((int) GLKVertexAttrib.Normal, 3, VertexAttribPointerType.Float,
			                        false, 6 * sizeof(float), 12);

			GL.Oes.BindVertexArray (0);
		}
Exemple #21
0
        void setupGL()
        {
            EAGLContext.SetCurrentContext(context);

            effect = new GLKBaseEffect();
            effect.LightingType = GLKLightingType.PerPixel;

            effect.Light0.Enabled       = true;
            effect.Light0.DiffuseColor  = new Vector4(1.0f, 0.4f, 0.4f, 1.0f);
            effect.Light0.Position      = new Vector4(-5f, -5f, 10f, 1f);
            effect.Light0.SpecularColor = new Vector4(1f, 0f, 0f, 1f);

            effect.Light1.Enabled       = true;
            effect.Light1.DiffuseColor  = new Vector4(1f, 0.4f, 0.4f, 1f);
            effect.Light1.Position      = new Vector4(15f, 15f, 10f, 1f);
            effect.Light1.SpecularColor = new Vector4(1f, 0f, 0f, 1f);

            effect.Material.DiffuseColor  = new Vector4(0f, 0.5f, 1f, 1f);
            effect.Material.AmbientColor  = new Vector4(0f, 0.5f, 0f, 1f);
            effect.Material.SpecularColor = new Vector4(1f, 0f, 0f, 1f);
            effect.Material.Shininess     = 20f;
            effect.Material.EmissiveColor = new Vector4(0.2f, 0f, 0.2f, 1f);

            GL.Enable(EnableCap.DepthTest);

            GL.Oes.GenVertexArrays(1, out vertexArray);
            GL.Oes.BindVertexArray(vertexArray);

            GL.GenBuffers(1, out vertexBuffer);
            GL.BindBuffer(BufferTarget.ArrayBuffer, vertexBuffer);
            GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(Monkey.MeshVertexData.Length * sizeof(float)),
                          Monkey.MeshVertexData, BufferUsage.StaticDraw);

            GL.EnableVertexAttribArray((int)GLKVertexAttrib.Position);
            GL.VertexAttribPointer((int)GLKVertexAttrib.Position, 3, VertexAttribPointerType.Float,
                                   false, 6 * sizeof(float), 0);

            GL.EnableVertexAttribArray((int)GLKVertexAttrib.Normal);
            GL.VertexAttribPointer((int)GLKVertexAttrib.Normal, 3, VertexAttribPointerType.Float,
                                   false, 6 * sizeof(float), 12);

            GL.Oes.BindVertexArray(0);
        }
        public void setupGL()
        {
            EAGLContext.SetCurrentContext(context);

            effects = new List <GLKBaseEffect> ();

            for (int i = 0; i < NumCubes; i++)
            {
                var effect = new GLKBaseEffect();
                effect.Light0.Enabled      = true;
                effect.Light0.DiffuseColor = new Vector4(gColorData [3 * i] / 255.0f,
                                                         gColorData [3 * i + 1] / 255.0f,
                                                         gColorData [3 * i + 2] / 255.0f,
                                                         1);
                effects.Add(effect);
            }

            for (int i = 0; i < NumStars; i++)
            {
                var effect = new GLKBaseEffect();
                effect.Light0.Enabled = true;
                effects.Add(effect);
            }

            GL.Enable(EnableCap.DepthTest);

            GL.Oes.GenVertexArrays(1, out vertexArray);
            GL.Oes.BindVertexArray(vertexArray);

            GL.GenBuffers(1, out vertexBuffer);
            GL.BindBuffer(BufferTarget.ArrayBuffer, vertexBuffer);

            GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(gCubeVertexData.Length * sizeof(float)), gCubeVertexData, BufferUsage.StaticDraw);

            GL.EnableVertexAttribArray((int)GLKVertexAttrib.Position);
            GL.VertexAttribPointer((int)GLKVertexAttrib.Position, 3, VertexAttribPointerType.Float, false, 24, 0);

            GL.EnableVertexAttribArray((int)GLKVertexAttrib.Normal);
            GL.VertexAttribPointer((int)GLKVertexAttrib.Normal, 3, VertexAttribPointerType.Float, false, 24, 12);

            GL.Oes.BindVertexArray(0);
        }
Exemple #23
0
        public void SetupGL()
        {
            Context             = new EAGLContext(EAGLRenderingAPI.OpenGLES2);
            DrawableDepthFormat = GLKViewDrawableDepthFormat.Format24;

            effect = new GLKBaseEffect();
            effect.Light0.Enabled = true;

            EAGLContext.SetCurrentContext(Context);

            GL.Enable(EnableCap.DepthTest);

            GL.Oes.GenVertexArrays(1, out vertexArray);
            GL.Oes.BindVertexArray(vertexArray);

            GL.GenBuffers(1, out vertexBuffer);
            GL.BindBuffer(BufferTarget.ArrayBuffer, vertexBuffer);

            GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(gCubeVertexData.Length * sizeof(float)), gCubeVertexData, BufferUsage.StaticDraw);

            GL.EnableVertexAttribArray((int)GLKVertexAttrib.Position);
            GL.VertexAttribPointer((int)GLKVertexAttrib.Position, 3, VertexAttribPointerType.Float, false, 24, 0);

            GL.EnableVertexAttribArray((int)GLKVertexAttrib.Normal);
            GL.VertexAttribPointer((int)GLKVertexAttrib.Normal, 3, VertexAttribPointerType.Float, false, 24, 12);

            GL.Oes.BindVertexArray(0);

            RandomizeBigCube();

            for (int i = 0; i < NumLittleCubes; i++)
            {
                littleCube[i] = bigCube;
            }

            timeOfLastRenderedFrame = CAAnimation.CurrentMediaTime();
        }
		public void setupGL ()
		{
			EAGLContext.SetCurrentContext (context);

			effects = new List<GLKBaseEffect> ();

			for (int i = 0; i < NumCubes; i++) {
				var effect = new GLKBaseEffect ();
				effect.Light0.Enabled = true;
				effect.Light0.DiffuseColor = new Vector4 (gColorData [3 * i] / 255.0f,
				                                          gColorData [3 * i + 1] / 255.0f,
				                                          gColorData [3 * i + 2] / 255.0f,
				                                          1);
				effects.Add (effect);
			}

			for (int i = 0; i < NumStars; i++) {
				var effect = new GLKBaseEffect ();
				effect.Light0.Enabled = true;
				effects.Add (effect);
			}

			GL.Enable (EnableCap.DepthTest);

			GL.Oes.GenVertexArrays (1, out vertexArray);
			GL.Oes.BindVertexArray (vertexArray);

			GL.GenBuffers (1, out vertexBuffer);
			GL.BindBuffer (BufferTarget.ArrayBuffer, vertexBuffer);

			GL.BufferData (BufferTarget.ArrayBuffer, (IntPtr) (gCubeVertexData.Length * sizeof (float)), gCubeVertexData, BufferUsage.StaticDraw);

			GL.EnableVertexAttribArray ((int) GLKVertexAttrib.Position);
			GL.VertexAttribPointer ((int) GLKVertexAttrib.Position, 3, VertexAttribPointerType.Float, false, 24, 0);

			GL.EnableVertexAttribArray ((int) GLKVertexAttrib.Normal);
			GL.VertexAttribPointer ((int) GLKVertexAttrib.Normal, 3, VertexAttribPointerType.Float, false, 24, 12);

			GL.Oes.BindVertexArray (0);
		}
        void _setupGLView()
        {
            // Craete a new context if needed
            if (EAGLContext.CurrentContext == null)
                EAGLContext.SetCurrentContext (new EAGLContext (EAGLRenderingAPI.OpenGLES2));

            _view = new GLKView (this.View.Bounds);
            _view.Context = EAGLContext.CurrentContext;
            _view.WeakDelegate = this;
            this.View.AddSubview (_view);

            _effect = new GLKBaseEffect ();
            _effect.Light0.Position = new Vector4 (5, 5, 5, 1);
            _effect.Light0.Enabled = true;

            GL.Enable (All.CullFace);

            sizeGLView ();

            _modelMatrix = Matrix4.CreateRotationX ((float)Math.PI / 5f);
            _effect.Transform.ModelViewMatrix = _modelMatrix;

            createBuffers (1);
        }
		public void SetupGL ()
		{
			Context = new EAGLContext (EAGLRenderingAPI.OpenGLES2);
			DrawableDepthFormat = GLKViewDrawableDepthFormat.Format24;

			effect = new GLKBaseEffect ();
			effect.Light0.Enabled = true;

			EAGLContext.SetCurrentContext (Context);

			GL.Enable (EnableCap.DepthTest);

			GL.Oes.GenVertexArrays (1, out vertexArray);
			GL.Oes.BindVertexArray (vertexArray);

			GL.GenBuffers (1, out vertexBuffer);
			GL.BindBuffer (BufferTarget.ArrayBuffer, vertexBuffer);

			GL.BufferData (BufferTarget.ArrayBuffer, (IntPtr) (gCubeVertexData.Length * sizeof (float)), gCubeVertexData, BufferUsage.StaticDraw);
			
			GL.EnableVertexAttribArray ((int) GLKVertexAttrib.Position);
			GL.VertexAttribPointer ((int) GLKVertexAttrib.Position, 3, VertexAttribPointerType.Float, false, 24, 0);
			
			GL.EnableVertexAttribArray ((int) GLKVertexAttrib.Normal);
			GL.VertexAttribPointer ((int) GLKVertexAttrib.Normal, 3, VertexAttribPointerType.Float, false, 24, 12);
			
			GL.Oes.BindVertexArray (0);

			RandomizeBigCube ();

			for (int i = 0; i< NumLittleCubes; i++)
				littleCube[i] = bigCube;

			timeOfLastRenderedFrame = CAAnimation.CurrentMediaTime();
		}