예제 #1
0
        public Renderer(Config config, GameContent content)
        {
            this.config = config;

            palette = content.Palette;

            if (config.video_highresolution)
            {
                screen = new DrawScreen(content.Wad, 640, 400);
            }
            else
            {
                screen = new DrawScreen(content.Wad, 320, 200);
            }

            menu            = new MenuRenderer(content.Wad, screen);
            threeD          = new ThreeDRenderer(content, screen, config.video_gamescreensize);
            statusBar       = new StatusBarRenderer(content.Wad, screen);
            intermission    = new IntermissionRenderer(content.Wad, screen);
            openingSequence = new OpeningSequenceRenderer(content.Wad, screen, this);
            autoMap         = new AutoMapRenderer(content.Wad, screen);
            finale          = new FinaleRenderer(content, screen);

            pause = Patch.FromWad(content.Wad, "M_PAUSE");

            var scale = screen.Width / 320;

            wipeBandWidth = 2 * scale;
            wipeBandCount = screen.Width / wipeBandWidth + 1;
            wipeHeight    = screen.Height / scale;
            wipeBuffer    = new byte[screen.Data.Length];

            palette.ResetColors(gammaCorrectionParameters[config.video_gammacorrection]);
        }
예제 #2
0
        public SfmlRenderer(RenderWindow window, CommonResource resource, bool highResolution)
        {
            sfmlWindow = window;
            palette    = resource.Palette;

            colors = InitColors(palette);

            sfmlWindowWidth  = (int)window.Size.X;
            sfmlWindowHeight = (int)window.Size.Y;

            if (highResolution)
            {
                screen            = new DrawScreen(resource.Wad, 640, 400);
                sfmlTextureWidth  = 512;
                sfmlTextureHeight = 1024;
            }
            else
            {
                screen            = new DrawScreen(resource.Wad, 320, 200);
                sfmlTextureWidth  = 256;
                sfmlTextureHeight = 512;
            }

            sfmlTextureData = new byte[4 * screen.Width * screen.Height];

            try
            {
                sfmlTexture = new SFML.Graphics.Texture((uint)sfmlTextureWidth, (uint)sfmlTextureHeight);
                sfmlSprite  = new SFML.Graphics.Sprite(sfmlTexture);
            }
            catch (Exception e)
            {
                Dispose();
                ExceptionDispatchInfo.Capture(e).Throw();
            }

            sfmlSprite.Position = new Vector2f(0, 0);
            sfmlSprite.Rotation = 90;
            var scaleX = (float)sfmlWindowWidth / screen.Width;
            var scaleY = (float)sfmlWindowHeight / screen.Height;

            sfmlSprite.Scale = new Vector2f(scaleY, -scaleX);

            sfmlStates = new RenderStates(BlendMode.None);

            menu            = new MenuRenderer(resource.Wad, screen);
            threeD          = new ThreeDRenderer(resource, screen);
            statusBar       = new StatusBarRenderer(resource.Wad, screen);
            intermission    = new IntermissionRenderer(resource.Wad, screen);
            openingSequence = new OpeningSequenceRenderer(resource.Wad, screen, this);
            autoMap         = new AutoMapRenderer(screen);
        }
예제 #3
0
        public SfmlRenderer(Config config, RenderWindow window, CommonResource resource)
        {
            try
            {
                Console.Write("Initialize renderer: ");

                this.config = config;

                config.video_gamescreensize  = Math.Clamp(config.video_gamescreensize, 0, this.MaxWindowSize);
                config.video_gammacorrection = Math.Clamp(config.video_gammacorrection, 0, this.MaxGammaCorrectionLevel);

                this.sfmlWindow = window;
                this.palette    = resource.Palette;

                this.sfmlWindowWidth  = (int)window.Size.X;
                this.sfmlWindowHeight = (int)window.Size.Y;

                if (config.video_highresolution)
                {
                    this.screen            = new DrawScreen(640, 400);
                    this.sfmlTextureWidth  = 512;
                    this.sfmlTextureHeight = 1024;
                }
                else
                {
                    this.screen            = new DrawScreen(320, 200);
                    this.sfmlTextureWidth  = 256;
                    this.sfmlTextureHeight = 512;
                }

                this.sfmlTextureData = new byte[4 * this.screen.Width * this.screen.Height];

                this.sfmlTexture = new Texture((uint)this.sfmlTextureWidth, (uint)this.sfmlTextureHeight);
                this.sfmlSprite  = new Sprite(this.sfmlTexture);

                this.sfmlSprite.Position = new Vector2f(0, 0);
                this.sfmlSprite.Rotation = 90;
                var scaleX = (float)this.sfmlWindowWidth / this.screen.Width;
                var scaleY = (float)this.sfmlWindowHeight / this.screen.Height;
                this.sfmlSprite.Scale = new Vector2f(scaleY, -scaleX);

                this.sfmlStates = new RenderStates(BlendMode.None);

                this.menu            = new MenuRenderer(this.screen);
                this.threeD          = new ThreeDRenderer(resource, this.screen, config.video_gamescreensize);
                this.statusBar       = new StatusBarRenderer(this.screen);
                this.intermission    = new IntermissionRenderer(this.screen);
                this.openingSequence = new OpeningSequenceRenderer(this.screen, this);
                this.autoMap         = new AutoMapRenderer(this.screen);
                this.finale          = new FinaleRenderer(resource, this.screen);

                this.pause = Patch.FromWad("M_PAUSE");

                var scale = this.screen.Width / 320;
                this.wipeBandWidth = 2 * scale;
                this.wipeBandCount = this.screen.Width / this.wipeBandWidth + 1;
                this.wipeHeight    = this.screen.Height / scale;
                this.wipeBuffer    = new byte[this.screen.Data.Length];

                this.palette.ResetColors(SfmlRenderer.gammaCorrectionParameters[config.video_gammacorrection]);

                Console.WriteLine("OK");
            }
            catch (Exception e)
            {
                Console.WriteLine("Failed");
                this.Dispose();
                ExceptionDispatchInfo.Throw(e);
            }
        }
예제 #4
0
        public SfmlRenderer(Config config, RenderWindow window, CommonResource resource)
        {
            try
            {
                Console.Write("Initialize renderer: ");

                this.config = config;

                config.video_gamescreensize  = Math.Clamp(config.video_gamescreensize, 0, MaxWindowSize);
                config.video_gammacorrection = Math.Clamp(config.video_gammacorrection, 0, MaxGammaCorrectionLevel);

                sfmlWindow = window;
                palette    = resource.Palette;

                sfmlWindowWidth  = (int)window.Size.X;
                sfmlWindowHeight = (int)window.Size.Y;

                if (config.video_highresolution)
                {
                    screen            = new DrawScreen(resource.Wad, 640, 400);
                    sfmlTextureWidth  = 512;
                    sfmlTextureHeight = 1024;
                }
                else
                {
                    screen            = new DrawScreen(resource.Wad, 320, 200);
                    sfmlTextureWidth  = 256;
                    sfmlTextureHeight = 512;
                }

                sfmlTextureData = new byte[4 * screen.Width * screen.Height];

                sfmlTexture = new SFML.Graphics.Texture((uint)sfmlTextureWidth, (uint)sfmlTextureHeight);
                sfmlSprite  = new SFML.Graphics.Sprite(sfmlTexture);

                sfmlSprite.Position = new Vector2f(0, 0);
                sfmlSprite.Rotation = 90;
                var scaleX = (float)sfmlWindowWidth / screen.Width;
                var scaleY = (float)sfmlWindowHeight / screen.Height;
                sfmlSprite.Scale       = new Vector2f(scaleY, -scaleX);
                sfmlSprite.TextureRect = new IntRect(0, 0, screen.Height, screen.Width);

                sfmlStates = new RenderStates(BlendMode.None);

                menu   = new MenuRenderer(resource.Wad, screen);
                threeD = new ThreeDRenderer(resource, screen, config.video_gamescreensize);
                //statusBar = new StatusBarRenderer(resource.Wad, screen);
                //intermission = new IntermissionRenderer(resource.Wad, screen);
                openingSequence = new OpeningSequenceRenderer(resource.Wad, screen, this);
                //autoMap = new AutoMapRenderer(resource.Wad, screen);
                //finale = new FinaleRenderer(resource, screen);

                //pause = Patch.FromWad(resource.Wad, "M_PAUSE");

                var scale = screen.Width / 320;
                wipeBandWidth = 2 * scale;
                wipeBandCount = screen.Width / wipeBandWidth + 1;
                wipeHeight    = screen.Height / scale;
                wipeBuffer    = new byte[screen.Data.Length];

                palette.ResetColors(gammaCorrectionParameters[config.video_gammacorrection]);

                Console.WriteLine("OK");
            }
            catch (Exception e)
            {
                Console.WriteLine("Failed");
                Dispose();
                ExceptionDispatchInfo.Throw(e);
            }
        }