Example #1
0
    static Jypeli.JypeliWindow UglyHackToInstantiateJypeliWindow(XNA_Window gwin, XNA_GDM gdm)
    {
        ConstructorInfo jpwCtr = typeof(Jypeli.JypeliWindow).GetConstructor(
            BindingFlags.NonPublic | BindingFlags.Instance,
            null, new Type[] { typeof(XNA_Window), typeof(XNA_GDM) }, null);

        Jypeli.JypeliWindow jpw = (Jypeli.JypeliWindow)(jpwCtr.Invoke(new object[] { gwin, gdm }));
        return(jpw);
    }
Example #2
0
    static XNA_Window UglyHackToGetXNAGAmeWindowWithReflection(Jypeli.JypeliWindow win)
    {
        // Get value of an instance from the base class type (confused yet?)
        BindingFlags bindFlags = BindingFlags.Instance | BindingFlags.NonPublic;

        FieldInfo[] _fields = typeof(Jypeli.JypeliWindow).GetFields(bindFlags);
        Console.WriteLine("{0} fields:", _fields.Length);
        foreach (FieldInfo fi in _fields)
        {
            Console.WriteLine(fi.Name);
            if (fi.FieldType == typeof(XNA_Window))
            {
                return((XNA_Window)(fi.GetValue(win)));
            }
        }
        return(null);
    }
Example #3
0
    static void UglyHackToSwitchJypeliWindowWithReflection(Jypeli.JypeliWindow aawin)
    {
        BindingFlags flgs = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy |
                            BindingFlags.DeclaredOnly | BindingFlags.Static;

        FieldInfo[] _fields = typeof(Jypeli.Game).GetFields(flgs);
        Console.WriteLine("{0} fields:", _fields.Length);
        foreach (FieldInfo fi in _fields)
        {
            Console.WriteLine(fi.Name);
            if (fi.FieldType == typeof(Jypeli.JypeliWindow))
            {
                fi.SetValue(null, aawin);
                break;
                //property.GetSetMethod(true).Invoke(game, new object[] { antialiasedWindow });
            }
        }
    }
Example #4
0
    private static void TryToSwitchAntialiasingOn()
    {
        // The GDM creates the graphicsdevices for windows to draw. Gain access to it.
        XNA_GDM gdm = UglyHackToGetGraphicsDeviceManagerWithReflection();

        gdm.PreferMultiSampling = true;
        gdm.ApplyChanges();

        // Ok, now lets switch the Jypeli.Game.Window before anyone noitices!
        XNA_Window gwin = UglyHackToGetXNAGAmeWindowWithReflection(VRPGame.Window);

        Jypeli.JypeliWindow antialiasedWindow = UglyHackToInstantiateJypeliWindow(gwin, gdm);

        UglyHackToSwitchJypeliWindowWithReflection(antialiasedWindow);

        // TODO: If everything else works do this e.g. with more reflection
        //  http://stackoverflow.com/questions/660480/determine-list-of-event-handlers-bound-to-event
        //Window.Resizing += new JypeliWindow.ResizeEvent( WindowResized );
        //Window.Resized += new JypeliWindow.ResizeEvent( WindowResized );
    }