예제 #1
0
        public void GaussianBlurRadius11_ShouldBlur()
        {
            preblur = new RenderImage("testGaussianBlur", 1280, 768);
            _gaussianBlur = new GaussianBlur(_resourceManager);

            _gaussianBlur.SetRadius(11);
            _gaussianBlur.SetAmount(2);
            _gaussianBlur.SetSize(new Vector2f(preblur.Width, preblur.Height));

            while (CluwneLib.IsRunning)
            {
                var lastFrameTime = clock.ElapsedTime.AsSeconds();
                clock.Restart();
                _frameEvent = new FrameEventArgs(lastFrameTime);
                CluwneLib.ClearCurrentRendertarget(Color.Black);
                CluwneLib.Screen.DispatchEvents();

                preblur.BeginDrawing(); // set temp as CRT (Current Render Target)
                //preblur.Clear();       //Clear
                sprite = _resourceManager.GetSprite("flashlight_mask");
                sprite.Position = new Vector2f();
                sprite.Draw();
                preblur.EndDrawing();  // set previous rendertarget as CRT (screen in this case)

                //_gaussianBlur.PerformGaussianBlur(preblur); // blur rendertarget

                preblur.Blit(0,0, preblur.Width, preblur.Height,Color.White, BlitterSizeMode.Crop ); // draw blurred nosprite logo

                CluwneLib.Screen.Display();

            }
        }
예제 #2
0
        public void GaussianBlurRadius11_ShouldBlur()
        {
            preblur = new RenderImage("testGaussianBlur", 1280, 768);
            blur = new RenderImage("testGaussianBlur1", 1280, 768);
            _gaussianBlur = new GaussianBlur(_resourceManager);

            _gaussianBlur.SetRadius(11);
            _gaussianBlur.SetAmount(2);
            _gaussianBlur.SetSize(new Size((int)preblur.Width, (int)preblur.Height));

            while (CluwneLib.IsRunning)
            {
                var lastFrameTime = clock.ElapsedTime.AsSeconds();
                clock.Restart();
                _frameEvent = new FrameEventArgs(lastFrameTime);
                CluwneLib.ClearCurrentRendertarget(Color.Black);
                CluwneLib.Screen.DispatchEvents();

                preblur.BeginDrawing(); // set temp as CRT (Current Render Target)
                preblur.Clear();       //Clear
                _resourceManager.GetSprite("AAAA").Draw(); //Draw NoSpritelogo
                preblur.EndDrawing();  // set previous rendertarget as CRT (screen in this case)

                _gaussianBlur.PerformGaussianBlur(preblur); // blur rendertarget

                preblur.Blit(0,0, 1280, 768); // draw blurred nosprite logo

                CluwneLib.Screen.Display();

            }
        }
예제 #3
0
 private void ResetRendertargets()
 {
     int w = (int)CluwneLib.Camera.ViewSize.X;
     int h = (int)CluwneLib.Camera.ViewSize.Y;
     /*
                 _baseTarget.Width = w;
                 _baseTarget.Height = h;
                 _sceneTarget.Width = w;
                 _sceneTarget.Height = h;
                 _tilesTarget.Width = w;
                 _tilesTarget.Height = h;
                 _overlayTarget.Width = w;
                 _overlayTarget.Height = h;
                 _composedSceneTarget.Width = w;
                 _composedSceneTarget.Height = h;
     */
     // TODO: See Startup for todos related to SFML
     /*_lightTarget.Width = w;
     _lightTarget.Height = h;
     _lightTargetIntermediate.Width = w;
     _lightTargetIntermediate.Height = h;
     screenShadows.Width = w;
     screenShadows.Height = h;
     shadowIntermediate.Width = w;
     shadowIntermediate.Height = h;
     shadowBlendIntermediate.Width = w;
     shadowBlendIntermediate.Height = h;
     playerOcclusionTarget.Dispose();
     playerOcclusionTarget = new RenderImage("playerOcclusionTarget", CluwneLib.Camera.ViewSize.X,
                                             CluwneLib.Camera.ViewSize.Y,
                                             ImageBufferFormats.BufferRGB888A8);
     playerOcclusionTarget.Width = w;
     playerOcclusionTarget.Height = h;*/
     //playerOcclusionTarget.DeviceReset();
     _gaussianBlur.Dispose();
     _gaussianBlur = new GaussianBlur(ResourceManager);
 }
예제 #4
0
        public void Startup()
        {
            LastUpdate = DateTime.Now;
            Now = DateTime.Now;

            _cleanupList = new List<RenderTarget>();
            _cleanupSpriteList = new List<CluwneSprite>();

            UserInterfaceManager.DisposeAllComponents();

            //Init serializer
            var serializer = IoCManager.Resolve<ISS14Serializer>();

            _entityManager = new EntityManager(NetworkManager);
            IoCManager.Resolve<IEntityManagerContainer>().EntityManager = _entityManager;

            NetworkManager.MessageArrived += NetworkManagerMessageArrived;

            NetworkManager.RequestMap();
            IoCManager.Resolve<IMapManager>().TileChanged += OnTileChanged;

            IoCManager.Resolve<IPlayerManager>().OnPlayerMove += OnPlayerMove;

            // TODO This should go somewhere else, there should be explicit session setup and teardown at some point.
            NetworkManager.SendClientName(ConfigurationManager.GetPlayerName());

            // Create new 
            _baseTarget = new RenderImage((uint)CluwneLib.Camera.ViewSize.X,
                                          (uint)CluwneLib.Camera.ViewSize.Y, true);
            _cleanupList.Add(_baseTarget);

            _baseTargetSprite = new CluwneSprite(_baseTarget);
            _cleanupSpriteList.Add(_baseTargetSprite);

            _sceneTarget = new RenderImage((uint)CluwneLib.Camera.ViewSize.X,
                                          (uint)CluwneLib.Camera.ViewSize.Y, true);
            _cleanupList.Add(_sceneTarget);
            _tilesTarget = new RenderImage((uint)CluwneLib.Camera.ViewSize.X,
                                           (uint)CluwneLib.Camera.ViewSize.Y, true);
            _cleanupList.Add(_tilesTarget);

            _overlayTarget = new RenderImage((uint)CluwneLib.Camera.ViewSize.X,
                                             (uint)CluwneLib.Camera.ViewSize.Y, true);
            _cleanupList.Add(_overlayTarget);
            //  _overlayTarget.SourceBlend = AlphaBlendOperation.SourceAlpha;
            //    _overlayTarget.DestinationBlend = AlphaBlendOperation.InverseSourceAlpha;
            // _overlayTarget.SourceBlendAlpha = AlphaBlendOperation.SourceAlpha;
            //_overlayTarget.DestinationBlendAlpha = AlphaBlendOperation.InverseSourceAlpha;

            _composedSceneTarget = new RenderImage((uint)CluwneLib.Camera.ViewSize.X,
                                                  (uint)CluwneLib.Camera.ViewSize.Y,
                                                 ImageBufferFormats.BufferRGB888A8);
            _cleanupList.Add(_composedSceneTarget);

            _lightTarget = new RenderImage("lightTarget", (int)CluwneLib.Camera.ViewSize.X,
                                           (int)CluwneLib.Camera.ViewSize.Y, ImageBufferFormats.BufferRGB888A8);

            _cleanupList.Add(_lightTarget);
            _lightTargetSprite = new CluwneSprite("lightTargetSprite", _lightTarget) { DepthWriteEnabled = false };

            _cleanupSpriteList.Add(_lightTargetSprite);

            _lightTargetIntermediate = new RenderImage("lightTargetIntermediate", (int)CluwneLib.Camera.ViewSize.X,
                                                      (int)CluwneLib.Camera.ViewSize.Y,
                                                      ImageBufferFormats.BufferRGB888A8);
            _cleanupList.Add(_lightTargetIntermediate);
            _lightTargetIntermediateSprite = new CluwneSprite("lightTargetIntermediateSprite", _lightTargetIntermediate) { DepthWriteEnabled = false };
            _cleanupSpriteList.Add(_lightTargetIntermediateSprite);

            _gasBatch = new SpriteBatch();
            //_gasBatch.SourceBlend = AlphaBlendOperation.SourceAlpha;
            //_gasBatch.DestinationBlend = AlphaBlendOperation.InverseSourceAlpha;
            //_gasBatch.SourceBlendAlpha = AlphaBlendOperation.SourceAlpha;
            //_gasBatch.DestinationBlendAlpha = AlphaBlendOperation.InverseSourceAlpha;

            _wallTopsBatch = new SpriteBatch();
            //_wallTopsBatch.SourceBlend = AlphaBlendOperation.SourceAlpha;
            //_wallTopsBatch.DestinationBlend = AlphaBlendOperation.InverseSourceAlpha;
            //_wallTopsBatch.SourceBlendAlpha = AlphaBlendOperation.SourceAlpha;
            //_wallTopsBatch.DestinationBlendAlpha = AlphaBlendOperation.InverseSourceAlpha;

            _decalBatch = new SpriteBatch();
            //_decalBatch.SourceBlend = AlphaBlendOperation.SourceAlpha;
            //_decalBatch.DestinationBlend = AlphaBlendOperation.InverseSourceAlpha;
            //_decalBatch.SourceBlendAlpha = AlphaBlendOperation.SourceAlpha;
            //_decalBatch.DestinationBlendAlpha = AlphaBlendOperation.InverseSourceAlpha;

            _floorBatch = new SpriteBatch();
            _wallBatch = new SpriteBatch();

            _gaussianBlur = new GaussianBlur(ResourceManager);

            _realScreenWidthTiles = (float)CluwneLib.Camera.ViewSize.X / MapManager.TileSize;
            _realScreenHeightTiles = (float)CluwneLib.Camera.ViewSize.Y / MapManager.TileSize;

            //Init GUI components
            _gameChat = new Chatbox(ResourceManager, UserInterfaceManager, KeyBindingManager);
            _gameChat.TextSubmitted += ChatTextboxTextSubmitted;
            UserInterfaceManager.AddComponent(_gameChat);

            //UserInterfaceManager.AddComponent(new StatPanelComponent(ConfigurationManager.GetPlayerName(), PlayerManager, NetworkManager, ResourceManager));

            var statusBar = new StatusEffectBar(ResourceManager, PlayerManager);
            statusBar.Position = new Point((int)CluwneLib.Camera.ViewSize.X - 800, 10);
            UserInterfaceManager.AddComponent(statusBar);

            var hotbar = new Hotbar(ResourceManager);
            hotbar.Position = new Point(5, (int)CluwneLib.Camera.ViewSize.Y - hotbar.ClientArea.Height - 5);
            hotbar.Update(0);
            UserInterfaceManager.AddComponent(hotbar);

            #region Lighting
            // TODO: Convert all shaders to GLSL
            // TODO: Convert QuadRenderer to use SFML
            // TODO: Convert shadowMapResolver to use SFML
            // TODO: Convert this shit right here to use SFML
            /*
                        quadRenderer = new QuadRenderer();
                        quadRenderer.LoadContent();
                        shadowMapResolver = new ShadowMapResolver(quadRenderer, ShadowmapSize.Size1024, ShadowmapSize.Size1024,
                                                                  ResourceManager);
                        shadowMapResolver.LoadContent();
                        lightArea128 = new LightArea(ShadowmapSize.Size128);
                        lightArea256 = new LightArea(ShadowmapSize.Size256);
                        lightArea512 = new LightArea(ShadowmapSize.Size512);
                        lightArea1024 = new LightArea(ShadowmapSize.Size1024);
                        screenShadows = new RenderImage("screenShadows", CluwneLib.Camera.ViewSize.X,
                                                        CluwneLib.Camera.ViewSize.Y, ImageBufferFormats.BufferRGB888A8);
                        _cleanupList.Add(screenShadows);
                        screenShadows.UseDepthBuffer = false;
                        shadowIntermediate = new RenderImage("shadowIntermediate", CluwneLib.Camera.ViewSize.X,
                                                             CluwneLib.Camera.ViewSize.Y,
                                                             ImageBufferFormats.BufferRGB888A8);
                        _cleanupList.Add(shadowIntermediate);
                        shadowIntermediate.UseDepthBuffer = false;
                        shadowBlendIntermediate = new RenderImage("shadowBlendIntermediate", CluwneLib.Camera.ViewSize.X,
                                                                  CluwneLib.Camera.ViewSize.Y,
                                                                  ImageBufferFormats.BufferRGB888A8);
                        _cleanupList.Add(shadowBlendIntermediate);
                        shadowBlendIntermediate.UseDepthBuffer = false;
                        playerOcclusionTarget = new RenderImage("playerOcclusionTarget", CluwneLib.Camera.ViewSize.X,
                                                                CluwneLib.Camera.ViewSize.Y,
                                                                ImageBufferFormats.BufferRGB888A8);
                        _cleanupList.Add(playerOcclusionTarget);
                        playerOcclusionTarget.UseDepthBuffer = false;
                        lightBlendShader = IoCManager.Resolve<IResourceManager>().GetShader("lightblend");
                        finalBlendShader = IoCManager.Resolve<IResourceManager>().GetShader("finallight");
                        lightMapShader = IoCManager.Resolve<IResourceManager>().GetShader("lightmap");

                        playerVision = IoCManager.Resolve<ILightManager>().CreateLight();
                        playerVision.SetColor(Color.Transparent);
                        playerVision.SetRadius(1024);
                        playerVision.Move(Vector2.Zero);
             */

            #endregion

            _handsGui = new HandsGui();
            _handsGui.Position = new Point(hotbar.Position.X + 5, hotbar.Position.Y + 7);
            UserInterfaceManager.AddComponent(_handsGui);

            var combo = new HumanComboGui(PlayerManager, NetworkManager, ResourceManager, UserInterfaceManager);
            combo.Update(0);
            combo.Position = new Point(hotbar.ClientArea.Right - combo.ClientArea.Width + 5,
                                       hotbar.Position.Y - combo.ClientArea.Height - 5);
            UserInterfaceManager.AddComponent(combo);

            var healthPanel = new HealthPanel();
            healthPanel.Position = new Point(hotbar.ClientArea.Right - 1, hotbar.Position.Y + 11);
            healthPanel.Update(0);
            UserInterfaceManager.AddComponent(healthPanel);

            var targetingUi = new TargetingGui();
            targetingUi.Update(0);
            targetingUi.Position = new Point(healthPanel.ClientArea.Right - 1,
                                             healthPanel.ClientArea.Bottom - targetingUi.ClientArea.Height);
            UserInterfaceManager.AddComponent(targetingUi);

            var inventoryButton = new ImageButton
                                      {
                                          ImageNormal = "button_inv",
                                          Position = new Point(hotbar.Position.X + 172, hotbar.Position.Y + 2)
                                      };
            inventoryButton.Update(0);
            inventoryButton.Clicked += inventoryButton_Clicked;
            UserInterfaceManager.AddComponent(inventoryButton);

            var statusButton = new ImageButton
                                   {
                                       ImageNormal = "button_status",
                                       Position =
                                           new Point(inventoryButton.ClientArea.Right, inventoryButton.Position.Y)
                                   };
            statusButton.Update(0);
            statusButton.Clicked += statusButton_Clicked;
            UserInterfaceManager.AddComponent(statusButton);

            var craftButton = new ImageButton
                                  {
                                      ImageNormal = "button_craft",
                                      Position = new Point(statusButton.ClientArea.Right, statusButton.Position.Y)
                                  };
            craftButton.Update(0);
            craftButton.Clicked += craftButton_Clicked;
            UserInterfaceManager.AddComponent(craftButton);

            var menuButton = new ImageButton
                                 {
                                     ImageNormal = "button_menu",
                                     Position = new Point(craftButton.ClientArea.Right, craftButton.Position.Y)
                                 };
            menuButton.Update(0);
            menuButton.Clicked += menuButton_Clicked;
            UserInterfaceManager.AddComponent(menuButton);

            CluwneLib.Camera.SetWorldCenter( new Vector2(0.0f, 0.0f));
        }
예제 #5
0
        private void ResetRendertargets()
        {
            int w = (int)CluwneLib.Screen.Size.X;
            int h = (int)CluwneLib.Screen.Size.Y;

            _baseTarget.Scale = new Vector2(w, h);
            _sceneTarget.Scale = new Vector2(w, h);
            _tilesTarget.Scale = new Vector2(w, h);
            _overlayTarget.Scale = new Vector2(w, h);
            _composedSceneTarget.Scale = new Vector2(w, h);

            _lightTarget.Scale = new Vector2(w, h);
            _lightTargetIntermediate.Scale = new Vector2(w, h);
            screenShadows.Scale = new Vector2(w, h);
            shadowIntermediate.Scale = new Vector2(w, h);
            shadowBlendIntermediate.Scale = new Vector2(w, h);

            playerOcclusionTarget.Dispose();
            playerOcclusionTarget = new RenderImage("playerOcclusionTarget", CluwneLib.CurrentClippingViewport.Width,
                                                    CluwneLib.CurrentClippingViewport.Height,
                                                    ImageBufferFormats.BufferRGB888A8);
            playerOcclusionTarget.Scale = new Vector2(w, h);
            //playerOcclusionTarget.DeviceReset();
            _gaussianBlur.Dispose();
            _gaussianBlur = new GaussianBlur(ResourceManager);
        }
예제 #6
0
        public void Startup()
        {
            LastUpdate = DateTime.Now;
            Now = DateTime.Now;

            _cleanupList = new List<RenderImage>();
            _cleanupSpriteList = new List<Sprite>();

            UserInterfaceManager.DisposeAllComponents();

            //Init serializer
            serializer = IoCManager.Resolve<ISS14Serializer>();

            _entityManager = new EntityManager(NetworkManager);
            IoCManager.Resolve<IEntityManagerContainer>().EntityManager = _entityManager;
            IoCManager.Resolve<IMapManager>().TileChanged += OnTileChanged;
            IoCManager.Resolve<IPlayerManager>().OnPlayerMove += OnPlayerMove;

            NetworkManager.MessageArrived += NetworkManagerMessageArrived;
            NetworkManager.RequestMap();
            // TODO This should go somewhere else, there should be explicit session setup and teardown at some point.
            NetworkManager.SendClientName(ConfigurationManager.GetPlayerName());

            // Create new
            _gaussianBlur = new GaussianBlur(ResourceManager);

            _realScreenWidthTiles = (float)CluwneLib.Screen.Size.X / MapManager.TileSize;
            _realScreenHeightTiles = (float)CluwneLib.Screen.Size.Y / MapManager.TileSize;

            InitializeRenderTargets();
            InitializeSpriteBatches();
            InitalizeLighting();
            InitializeGUI();
        }