Example #1
0
        private void CreateNativeBinding(out NativeBinding result)
        {
            var pUnboxedEffect = Effect.GetUnboxedID3DXEffect();

            result = default(NativeBinding);

            var pGetParameterByName = COMUtils.GetMethodFromVTable <DGetParameterByName>(
                pUnboxedEffect, KnownMethodSlots.GetParameterByName
                );

            var hParameter = pGetParameterByName(pUnboxedEffect, null, Name);

            if (hParameter == null)
            {
                throw new Exception("Could not find d3dx parameter for uniform " + Name);
            }

            var layout = new Layout(Type, pUnboxedEffect, hParameter);

            result = new NativeBinding {
                pUnboxedEffect = pUnboxedEffect,
                hParameter     = hParameter,
                Fixups         = layout.Fixups,
                UploadSize     = layout.UploadSize
            };

            result.pSetRawValue = COMUtils.GetMethodFromVTable <DSetRawValue>(result.pUnboxedEffect, KnownMethodSlots.SetRawValue);

            result.IsValid = true;
        }
Example #2
0
            private void FixupMembers(List <Fixup> fixups, Type type, void *hParameter, int sourceOffset, ref uint uploadSize)
            {
                uploadSize = 0;

                D3DXPARAMETER_DESC desc;
                var pGetParameter     = COMUtils.GetMethodFromVTable <DGetParameter>(pUnboxedEffect, KnownMethodSlots.GetParameter);
                var pGetParameterDesc = COMUtils.GetMethodFromVTable <DGetParameterDesc>(pUnboxedEffect, KnownMethodSlots.GetParameterDesc);

                for (uint i = 0; i < 999; i++)
                {
                    var hMember = pGetParameter(pUnboxedEffect, hParameter, i);
                    if (hMember == null)
                    {
                        break;
                    }

                    pGetParameterDesc(pUnboxedEffect, hMember, out desc);

                    FixupMember(fixups, hMember, type, 0, ref desc, ref uploadSize);
                }
            }