Пример #1
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            string version = GL.GetString(StringName.Version);
            int    major   = (int)version[0];
            int    minor   = (int)version[2];

            if (major <= 1 && minor < 5)
            {
                System.Windows.Forms.MessageBox.Show("You need at least OpenGL 1.5 to run this example. Aborting.", "Extensions not supported",
                                                     System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
                this.Exit();
            }

            GL.ClearColor(1.0f, 1.0f, 1.0f, 1.0f);
            GL.ClearDepth(1.0d);
            GL.DepthFunc(DepthFunction.Less);
            GL.MatrixMode(MatrixMode.Projection);
            GL.ShadeModel(ShadingModel.Smooth);
            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.One);
            GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Nicest);
            GL.Hint(HintTarget.PointSmoothHint, HintMode.Nicest);
            GL.Hint(HintTarget.LineSmoothHint, HintMode.Nicest);
            GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);

            GL.Enable(EnableCap.DepthTest);
            GL.Enable(EnableCap.ColorMaterial);
            GL.FrontFace(FrontFaceDirection.Cw);
            GL.Enable(EnableCap.CullFace);
            //GL.Enable(EnableCap.Lighting);

            Debug.On = false;

            camera = new Camera(0.1f, 2000.0f);
            camera.Position(0, 0, 1, 0, 0, 0, 0, 1, 0);

            GL.Enable(EnableCap.Light0);
            GL.Light(LightName.Light0, LightParameter.Position, new Vector4(new Vector3(0, 0, 0)));
            GL.Light(LightName.Light0, LightParameter.Ambient, new Color4(255, 255, 255, 0));
            GL.Light(LightName.Light0, LightParameter.Diffuse, new Color4(255, 100, 0, 0));

            MouseFunctions.setPosition(new Point(Game.width >> 1, Game.height >> 1));
            Mouse.ButtonDown += new EventHandler <MouseButtonEventArgs>(mouseDownEvents);
            //Mouse.Move += new EventHandler<MouseMoveEventArgs>(Primitive.MouseMoveEvent);             // Object picking

            font       = new TrueTypeFont(new Font("Times New Roman", 20f, FontStyle.Bold), true);
            font.color = new Vector3(1.0f, 0.0f, 1.0f);

            if (!loadContent())
            {
                Core.ErrorExit("Error loading content");
            }
        }
Пример #2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            string version = GL.GetString(StringName.Version);
            int major = (int)version[0];
            int minor = (int)version[2];
            if (major <= 1 && minor < 5)
            {
                System.Windows.Forms.MessageBox.Show("You need at least OpenGL 1.5 to run this example. Aborting.", "Extensions not supported",
                    System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
                this.Exit();
            }

            GL.ClearColor(1.0f, 1.0f, 1.0f, 1.0f);
            GL.ClearDepth(1.0d);
            GL.DepthFunc(DepthFunction.Less);
            GL.MatrixMode(MatrixMode.Projection);
                GL.ShadeModel(ShadingModel.Smooth);
            GL.MatrixMode(MatrixMode.Modelview);
                GL.LoadIdentity();
                GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.One);
                GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Nicest);
                GL.Hint(HintTarget.PointSmoothHint, HintMode.Nicest);
                GL.Hint(HintTarget.LineSmoothHint, HintMode.Nicest);
                GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);

            GL.Enable(EnableCap.DepthTest);
            GL.Enable(EnableCap.ColorMaterial);
            GL.FrontFace(FrontFaceDirection.Cw);
            GL.Enable(EnableCap.CullFace);
            //GL.Enable(EnableCap.Lighting);

            Debug.On = false;

            camera = new Camera(0.1f, 2000.0f);
            camera.Position(0, 0, 1,   0, 0, 0,   0, 1, 0);

            GL.Enable(EnableCap.Light0);
            GL.Light(LightName.Light0, LightParameter.Position, new Vector4(new Vector3(0, 0, 0)));
            GL.Light(LightName.Light0, LightParameter.Ambient, new Color4(255, 255, 255, 0));
            GL.Light(LightName.Light0, LightParameter.Diffuse, new Color4(255, 100, 0, 0));

            MouseFunctions.setPosition(new Point(Game.width >> 1, Game.height >> 1));
            Mouse.ButtonDown += new EventHandler<MouseButtonEventArgs>(mouseDownEvents);
            //Mouse.Move += new EventHandler<MouseMoveEventArgs>(Primitive.MouseMoveEvent);             // Object picking

            font = new TrueTypeFont(new Font("Times New Roman", 20f, FontStyle.Bold), true);
            font.color = new Vector3(1.0f, 0.0f, 1.0f);

            if (!loadContent()) { Core.ErrorExit("Error loading content"); }
        }