示例#1
0
        private static void init(ShaderI shader, Loader.LoadedCallbackMethod loadedCallback)
        {
            try
            {
                CameraConstant = shader.Variable("Camera"); DiffuseConstant = shader.Resource("Diffuse");
                var elements = new List <BufferLayoutElement>();
                elements.Add(new BufferLayoutElement(BufferLayoutElementTypes.Vector3, BufferLayoutElementUsages.Position, 0, 0, 0)); elements.Add(new BufferLayoutElement(BufferLayoutElementTypes.RGBAx8, BufferLayoutElementUsages.Color, 0, 0, 3)); elements.Add(new BufferLayoutElement(BufferLayoutElementTypes.Vector2, BufferLayoutElementUsages.UV, 0, 0, 4));
                BufferLayoutDesc = BufferLayoutDescAPI.New(elements);
                BufferLayout     = BufferLayoutAPI.New(shader, shader, BufferLayoutDesc);
            }
            catch (Exception e)
            {
                FailedToLoad = true;
                Loader.AddLoadableException(e);
                Dispose();
                if (loadedCallback != null)
                {
                    loadedCallback(null, false);
                }
                return;
            }

            Loaded = true;
            if (loadedCallback != null)
            {
                loadedCallback(null, true);
            }
        }
示例#2
0
        private static void init(ShaderI shader, Loader.LoadedCallbackMethod loadedCallback)
        {
            try
            {
                CameraConstant = shader.Variable("Camera");PositionConstant = shader.Variable("Position");SizeConstant = shader.Variable("Size");PositionUVConstant = shader.Variable("PositionUV");SizeUVConstant = shader.Variable("SizeUV");TexelOffsetConstant = shader.Variable("TexelOffset");ColorConstant = shader.Variable("Color");DiffuseTextureConstant = shader.Resource("DiffuseTexture");
                var elements = new List<BufferLayoutElement>();
                elements.Add(new BufferLayoutElement(BufferLayoutElementTypes.Vector2, BufferLayoutElementUsages.Position, 0, 0, 0));
                BufferLayoutDesc = BufferLayoutDescAPI.New(elements);
                BufferLayout = BufferLayoutAPI.New(shader, shader, BufferLayoutDesc);
            }
            catch (Exception e)
            {
                FailedToLoad = true;
                Loader.AddLoadableException(e);
                Dispose();
                if (loadedCallback != null) loadedCallback(null, false);
                return;
            }

            Loaded = true;
            if (loadedCallback != null) loadedCallback(null, true);
        }
示例#3
0
        private void init(ShaderI shader, Texture2DI texture, Stream stream, string metricsFileName, Loader.LoadedCallbackMethod loadedCallback)
        {
            try
            {
                // load characters
                var metrics = new FontMetrics();
                metrics.Load(stream);

                Characters = new Character[metrics.Characters.Length];
                for (int i = 0; i != metrics.Characters.Length; ++i)
                {
                    var character = metrics.Characters[i];
                    Characters[i] = new Character(character.Key, new Vector2(character.X, character.Y), new Vector2(character.Width, character.Height));
                }

                // get shader variables
                this.texture     = texture;
                this.shader      = shader;
                shaderCamera     = shader.Variable("Camera");
                shaderPosition   = shader.Variable("Position");
                shaderSize       = shader.Variable("Size");
                shaderPositionUV = shader.Variable("PositionUV");
                shaderSizeUV     = shader.Variable("SizeUV");
                texelOffset      = shader.Variable("TexelOffset");
                shaderColor      = shader.Variable("Color");
                shaderTexture    = shader.Resource("DiffuseTexture");

                // create buffers
                var layoutDesc = BufferLayoutDescAPI.New(BufferLayoutTypes.Position2);
                layout = BufferLayoutAPI.New(this, shader, layoutDesc);

                var Indices = new int[6]
                {
                    0, 1, 2,
                    0, 2, 3
                };

                var Vertices = new float[8]
                {
                    0, 0,
                    0, 1,
                    1, 1,
                    1, 0,
                };

                indexBuffer  = IndexBufferAPI.New(this, BufferUsages.Default, Indices);
                vertexBuffer = VertexBufferAPI.New(this, layoutDesc, BufferUsages.Default, VertexBufferTopologys.Triangle, Vertices);
            }
            catch (Exception e)
            {
                FailedToLoad = true;
                Loader.AddLoadableException(e);
                Dispose();
                if (loadedCallback != null)
                {
                    loadedCallback(this, false);
                }
            }

            Loaded = true;
            if (loadedCallback != null)
            {
                loadedCallback(this, true);
            }
        }
示例#4
0
        private static void init(ShaderI shader, Loader.LoadedCallbackMethod loadedCallback)
        {
            try
            {
                CameraConstant = shader.Variable("Camera"); PositionConstant = shader.Variable("Position"); SizeConstant = shader.Variable("Size"); TexelOffsetConstant = shader.Variable("TexelOffset"); ColorConstant = shader.Variable("Color"); FadeConstant = shader.Variable("Fade"); Fade2Constant = shader.Variable("Fade2"); MainTextureConstant = shader.Resource("MainTexture"); MainTexture2Constant = shader.Resource("MainTexture2"); MainTexture3Constant = shader.Resource("MainTexture3");
                var elements = new List <BufferLayoutElement>();
                elements.Add(new BufferLayoutElement(BufferLayoutElementTypes.Vector2, BufferLayoutElementUsages.Position, 0, 0, 0));
                BufferLayoutDesc = BufferLayoutDescAPI.New(elements);
                BufferLayout     = BufferLayoutAPI.New(shader, shader, BufferLayoutDesc);
            }
            catch (Exception e)
            {
                FailedToLoad = true;
                Loader.AddLoadableException(e);
                Dispose();
                if (loadedCallback != null)
                {
                    loadedCallback(null, false);
                }
                return;
            }

            Loaded = true;
            if (loadedCallback != null)
            {
                loadedCallback(null, true);
            }
        }
示例#5
0
        private static void init(ShaderI shader, Loader.LoadedCallbackMethod loadedCallback)
        {
            try
            {
                CameraConstant = shader.Variable("Camera");BillboardTransformConstant = shader.Variable("BillboardTransform");DiffuseConstant = shader.Resource("Diffuse");ColorPalletConstant = shader.Variable("ColorPallet");ScalePalletConstant = shader.Variable("ScalePallet");TransformsConstant = shader.Variable("Transforms");
                var elements = new List<BufferLayoutElement>();
                elements.Add(new BufferLayoutElement(BufferLayoutElementTypes.Vector3, BufferLayoutElementUsages.Position, 0, 0, 0));elements.Add(new BufferLayoutElement(BufferLayoutElementTypes.Vector2, BufferLayoutElementUsages.UV, 0, 0, 3));
                BufferLayoutDesc = BufferLayoutDescAPI.New(elements);
                BufferLayout = BufferLayoutAPI.New(shader, shader, BufferLayoutDesc);
            }
            catch (Exception e)
            {
                FailedToLoad = true;
                Loader.AddLoadableException(e);
                Dispose();
                if (loadedCallback != null) loadedCallback(null, false);
                return;
            }

            Loaded = true;
            if (loadedCallback != null) loadedCallback(null, true);
        }
示例#6
0
        private void init(ShaderI shader, Texture2DI texture, Stream stream, string metricsFileName, Loader.LoadedCallbackMethod loadedCallback)
        {
            try
            {
                // load characters
                var metrics = new FontMetrics();
                metrics.Load(stream);

                Characters = new Character[metrics.Characters.Length];
                for (int i = 0; i != metrics.Characters.Length; ++i)
                {
                    var character = metrics.Characters[i];
                    Characters[i] = new Character(character.Key, new Vector2(character.X, character.Y), new Vector2(character.Width, character.Height));
                }

                // get shader variables
                this.texture = texture;
                this.shader = shader;
                shaderCamera = shader.Variable("Camera");
                shaderPosition = shader.Variable("Position");
                shaderSize = shader.Variable("Size");
                shaderPositionUV = shader.Variable("PositionUV");
                shaderSizeUV = shader.Variable("SizeUV");
                texelOffset = shader.Variable("TexelOffset");
                shaderColor = shader.Variable("Color");
                shaderTexture = shader.Resource("DiffuseTexture");

                // create buffers
                var layoutDesc = BufferLayoutDescAPI.New(BufferLayoutTypes.Position2);
                layout = BufferLayoutAPI.New(this, shader, layoutDesc);

                var Indices = new int[6]
                {
                    0, 1, 2,
                    0, 2, 3
                };

                var Vertices = new float[8]
                {
                    0, 0,
                    0, 1,
                    1, 1,
                    1, 0,
                };

                indexBuffer = IndexBufferAPI.New(this, BufferUsages.Default, Indices);
                vertexBuffer = VertexBufferAPI.New(this, layoutDesc, BufferUsages.Default, VertexBufferTopologys.Triangle, Vertices);
            }
            catch (Exception e)
            {
                FailedToLoad = true;
                Loader.AddLoadableException(e);
                Dispose();
                if (loadedCallback != null) loadedCallback(this, false);
            }

            Loaded = true;
            if (loadedCallback != null) loadedCallback(this, true);
        }