コード例 #1
0
ファイル: Container.cs プロジェクト: Daramkun/ProjectLiqueur
        public override void Intro( params object [] args )
        {
            LiqueurSystem.Window.Title = "Simple Dodge";
            LiqueurSystem.GraphicsDevice.BlendState = true;
            LiqueurSystem.GraphicsDevice.BlendOperation = BlendOperation.AlphaBlend;

            Add ( InputHelper.CreateInstance () );
            InputHelper.IsKeyboardEnabled = true;
            Add ( SceneContainer = new SceneContainer ( new MenuScene () ) );

            contentManager = new ContentManager ( FileSystemManager.GetFileSystem ( "ManifestFileSystem" ) );
            contentManager.AddDefaultContentLoader ();
            LiqueurSystem.Launcher.InvokeInMainThread ( () =>
            {
                fpsFont = contentManager.Load<TrueTypeFont> ( "Test.Game.Dodge.Resources.GameFont.ttf", 20 );
            } );

            FpsCalculator calc;
            Add ( calc = new FpsCalculator () );
            calc.DrawEvent += ( object sender, GameTimeEventArgs e ) =>
            {
                string fpsString = string.Format ( "Update FPS:{0:0.00}\nRender FPS:{1:0.00}", calc.UpdateFPS, calc.DrawFPS );
                fpsFont.DrawFont ( fpsString, Color.White,
                    LiqueurSystem.GraphicsDevice.ScreenSize - fpsFont.MeasureString ( fpsString ) - new Vector2 ( 10, 10 ) );
            };

            base.Intro ( args );
        }
コード例 #2
0
ファイル: Container.cs プロジェクト: Daramkun/ProjectLiqueur
        public override void Intro( params object [] args )
        {
            LiqueurSystem.GraphicsDevice.CullingMode = CullingMode.None;

            Add ( InputHelper.CreateInstance () );

            FpsCalculator calc = new FpsCalculator ();
            calc.DrawEvent += ( object sender, GameTimeEventArgs e ) =>
            {
                int childrenCount = 0;
                for ( int i = 0; i < 6; ++i )
                    childrenCount += nodes [ i ].ChildrenCount;
                LiqueurSystem.Window.Title = string.Format ( "Update FPS: {0}, Draw FPS: {1}, Children count: {2}",
                    calc.UpdateFPS, calc.DrawFPS, childrenCount );
            };
            Add ( calc );

            ContentManager.ContentLoaderAssemblies.Add ( Assembly.Load ( "Daramkun.Liqueur.Spirit" ) );
            contentManager = new ContentManager ( FileSystemManager.GetFileSystem ( "ManifestFileSystem" ) );
            contentManager.AddDefaultContentLoader ();
            Texture2DContentLoader.AddDefaultDecoders ();

            textures = new ITexture2D [ 6 ];
            textures [ 0 ] = contentManager.Load<ITexture2D> ( "Test.Game.PerformanceTester.Resources.0096x0096.png" );
            textures [ 1 ] = contentManager.Load<ITexture2D> ( "Test.Game.PerformanceTester.Resources.0128x0128.png" );
            textures [ 2 ] = contentManager.Load<ITexture2D> ( "Test.Game.PerformanceTester.Resources.0256x0256.png" );
            textures [ 3 ] = contentManager.Load<ITexture2D> ( "Test.Game.PerformanceTester.Resources.0512x0512.png" );
            textures [ 4 ] = contentManager.Load<ITexture2D> ( "Test.Game.PerformanceTester.Resources.1024x1024.png" );
            textures [ 5 ] = contentManager.Load<ITexture2D> ( "Test.Game.PerformanceTester.Resources.2048x2048.png" );

            nodes = new Node [ 6 ];
            for ( int i = 0; i < 6; ++i )
            {
                nodes [ i ] = Add ( new Node () );
            }

            base.Intro ( args );
        }
コード例 #3
0
            public override void Intro( params object [] args )
            {
                LiqueurSystem.GraphicsDevice.IsZWriteEnable = true;
                LiqueurSystem.GraphicsDevice.CullingMode = CullingMode.None;
                LiqueurSystem.GraphicsDevice.ScreenSize = new Vector2 ( 800, 600 );
                LiqueurSystem.GraphicsDevice.BlendState = true;
                LiqueurSystem.GraphicsDevice.BlendOperation = BlendOperation.AlphaBlend;

                vertexShader = LiqueurSystem.GraphicsDevice.CreateShader ( @"#version 120
                attribute vec3 a_position;
                attribute vec2 a_texcoord;

                uniform mat4 proj;
                uniform mat4 modelView;

                varying vec2 v_texcoord;

                void main () {
                vec4 pos = vec4(a_position, 1);
                pos = modelView * pos;
                pos = proj * pos;
                gl_Position = pos;
                v_texcoord = a_texcoord;
                }
                    ", ShaderType.VertexShader );
                vertexShader.Option = new ShaderOption ()
                {
                    AttributeOrdering = new ShaderOption.AttributeOrder []
                    {
                        new ShaderOption.AttributeOrder () { Name = "a_position", VertexType = FlexibleVertexFormat.PositionXYZ },
                        new ShaderOption.AttributeOrder () { Name = "a_texcoord", VertexType = FlexibleVertexFormat.TextureUV1 }
                    }
                };
                fragShader = LiqueurSystem.GraphicsDevice.CreateShader ( @"#version 120
                varying vec2 v_texcoord;

                uniform sampler2D texture;

                void main () {
                gl_FragColor = texture2D ( texture, v_texcoord.st );
                }
                    ", ShaderType.FragmentShader );
                effect = LiqueurSystem.GraphicsDevice.CreateEffect ( vertexShader, fragShader );
                effect.SetArgument<Matrix4x4> ( "modelView", Matrix4x4.Identity * new Daramkun.Liqueur.Mathematics.Transforms.View ( new Vector3 ( -7, 7, 10 ),
                                                                                            new Vector3 ( 0f, 0f, 0f ),
                                                                                            new Vector3 ( 0, 1, 0 ) ).Matrix );
                effect.SetArgument<Matrix4x4> ( "proj", new PerspectiveFieldOfViewProjection ( ( float ) Math.PI / 4, 800 / 600.0f, 0.0001f, 1000.0f ).Matrix );

                vertexBuffer = LiqueurSystem.GraphicsDevice.CreateVertexBuffer<Vertex> ( FlexibleVertexFormat.PositionXY |
                                                                                        FlexibleVertexFormat.Diffuse, new Vertex []
                                                                                        {
                    new Vertex ( new Vector2 ( -5.0f, +5.0f ), new Vector2 ( 0, 1 ) ),
                    new Vertex ( new Vector2 ( +5.0f, -5.0f ), new Vector2 ( 1, 0 ) ),
                    new Vertex ( new Vector2 ( -5.0f, -5.0f ), new Vector2 ( 0, 0 ) ),
                    new Vertex ( new Vector2 ( +5.0f, +5.0f ), new Vector2 ( 1, 1 ) ),
                } );
                indexBuffer = LiqueurSystem.GraphicsDevice.CreateIndexBuffer ( new int [] { 0, 2, 1, 0, 1, 3, } );

                texture = LiqueurSystem.GraphicsDevice.CreateTexture2D ( new PngDecoder ().Decode (
                    Assembly.GetEntryAssembly ().GetManifestResourceStream ( "Test.Windows.CSharp.temp.png" ) )
                                                                        );

                renderBuffer = LiqueurSystem.GraphicsDevice.CreateRenderBuffer ( 1024, 1024 );

                sprite = new Sprite ( texture );
                font = new LsfFont ( Assembly.GetEntryAssembly ().GetManifestResourceStream ( "Test.Windows.CSharp.temp.lsf" ) );

                FpsCalculator calc = new FpsCalculator ();
                calc.DrawEvent += ( object sender, GameTimeEventArgs e ) =>
                {
                    string fpsString = string.Format ( "Update FPS: {0:0.00}\nRender FPS: {1:0.00}", calc.UpdateFPS, calc.DrawFPS );
                    font.DrawFont ( fpsString, Color.Black,
                                   new Vector2 ( 0, LiqueurSystem.GraphicsDevice.ScreenSize.Y - font.MeasureString ( fpsString ).Y ) );
                };
                Add ( calc );

                base.Intro ( args );
            }