Exemple #1
0
        private static void Init()
        {
            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_DEPTH);
            Glut.glutInitWindowSize(Width, Height);

            ScreenWidth  = Glut.glutGet(Glut.GLUT_SCREEN_WIDTH);
            ScreenHeight = Glut.glutGet(Glut.GLUT_SCREEN_HEIGHT);

            Glut.glutInitWindowPosition((ScreenWidth - Width) / 2, (ScreenHeight - Height) / 2);
            Glut.glutCreateWindow("Plexico 2D Game - Copyright Alex Tan 2016");
            //Glut.glutGameModeString(Width+"x"+Height+":32@60");

            Glut.glutSetOption(Glut.GLUT_ACTION_ON_WINDOW_CLOSE, Glut.GLUT_ACTION_CONTINUE_EXECUTION);
            Gl.Viewport(0, 0, Width, Height);
            Glut.glutReshapeFunc(OnReshape);
            Glut.glutDisplayFunc(delegate() { });
            Glut.glutIdleFunc(MainGameLoop);

            //Console.SetWindowSize(Console.LargestWindowWidth / 4, Console.LargestWindowHeight / 4);
            //Console.SetWindowPosition(0, 0);
            Mode = ProgramMode.None;

            AssetsManager.Init();
            Input.Init();
            Gui.Init();
            SwitchToTitleScreen();
        }
Exemple #2
0
 static void Main()
 {
     Glut.glutInit();
     Glut.glutSetOption(Glut.GLUT_MULTISAMPLE, 8);
     Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_RGBA | Glut.GLUT_DEPTH | Glut.GLUT_MULTISAMPLE);
     Glut.glutInitWindowSize(Globals.defaultwindowwidth, Globals.defaultwindowheight);
     Glut.glutCreateWindow("Marvis Console");
     init_graphics();
     Glut.glutDisplayFunc(on_display);
     Glut.glutPassiveMotionFunc(on_mousemove);
     Glut.glutMotionFunc(on_mousemove);
     Glut.glutMouseFunc(on_mouseclick);
     Glut.glutMouseWheelFunc(on_mousewheel);
     Glut.glutIdleFunc(idle);
     Glut.glutReshapeFunc(on_reshape);
     Glut.glutMainLoop();
 }
Exemple #3
0
        static void Main()
        {
            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_DEPTH);
            Glut.glutInitWindowSize(Width, Height);

            ScreenWidth  = Glut.glutGet(Glut.GLUT_SCREEN_WIDTH);
            ScreenHeight = Glut.glutGet(Glut.GLUT_SCREEN_HEIGHT);

            Glut.glutInitWindowPosition((ScreenWidth - Width) / 2, (ScreenHeight - Height) / 2);
            Glut.glutCreateWindow("");
            //Glut.glutGameModeString(Width+"x"+Height+":32@60");

            Glut.glutSetOption(Glut.GLUT_ACTION_ON_WINDOW_CLOSE, Glut.GLUT_ACTION_CONTINUE_EXECUTION);
            Gl.Viewport(0, 0, Width, Height);
            Glut.glutDisplayFunc(delegate() { });
            Glut.glutIdleFunc(MainGameLoop);

            Init();

            Glut.glutMainLoop();
        }
Exemple #4
0
        public static void InitDefaultGraphicContext(int width, int hegith, string header)
        {
            MonitorWidth       = width;
            MonitorHeight      = hegith;
            _monitorHeader     = header;
            Close              = true;
            GameObjectsArray   = new List <GameObject>();
            BackendObjectArray = new List <GameObject>();

            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_DEPTH);
            Glut.glutInitWindowSize(MonitorWidth, MonitorHeight);
            Glut.glutSetOption(Glut.GLUT_ACTION_ON_WINDOW_CLOSE, Glut.GLUT_ACTION_CONTINUE_EXECUTION);


            Glut.glutCreateWindow(_monitorHeader);



            CreateProjectionMatrix();
            InitDefaultCallbacks();
        }
Exemple #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));
        }