Ejemplo n.º 1
0
        private void Visualize_Load(object sender, EventArgs e)
        {
            //Compute object position and dimension
            Dimension_Xp = (float)Visualize_Size.X / 2;
            Dimension_Yp = (float)Visualize_Size.Y / 2;
            Dimension_Zp = (float)Visualize_Size.Z / 2;
            Dimension_Xn = (float)-Visualize_Size.X / 2;
            Dimension_Yn = (float)-Visualize_Size.Y / 2;
            Dimension_Zn = (float)-Visualize_Size.Z / 2;

            //init transformation matrix
            Matrix = new float[] { 1.0f, 0.0f, 0.0f, 0.0f,
                                   0.0f, 1.0f, 0.0f, 0.0f,
                                   0.0f, 0.0f, 1.0f, 0.0f,
                                   0.0f, 0.0f, 0.0f, 1.0f };

            //File path
            string[] imageFiles = new string[] {
                "image/Xplus.png",
                "image/Xminus.png",
                "image/Yplus.png",
                "image/Yminus.png",
                "image/Zplus.png",
                "image/Zminus.png"
            };

            //Config Gl control
            Visualize.InitializeContexts();
            Visualize.SwapBuffers();
            Visualize_SizeChanged(sender, e);
            Gl.glShadeModel(Gl.GL_SMOOTH);
            Gl.glEnable(Gl.GL_LINE_SMOOTH);
            Gl.glEnable(Gl.GL_TEXTURE_2D);                                                  // Enable Texture Mapping
            Gl.glEnable(Gl.GL_NORMALIZE);
            Gl.glEnable(Gl.GL_COLOR_MATERIAL);
            Gl.glEnable(Gl.GL_DEPTH_TEST);                                                  // Enables Depth Testing
            Gl.glEnable(Gl.GL_BLEND);
            Gl.glEnable(Gl.GL_LIGHTING);
            Gl.glEnable(Gl.GL_LIGHT0);
            Gl.glHint(Gl.GL_POLYGON_SMOOTH_HINT, Gl.GL_NICEST);     // Really Nice Point Smoothing
            Gl.glClearColor(0.6f, 0.7f, 0.9f, 0.2f);
            //Load file
            textures = LoadTexture(imageFiles);

            //Setup timer
            Timer          = new Timer();
            Timer.Interval = 20;
            Timer.Tick    += new EventHandler(GraphicTimer_Tick);
            Timer.Start();
        }