コード例 #1
0
        /// <summary>
        /// Explicit operator to convert this view into its attached index buffer.
        /// </summary>
        /// <param name="view">View to convert.</param>
        /// <returns>The attached buffer.</returns>
        /// <exception cref="System.InvalidCastException">Thrown when the buffer is not a index buffer.</exception>
        public static GorgonIndexBuffer ToIndexBuffer(GorgonBufferShaderView view)
        {
            if (view._indexBuffer == null)
            {
                throw new InvalidCastException(string.Format(Resources.GORGFX_VIEW_RESOURCE_NOT_BUFFER, "index"));
            }

            return(view._indexBuffer);
        }
コード例 #2
0
ファイル: GorgonViewCache.cs プロジェクト: tmp7701/Gorgon
        /// <summary>
        /// Function to retrieve a buffer view.
        /// </summary>
        /// <param name="format">Format of the view.</param>
        /// <param name="start">Starting element for the view.</param>
        /// <param name="count">Number of elements for the view.</param>
        /// <param name="isRaw">TRUE for raw buffers, FALSE for standard.</param>
        /// <returns>The cached buffer shader view.</returns>
        public GorgonBufferShaderView GetBufferView(BufferFormat format, int start, int count, bool isRaw)
        {
            var key = new ViewKey(format, start, count, Convert.ToInt32(isRaw), 0);

            lock (_syncLock)
            {
                GorgonBufferShaderView result;

                if (_bufferViews.TryGetValue(key, out result))
                {
                    return(result);
                }

                result = new GorgonBufferShaderView(_resource, format, start, count, isRaw);

                result.Initialize();
                _bufferViews.Add(key, result);

                return(result);
            }
        }