Пример #1
0
        private void init(IDisposableResource parent, IBufferLayoutDesc bufferLayoutDesc, BufferUsages usage, VertexBufferTopologys topology, float[] vertices, int[] indices)
        {
            try
            {
                var video = parent.FindParentOrSelfWithException <Video>();

                this.topology = topology;
                REIGN_D3DPRIMITIVETYPE topologyType = REIGN_D3DPRIMITIVETYPE.TRIANGLELIST;
                switch (topology)
                {
                case VertexBufferTopologys.Triangle: topologyType = REIGN_D3DPRIMITIVETYPE.TRIANGLELIST; break;

                case VertexBufferTopologys.Line: topologyType = REIGN_D3DPRIMITIVETYPE.LINELIST; break;

                case VertexBufferTopologys.Point: topologyType = REIGN_D3DPRIMITIVETYPE.POINTLIST; break;
                }

                com = new VertexBufferCom(video.com, topologyType);
                var error = com.Init(vertices, REIGN_D3DUSAGE.WRITEONLY, vertexCount, vertexByteSize);
                if (error == VertexBufferErrors.VertexBuffer)
                {
                    Debug.ThrowError("VertexBuffer", "Failed to create VertexBuffer");
                }

                if (indices != null && indices.Length != 0)
                {
                    indexBuffer = new IndexBuffer(this, usage, indices);
                }
            }
            catch (Exception e)
            {
                Dispose();
                throw e;
            }
        }
Пример #2
0
 public override void Dispose()
 {
     disposeChilderen();
     if (com != null)
     {
         com.Dispose();
         com = null;
     }
     base.Dispose();
 }
Пример #3
0
 public override void Dispose()
 {
     disposeChilderen();
     if (com != null)
     {
         com.Dispose();
         com = null;
     }
     base.Dispose();
 }
Пример #4
0
        private void init(IDisposableResource parent, IBufferLayoutDesc bufferLayoutDesc, BufferUsages usage, VertexBufferTopologys topology, float[] vertices, int[] indices)
        {
            try
            {
                var video = parent.FindParentOrSelfWithException <Video>();

                this.topology = topology;
                REIGN_D3D_PRIMITIVE_TOPOLOGY topologyType = REIGN_D3D_PRIMITIVE_TOPOLOGY.TRIANGLELIST;
                switch (topology)
                {
                case VertexBufferTopologys.Triangle: topologyType = REIGN_D3D_PRIMITIVE_TOPOLOGY.TRIANGLELIST; break;

                case VertexBufferTopologys.Line: topologyType = REIGN_D3D_PRIMITIVE_TOPOLOGY.LINELIST; break;

                case VertexBufferTopologys.Point: topologyType = REIGN_D3D_PRIMITIVE_TOPOLOGY.POINTLIST; break;
                }

                com = new VertexBufferCom(video.com, topologyType);
                var bufferUsage = (usage == BufferUsages.Write) ? REIGN_D3D11_USAGE.DYNAMIC : REIGN_D3D11_USAGE.DEFAULT;
                var cpuUsage    = (usage == BufferUsages.Write) ? REIGN_D3D11_CPU_ACCESS_FLAG.WRITE : (REIGN_D3D11_CPU_ACCESS_FLAG)0;
                var error       = com.Init(vertices, vertexCount, vertexByteSize, bufferUsage, cpuUsage);
                if (error == VertexBufferErrors.Buffer)
                {
                    Debug.ThrowError("VertexBuffer", "Failed to create Buffer");
                }

                if (indices != null && indices.Length != 0)
                {
                    indexBuffer = new IndexBuffer(this, usage, indices);
                }
            }
            catch (Exception e)
            {
                Dispose();
                throw e;
            }
        }
Пример #5
0
        private void init(IDisposableResource parent, IBufferLayoutDesc bufferLayoutDesc, BufferUsages usage, VertexBufferTopologys topology, float[] vertices, int[] indices)
        {
            try
            {
                var video = parent.FindParentOrSelfWithException<Video>();

                this.topology = topology;
                REIGN_D3D_PRIMITIVE_TOPOLOGY topologyType = REIGN_D3D_PRIMITIVE_TOPOLOGY.TRIANGLELIST;
                switch (topology)
                {
                    case VertexBufferTopologys.Triangle: topologyType = REIGN_D3D_PRIMITIVE_TOPOLOGY.TRIANGLELIST; break;
                    case VertexBufferTopologys.Line: topologyType = REIGN_D3D_PRIMITIVE_TOPOLOGY.LINELIST; break;
                    case VertexBufferTopologys.Point: topologyType = REIGN_D3D_PRIMITIVE_TOPOLOGY.POINTLIST; break;
                }

                com = new VertexBufferCom(video.com, topologyType);
                var bufferUsage = (usage == BufferUsages.Write) ? REIGN_D3D11_USAGE.DYNAMIC : REIGN_D3D11_USAGE.DEFAULT;
                var cpuUsage = (usage == BufferUsages.Write) ? REIGN_D3D11_CPU_ACCESS_FLAG.WRITE : (REIGN_D3D11_CPU_ACCESS_FLAG)0;
                var error = com.Init(vertices, vertexCount, vertexByteSize, bufferUsage, cpuUsage);
                if (error == VertexBufferErrors.Buffer) Debug.ThrowError("VertexBuffer", "Failed to create Buffer");

                if (indices != null && indices.Length != 0) indexBuffer = new IndexBuffer(this, usage, indices);
            }
            catch (Exception e)
            {
                Dispose();
                throw e;
            }
        }
Пример #6
0
        private void init(IDisposableResource parent, IBufferLayoutDesc bufferLayoutDesc, BufferUsages usage, VertexBufferTopologys topology, float[] vertices, int[] indices)
        {
            try
            {
                var video = parent.FindParentOrSelfWithException<Video>();

                this.topology = topology;
                REIGN_D3DPRIMITIVETYPE topologyType = REIGN_D3DPRIMITIVETYPE.TRIANGLELIST;
                switch (topology)
                {
                    case VertexBufferTopologys.Triangle: topologyType = REIGN_D3DPRIMITIVETYPE.TRIANGLELIST; break;
                    case VertexBufferTopologys.Line: topologyType = REIGN_D3DPRIMITIVETYPE.LINELIST; break;
                    case VertexBufferTopologys.Point: topologyType = REIGN_D3DPRIMITIVETYPE.POINTLIST; break;
                }

                com = new VertexBufferCom(video.com, topologyType);
                var error = com.Init(vertices, REIGN_D3DUSAGE.WRITEONLY, vertexCount, vertexByteSize);
                if (error == VertexBufferErrors.VertexBuffer) Debug.ThrowError("VertexBuffer", "Failed to create VertexBuffer");

                if (indices != null && indices.Length != 0) indexBuffer = new IndexBuffer(this, usage, indices);
            }
            catch (Exception e)
            {
                Dispose();
                throw e;
            }
        }