Ejemplo n.º 1
0
        public void SetUniformMatrix(string name, bool transpose, dynamic data)
        {
            Activate();

            Type type = data.GetType();

            if (!uniformLocations.ContainsKey(name))
            {
                uniformLocations.Add(name, GL.GetUniformLocation(shaderProgramHandle, name));
            }

            uniformData[name] = data;

            if (uniformMethods.ContainsKey(type))
            {
                uniformMethods[type](null, new object[] { uniformLocations[name], transpose, data });
            }
            else
            {
                foreach (string methodName in uniformSetMethodsMatrix)
                {
                    Type[]     argTypes   = new Type[] { typeof(int), typeof(bool), data.GetType().MakeByRefType() };
                    MethodInfo methodInfo = typeof(GL).GetMethod(methodName, argTypes);

                    if (methodInfo != null)
                    {
                        uniformMethods[type] = FastMethodInvoker.GetMethodInvoker(methodInfo);
                        uniformMethods[type](null, new object[] { uniformLocations[name], transpose, data });
                        return;
                    }
                }

                throw new Exception("No UniformMatrix method found");
            }
        }
Ejemplo n.º 2
0
        public void SetUniform(string name, dynamic data)
        {
            Activate();

            Type type = data.GetType();

            if (!uniformLocations.ContainsKey(name))
            {
                uniformLocations.Add(name, GL.GetUniformLocation(programObject, name));
            }

            uniformData[name] = data;

            if (uniformMethods.ContainsKey(type))
            {
                uniformMethods[type](null, new object[] { uniformLocations[name], data });
            }
            else
            {
                foreach (string methodName in uniformSetMethods)
                {
                    Type[]     argTypes   = new Type[] { typeof(int), type };
                    MethodInfo methodInfo = typeof(GL).GetMethod(methodName, argTypes);

                    if (methodInfo != null)
                    {
                        uniformMethods[type] = FastMethodInvoker.GetMethodInvoker(methodInfo);
                        uniformMethods[type](null, new object[] { uniformLocations[name], data });
                        return;
                    }
                }

                throw new Exception("No Uniform method found");
            }
        }
Ejemplo n.º 3
0
        public void SetFastInvokeHandler(string name, MethodInfo m)
        {
            name = name.ToUpper();

            if (!propertydelegateList.Keys.Contains(name))
            {
                propertydelegateList[name] = FastMethodInvoker.GetMethodInvoker(m);
            }
        }
Ejemplo n.º 4
0
        public override void CacheMethod()
        {
            Type type = assembly.GetType(MainClassName);

            mainMethod        = FastMethodInvoker.GetMethodInvoker(type.GetMethod(mainMethodName));
            updateMethod      = FastMethodInvoker.GetMethodInvoker(type.GetMethod(updateMethodName));
            fixedUpdateMethod = FastMethodInvoker.GetMethodInvoker(type.GetMethod(fixedUpdateMethodName));
            lateUpdateMethod  = FastMethodInvoker.GetMethodInvoker(type.GetMethod(lateUpdateMethodName));
            destroyMethod     = FastMethodInvoker.GetMethodInvoker(type.GetMethod(destroyMethodName));
        }
Ejemplo n.º 5
0
        private void AddMethod(MethodInfo method)
        {
            var cmdAttribute      = method.GetCustomAttribute <CustomCommandAttribute>() !;
            var fastInvokeHandler = _fastMethodInvoker.GetMethodInvoker(method);
            var methodData        = new CommandMethodData(method, fastInvokeHandler, cmdAttribute.Priority);

            methodData.UserParameters = GetUserParameterInformation(method, methodData).ToList();
            if (!AddInstanceIfRequired(method, methodData))
            {
                return;
            }

            methodData.CompleteInitialization();
            AddCmdAndAliasesToCommandDatas(methodData, cmdAttribute.Command);
        }
Ejemplo n.º 6
0
 public void CacheMethod()
 {
     if (GameEnvironment.Instance.Platform == GamePlatform.iOS)
     {
         i_updateMethod      = appdomain.LoadedTypes[MainClassName].GetMethod(updateMethodName, 0);
         i_fixedUpdateMethod = appdomain.LoadedTypes[MainClassName].GetMethod(fixedUpdateMethodName, 0);
         i_lateUpdateMethod  = appdomain.LoadedTypes[MainClassName].GetMethod(lateUpdateMethodName, 0);
     }
     else
     {
         Type type = assembly.GetType("HotFixEnter");
         m_mainMethod        = FastMethodInvoker.GetMethodInvoker(type.GetMethod("Main"));
         m_updateMethod      = FastMethodInvoker.GetMethodInvoker(type.GetMethod("Update"));
         m_fixedUpdateMethod = FastMethodInvoker.GetMethodInvoker(type.GetMethod("FixedUpdate"));
         m_lateUpdateMethod  = FastMethodInvoker.GetMethodInvoker(type.GetMethod("LateUpdate"));
         m_DestroyMethod     = FastMethodInvoker.GetMethodInvoker(type.GetMethod("Destroy"));
     }
 }
Ejemplo n.º 7
0
        public override void Invoke(string className, string methodName, object instance, params object[] args)
        {
            base.Invoke(className, className, instance, args);

            Dictionary <string, FastMethodInvoker.FastInvokeHandler> temp;

            if (!cache.TryGetValue(className, out temp))
            {
                temp = new Dictionary <string, FastMethodInvoker.FastInvokeHandler>();
                cache.Add(className, temp);
            }

            FastMethodInvoker.FastInvokeHandler method;
            if (!temp.TryGetValue(methodName, out method))
            {
                Type type = assembly.GetType(className);
                method = FastMethodInvoker.GetMethodInvoker(type.GetMethod(methodName));
                temp.Add(methodName, method);
            }

            method.Invoke(instance, args);
        }