Ejemplo n.º 1
0
        public void UpdateVertexData(GLContext control)
        {
            CellSize   = (int)Runtime.GridSettings.CellSize;
            CellAmount = (int)Runtime.GridSettings.CellAmount;

            Vector3[]    vertices = Vertices;
            List <float> buffer   = new List <float>();

            for (int i = 0; i < vertices.Length; i++)
            {
                buffer.Add(vertices[i].X);
                buffer.Add(vertices[i].Y);
                buffer.Add(vertices[i].Z);
            }

            var data = buffer.ToArray();

            GL.BindBuffer(BufferTarget.ArrayBuffer, vbo_position);
            GL.BufferData <Vector3>(BufferTarget.ArrayBuffer,
                                    new IntPtr(data.Length * sizeof(float)),
                                    vertices, BufferUsageHint.StaticDraw);


            GLErrorHandler.CheckGLError();
        }
Ejemplo n.º 2
0
        public void UpdateVertexData()
        {
            Vector3[] vertices = new Vector3[3];
            vertices[0] = new Vector3(-1f, -1f, 1f);
            vertices[1] = new Vector3(3f, -1f, 1f);
            vertices[2] = new Vector3(-1f, 3f, 1f);

            GL.GenBuffers(1, out vbo_position);
            GL.BindBuffer(BufferTarget.ArrayBuffer, vbo_position);
            GL.BufferData <Vector3>(BufferTarget.ArrayBuffer,
                                    new IntPtr(vertices.Length * Vector3.SizeInBytes),
                                    vertices, BufferUsageHint.StaticDraw);

            vao = new VertexBufferObject(vbo_position);
            vao.AddAttribute(0, 3, VertexAttribPointerType.Float, false, 12, 0);
            vao.Initialize();

            Prepare();

            GLErrorHandler.CheckGLError();
        }