示例#1
0
 public SpriteMesh(IEnumerable <Sprite> sprites, Texture2D texture, BufferMode bufferMode)
 {
     _sprites = sprites.ToArray();
     Mesh     = new Mesh(_sprites.Length * 4, _sprites.Length * 6, texture, bufferMode);
     PrepareVertices();
     PrepareQuadIndices();
 }
示例#2
0
文件: Mesh.cs 项目: thomasvt/pose
 public Mesh(int vertexCapacity, int indexCapacity, Texture2D texture, BufferMode bufferMode)
 {
     Texture     = texture;
     BufferMode  = bufferMode;
     Vertices    = new VertexPositionColorTexture[vertexCapacity];
     Indices     = new int[indexCapacity];
     VertexCount = 0;
     IndexCount  = 0;
 }
示例#3
0
        /// <summary>
        /// Initialize this shader program object.
        /// </summary>
        /// <param name="feedbackVaryings"></param>
        /// <param name="mode"></param>
        /// <param name="shaders"></param>
        public void Initialize(string[] feedbackVaryings, BufferMode mode, params Shader[] shaders)
        {
            if (glTransformFeedbackVaryings == null)
            {
                glTransformFeedbackVaryings = GL.Instance.GetDelegateFor("glTransformFeedbackVaryings", GLDelegates.typeof_void_uint_int_stringN_uint) as GLDelegates.void_uint_int_stringN_uint;
            }
            glTransformFeedbackVaryings(this.ProgramId, 1, feedbackVaryings, (uint)mode);

            this.Initialize(shaders);
        }
示例#4
0
 /// <summary>To initialize this structure with default value, use this constructor. The argument value is ignored.</summary>
 /// <remarks>This is only here because C# doesn’t support parameterless constructors for structures.</remarks>
 public BufferDesc(bool unused)
 {
     baseStruct        = new DeviceObjectAttribs(true);
     uiSizeInBytes     = 0;
     BindFlags         = BindFlags.None;
     Usage             = Usage.Default;
     CPUAccessFlags    = CpuAccessFlags.None;
     Mode              = BufferMode.Undefined;
     ElementByteStride = 0;
     CommandQueueMask  = 1;
 }
示例#5
0
 /// <summary>
 /// Конструктор буфера
 /// </summary>
 /// <param name="capacity"></param>
 /// <param name="mode"></param>
 public CircularBuffer(int capacity = 7, BufferMode mode = BufferMode.Wait)
 {
     if (capacity <= 0)
     {
         Capacity = 7;
     }
     else
     {
         Capacity = capacity;
     }
     Mode       = mode;
     _buffer    = new T[capacity];
     _freeIndex = _buffer.Length - 1; //Свободная ячейка указаывает на последний элемент массива
     _headIndex = -1;                 //Голова ни на что не указывает, т.к. нет значения
 }
示例#6
0
        internal void ValidateBufferUsageGPU(Validation.ValidationContext result, BufferMode usingMode)
        {
            result = result.GetContext(this);

            if (!this._target.HasValue)
            {
                return;
            }
            if (usingMode == this._target.Value)
            {
                return;
            }

            result.AddLinkError("Device Buffer Target", $"is set as {this._target.Value}. But an accessor wants to use it as '{usingMode}'.");
        }
示例#7
0
        public void Startup(BufferMode mode)
        {
            _mode = mode;
            if (mode == BufferMode.Read)
            {
                int length = 0;
                _readStream.Seek(0, System.IO.SeekOrigin.Begin);
                _reader.Read(ref length);

                /*
                 * skip the first length data
                 * do has some way to set reader data length limit?
                 */
                _writeStream.Seek(0, System.IO.SeekOrigin.End);
            }
            else
            {
                _writeStream.Seek(0, System.IO.SeekOrigin.Begin);
                _readStream.Seek(0, System.IO.SeekOrigin.End);
                // prepare read size
                _writer.Write((int)4);
            }
        }
示例#8
0
        public ER ReceiveDataNblk(pointer p_data, int len)
        {
            int result = 0;

            if (p_data == null)
            {
                return(ER.E_PAR);
            }

            if ((m_RecvMode != BufferMode.None) && (m_RecvMode != BufferMode.NormalCopy))
            {
                return(ER.E_OBJ);
            }

            result = CopyRecvData(p_data, len);
            if (result == 0)
            {
                return(ER.E_WBLK);
            }

            m_RecvMode = BufferMode.NormalCopy;

            return((ER)result);
        }
示例#9
0
        public ER SendData(pointer p_data, int len, TMO tmout)
        {
            int result = 0;
            ER  ret;

            if (p_data == null)
            {
                return(ER.E_PAR);
            }

            if ((m_SendMode != BufferMode.None) && (m_SendMode != BufferMode.NormalCopy))
            {
                return(ER.E_OBJ);
            }

            Task task = m_Nucleus.GetTask(ID.TSK_SELF);

            if ((tmout != 0) && (task == null))
            {
                return(ER.E_CTX);
            }

            int space = tcp.tcp_sndbuf(m_TPcb);

            if ((m_SendPBuf == null) && (space >= len))
            {
                m_SendPBuf = p_data;
                m_SendPos  = 0;
                m_SendLen  = len;
                SentData(this, m_TPcb, (ushort)space);
            }
            else
            {
                if (task == null)
                {
                    return(ER.E_TMOUT);
                }

                if (tmout == 0)
                {
                    return(ER.E_TMOUT);
                }

                ret = task.Wait(m_SendTaskQueue, TSKWAIT.TTW_TCP, m_CepID, tmout);

                switch (ret)
                {
                case ER.E_OK:
                    if (m_SendPBuf != null)
                    {
                        return(ER.E_RLWAI);
                    }

                    m_SendPBuf = p_data;
                    m_SendPos  = 0;
                    m_SendLen  = len;
                    SentData(this, m_TPcb, tcp.tcp_sndbuf(m_TPcb));
                    break;

                case ER.E_TMOUT:
                    return(ER.E_TMOUT);

                default:
                    return(ER.E_RLWAI);
                }
            }

            m_SendMode = BufferMode.NormalCopy;

            return((ER)result);
        }
示例#10
0
        public static void Start(int RunTimeMs = 2000, int Readings = 0, BufferMode Mode = BufferMode.Fill)
        {
            if (Status != InitMode.Configured)
            {
                throw new Exception("Pru1Aio must be configured prior to operation.");
            }

            lock (Pru1Aio.Locker)
            {
                Pru1Aio.Mode      = Mode;
                Pru1Aio.RunTimeMs = RunTimeMs;
                RunLimit          = false;

                unsafe
                {
                    if (Readings % PruMemory->Control.BufferSize != 0)
                    {
                        throw new Exception("Readings must be a multiple of the buffer size.  Inter-buffer reading limits are not supported.");
                    }

                    if (Pru1Aio.Mode == BufferMode.Fill || RunTimeMs > 0)
                    {
                        RunLimit = true;
                        if (RunTimeMs == 0 && Readings == 0)
                        {
                            Pru1Aio.pru_rta_stop_capture(PruMemory);
                            Pru1Aio.pru_rta_clear_pru((int)PRU_NUM.PRU1);
                            Pru1Aio.pru_rta_clear_pru((int)PRU_NUM.PRU0);
                            return;
                        }
                        if (RunTimeMs > 0 && Readings == 0)
                        {
                            //Pru1Aio._Buffer = new Pru1AioReading[RunTimeMs / 1000 * PruMemory->Control.SampleRate];
                            Pru1Aio._Buffer = Pru1Aio.InitializeArray <Reading>((int)(RunTimeMs / 1000 * PruMemory->Control.SampleRate));
                            _Calls          = (int)(PruMemory->Control.SampleRate / PruMemory->Control.BufferSize * RunTimeMs / 1000);
                        }
                        else if (RunTimeMs == 0 && Readings > 0)
                        {
                            //Pru1Aio._Buffer = new Pru1AioReading[Readings];
                            Pru1Aio._Buffer = Pru1Aio.InitializeArray <Reading>((int)(Readings));
                            _Calls          = Readings / PruMemory->Control.BufferSize;
                        }
                        else if (RunTimeMs > 0 && Readings > 0)
                        {
                            //Pru1Aio._Buffer = new Pru1AioReading[Readings];
                            Pru1Aio._Buffer = Pru1Aio.InitializeArray <Reading>((int)(Readings));
                            _Calls          = (int)(PruMemory->Control.SampleRate / PruMemory->Control.BufferSize * RunTimeMs / 1000);
                        }
                    }
                    else if (Pru1Aio.Mode == BufferMode.Ring)
                    {
                        //Pru1Aio._Buffer = new Pru1AioReading[Readings];
                        Pru1Aio._Buffer  = Pru1Aio.InitializeArray <Reading>((int)(Readings));
                        Pru1Aio.RunLimit = false;
                    }

                    _DroppedBuffers = new List <int>();

                    Pru1Aio.pru_rta_configure(&(PruMemory->Control));

                    Pru1Aio.pru_rta_start_firmware();

                    Signals      = 0;
                    _IsCapturing = true;
                    _Status      = InitMode.Running;
                    MessageInvoker(MessageType.Start, new Reading(), 0, 0);
                    Pru1Aio.pru_rta_start_capture(PruMemory, CaptureBuffer, CallState, AsynchCall);
                }
            }
        }
 public SfmlAudioInitializerArgs(string key, BufferMode bufferMode) : base(key)
 {
     this.BufferMode = bufferMode;
 }
示例#12
0
        public ER GetBuffer(ref pointer p_data, TMO tmout)
        {
            int result;
            ER  ret;

            //if (p_data == null)
            //	return ER.E_PAR;

            if ((m_SendMode != BufferMode.None) && (m_SendMode != BufferMode.ReduceCopy))
            {
                return(ER.E_OBJ);
            }

            Task task = m_Nucleus.GetTask(ID.TSK_SELF);

            if ((tmout != 0) && (task == null))
            {
                return(ER.E_CTX);
            }

            // リングバッファが空っぽかループしている場合
            if (m_RCSendWrPos <= m_RCSendRdPos)
            {
                result = m_RCSendData.Length - 1 - m_RCSendWrPos;
            }
            // リングバッファのループしていない区間
            else
            {
                result = m_RCSendWrPos - m_RCSendRdPos;
            }

            if ((m_SendTaskQueue.First == null) && (result != 0))
            {
                p_data = new pointer(m_RCSendData, m_RCSendWrPos);
            }
            else
            {
                if (task == null)
                {
                    return(ER.E_TMOUT);
                }

                if (tmout == 0)
                {
                    return(ER.E_TMOUT);
                }

                ret = task.Wait(m_SendTaskQueue, TSKWAIT.TTW_TCP, m_CepID, tmout);

                switch (ret)
                {
                case ER.E_OK:
                    // リングバッファが空っぽかループしている場合
                    if (m_RCSendWrPos <= m_RCSendRdPos)
                    {
                        result = m_RCSendData.Length - 1 - m_RCSendWrPos;
                    }
                    // リングバッファのループしていない区間
                    else
                    {
                        result = m_RCSendWrPos - m_RCSendRdPos;
                    }
                    if (result == 0)
                    {
                        return(ER.E_RLWAI);
                    }
                    p_data = new pointer(m_RCSendData, m_RCSendWrPos);
                    break;

                case ER.E_TMOUT:
                    return(ER.E_TMOUT);

                default:
                    return(ER.E_RLWAI);
                }
            }

            m_SendMode = BufferMode.ReduceCopy;

            return((ER)result);
        }
示例#13
0
        public ER ReceiveBuffer(ref pointer p_data, TMO tmout)
        {
            int result = 0;
            ER  ret;

            if (p_data == null)
            {
                return(ER.E_PAR);
            }

            if ((m_RecvMode != BufferMode.None) && (m_RecvMode != BufferMode.ReduceCopy))
            {
                return(ER.E_OBJ);
            }

            Task task = m_Nucleus.GetTask(ID.TSK_SELF);

            if ((tmout != 0) && (task == null))
            {
                return(ER.E_CTX);
            }

            if ((m_RecvTaskQueue.First == null) && (m_RecvPBuf != null || m_RecvDataQueue.Count != 0))
            {
                p_data = new pointer(m_RecvPBufPos.payload, m_RecvPos);
                result = m_RecvPBufPos.len - m_RecvPos;
            }
            else
            {
                if (task == null)
                {
                    return(ER.E_TMOUT);
                }

                if (tmout == 0)
                {
                    return(ER.E_TMOUT);
                }

                ret = task.Wait(m_RecvTaskQueue, TSKWAIT.TTW_TCP, m_CepID, tmout);

                switch (ret)
                {
                case ER.E_OK:
                    if (m_RecvDataQueue.Count == 0)
                    {
                        return(ER.E_RLWAI);
                    }
                    p_data = new pointer(m_RecvPBufPos.payload, m_RecvPos);
                    result = m_RecvPBufPos.len - m_RecvPos;
                    break;

                case ER.E_TMOUT:
                    return(ER.E_TMOUT);

                default:
                    return(ER.E_RLWAI);
                }
            }

            m_RecvMode = BufferMode.ReduceCopy;

            return((ER)result);
        }
示例#14
0
 /// <summary>
 /// Create a Sound that contains audio samples.
 /// </summary>
 /// <param name="filename">The path of audio file.</param>
 /// <param name="mode">Specifies a value indicating whether the whole buffer should be filled immediately or streamed later.</param>
 /// <returns>A sound buffer of given <see cref="Stream"/>.</returns>
 public Sound LoadSound(string filename, BufferMode mode = BufferMode.Sample)
 {
     return(LoadSound(File.Open(filename, FileMode.Open, FileAccess.Read), mode));
 }
示例#15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Sound"/> class from an array of byte containing audio data.
 /// </summary>
 /// <param name="data">An array of bytes containing audio data.</param>
 /// <param name="mode">Specifies a value indicating whether the whole buffer should be filled immediately or streamed later.</param>
 /// <inheritdoc/>
 internal Sound(byte[] data, BufferMode mode)
     : this(new MemoryStream(data), mode)
 {
 }
示例#16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Sound"/> class from a file.
 /// </summary>
 /// <param name="filename">Path of the audio file.</param>
 /// <param name="mode">Specifies a value indicating whether the whole buffer should be filled immediately or streamed later.</param>
 /// <inheritdoc/>
 internal Sound(string filename, BufferMode mode)
     : this(File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read), mode)
 {
 }
示例#17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Sound"/> class from an audio stream.
 /// </summary>
 /// <param name="stream"><see cref="Stream"/> containing audio data.</param>
 /// <param name="mode">Specifies a value indicating whether the whole buffer should be filled immediately or streamed later.</param>
 /// <inheritdoc/>
 internal Sound(Stream stream, BufferMode mode)
     : this()
 {
     Mode = mode;
     Initialize(new SoundDecoder(stream));
 }
示例#18
0
 /// <summary>
 /// Create a Sound that contains audio samples.
 /// </summary>
 /// <param name="stream"><see cref="Stream"/> that contains audio samples.</param>
 /// <param name="mode">Specifies a value indicating whether the whole buffer should be filled immediately or streamed later.</param>
 /// <returns>A sound buffer of given <see cref="Stream"/>.</returns>
 public Sound LoadSound(Stream stream, BufferMode mode = BufferMode.Sample)
 {
     return(new Sound(stream, mode));
 }
示例#19
0
 /// <summary>
 /// Create a Sound that contains audio samples.
 /// </summary>
 /// <param name="buffer">An array of bytes that contains audio samples.</param>
 /// <param name="mode">Specifies a value indicating whether the whole buffer should be filled immediately or streamed later.</param>
 /// <returns>A sound buffer of given <see cref="Stream"/>.</returns>
 public Sound LoadSound(byte[] buffer, BufferMode mode = BufferMode.Sample)
 {
     return(LoadSound(new MemoryStream(buffer), mode));
 }