示例#1
0
 public List<KeyValuePair<string, string>> GetOpenGLPNameInfo()
 {
     List<KeyValuePair<string, string>> info = 
         new List<KeyValuePair<string, string>>(); 
     foreach (GetPName pname in Enum.GetValues(typeof(GetPName)))
     {
         double[] buff = new double[32];
         GL.GetDouble(pname, buff);
         int last = 0;
         for (int i = 0; i < 32; i++)
         {
             if (buff[i] != 0.0)
             {
                 last = i + 1;
             }
         }
         string str = null;
         switch (last)
         {
             case 0:
                 str = "0";
                 break;
             case 1:
                 str = buff[0].ToString();
                 break;
             case 2:
                 Vector2d v2 = new Vector2d(buff[0], buff[1]);
                 str = v2.ToString();
                 break;
             case 3:
                 Vector3d v3 = new Vector3d(buff[0], buff[1], buff[2]);
                 str = v3.ToString();
                 break;
             case 4:
                 Vector4d v4 = new Vector4d(buff[0], buff[1], buff[2], buff[3]);
                 str = v4.ToString();
                 break;
             case 16:
                 Matrix4d m4 = new Matrix4d(buff[0], buff[1], buff[2], buff[3],
                                         buff[4], buff[5], buff[6], buff[7],
                                         buff[8], buff[9], buff[10], buff[11],
                                         buff[12], buff[13], buff[14], buff[15]);
                 str = m4.ToString();
                 break;
             default:
                 StringBuilder sb = new StringBuilder();
                 for (int i = 0; i < last; i++)
                 {
                     sb.Append(buff[i]);
                     sb.Append(',');
                 }
                 str = sb.ToString();
                 break;
         }
         info.Add(new KeyValuePair<string, string>(pname.ToString(), str));
     } 
     return info;
 }
示例#2
0
 private bool Approximate(Vector4 v, Vector4d vd)
 {
     if (Math.Abs(v.x - vd.x) < deviation &&
         Math.Abs(v.y - vd.y) < deviation &&
         Math.Abs(v.z - vd.z) < deviation &&
         Math.Abs(v.w - vd.w) < deviation)
     {
         return(true);
     }
     else
     {
         Assert.Fail(string.Format("{0}\n{1}", v.ToString("0.00000"), vd.ToString("0.00000")));
         return(false);
     }
 }
示例#3
0
        public List <KeyValuePair <string, string> > GetOpenGLPNameInfo()
        {
            List <KeyValuePair <string, string> > info =
                new List <KeyValuePair <string, string> >();

            foreach (GetPName pname in Enum.GetValues(typeof(GetPName)))
            {
                double[] buff = new double[32];
                GL.GetDouble(pname, buff);
                int last = 0;
                for (int i = 0; i < 32; i++)
                {
                    if (buff[i] != 0.0)
                    {
                        last = i + 1;
                    }
                }
                string str = null;
                switch (last)
                {
                case 0:
                    str = "0";
                    break;

                case 1:
                    str = buff[0].ToString();
                    break;

                case 2:
                    Vector2d v2 = new Vector2d(buff[0], buff[1]);
                    str = v2.ToString();
                    break;

                case 3:
                    Vector3d v3 = new Vector3d(buff[0], buff[1], buff[2]);
                    str = v3.ToString();
                    break;

                case 4:
                    Vector4d v4 = new Vector4d(buff[0], buff[1], buff[2], buff[3]);
                    str = v4.ToString();
                    break;

                case 16:
                    Matrix4d m4 = new Matrix4d(buff[0], buff[1], buff[2], buff[3],
                                               buff[4], buff[5], buff[6], buff[7],
                                               buff[8], buff[9], buff[10], buff[11],
                                               buff[12], buff[13], buff[14], buff[15]);
                    str = m4.ToString();
                    break;

                default:
                    StringBuilder sb = new StringBuilder();
                    for (int i = 0; i < last; i++)
                    {
                        sb.Append(buff[i]);
                        sb.Append(',');
                    }
                    str = sb.ToString();
                    break;
                }
                info.Add(new KeyValuePair <string, string>(pname.ToString(), str));
            }
            return(info);
        }
示例#4
0
        public new void ToString()
        {
            Vector4d v = new Vector4d(1, 2, 3, 4);

            Assert.AreEqual("1,2,3,4", v.ToString());
        }