Example #1
0
        public SurfaceManager()
        {
            Shaders.Add(
                ShaderFileLoader.CreateDefault(asset("Shaders/")).Load(".")
                );
            new[]
            {
                "geometry", "uvcolor",
                "Deferred/gSprite",
                "Deferred/gLevel",
                "Deferred/debug",
                "Deferred/compose",
                "Deferred/pointlight"
            }.ForEach(name => Shaders.MakeShaderProgram(name));

            Primitives = new IndexedSurface <PrimitiveVertexData>()
                         .WithShader(Shaders["geometry"])
                         .AndSettings(ViewMatrix, ProjectionMatrix);
            ConsoleBackground = new IndexedSurface <PrimitiveVertexData>()
                                .WithShader(Shaders["geometry"])
                                .AndSettings(ViewMatrix, ProjectionMatrix);

            ConsoleFont        = Font.FromJsonFile(font("Inconsolata.json"));
            ConsoleFontSurface = new IndexedSurface <UVColorVertexData>()
                                 .WithShader(Shaders["uvcolor"])
                                 .AndSettings(
                ViewMatrix, ProjectionMatrix,
                new TextureUniform("diffuse", new Texture(font("Inconsolata.png"), preMultiplyAlpha: true))
                );

            UIFont        = Font.FromJsonFile(font("HelveticaNeue.json"));
            UIFontSurface = new IndexedSurface <UVColorVertexData>()
                            .WithShader(Shaders["uvcolor"])
                            .AndSettings(
                ViewMatrix, ProjectionMatrix,
                new TextureUniform("diffuse", new Texture(font("HelveticaNeue.png"), preMultiplyAlpha: true))
                );

            LevelSurface = new IndexedSurface <LevelVertex>()
                           .WithShader(Shaders["Deferred/gLevel"])
                           .AndSettings(ViewMatrix, ProjectionMatrix);

            PointLights = new IndexedSurface <PointLightVertex>()
                          .WithShader(Shaders["Deferred/pointlight"])
                          .AndSettings(ViewMatrix, ProjectionMatrix);

            GameSurfaces = new GameSurfaceManager(Shaders, ViewMatrix, ProjectionMatrix);
        }