Exemplo n.º 1
0
        public MiniTriSample()
        {
            this.Window.Title = "Samurai Mini Tri Sample";

            this.Graphics.ClearColor = Color4.CornflowerBlue;

            //this.vertexBuffer = new StaticVertexBuffer<Vertex>(this.Graphics, verticies);

            VertexElement[] elements = new VertexElement[]
            {
                new VertexElement(VertexElementType.Float, 3, 0, 12),
                new VertexElement(VertexElementType.Float, 4, 36, 16)
            };

            using (DataBuffer data = DataBuffer.Create(verticies))
            {
                this.vertexBuffer = new StaticVertexBuffer(this.Graphics, elements, data);
            }

            this.shaderProgram = new ShaderProgram(this.Graphics,
                VertexShader.Compile(this.Graphics, vertexShaderCode),
                FragmentShader.Compile(this.Graphics, fragmentShaderCode)
            );

            this.Graphics.ShaderProgram = this.shaderProgram;
        }
Exemplo n.º 2
0
 internal void SetVertexDescription(VertexElement[] elements)
 {
     for (int i = 0; i < elements.Length; i++)
     {
         this.Graphics.GL.EnableVertexAttribArray((uint)i);
         this.Graphics.GL.VertexAttribPointer((uint)i, elements[i].Count, (uint)elements[i].Type, true, elements[i].Stride, (IntPtr)elements[i].Offset);
     }
 }
Exemplo n.º 3
0
        public DynamicVertexBuffer(GraphicsContext graphics, VertexElement[] vertexElements)
            : base(graphics)
        {
            if (vertexElements == null)
                throw new ArgumentNullException("vertexElements");

            this.SetVertexDescription(vertexElements);
        }
Exemplo n.º 4
0
        public StaticVertexBuffer(GraphicsContext graphics, VertexElement[] vertexElements, DataBuffer data)
            : base(graphics)
        {
            if (vertexElements == null)
                throw new ArgumentNullException("vertexElements");

            this.SetVertexDescription(vertexElements);
            this.SetDataInternal(data, 0, data.Length, GLContext.StaticDraw);
        }