Пример #1
0
        protected override void Load()
        {
            Title     = "LancerEdit";
            guiHelper = new ImGuiHelper(this);
            Audio     = new AudioManager(this);
            FileDialog.RegisterParent(this);
            Viewport = new ViewportManager(RenderState);
            var texturefilters = new List <string>(defaultFilters);

            if (RenderState.MaxAnisotropy > 0)
            {
                anisotropyLevels = RenderState.GetAnisotropyLevels();
                foreach (var lvl in anisotropyLevels)
                {
                    texturefilters.Add(string.Format("Anisotropic {0}x", lvl));
                }
            }
            filters     = texturefilters.ToArray();
            Resources   = new ResourceManager(this);
            Commands    = new CommandBuffer();
            Billboards  = new Billboards();
            Polyline    = new PolylineRender(Commands);
            DebugRender = new PhysicsDebugRenderer();
            Viewport.Push(0, 0, 800, 600);
        }
Пример #2
0
        public void Begin(int fixWidth = -1, int fixHeight = -1)
        {
            var renderWidth  = Math.Max(120, (int)ImGui.GetWindowWidth() - MarginW);
            var renderHeight = Math.Max(120, (int)ImGui.GetWindowHeight() - MarginH);

            if (fixWidth > 0)
            {
                renderWidth = fixWidth;
            }
            if (fixHeight > 0)
            {
                renderHeight = fixHeight;
            }
            //Generate render target
            if (rh != renderHeight || rw != renderWidth)
            {
                if (RenderTarget != null)
                {
                    ImGuiHelper.DeregisterTexture(RenderTarget);
                    RenderTarget.Dispose();
                }
                RenderTarget = new RenderTarget2D(renderWidth, renderHeight);
                rid          = ImGuiHelper.RegisterTexture(RenderTarget);
                rw           = renderWidth;
                rh           = renderHeight;
            }
            cc = rstate.ClearColor;
            RenderTarget.BindFramebuffer();
            vps.Push(0, 0, rw, rh);
            rstate.Cull         = true;
            rstate.DepthEnabled = true;
            rstate.ClearColor   = Background;
            rstate.ClearAll();
        }
Пример #3
0
 protected override void Load()
 {
     Title = "Thn Player";
     LibreLancer.Shaders.AllShaders.Compile();
     guiHelper = new ImGuiHelper(this);
     FileDialog.RegisterParent(this);
     Viewport = new ViewportManager(this.RenderState);
     Viewport.Push(0, 0, 800, 600);
     Billboards = new Billboards();
     Nebulae    = new NebulaVertices();
     Resources  = new GameResourceManager(this);
     Renderer2D = new Renderer2D(this.RenderState);
     Audio      = new AudioManager(this);
     Sounds     = new SoundManager(Audio);
     Services.Add(Sounds);
     Services.Add(Billboards);
     Services.Add(Nebulae);
     Services.Add(Resources);
     Services.Add(Renderer2D);
     fontMan = new FontManager();
     fontMan.ConstructDefaultFonts();
     Services.Add(fontMan);
     Services.Add(new GameConfig());
     Typewriter = new Typewriter(this);
     Services.Add(Typewriter);
     Keyboard.KeyDown += KeyboardOnKeyDown;
 }
Пример #4
0
        void DrawGL(int renderWidth, int renderHeight)
        {
            //Set state
            renderTarget.BindFramebuffer();
            rstate.Cull = true;
            var cc = rstate.ClearColor;

            rstate.DepthEnabled = true;
            rstate.ClearColor   = Color4.CornflowerBlue * new Color4(0.3f, 0.3f, 0.3f, 1f);
            rstate.ClearAll();
            vps.Push(0, 0, renderWidth, renderHeight);
            var cam = new LookAtCamera();

            cam.Update(renderWidth, renderHeight, new Vector3(zoom, 0, 0), Vector3.Zero);
            buffer.StartFrame(rstate);
            polyline.SetCamera(cam);
            billboards.Begin(cam, buffer);
            debug.StartFrame(cam, rstate);
            instance.Draw(polyline, billboards, debug, transform, sparam);
            polyline.FrameEnd();
            billboards.End();
            buffer.DrawOpaque(rstate);
            rstate.DepthWrite = false;
            buffer.DrawTransparent(rstate);
            rstate.DepthWrite = true;
            debug.Render();
            //Restore state
            rstate.Cull         = false;
            rstate.BlendMode    = BlendMode.Normal;
            rstate.DepthEnabled = false;
            rstate.ClearColor   = cc;
            RenderTarget2D.ClearBinding();
            vps.Pop();
        }
Пример #5
0
        public void Begin(int fixWidth = -1, int fixHeight = -1)
        {
            ImGuiHelper.AnimatingElement();
            var renderWidth  = Math.Max(120, (int)ImGui.GetWindowWidth() - MarginW);
            var renderHeight = Math.Max(120, (int)ImGui.GetWindowHeight() - MarginH);

            if (fixWidth > 0)
            {
                renderWidth = fixWidth;
            }
            if (fixHeight > 0)
            {
                renderHeight = fixHeight;
            }
            //Generate render target
            if (rh != renderHeight || rw != renderWidth)
            {
                if (RenderTarget != null)
                {
                    ImGuiHelper.DeregisterTexture(RenderTarget.Texture);
                    RenderTarget.Dispose();
                }
                RenderTarget = new RenderTarget2D(renderWidth, renderHeight);
                rid          = ImGuiHelper.RegisterTexture(RenderTarget.Texture);
                rw           = renderWidth;
                rh           = renderHeight;
            }
            if (mw.Config.MSAA != 0 && ((mrw != rw) || (mrh != rh) || (msamples != mw.Config.MSAA)))
            {
                if (msaa != null)
                {
                    msaa.Dispose();
                }
                msaa = new MultisampleTarget(rw, rh, mw.Config.MSAA);
            }
            else if (msaa != null)
            {
                msaa.Dispose();
                mrw      = mrh = -1;
                msamples = 0;
                msaa     = null;
            }
            cc = rstate.ClearColor;
            if (mw.Config.MSAA != 0)
            {
                rstate.RenderTarget = msaa;
            }
            else
            {
                rstate.RenderTarget = RenderTarget;
            }
            vps.Push(0, 0, rw, rh);
            rstate.Cull         = true;
            rstate.DepthEnabled = true;
            rstate.ClearColor   = Background;
            rstate.ClearAll();
        }
Пример #6
0
 protected override void Load()
 {
     Title     = "LancerEdit";
     guiHelper = new ImGuiHelper(this);
     Audio     = new AudioManager(this);
     FileDialog.RegisterParent(this);
     Viewport  = new ViewportManager(RenderState);
     Resources = new ResourceManager(this);
     Viewport.Push(0, 0, 800, 600);
 }
Пример #7
0
 protected override void Load()
 {
     Title     = "InterfaceEdit";
     guiHelper = new ImGuiHelper(this);
     FileDialog.RegisterParent(this);
     Renderer2D = new Renderer2D(RenderState);
     Services.Add(Renderer2D);
     Viewport = new ViewportManager(RenderState);
     Viewport.Push(0, 0, Width, Height);
     new MaterialMap();
     Fonts = new FontManager();
 }
Пример #8
0
 protected override void Load()
 {
     Title     = "LancerEdit";
     guiHelper = new ImGuiHelper(this);
     Audio     = new AudioManager(this);
     FileDialog.RegisterParent(this);
     Viewport    = new ViewportManager(RenderState);
     Resources   = new ResourceManager(this);
     Commands    = new CommandBuffer();
     Billboards  = new Billboards();
     Polyline    = new PolylineRender(Commands);
     DebugRender = new PhysicsDebugRenderer();
     Viewport.Push(0, 0, 800, 600);
 }
        int RenderGradientInternal(ViewportManager vps, Color4 top, Color4 bottom)
        {
            var target = new RenderTarget2D(128, 128);
            var r2d    = game.GetService <Renderer2D>();

            target.BindFramebuffer();
            vps.Push(0, 0, 128, 128);
            r2d.Start(128, 128);
            r2d.DrawVerticalGradient(new Rectangle(0, 0, 128, 128), top, bottom);
            r2d.Finish();
            vps.Pop();
            RenderTarget2D.ClearBinding();
            toFree.Add(target);
            return(RegisterTexture(target));
        }
Пример #10
0
        int RenderGradientInternal(ViewportManager vps, Color4 top, Color4 bottom)
        {
            var target = new RenderTarget2D(128, 128);
            var r2d    = game.GetService <Renderer2D>();

            game.RenderState.RenderTarget = target;
            vps.Push(0, 0, 128, 128);
            r2d.Start(128, 128);
            r2d.DrawVerticalGradient(new Rectangle(0, 0, 128, 128), top, bottom);
            r2d.Finish();
            vps.Pop();
            game.RenderState.RenderTarget = null;
            toFree.Add(target);
            return(RegisterTexture(target.Texture));
        }
Пример #11
0
        protected override void Load()
        {
            Title     = "LancerEdit";
            guiHelper = new ImGuiHelper(this);
            Audio     = new AudioManager(this);
            FileDialog.RegisterParent(this);
            Viewport = new ViewportManager(RenderState);
            var texturefilters = new List <string>(defaultFilters);

            if (RenderState.MaxAnisotropy > 0)
            {
                anisotropyLevels = RenderState.GetAnisotropyLevels();
                foreach (var lvl in anisotropyLevels)
                {
                    texturefilters.Add(string.Format("Anisotropic {0}x", lvl));
                }
            }
            filters     = texturefilters.ToArray();
            Resources   = new ResourceManager(this);
            Commands    = new CommandBuffer();
            Billboards  = new Billboards();
            Polyline    = new PolylineRender(Commands);
            DebugRender = new PhysicsDebugRenderer();
            Viewport.Push(0, 0, 800, 600);
            Keyboard.KeyDown += Keyboard_KeyDown;

            //TODO: Icon-setting code very messy
            int w, h, c;
            var stream = typeof(MainWindow).Assembly.GetManifestResourceStream("LancerEdit.reactor_64.png");
            var bytes  = new byte[stream.Length];

            stream.Read(bytes, 0, (int)stream.Length);
            StbSharp.Stb.stbi_set_flip_vertically_on_load(0);
            var img = StbSharp.Stb.stbi_load_from_memory(bytes, out w, out h, out c, StbSharp.Stb.STBI_rgb_alpha);

            StbSharp.Stb.stbi_set_flip_vertically_on_load(1);
            SetWindowIcon(w, h, img);

            //Open passed in files!
            if (InitOpenFile != null)
            {
                foreach (var f in InitOpenFile)
                {
                    OpenFile(f);
                }
            }
        }
Пример #12
0
        protected override void Load()
        {
            Title     = "LancerEdit";
            guiHelper = new ImGuiHelper(this);
            guiHelper.PauseWhenUnfocused = Config.PauseWhenUnfocused;
            Audio = new AudioManager(this);
            FileDialog.RegisterParent(this);
            Viewport = new ViewportManager(RenderState);
            InitOptions();
            Resources   = new GameResourceManager(this);
            Commands    = new CommandBuffer();
            Billboards  = new Billboards();
            Polyline    = new PolylineRender(Commands);
            DebugRender = new PhysicsDebugRenderer();
            Viewport.Push(0, 0, 800, 600);
            Keyboard.KeyDown += Keyboard_KeyDown;

            //TODO: Icon-setting code very messy
            int w, h, c;
            var stream = typeof(MainWindow).Assembly.GetManifestResourceStream("LancerEdit.reactor_64.png");
            var bytes  = new byte[stream.Length];

            stream.Read(bytes, 0, (int)stream.Length);
            StbSharp.Stb.stbi_set_flip_vertically_on_load(0);
            var img = StbSharp.Stb.stbi_load_from_memory(bytes, out w, out h, out c, StbSharp.Stb.STBI_rgb_alpha);

            StbSharp.Stb.stbi_set_flip_vertically_on_load(1);
            SetWindowIcon(w, h, img);

            //Open passed in files!
            if (InitOpenFile != null)
            {
                foreach (var f in InitOpenFile)
                {
                    OpenFile(f);
                }
            }

            Renderer2D = new Renderer2D(RenderState);
            RichText   = Renderer2D.CreateRichTextEngine();
            Services.Add(Renderer2D);
            Fonts = new FontManager(this);
            Fonts.ConstructDefaultFonts();
            Services.Add(Fonts);
        }
Пример #13
0
        protected override void Load()
        {
            Title     = "System Viewer";
            guiHelper = new ImGuiHelper(this);
            FileDialog.RegisterParent(this);
            Viewport = new ViewportManager(this.RenderState);
            Viewport.Push(0, 0, 800, 600);
            Billboards = new Billboards();
            Nebulae    = new NebulaVertices();
            Resources  = new ResourceManager(this);
            Renderer2D = new Renderer2D(this.RenderState);

            Services.Add(Billboards);
            Services.Add(Nebulae);
            Services.Add(Resources);
            Services.Add(Renderer2D);
            Services.Add(new GameConfig());
        }
Пример #14
0
 protected override void Load()
 {
     Title     = "System Viewer";
     guiHelper = new ImGuiHelper(this);
     FileDialog.RegisterParent(this);
     Viewport = new ViewportManager(this.RenderState);
     Viewport.Push(0, 0, 800, 600);
     Billboards = new Billboards();
     Nebulae    = new NebulaVertices();
     Resources  = new GameResourceManager(this);
     Renderer2D = new Renderer2D(this.RenderState);
     RichText   = Renderer2D.CreateRichTextEngine();
     Services.Add(Billboards);
     Services.Add(Nebulae);
     Services.Add(Resources);
     Services.Add(Renderer2D);
     fontMan = new FontManager(this);
     fontMan.ConstructDefaultFonts();
     Services.Add(fontMan);
     Services.Add(new GameConfig());
 }
Пример #15
0
        void DrawGL(int renderWidth, int renderHeight)
        {
            //Set state
            renderTarget.BindFramebuffer();
            rstate.Cull = true;
            var cc = rstate.ClearColor;

            rstate.DepthEnabled = true;
            rstate.ClearColor   = Color4.CornflowerBlue * new Color4(0.3f, 0.3f, 0.3f, 1f);
            rstate.ClearAll();
            vps.Push(0, 0, renderWidth, renderHeight);
            //Draw Model
            var cam = new ChaseCamera(new Viewport(0, 0, renderWidth, renderHeight));

            cam.ChasePosition         = Vector3.Zero;
            cam.ChaseOrientation      = Matrix4.CreateRotationX(MathHelper.Pi);
            cam.DesiredPositionOffset = new Vector3(zoom, 0, 0);
            //cam.OffsetDirection = Vector3.UnitX;
            cam.Reset();
            cam.Update(TimeSpan.FromSeconds(500));
            buffer.StartFrame(rstate);
            polyline.SetCamera(cam);
            billboards.Begin(cam, buffer);
            debug.StartFrame(cam, rstate);
            instance.Draw(polyline, billboards, debug, transform, sparam);
            polyline.FrameEnd();
            billboards.End();
            buffer.DrawOpaque(rstate);
            rstate.DepthWrite = false;
            buffer.DrawTransparent(rstate);
            rstate.DepthWrite = true;
            debug.Render();
            //Restore state
            rstate.Cull         = false;
            rstate.BlendMode    = BlendMode.Normal;
            rstate.DepthEnabled = false;
            rstate.ClearColor   = cc;
            RenderTarget2D.ClearBinding();
            vps.Pop();
        }
Пример #16
0
 protected override void Load()
 {
     Title     = "LancerEdit";
     guiHelper = new ImGuiHelper(this);
     guiHelper.PauseWhenUnfocused = Config.PauseWhenUnfocused;
     Audio = new AudioManager(this);
     FileDialog.RegisterParent(this);
     Viewport    = new ViewportManager(RenderState);
     options     = new OptionsWindow(this);
     Resources   = new GameResourceManager(this);
     Commands    = new CommandBuffer();
     Billboards  = new Billboards();
     Polyline    = new PolylineRender(Commands);
     DebugRender = new PhysicsDebugRenderer();
     Viewport.Push(0, 0, 800, 600);
     Keyboard.KeyDown += Keyboard_KeyDown;
     //TODO: Icon-setting code very messy
     using (var stream = typeof(MainWindow).Assembly.GetManifestResourceStream("LancerEdit.reactor_64.png"))
     {
         var icon = LibreLancer.ImageLib.Generic.BytesFromStream(stream);
         SetWindowIcon(icon.Width, icon.Height, icon.Data);
     }
     //Open passed in files!
     if (InitOpenFile != null)
     {
         foreach (var f in InitOpenFile)
         {
             OpenFile(f);
         }
     }
     Renderer2D = new Renderer2D(RenderState);
     RichText   = Renderer2D.CreateRichTextEngine();
     Services.Add(Renderer2D);
     Fonts = new FontManager();
     Fonts.ConstructDefaultFonts();
     Services.Add(Fonts);
     gen3dbDlg = new CommodityIconDialog(this);
 }
 protected override void Load()
 {
     Title      = "Librelancer";
     imGui      = new ImGuiHelper(this);
     Renderer2D = new Renderer2D(RenderState);
     Viewport   = new ViewportManager(RenderState);
     Viewport.Push(0, 0, Width, Height);
     FileDialog.RegisterParent(this);
     freelancerFolder = new TextBuffer(512);
     config           = GameConfig.Create();
     freelancerFolder.SetText(config.FreelancerPath);
     resolutionX     = config.BufferWidth;
     resolutionY     = config.BufferHeight;
     vsync           = config.VSync;
     skipIntroMovies = !config.IntroMovies;
     masterVolume    = config.MasterVolume;
     musicVolume     = config.MusicVolume;
     sfxVolume       = config.SfxVolume;
     if (Program.introForceDisable)
     {
         skipIntroMovies = true;
     }
 }
Пример #18
0
        void DrawGL(int renderWidth, int renderHeight)
        {
            //Set state
            renderTarget.BindFramebuffer();
            rstate.Cull = true;
            var cc = rstate.ClearColor;

            rstate.DepthEnabled = true;
            rstate.ClearColor   = Color4.CornflowerBlue;
            rstate.ClearAll();
            vps.Push(0, 0, renderWidth, renderHeight);
            //Draw Model
            var cam = new ChaseCamera(new Viewport(0, 0, renderWidth, renderHeight));

            cam.ChasePosition         = Vector3.Zero;
            cam.ChaseOrientation      = Matrix4.CreateRotationX(MathHelper.Pi);
            cam.DesiredPositionOffset = new Vector3(drawable.GetRadius() * 2, 0, 0);
            cam.OffsetDirection       = Vector3.UnitX;
            cam.Reset();
            cam.Update(TimeSpan.FromSeconds(500));
            buffer.StartFrame();
            drawable.Update(cam, TimeSpan.Zero, TimeSpan.Zero);
            drawable.Update(cam, TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(0));
            drawable.DrawBuffer(buffer, Matrix4.Identity, Lighting.Empty);
            buffer.DrawOpaque(rstate);
            rstate.DepthWrite = false;
            buffer.DrawTransparent(rstate);
            rstate.DepthWrite = true;
            //Restore state
            rstate.Cull         = false;
            rstate.BlendMode    = BlendMode.Normal;
            rstate.DepthEnabled = false;
            rstate.ClearColor   = cc;
            RenderTarget2D.ClearBinding();
            vps.Pop();
        }
Пример #19
0
        void DrawGL(int renderWidth, int renderHeight)
        {
            //Set state
            renderTarget.BindFramebuffer();
            rstate.Cull = true;
            var cc = rstate.ClearColor;

            rstate.DepthEnabled = true;
            rstate.ClearColor   = Color4.CornflowerBlue * new Color4(0.3f, 0.3f, 0.3f, 1f);
            rstate.ClearAll();
            vps.Push(0, 0, renderWidth, renderHeight);
            //Draw Model
            var cam = new ChaseCamera(new Viewport(0, 0, renderWidth, renderHeight));

            cam.ChasePosition         = Vector3.Zero;
            cam.ChaseOrientation      = Matrix4.CreateRotationX(MathHelper.Pi);
            cam.DesiredPositionOffset = new Vector3(drawable.GetRadius() * 2, 0, 0);
            //cam.OffsetDirection = Vector3.UnitX;
            cam.Reset();
            cam.Update(TimeSpan.FromSeconds(500));
            cam.UpdateFrameNumber(rand.Next()); //Stop bad matrix caching
            drawable.Update(cam, TimeSpan.Zero, TimeSpan.Zero);
            if (viewMode != M_NONE)
            {
                buffer.StartFrame(rstate);
                if (drawable is CmpFile)
                {
                    DrawCmp(cam, false);
                }
                else
                {
                    DrawSimple(cam, false);
                }
                buffer.DrawOpaque(rstate);
                rstate.DepthWrite = false;
                buffer.DrawTransparent(rstate);
                rstate.DepthWrite = true;
            }
            if (doWireframe)
            {
                buffer.StartFrame(rstate);
                GL.PolygonOffset(1, 1);
                rstate.Wireframe = true;
                if (drawable is CmpFile)
                {
                    DrawCmp(cam, true);
                }
                else
                {
                    DrawSimple(cam, false);
                }
                GL.PolygonOffset(0, 0);
                buffer.DrawOpaque(rstate);
                rstate.Wireframe = false;
            }
            //Draw hardpoints
            DrawHardpoints(cam);
            //Restore state
            rstate.Cull         = false;
            rstate.BlendMode    = BlendMode.Normal;
            rstate.DepthEnabled = false;
            rstate.ClearColor   = cc;
            RenderTarget2D.ClearBinding();
            vps.Pop();
        }