Example #1
0
        public GLForm(int scaleX, int scaleY, params string[] expr)
        {
            Random r = new Random();

            exe    = new Executer[expr.Length];
            Colors = new float[expr.Length][];
            for (int i = 0; i < expr.Length; i++)
            {
                exe[i] = Executer.Create(expr[i]);
                //x^sin(x)
                exe[i].RegisterFunction("abs", typeof(Math).GetMethod("Abs", new Type[] { typeof(double) }));
                exe[i].RegisterFunction("sin", typeof(Math).GetMethod("Sin"));
                exe[i].RegisterFunction("cos", typeof(Math).GetMethod("Cos"));
                exe[i].RegisterFunction("log", typeof(Math).GetMethod("Log", new Type[] { typeof(double), typeof(double) }));

                Colors[i]    = new float[3];
                Colors[i][0] = (float)(r.Next() % 100) / 100;
                Colors[i][1] = (float)(r.Next() % 100) / 100;
                Colors[i][2] = (float)(r.Next() % 100) / 100;
            }
            this.ScaleX = scaleX;
            this.ScaleY = scaleY;
            InitializeComponent();
            oc = new OpenGLControl();
            ((ISupportInitialize)(oc)).BeginInit();

            oc.Dock              = DockStyle.Fill;
            oc.DrawFPS           = true;
            oc.FrameRate         = 20;
            oc.RenderContextType = RenderContextType.FBO;

            oc.OpenGLInitialized += Oc_OpenGLInitialized;
            oc.OpenGLDraw        += Oc_OpenGLDraw;
            oc.Resized           += Oc_Resized;
            Controls.Add(oc);
            ((ISupportInitialize)(oc)).EndInit();
        }