Exemplo n.º 1
0
        public static ParameterInfo GetParameter(
            this ID3DXEffectCompiler compiler,
            IntPtr targetHandle,
            int paramIndex)
        {
            VerifyNonNullArgument(
                compiler,
                "compiler");

            var paramHandle = compiler.GetParameter(
                targetHandle,
                (uint)paramIndex);
            var paramDesc_ = compiler.GetParameterDesc(paramHandle);

            if (!paramDesc_.HasValue)
            {
                return(null);
            }

            var paramDesc   = paramDesc_.Value;
            var annotations =
                from annotationIndex in Enumerable.Range(
                    0,
                    (int)paramDesc.Annotations)
                let annotationHandle = compiler.GetAnnotation(
                    paramHandle,
                    (uint)annotationIndex)
                                       let annotation =
                    annotationHandle == IntPtr.Zero
                  ? String.Empty
                  : Marshal.PtrToStringAnsi(annotationHandle)
                    select annotation;

            return(new ParameterInfo
            {
                Annotations = annotations.ToArray(),
                Bytes = (int)paramDesc.Bytes,
                Class = paramDesc.Class.ToParameterClass(),
                Columns = (int)paramDesc.Columns,
                Elements = (int)paramDesc.Elements,
                Flags = paramDesc.Flags.ToParameterFlags(),
                Name = paramDesc.Name.ReadAsAnsiString(),
                Rows = (int)paramDesc.Rows,
                Semantic = paramDesc.Semantic.ReadAsAnsiString(),
                StructMembers = (int)paramDesc.StructMembers,
                Type = paramDesc.Type.ToParameterType(),
            });
        }
Exemplo n.º 2
0
        public static D3DXPARAMETER_DESC?GetParameterDesc(
            this ID3DXEffectCompiler compiler,
            IntPtr parameterHandle)
        {
            VerifyNonNullArgument(
                compiler,
                "compiler");

            var desc = default(D3DXPARAMETER_DESC);

            return(Succeeded(
                       compiler.GetParameterDesc(
                           parameterHandle,
                           out desc))
                   ? (D3DXPARAMETER_DESC?)desc
                   : null);
        }