Пример #1
0
        protected override void OnLoad(System.EventArgs e)
        {
            //generate stopwatch
            sw = new Stopwatch();

            //set size of the render
            virtual_size = Settings.Instance.video.CreateSizeVector(VideoSettings.Target.main);

            state = new GameState();

            string versionOpenGL = GL.GetString(StringName.Version);

            log(versionOpenGL);

            // make the Coursor disapear
            Cursor.Hide();

            // center it on the window
            Cursor.Position = new Point(
                (Bounds.Left + Bounds.Right) / 2,
                (Bounds.Top + Bounds.Bottom) / 2);

            // other state
            GL.ClearColor(System.Drawing.Color.Black);
            VSync      = VSyncMode.On;
            screenSize = new Vector2(Width, Height);

            // create instances of necessary objects
            textureLoader      = new TextureLoader(this);
            framebufferCreator = new FramebufferCreator(this);
            meshLoader         = new MeshLoader(this);
            shaderLoader       = new ShaderLoader(this);
            materialLoader     = new MaterialLoader(this);
            templateLoader     = new TemplateLoader(this);

            mScene = new Scene(this);

            // create gameInput
            gameInput = new GameInput(mScene, Keyboard, Mouse);

            // set files for displaying loading screen
            shaderLoader.fromXmlFile("shaders\\composite.xsp");

            shaderLoader.fromTextFile("shaders\\composite.vs", "shaders\\splash_shader.fs");

            meshLoader.fromObj("models\\sprite_plane.obj");

            textureLoader.fromPng("materials\\ultra_engine_back.png", true);
            textureLoader.fromPng("materials\\ultra_engine_back_h.png", true);

            materialLoader.fromXmlFile("materials\\composite.xmf");

            //loading noise manualy so we can disable multisampling
            textureLoader.fromPng("materials\\noise_pixel.png", false);

            // load files for loading screen
            textureLoader.LoadTextures();
            meshLoader.loadMeshes();
            shaderLoader.loadShaders();
            materialLoader.loadMaterials();

            // load files from cache
            if (Settings.Instance.game.useCache)
            {
                meshLoader.readCacheFile();
                //shaderLoader.readCacheFile();
                //textureLoader.readCacheFile();
                materialLoader.readCacheFile();
                templateLoader.readCacheFile();
            }

            // setup 2d filter (loading screen)
            splashFilter2d = new Quad2d(this);

            // set time to zero
            spawnTime = get_time();
        }