Exemplo n.º 1
0
        public void DrawTransparent(RenderState state)
        {
            while (!_sorted)
            {
            }
            if (!_filled)
            {
                FillBillboards();
            }
            Billboards lastbb = null;

            for (int i = transparentCommand - 1; i >= 0; i--)
            {
                if (lastbb != null && Transparents[cmdptr[i]].CmdType != RenderCmdType.Billboard && Transparents[cmdptr[i]].CmdType != RenderCmdType.BillboardCustom)
                {
                    lastbb.FlushCommands(state);
                    lastbb = null;
                }
                lastbb = (Transparents[cmdptr[i]].Source as Billboards);
                Transparents[cmdptr[i]].Run(state);
            }
            if (lastbb != null)
            {
                lastbb.FlushCommands(state);
            }
        }
Exemplo n.º 2
0
        public SystemRenderer(ICamera camera, GameDataManager data, ResourceManager rescache, Game game)
        {
            this.camera      = camera;
            AsteroidFields   = new List <AsteroidFieldRenderer>();
            Nebulae          = new List <NebulaRenderer>();
            StarSphereModels = new IDrawable[0];
            Polyline         = new PolylineRender(commands);
            cache            = rescache;
            rstate           = cache.Game.RenderState;
            this.game        = game;
            gconfig          = game.GetService <GameConfig>();
            billboards       = game.GetService <Billboards>();
            resman           = game.GetService <ResourceManager>();
            nebulae          = game.GetService <NebulaVertices>();
            dot           = (Texture2D)rescache.FindTexture(ResourceManager.WhiteTextureName);
            DebugRenderer = new PhysicsDebugRenderer();

            if (GLExtensions.Features430)
            {
                pointLightBuffer = new ShaderStorageBuffer(MAX_POINTS * (16 * sizeof(float)));
                if (pointLightCull == null)
                {
                    pointLightCull = new ComputeShader(Resources.LoadString("LibreLancer.Shaders.lightingcull.glcompute"));
                }
            }
        }
Exemplo n.º 3
0
        protected override void Load()
        {
            Thread.CurrentThread.Name = "FreelancerGame UIThread";
            //Move to stop _TSGetMainThread error on OSX
            MinimumWindowSize = new Point(640, 480);
            SetVSync(Config.VSync);
            new IdentityCamera(this);
            uithread       = Thread.CurrentThread.ManagedThreadId;
            useintromovies = _cfg.IntroMovies;
            FLLog.Info("Platform", Platform.RunningOS.ToString() + (IntPtr.Size == 4 ? " 32-bit" : " 64-bit"));
            FLLog.Info("Available Threads", Environment.ProcessorCount.ToString());
            //Cache
            ResourceManager = new GameResourceManager(this);
            //Init Audio
            FLLog.Info("Audio", "Initialising Audio");
            Audio = new AudioManager(this);
            if (_cfg.MuteMusic)
            {
                Audio.Music.Volume = 0f;
            }
            //Load data
            FLLog.Info("Game", "Loading game data");
            GameData    = new GameDataManager(_cfg.FreelancerPath, ResourceManager);
            IntroMovies = GameData.GetIntroMovies();
            MpvOverride = _cfg.MpvOverride;
            Thread GameDataLoaderThread = new Thread(() =>
            {
                GameData.LoadData();
                Sound = new SoundManager(GameData, Audio);
                FLLog.Info("Game", "Finished loading game data");
                InitialLoadComplete = true;
            });

            GameDataLoaderThread.Name = "GamedataLoader";
            GameDataLoaderThread.Start();
            //
            Renderer2D      = new Renderer2D(RenderState);
            Fonts           = new FontManager(this);
            Billboards      = new Billboards();
            Nebulae         = new NebulaVertices();
            ViewportManager = new ViewportManager(RenderState);
            ViewportManager.Push(0, 0, Width, Height);
            Screenshots = new ScreenshotManager(this);

            Services.Add(Billboards);
            Services.Add(Nebulae);
            Services.Add(ResourceManager);
            Services.Add(Renderer2D);
            Services.Add(Config);
            Services.Add(Fonts);

            if (useintromovies && IntroMovies.Count > 0)
            {
                ChangeState(new IntroMovie(this, 0));
            }
            else
            {
                ChangeState(new LoadingDataState(this));
            }
        }
Exemplo n.º 4
0
        Shader GetPuffShader(Billboards bl)
        {
			if (_puffringsh == null)
			{
				_puffringsh = bl.GetShader("nebula_extpuff.frag");
				_ptex0 = _puffringsh.GetLocation("tex0");
				_pfogcolor = _puffringsh.GetLocation("FogColor");
				_pfogfactor = _puffringsh.GetLocation("FogFactor");
			}
            return _puffringsh;
        }
Exemplo n.º 5
0
 public void AddCommand(Billboards billboards, int hash, int index, int sortLayer, float z)
 {
     Transparents[transparentCommand++] = new RenderCommand()
     {
         Key     = RenderCommand.MakeKey(RenderType.Transparent, 0, sortLayer, z, 0),
         CmdType = RenderCmdType.Billboard,
         Source  = billboards,
         Hash    = hash,
         Index   = index,
     };
 }
Exemplo n.º 6
0
 public void AddCommand(Billboards billboards, int hash, int index, int sortLayer, float z)
 {
     Transparents[transparentCommand++] = new RenderCommand()
     {
         CmdType   = RenderCmdType.Billboard,
         Source    = billboards,
         Hash      = hash,
         Index     = index,
         SortLayer = sortLayer,
         Z         = z
     };
 }
Exemplo n.º 7
0
 Shader GetRadialShader(Billboards bl)
 {
     if (_radialsh == null)
     {
         _radialsh     = bl.GetShader("sun_radial.frag");
         _radialtex0   = _radialsh.GetLocation("tex0");
         _radialinner  = _radialsh.GetLocation("innercolor");
         _radialouter  = _radialsh.GetLocation("outercolor");
         _radialexpand = _radialsh.GetLocation("expand");
     }
     return(_radialsh);
 }
Exemplo n.º 8
0
 Shader GetSpineShader(Billboards bl)
 {
     if (_spinesh == null)
     {
         _spinesh    = bl.GetShader("sun_spine.frag");
         _spinetex0  = _spinesh.GetLocation("tex0");
         _spineinner = _spinesh.GetLocation("innercolor");
         _spineouter = _spinesh.GetLocation("outercolor");
         _spinealpha = _spinesh.GetLocation("alpha");
     }
     return(_spinesh);
 }
Exemplo n.º 9
0
 public void AddCommand(Billboards billboards, Shader shader, ShaderAction setup, RenderUserData userData, int indexStart, int layer, float z)
 {
     Transparents[transparentCommand++] = new RenderCommand()
     {
         CmdType     = RenderCmdType.BillboardCustom,
         Source      = billboards,
         ShaderSetup = setup,
         UserData    = userData,
         Index       = indexStart,
         Cleanup     = shader,
         SortLayer   = layer,
         Z           = z
     };
 }
Exemplo n.º 10
0
 public override bool PrepareRender(ICamera camera, NebulaRenderer nr, SystemRenderer sys)
 {
     billboards  = sys.Billboards;
     res         = sys.ResourceManager;
     renderCount = 0;
     for (int i = 0; i < Projectiles.Projectiles.Length; i++)
     {
         if (Projectiles.Projectiles[i].Alive)
         {
             toRender[renderCount++] = Projectiles.Projectiles[i];
         }
     }
     if (renderCount > 0)
     {
         sys.AddObject(this);
     }
     return(true);
 }
Exemplo n.º 11
0
        public void DrawTransparent(RenderContext context)
        {
            Billboards lastbb = null;

            for (int i = transparentCommand - 1; i >= 0; i--)
            {
                if (lastbb != null && Transparents[cmdptr[i]].CmdType != RenderCmdType.Billboard)
                {
                    lastbb.FlushCommands(context);
                    lastbb = null;
                }
                lastbb = (Transparents[cmdptr[i]].Source as Billboards);
                Transparents[cmdptr[i]].Run(context);
            }
            if (lastbb != null)
            {
                lastbb.FlushCommands(context);
            }
        }
Exemplo n.º 12
0
		public NebulaRenderer(Nebula n, ICamera c, Game g)
		{
			Nebula = n;
			camera = c;
			game = g;
            nverts = g.GetService<NebulaVertices>();
            render2D = g.GetService<Renderer2D>();
            resman = g.GetService<ResourceManager>();
            billboards = g.GetService<Billboards>();
			rand = new Random();
			if (n.HasInteriorClouds)
			{
				puffsinterior = new InteriorPuff[n.InteriorCloudCount];
				for (int i = 0; i < n.InteriorCloudCount; i++)
					puffsinterior[i].Spawned = false;
			}
			GenerateExteriorPuffs();
			//Set Timers
			dynLightningTimer = Nebula.DynamicLightningGap;
			bckLightningTimer = Nebula.BackgroundLightningGap;
		}
Exemplo n.º 13
0
        protected override void Load()
        {
            Thread.CurrentThread.Name = "FreelancerGame UIThread";
            //Move to stop _TSGetMainThread error on OSX
            MinimumWindowSize = new Point(640, 480);
            SetVSync(Config.Settings.VSync);
            Config.Settings.RenderContext = RenderContext;
            new IdentityCamera(this);
            uithread       = Thread.CurrentThread.ManagedThreadId;
            useintromovies = _cfg.IntroMovies;
            FLLog.Info("Platform", Platform.RunningOS.ToString() + (IntPtr.Size == 4 ? " 32-bit" : " 64-bit"));
            FLLog.Info("Available Threads", Environment.ProcessorCount.ToString());
            //Cache
            ResourceManager = new GameResourceManager(this);
            //Init Audio
            FLLog.Info("Audio", "Initialising Audio");
            Audio = new AudioManager(this);
            Audio.WaitReady();
            Audio.MasterVolume = _cfg.Settings.MasterVolume;
            Audio.Music.Volume = _cfg.Settings.MusicVolume;
            //Load data
            FLLog.Info("Game", "Loading game data");
            GameData    = new GameDataManager(_cfg.FreelancerPath, ResourceManager);
            IntroMovies = GameData.GetIntroMovies();
            MpvOverride = _cfg.MpvOverride;
            Saves       = new SaveGameFolder();
            var    saveLoadTask         = Task.Run(() => Saves.Load(GetSaveFolder()));
            Thread GameDataLoaderThread = new Thread(() =>
            {
                GameData.LoadData(this, () =>
                {
                    Sound = new SoundManager(GameData, Audio, this);
                    Services.Add(Sound);
                    InisLoaded = true;
                });
                FLLog.Info("Game", "Finished loading game data");
                saveLoadTask.Wait();
                Saves.Infocards     = GameData.Ini.Infocards;
                InitialLoadComplete = true;
            });

            GameDataLoaderThread.Name = "GamedataLoader";
            GameDataLoaderThread.Start();
            //
            Fonts      = new FontManager();
            Billboards = new Billboards();
            Nebulae    = new NebulaVertices();
            RenderContext.PushViewport(0, 0, Width, Height);
            Screenshots = new ScreenshotManager(this);
            Typewriter  = new Typewriter(this);

            Services.Add(Billboards);
            Services.Add(Nebulae);
            Services.Add(ResourceManager);
            Services.Add(Config);
            Services.Add(Fonts);
            Services.Add(GameData);
            Services.Add(Sound);
            Services.Add(Typewriter);
            Debug = new DebugView(this);
            if (useintromovies && IntroMovies.Count > 0)
            {
                ChangeState(new IntroMovie(this, 0));
            }
            else
            {
                ChangeState(new LoadingDataState(this));
            }
        }