Exemple #1
0
        /// <summary>
        /// Unload contents
        /// </summary>
        public override void UnloadContent()
        {
            if (Mesh != null)
            {
                Mesh.Dispose();
            }
            Mesh = null;

            if (SimpleShader != null)
            {
                SimpleShader.Dispose();
            }
            SimpleShader = null;

            if (Font != null)
            {
                Font.Dispose();
            }
            Font = null;

            if (Batch != null)
            {
                Batch.Dispose();
            }
            Batch = null;

            if (Texture != null)
            {
                Texture.Dispose();
            }
            Texture = null;
        }
Exemple #2
0
 protected override void LoadContent()
 {
     Bindings.XNA.SLSharp.Init(GraphicsDevice);
     Shader.DebugMode = true;
     _shader          = Shader.CreateSharedShader <SimpleShader>();
     _model           = Content.Load <Model>("xwing");
 }
Exemple #3
0
        public StreamingSource(int[] message, SimpleShader simpleShader)
            : base(simpleShader, 0, 1)
        {
            Message = message;

            Size = new Vector2(Delta * (Message.Length + 1), Delta * 2);

            InstasingList.Add(new VisualUniforms(Color4.Black));
            for (int i = 0; i < Message.Length; i++)
            {
                var bit   = message[i];
                var glyph = new Glyph7x5(bit == 0?'0':'1',
                                         new Vector2(Delta * i + 4, 2),
                                         SimpleShader);
                BitMessage.Add(glyph);
                Childrens.Add(glyph);
            }
            var vertices = new List <Vector2>();

            vertices.AddRange(Polyline(new[]
            {
                new Vector2(Delta * Message.Length, 0),
                new Vector2(-1, 0),
                new Vector2(-1, Delta * 2),
                new Vector2(Delta * Message.Length, Delta * 2)
            }, 2));

            CreateOutput(0, ConnectorOrientation.Right, new Vector2(Delta * (Message.Length + 1), 0));

            Shape = vertices.ToArray();
        }
Exemple #4
0
        public void OnLoad()
        {
            var dir = Directory.GetCurrentDirectory();

            ResourceGroupManager.Singleton.AddResourceLocation(dir, "FileSystem");
            MaterialManager.Singleton.Initialise();

            _scene = _root.CreateSceneManager("DefaultSceneManager", "SLSharpInstance");
            _scene.ClearScene();

            Bindings.MOGRE.SLSharp.Init();
            Shader.DebugMode = true;

            //Shader.DebugMode = true;

            _shader = Shader.CreateSharedShader <SimpleShader>();

            _patchEntity = _scene.CreateEntity("Box", "box.mesh");
            _scene.RootSceneNode.AttachObject(_patchEntity);

            var mat  = _shader.ToMaterial();
            var pass = mat.GetTechnique(0).GetPass(0);

            pass.SetAlphaRejectSettings(CompareFunction.CMPF_GREATER_EQUAL, 128);
            pass.CullingMode = CullingMode.CULL_NONE;

            // SL# on OGRE: bind auto semantic to a uniform!
            // (we might automate this via semantic attributes within the SL# shaders in future!)
            _shader.SetAuto(() => _shader.ModelviewProjection, GpuProgramParameters.AutoConstantType.ACT_WORLDVIEWPROJ_MATRIX);

            _shader.Begin();

            // Set a texture

            /*
             * var smp = _shader.Sampler(() => _shader.Texture);
             * smp.SetTextureName(TextureManager.Singleton.Load("test.png", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME).Name);
             * smp.SetTextureName(_wang.AsTexture.Name);
             * smp.SetTextureFiltering(FilterOptions.FO_POINT, FilterOptions.FO_POINT, FilterOptions.FO_POINT);
             */

            _patchEntity.SetMaterial(mat);

            _camera          = _scene.CreateCamera("MainCamera");
            _camera.Position = new Vector3(0, 0, 5);
            _camera.LookAt(Vector3.ZERO);
            _camera.NearClipDistance = 0.0001f;
            _camera.FarClipDistance  = 4.0f;
            _camera.AutoAspectRatio  = true;

            var vp = _window.AddViewport(_camera);

            vp.BackgroundColour = ColourValue.Blue;
        }
        public StreamingSplitter(SimpleShader simpleShader)
            : base(simpleShader, 1, 2)
        {
            Size = new Vector2(Delta * 2, Delta * 2);
            InstasingList.Add(new VisualUniforms(Color4.Black));
            Shape = Circle(new Vector2(Delta, Delta), 0, 20);
            CreateInput(0, ConnectorOrientation.Left, new Vector2(0, Delta));

            CreateOutput(0, ConnectorOrientation.Right, new Vector2(Delta * 2, Delta));
            CreateOutput(1, ConnectorOrientation.Bottom, new Vector2(Delta, 0));
        }
 public StreamingVisual(SimpleShader simpleShader, int inCount, int outCount)
     : base(simpleShader)
 {
     _frame = new DrawingVisual(simpleShader);
     _frame.InstasingList.Add(new VisualUniforms(new Color4(0, 0, 1f, 0.3f)));
     _frame.IsVisible = false;
     Childrens.Add(_frame);
     InCount  = inCount;
     OutCount = outCount;
     Inputs   = new Edge[inCount];
     Outputs  = new Edge[outCount];
     Bits     = new Glyph7x5[inCount];
 }
Exemple #7
0
        protected override void Initialize(SharpDxGraphicsSystem system)
        {
            this.shader = system.ShaderCache.GetNewOrCachedShader(
                system.Renderer.Device,
                system.Renderer.DeviceContext,
                Resources.LightShaderPath,
                "VS",
                "PS",
                SimpleVertex.VertexInputLayout);

            this.cubeMesh = new PolyMesh(system.Renderer.Device,
                                         cubeVertices,
                                         cubeIndices);

            system.Renderer.AddRenderable(this);
        }
Exemple #8
0
        public void OnLoad()
        {
            var dir = Directory.GetCurrentDirectory();

            ResourceGroupManager.Instance.AddResourceLocation(dir, "Folder");
            //MaterialManager.Instance.Initialize();

            _scene = _root.CreateSceneManager("DefaultSceneManager", "SLSharpInstance");
            _scene.ClearScene();

            Bindings.Axiom.SLSharp.Init();
            Shader.DebugMode = true;

            //Shader.DebugMode = true;

            _shader = Shader.CreateSharedShader <SimpleShader>();

            _patchEntity = _scene.CreateEntity("Box", "box.mesh");
            _scene.RootSceneNode.AttachObject(_patchEntity);

            var mat  = _shader.ToMaterial();
            var pass = mat.GetTechnique(0).GetPass(0);

            pass.SetAlphaRejectSettings(CompareFunction.GreaterEqual, 128);
            pass.CullingMode = CullingMode.None;

            // SL# on OGRE: bind auto semantic to a uniform!
            // (we might automate this via semantic attributes within the SL# shaders in future!)
            _shader.SetAuto(() => _shader.ModelviewProjection, GpuProgramParameters.AutoConstantType.WorldViewProjMatrix);

            _shader.Begin();

            _patchEntity.MaterialName = mat.Name;
            //_patchEntity.Material = mat;


            _camera          = _scene.CreateCamera("MainCamera");
            _camera.Position = new Vector3(0, 0, 5);
            _camera.LookAt(Vector3.Zero);
            _camera.Near            = 0.00001f;
            _camera.Far             = 4.0f;
            _camera.AutoAspectRatio = true;

            var vp = _root.AutoWindow.AddViewport(_camera);

            vp.BackgroundColor = ColorEx.CornflowerBlue;
        }
        public StreamingReceiver(SimpleShader simpleShader) : base(simpleShader, 1, 0)
        {
            Size = new Vector2(Delta * 8, Delta * 2);
            InstasingList.Add(new VisualUniforms(Color4.Black));

            var vertices = new List <Vector2>();

            vertices.AddRange(Polyline(new[]
            {
                new Vector2(Delta, 0),
                new Vector2(Delta * 8, 0),
                new Vector2(Delta * 8, Delta * 2),
                new Vector2(Delta, Delta * 2)
            }, 2));

            CreateInput(0, ConnectorOrientation.Left, new Vector2(0, 0));
            Shape = vertices.ToArray();
        }
Exemple #10
0
        public StreamingWire(SimpleShader simpleShader) :
            base(simpleShader, 1, 1)
        {
            InstasingList.Add(new VisualUniforms(Color4.Black));
            MovingWire = new DrawingVisual(SimpleShader);
            MovingWire.InstasingList.Add(new VisualUniforms(Color4.Red));
            OldMovingWire = new DrawingVisual(SimpleShader);
            OldMovingWire.InstasingList.Add(new VisualUniforms(Color4.Red));
            MovingCircle = new DrawingVisual(SimpleShader);
            MovingCircle.InstasingList.Add(new VisualUniforms(Color4.Black));
            MovingCircle.Scale = new Vector2(0, 0);
            MovingCircle.Shape = Circle(Vector2.Zero, Thickness / 2, 10);
            Childrens.Add(OldMovingWire);
            Childrens.Add(MovingWire);
            Childrens.Add(MovingCircle);

            pathAnimation = new PathAnimation(this);
        }
        public StreamingSummator(SimpleShader simpleShader, int inCount)
            : base(simpleShader, inCount, 1)
        {
            Size = new Vector2(Delta * 4, Delta * 4);
            InstasingList.Add(new VisualUniforms(Color4.Black));

            var vertices = new List <Vector2>();

            var center = new Vector2(Delta * 2, Delta * 2);

            vertices.AddRange(Round(center, Delta, 2, 60));
            var l = new Vector2(Delta * 1.5f, Delta * 2);
            var r = new Vector2(Delta * 2.5f, Delta * 2);

            vertices.AddRange(Line(l, r, 2));
            var u = new Vector2(Delta * 2, Delta * 2.5f);
            var d = new Vector2(Delta * 2, Delta * 1.5f);

            vertices.AddRange(Line(u, d, 2));

            CreateInput(0, ConnectorOrientation.Left, new Vector2(0, Delta * 2));
            CreateOutput(0, ConnectorOrientation.Right, new Vector2(Delta * 4, Delta * 2));

            if (Up)
            {
                CreateInput(1, ConnectorOrientation.Top, new Vector2(Delta * 2, Delta * 4));
            }
            else if (Down)
            {
                CreateInput(1, ConnectorOrientation.Bottom, new Vector2(Delta * 2, 0));
            }

            Shape = vertices.ToArray();

            GlyphPlus = new Glyph7x5(' ', new Vector2(Delta * 1, -5), SimpleShader);
            Childrens.Add(GlyphPlus);

            GlyphEqual = new Glyph7x5(' ', new Vector2(Delta * 3, -5), SimpleShader);
            Childrens.Add(GlyphEqual);
        }
        public StreamingRegister(SimpleShader simpleShader)
            : base(simpleShader, 1, 1)
        {
            Size = new Vector2(Delta * 6, Delta * 2);
            InstasingList.Add(new VisualUniforms(Color4.Black));
            var vertices = new List <Vector2>();

            vertices.AddRange(Rectangle(
                                  new Vector2(Delta, 0),
                                  new Vector2(Delta * 5, Delta * 2), 2));
            Shape = vertices.ToArray();

            CreateInput(0, ConnectorOrientation.Left, new Vector2(0, Delta));
            CreateOutput(0, ConnectorOrientation.Right, new Vector2(Delta * 6, Delta));

            GlyphWord.CollectionChanged += (s, e) =>
            {
                if (e.NewItems != null)
                {
                    foreach (Glyph7x5 glyph in e.NewItems)
                    {
                        Childrens.Add(glyph);
                    }
                }
                if (e.OldItems != null)
                {
                    foreach (Glyph7x5 glyph in e.OldItems)
                    {
                        Childrens.Remove(glyph);
                    }
                }
            };

            Word        = _word;
            MemoryGlyph = new Glyph7x5('0', new Vector2(Delta * 2.5f, Delta * 2 + 2), SimpleShader);
            Childrens.Add(MemoryGlyph);
        }
Exemple #13
0
        // For uniforms and shaders setup. Does not handle vertex/index buffers
        private static unsafe void EncodeSimple(RendererBGFXInstance *sys, bgfx.Encoder *encoder, ref SimpleShader simpleShader, ushort viewId, ref float4x4 tx, ref SimpleMaterialBGFX mat, byte flipCulling, uint depth)
        {
            ulong state = mat.state;

            if (flipCulling != 0)
            {
                state = FlipCulling(state);
            }
            bgfx.set_state(state, 0);

            fixed(float4x4 *p = &tx)
            bgfx.encoder_set_transform(encoder, p, 1);

            // material uniforms setup
            fixed(float4 *p = &mat.constAlbedo_Opacity)
            bgfx.encoder_set_uniform(encoder, simpleShader.m_uniformColor0, p, 1);

            fixed(float4 *p = &mat.mainTextureScaleTranslate)
            bgfx.encoder_set_uniform(encoder, simpleShader.m_uniformTexMad, p, 1);

            fixed(float4 *p = &mat.billboarded)
            bgfx.encoder_set_uniform(encoder, simpleShader.m_uniformBillboarded, p, 1);

            bgfx.encoder_set_texture(encoder, 0, simpleShader.m_samplerTexColor0, mat.texAlbedoOpacity, UInt32.MaxValue);
            bgfx.encoder_submit(encoder, viewId, simpleShader.m_prog, depth, (byte)bgfx.DiscardFlags.All);
        }
Exemple #14
0
        static void Main(string[] args)
        {
            Font font = new Font(@".\GapSansBold.ttf")
            {
                FontSize = 51,
            };

            controller = new GameController(0);
            GameKeybindHost host = new GameKeybindHost(new GameKeybindList()
            {
                { "g_test", context => Keyboard.IsAnyKeyPressed, context => context.ControllerState.Buttons[GamepadButtonFlags.A, true] }
            });

            actor = GameKeybindActor.CreateControllerActor(controller);
            actor.ConnectHost(host);


            portal = STPProject.CreateFromZIP("portal.zip");

            window = new GLWindow(1280, 720, "0ms", WindowFlags.Window, VSyncMode.Off);
            window.ApplySetup(new Window2DSetup());
            window.SetRenderPipeline(new TestRenderPipeline());

            window.SetScene(scene = new Scene()
            {
                ShowAxisHelper = true
            });
            scene.Background.Color = Color4.DarkGray;
            scene.Camera           = new Camera()
            {
            };

            SimpleShader shader = new SimpleShader("basic", AssemblyUtility.ReadAssemblyFile("SM_TEST.Default Fragment Shader1.frag"), (a, b) => {
                a["Color"].SetColor(b.Material.Tint);
                a["Scale"].SetFloat(b.Material.ShaderArguments.Get("Scale", 1f));
            });
            DrawObject2D obj = new DrawObject2D()
            {
                Material =
                {
                    CustomShader    = shader,
                    Tint            = new Color4(1f, 0.151217f, 0.050313f, 1),
                    ShaderArguments =
                    {
                        ["Scale"] = 50f
                    }
                }
            };/*
               * DrawObject2D obj2 = new DrawObject2D()
               * {
               * Material =
               * {
               *    Tint = Color4.Aqua,
               *    CustomShader = shader,
               *    ShaderArguments =
               *    {
               *        ["Scale"] = 1000f
               *    }
               * }
               * };
               * obj2.Transform.Position.Set(300);*/

            scene.Objects.Add(obj);

            window.RenderFrame += Window_RenderFrame;
            window.Run();

            Debug.WriteLine("Window Closed");
        }
 public StreamingComponent(SimpleShader simpleShader, int inCount, int outCount)
     : base(simpleShader, inCount, outCount)
 {
     InputConnectors  = new Connector[inCount];
     OutputConnectors = new Connector[outCount];
 }