public LinesBase(OpenGL gl, List<Tuple<vec3, vec3>> lines, Material material = null, OGLModelUsage usage = OGLModelUsage.StaticRead)
        {
            var verts = new vec3[lines.Count * 2];
            var normals = new vec3[lines.Count * 2];
            var indices = new uint[lines.Count * 2];

            for (int i = 0; i < lines.Count; i++)
            {
                var i2 = i * 2;
                verts[i2] = lines[i].Item1;
                verts[i2 + 1] = lines[i].Item2;

                normals[i2] = new vec3(1, 1, 1);
                normals[i2 + 1] = new vec3(1, 1, 1);

                indices[i2] = (uint)i2;
                indices[i2 + 1] = (uint)(i2 + 1);
            }

            if (material != null)
                Material = material;

            Vertices = verts;
            Normals = normals;
            Indices = indices;
            GlDrawMode = OpenGL.GL_LINES;

            if (gl != null)
                GenerateGeometry(gl, usage);
        }
        /// <summary>
        /// Applies the material to the shader if the "Parameters" are an implementation of "IMaterialShaderParameters".
        /// </summary>
        /// <param name="gl">The GL.</param>
        /// <param name="m">The material.</param>
        /// <param name="throwException">Property that sets whether it should throw an exception or just return when this shaderprogram doesn't implement the required interface.</param>
        public void ApplyMaterial(OpenGL gl, Material m, bool throwException = true)
        {
            // Test if the parameters implementing the required interface.
            if (!TypeTest(throwException, typeof(IMaterialShaderParameters)))
                return;

            var prms = Parameters as IMaterialShaderParameters;

            prms.ApplyMaterialParameters(gl, this, m);
        }
        public Axis(OpenGL gl, Material matX, Material matY, Material matZ, float lineWidth)
        {
            RecalculateShape(gl);

            LineX.Material = matX;
            LineY.Material = matY;
            LineZ.Material = matZ;

            LineX.LineWidth = lineWidth;
            LineY.LineWidth = lineWidth;
            LineZ.LineWidth = lineWidth;
        }
        public SquareGrid(OpenGL gl, int directionLineCount, float stepSize)
        {
            _directionLineCount = directionLineCount;
            _stepSize = stepSize;

            RecalculateShape();

            _gridLines = new LinesBase(gl, _lines);

            Material = new Material();
            Material.Ambient = new ColorF(255, 146, 134, 188); // Purple.
            Material.Shininess = 1f;
        }
        public static void ApplyMaterialParameters(OpenGL gl, ExtShaderProgram esp, Material m)
        {
            var p = esp.Program;
            var prms = esp.Parameters as IMaterialShaderParameters;

            var amb = m.Ambient;
            var diff = m.Diffuse;
            var spec = m.Specular;
            var shini = m.Shininess;
            var emit = m.Emission;

            if (prms.AmbientId != null && amb != null)
                p.SetUniform3(gl, prms.AmbientId, amb.R, amb.G, amb.B);
            if (prms.DiffuseId != null && diff != null)
                p.SetUniform3(gl, prms.DiffuseId, diff.R, diff.G, diff.B);
            if (prms.SpecularId != null && spec != null)
                p.SetUniform3(gl, prms.SpecularId, spec.R, spec.G, spec.B);
            if (prms.EmissionId != null && emit != null)
                p.SetUniform3(gl, prms.EmissionId, emit.R, emit.G, emit.B);
            if (prms.ShininessId != null)
                p.SetUniform1(gl, prms.ShininessId, shini);
        }
 public void ApplyAll(SharpGL.OpenGL gl, ExtShaderProgram esp, Material mat = null, Projection pr = null, ModelView mv = null, Normal nrml = null)
 {
 }