开发者

IronPython: Trouble building a WPF ShaderEffect

I'm trying to build an extensible program where users, among other things, can build their own shader effects.

Google searching got me this far;

class Test(ShaderEffect):
    inputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", type(Test()), 0)

But I still get the error;

TypeError: cannot access protected member RegisterPixelShaderSamplerProperty without a python subclass of ShaderEffect.

Any help would be greatly appreciat开发者_StackOverflow社区ed.

The best source on the net I could find is linked here


You will need to use Reflection to access protected memeber of .NET class - you don't have a Python subclass where you can access such member directly.

Try somethink like this (I have't tested it):

inputPropertyType = ShaderEffect.GetType().GetMember(
    'RegisterPixelShaderSamplerProperty',
    BindingFlags.Instance | BindingFlags.NonPublic)
inputProperty = inputPropertyType.GetValue(ShaderEffect, None)
inputProperty("Input", type(Test()), 0)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜