Ejemplo n.º 1
0
        public Shape()
        {
            MatrixGroups = new List <MatrixGroup>();

            VertexDescription = new VertexDescription();
            ShapeMaterial     = null;

            VertexData = new MeshVertexHolder();
            Indices    = new List <int>();
        }
Ejemplo n.º 2
0
        private void UploadBufferToGPU <T>(ShaderAttributeIds attribute, T[] data) where T : struct
        {
            // See if this attribute is already enabled. If it's not already enabled, we need to generate a buffer for it.
            if (!VertexDescription.AttributeIsEnabled(attribute))
            {
                VertexDescription.EnableAttribute(attribute);
            }

            // Bind the buffer before updating the data.
            GL.BindBuffer(BufferTarget.ArrayBuffer, VertexDescription.GetAttributeBufferId(attribute));

            // Finally, update the data.
            int stride = VertexDescription.GetStride(attribute);

            GL.BufferData <T>(BufferTarget.ArrayBuffer, (IntPtr)(data.Length * stride), data, BufferUsageHint.StaticDraw);
        }
Ejemplo n.º 3
0
            public void Bind()
            {
                for (int i = 0; i < m_glBufferIndexes.Length; i++)
                {
                    ShaderAttributeIds id = (ShaderAttributeIds)i;
                    if (VertexDescription.AttributeIsEnabled(id))
                    {
                        GL.BindBuffer(BufferTarget.ArrayBuffer, m_glBufferIndexes[i]);
                        GL.EnableVertexAttribArray(i);
                        GL.VertexAttribPointer(i, VertexDescription.GetAttributeSize(id), VertexDescription.GetAttributePointerType(id), false, VertexDescription.GetStride(id), 0);
                    }
                }

                // Bind the Element Array Buffer as well
                GL.BindBuffer(BufferTarget.ElementArrayBuffer, m_glIndexBuffer);
            }
Ejemplo n.º 4
0
            public Shape()
            {
                Attributes        = new List <ShapeVertexAttribute>();
                VertexData        = new MeshVertexHolder();
                Indexes           = new List <int>();
                VertexDescription = new VertexDescription();
                MatrixDataTable   = new List <SkinDataTable>();
                OverrideVertPos   = new List <Vector3>();
                OverrideNormals   = new List <Vector3>();

                m_glBufferIndexes = new int[15];
                for (int i = 0; i < m_glBufferIndexes.Length; i++)
                {
                    m_glBufferIndexes[i] = -1;
                }

                m_glIndexBuffer = GL.GenBuffer();
            }
Ejemplo n.º 5
0
        protected virtual void Dispose(bool manualDispose)
        {
            if (!m_hasBeenDisposed)
            {
                if (manualDispose)
                {
                    // TODO: dispose managed state (managed objects).
                }

                // Set large fields to null.
                VertexData = null;

                VertexDescription.Dispose();
                VertexDescription = null;

                Indices = null;

                m_hasBeenDisposed = true;
            }
        }