public BasicShadedColoredMaterial()
        {
            var vertexShader = new GlShader(ShaderType.VertexShader);

            vertexShader.LoadSource(VertexShaderSource);

            var fragmentShader = new GlShader(ShaderType.FragmentShader);

            fragmentShader.LoadSource(FragmentShaderSource);

            Bind();
            LoadShader(vertexShader);
            LoadShader(fragmentShader);
            Link();

            PositionBuffer = new GlBuffer(BufferTarget.ArrayBuffer);
            PositionBuffer.Bind();

            NormalBuffer = new GlBuffer(BufferTarget.ArrayBuffer);
            NormalBuffer.Bind();

            ColorBuffer = new GlBuffer(BufferTarget.ArrayBuffer);
            ColorBuffer.Bind();

            MatrixBuffer = new GlBuffer(BufferTarget.ArrayBuffer);
            MatrixBuffer.Bind();

            var positionBufferLayout = new GlBufferLayout();

            positionBufferLayout.Add(VertexAttribPointerType.Float, 3); //Vector3 3 floats

            var normalBufferLayout = new GlBufferLayout();

            normalBufferLayout.Add(VertexAttribPointerType.Float, 3);

            var colorBufferLayout = new GlBufferLayout();

            colorBufferLayout.Add(VertexAttribPointerType.Float, 4);

            var matrixBufferLayout = new GlBufferLayout();

            matrixBufferLayout.Add(VertexAttribPointerType.Float, 4, divisor: 1); //Matrix 16 floats
            matrixBufferLayout.Add(VertexAttribPointerType.Float, 4, divisor: 1);
            matrixBufferLayout.Add(VertexAttribPointerType.Float, 4, divisor: 1);
            matrixBufferLayout.Add(VertexAttribPointerType.Float, 4, divisor: 1);

            VertexArray = new GlVertexArray();
            VertexArray.AddBuffer(PositionBuffer, positionBufferLayout);
            VertexArray.AddBuffer(NormalBuffer, normalBufferLayout);
            VertexArray.AddBuffer(ColorBuffer, colorBufferLayout);
            VertexArray.AddBuffer(MatrixBuffer, matrixBufferLayout);
        }
Exemplo n.º 2
0
        public int AddVertexPool(VertexPool vertexPool)
        {
            int newIndex = 0;

            while (_vertexPools.ContainsKey(newIndex))
            {
                newIndex++;
            }

            _vertexPools.Add(newIndex, GlVertexArray.FromVertexPool(_Program, vertexPool));

            return(newIndex);
        }