Пример #1
0
 private void DefineStruct(Type structType)
 {
     if (!DefineType(structType))
     {
         return;
     }
     AddGlobal(GlslAst.Struct(structType.Name,
                              from field in structType.GetGLFields()
                              let fi = GetArrayLen(field, field.FieldType)
                                       select Ast.Fld(fi.Item1, field.Name, fi.Item2)));
 }
Пример #2
0
 private void DeclareVarying(MemberInfo member, Type memberType, GlslAst.VaryingKind kind)
 {
     if (!member.Name.StartsWith("<>"))
     {
         var ai         = GetArrayLen(member, memberType);
         var qualifiers = member.GetQualifiers();
         var vary       = GlslAst.Vary(kind, qualifiers, ai.Item1, member.Name, ai.Item2);
         if (!(member.IsBuiltin() || member.IsDefined(typeof(OmitInGlslAttribute), true)))
         {
             AddGlobal(vary);
         }
         _globalVars.Add(member.Name, vary.Definition);
     }
 }
Пример #3
0
 private void DeclareConstant(Type constType, string name, Expression value)
 {
     Ast.Constant con;
     if (constType.IsArray)
     {
         var nai = value.Expect <NewArrayExpression> (ExpressionType.NewArrayInit);
         con = Ast.Const(constType.GetElementType(), name, nai.Expressions.Count, Expr(value));
     }
     else
     {
         con = Ast.Const(constType, name, Expr(value));
     }
     _currentScope.CodeOut(GlslAst.DeclConst(con));
     _constants.Add(name, con);
 }
Пример #4
0
 private void DeclareUniforms(Type type)
 {
     if (!DefineType(type))
     {
         return;
     }
     foreach (var field in type.GetUniforms())
     {
         var ai = GetArrayLen(field, field.FieldType.GetGenericArguments().Single());
         if (ai.Item1.GetGLAttribute() is GLStruct)
         {
             DefineStruct(ai.Item1);
         }
         var unif = GlslAst.Unif(ai.Item1, field.Name, ai.Item2);
         AddGlobal(unif);
         _globalVars.Add(field.Name, unif.Definition);
     }
 }
Пример #5
0
 protected override Ast.InitStruct InitStructure(Type type,
                                                 IEnumerable <Tuple <Ast.VariableRef, Ast.Expression> > initFields)
 {
     return(GlslAst.InitS(type, initFields));
 }
Пример #6
0
 protected override Ast.NewArray ArrayConstant(Type type, int count, IEnumerable <Ast.Expression> items)
 {
     return(GlslAst.Arr(type, count, items));
 }