コード例 #1
0
 public Avatar(GlControl ViewPort, GlObject World)
 {
     camera        = new Camera(origin, center, up);
     this.World    = World;
     this.ViewPort = ViewPort;
     Glut.glutKeyboardFunc(new Glut.KeyboardCallback(keymove));
     Glut.glutSpecialFunc(new Glut.SpecialCallback(specialKeyMove));
     Glut.glutSpecialUpFunc(new Glut.SpecialUpCallback(specialKeyUp));
     Glut.glutMouseFunc(new Glut.MouseCallback(this.MouseFunc));
 }
コード例 #2
0
        public void SetMainLoop()
        {
            //отлов действий пользователя
            Glut.glutMotionFunc(ClickedMotion);
            Glut.glutMouseFunc(Mouse);
            Glut.glutPassiveMotionFunc(PassiveMotion);
            Glut.glutKeyboardFunc(Key);
            Glut.glutKeyboardUpFunc(KeyUp);
            Glut.glutSpecialFunc(KeySpecial);
            Glut.glutSpecialUpFunc(KeySpecialUp);

            //старт игрового цикла
            Glut.glutTimerFunc(Config.TimePerFrame, MainProcess, 0);
            Glut.glutMainLoop();
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: Ofri-Chen/Tetris
        private static void InitializeGlut()
        {
            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_DEPTH);
            Glut.glutInitWindowSize(ConfigurationHandler.WindowWidth, ConfigurationHandler.WindowHeight);
            Glut.glutCreateWindow("Tetris");
            Glut.glutFullScreen();

            Glut.glutIdleFunc(OnRenderFrame);
            Glut.glutDisplayFunc(OnDisplay);
            Glut.glutCloseFunc(OnClose);

            Glut.glutKeyboardFunc(KeyboardManager.OnKeyboardDown);
            Glut.glutSpecialFunc(KeyboardManager.OnSpecialKeyboardDown);
            Glut.glutSpecialUpFunc(KeyboardManager.OnSpecialKeyboardUp);
        }
コード例 #4
0
ファイル: Input.cs プロジェクト: mrenow/2D-Game
        public static void Init()
        {
            Keys              = new bool[255];
            KeysTyped         = new bool[255];
            SpecialKeys       = new bool[255];
            Mouse             = new bool[3];
            KeysTypedCooldown = new CooldownTimer[255];
            for (int i = 0; i < KeysTypedCooldown.Length; i++)
            {
                KeysTypedCooldown[i] = new CooldownTimer(3);
            }

            Glut.glutKeyboardFunc(OnKeyboardDown);
            Glut.glutKeyboardUpFunc(OnKeyboardUp);
            Glut.glutSpecialFunc(OnSpecialDown);
            Glut.glutSpecialUpFunc(OnSpecialUp);
            Glut.glutMouseFunc(OnMousePress);
            Glut.glutMotionFunc(OnMouseMove);
            Glut.glutPassiveMotionFunc(OnMouseMove);
            Glut.glutMouseWheelFunc(OnMouseScroll);
        }
コード例 #5
0
        private void StartOpenGl()
        {
            exit = false;
            Glut.glutInit();


            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_DEPTH | Glut.GLUT_ALPHA | Glut.GLUT_STENCIL |
                                     Glut.GLUT_MULTISAMPLE);

            // http://www.lighthouse3d.com/cg-topics/glut-and-freeglut/
            // Note: glutSetOption is only available with freeglut
            Glut.glutSetOption(Glut.GLUT_ACTION_ON_WINDOW_CLOSE, Glut.GLUT_ACTION_GLUTMAINLOOP_RETURNS);

            Glut.glutInitWindowSize(width, height);
            Glut.glutCreateWindow("OpenGL Test");


            Glut.glutIdleFunc(OnRenderFrame);
            Glut.glutDisplayFunc(OnDisplay);
            Glut.glutDisplayFunc(OnDisplay);

            Glut.glutKeyboardFunc(OnKeyboardDown);
            Glut.glutSpecialFunc(OnSpecialKeyboardDown);
            Glut.glutKeyboardUpFunc(OnKeyboardUp);
            Glut.glutSpecialUpFunc(OnSpecialKeyboardUp);

            Glut.glutCloseFunc(OnClose);
            Glut.glutReshapeFunc(OnReshape);

            // add our mouse callbacks for this tutorial
            Glut.glutMouseFunc(OnMouse);
            Glut.glutMotionFunc(OnMove);

            #region GL_VERSION

            //this will return your version of opengl
            int major, minor;
            major = Gl.GetInteger(GetPName.MajorVersion);
            minor = Gl.GetInteger(GetPName.MinorVersion);
            GameCore.TheGameCore.RaiseMessage("Major " + major + " Minor " + minor);
//            Console.WriteLine("Major " + major + " Minor " + minor);
            //you can also get your GLSL version, although not sure if it varies from the above
            GameCore.TheGameCore.RaiseMessage("GLSL " + Gl.GetString(StringName.ShadingLanguageVersion));

            #endregion

            Gl.Enable(EnableCap.DepthTest);

            Gl.Enable(EnableCap.Blend);
            Gl.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

            RenderObjects.RenderObjects.TheResourceManager = theResourceManager;

            Camera camera = new Camera(new Vector3(0, 20, 10), Quaternion.Identity);
            camera.SetDirection(new Vector3(1, -3, -1));
            TheGameStatus.TheEnvironment = new Environment();
            TheGameStatus.TheCamera      = camera;

            theSceneManager = new SceneManager(TheGameStatus, TheUserInputPlayer, theKeyBindings,
                                               theResourceManager, new RenderStatus()
            {
                Width = width, Height = height
            });

            theSceneManager.AddCamera(camera);

            theSceneManager.AddLayer(new RenderLayerSkyBox());
            theSceneManager.AddLayer(new RenderLayerGame());
            theSceneManager.AddLayer(new RenderLayerMapDrawArrays());
            theSceneManager.AddLayer(new RenderLayerHud());
            theSceneManager.AddLayer(layerInfo = new RenderLayerTextInfo());


            theSceneManager.OnLoad();

            watch = Stopwatch.StartNew();

            Glut.glutMainLoop();


            GameCore.TheGameCore.OnGameEventHandler(new GameEventArgs(GameEventArgs.Types.RendererExited));
        }