コード例 #1
0
        /// <summary>
        /// Performs a deep copy of this <see cref="IGraphicsState"/>.
        /// </summary>
        /// <returns>
        /// It returns the equivalent of this <see cref="IGraphicsState"/>, but all objects referenced
        /// are not referred by both instances.
        /// </returns>
        public override IGraphicsState Push()
        {
            ShaderUniformStateBase copiedState = (ShaderUniformStateBase)base.Push();

            if (copiedState._UniformBuffer != null)
            {
                copiedState._UniformBuffer.IncRef();
            }

#if ENABLE_REFS_ON_COPY
            foreach (KeyValuePair <string, UniformStateMember> pair in copiedState.UniformState)
            {
                //if (pair.Value.GetUniformType().GetInterface("IGraphicsResource") == null)
                //	continue;

                IGraphicsResource graphicsResource = pair.Value.GetUniformValue(this) as IGraphicsResource;
                if (graphicsResource == null)
                {
                    continue;
                }

                // Copied share references
                graphicsResource.IncRef();
            }
#endif

            return(copiedState);
        }
コード例 #2
0
        /// <summary>
        /// Merge this state with another one.
        /// </summary>
        /// <param name="state">
        /// A <see cref="IGraphicsState"/> having the same <see cref="StateIdentifier"/> of this state.
        /// </param>
        public override void Merge(IGraphicsState state)
        {
            if (state == null)
            {
                throw new ArgumentNullException("state");
            }

            ShaderUniformStateBase otherState = state as ShaderUniformStateBase;

            if (otherState == null)
            {
                throw new ArgumentException("not a ShaderUniformState", "state");
            }
        }