Ejemplo n.º 1
0
        private void OnGlfwWindowSize(Window *window, int width, int height)
        {
            try
            {
                var oldSize = _framebufferSize;
                GLFW.GetFramebufferSize(window, out var fbW, out var fbH);
                _framebufferSize = (fbW, fbH);
                _windowSize      = (width, height);

                if (fbW == 0 || fbH == 0 || width == 0 || height == 0)
                {
                    return;
                }

                _pixelRatio = _framebufferSize / _windowSize;

                GL.Viewport(0, 0, fbW, fbH);
                if (fbW != 0 && fbH != 0)
                {
                    RegenerateLightingRenderTargets();
                }

                OnWindowResized?.Invoke(new WindowResizedEventArgs(oldSize, _framebufferSize));
            }
            catch (Exception e)
            {
                CatchCallbackException(e);
            }
        }
Ejemplo n.º 2
0
        private void OnGlfwWindowSize(Window *window, int width, int height)
        {
            try
            {
                var oldSize = _framebufferSize;
                GLFW.GetFramebufferSize(window, out var fbW, out var fbH);
                _framebufferSize = (fbW, fbH);
                _windowSize      = (width, height);
                UpdateWindowLoadedRtSize();

                if (fbW == 0 || fbH == 0 || width == 0 || height == 0)
                {
                    return;
                }

                _pixelRatio = _framebufferSize / _windowSize;

                GL.Viewport(0, 0, fbW, fbH);
                if (fbW != 0 && fbH != 0)
                {
                    _mainViewport.Dispose();
                    CreateMainViewport();
                }

                OnWindowResized?.Invoke(new WindowResizedEventArgs(oldSize, _framebufferSize));
            }
            catch (Exception e)
            {
                CatchCallbackException(e);
            }
        }
Ejemplo n.º 3
0
        public override void Initialize()
        {
            ReloadConfig();

            _rootViewportSizeChangedSubscriber = new GodotSignalSubscriber0();
            _rootViewportSizeChangedSubscriber.Connect(_sceneTreeHolder.SceneTree.Root, "size_changed");
            _rootViewportSizeChangedSubscriber.Signal += () =>
            {
                // TODO: Uh maybe send oldSize correctly here.
                OnWindowResized?.Invoke(new WindowResizedEventArgs(Vector2i.Zero, ScreenSize));
            };
        }
Ejemplo n.º 4
0
        void Update()
        {
            UpdatedVectorBottomLeft = _camera.Camera.ScreenToWorldPoint(new Vector3(0, 0, 30));
            UpdatedVectorTopRight   = _camera.Camera.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, 30));

            if ((initialVectorBottomLeft != UpdatedVectorBottomLeft) || (initialVectorTopRight != UpdatedVectorTopRight))
            {
                OnScreenResizedHandler?.Invoke();
            }

            FSMUpdate();
        }
Ejemplo n.º 5
0
        private void OnGlfwWindowSize(Window *window, int width, int height)
        {
            var oldSize = _screenSize;

            GLFW.GetFramebufferSize(window, out var fbW, out var fbH);
            _screenSize = (fbW, fbH);

            GL.Viewport(0, 0, fbW, fbH);
            if (fbW != 0 && fbH != 0)
            {
                _regenerateLightRenderTarget();
            }

            OnWindowResized?.Invoke(new WindowResizedEventArgs(oldSize, _screenSize));
        }
Ejemplo n.º 6
0
        private void _initWindow()
        {
            var width  = _configurationManager.GetCVar <int>("display.width");
            var height = _configurationManager.GetCVar <int>("display.height");

            _window = new GameWindow(
                width,
                height,
                GraphicsMode.Default,
                "Space Station 14",
                GameWindowFlags.Default,
                DisplayDevice.Default,
                3, 3,
#if DEBUG
                GraphicsContextFlags.Debug | GraphicsContextFlags.ForwardCompatible
#else
                GraphicsContextFlags.ForwardCompatible
#endif
                )
            {
                Visible = true
            };

            _windowSize = new Vector2i(_window.Width, _window.Height);

            _mainThread = Thread.CurrentThread;

            _window.KeyDown += (sender, eventArgs) =>
            {
                _gameController.GameController.KeyDown((KeyEventArgs)eventArgs);
            };

            _window.KeyUp  += (sender, eventArgs) => { _gameController.GameController.KeyUp((KeyEventArgs)eventArgs); };
            _window.Closed += (sender, eventArgs) => { _gameController.GameController.Shutdown("Window closed"); };
            _window.Resize += (sender, eventArgs) =>
            {
                var oldSize = _windowSize;
                _windowSize = new Vector2i(_window.Width, _window.Height);
                GL.Viewport(0, 0, _window.Width, _window.Height);
                GL.BindTexture(TextureTarget.Texture2D, LightTexture.Handle);
                var(lightW, lightH) = _lightMapSize();
                GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba16f, lightW, lightH, 0,
                              PixelFormat.Rgba, PixelType.Float, IntPtr.Zero);
                OnWindowResized?.Invoke(new WindowResizedEventArgs(oldSize, _windowSize));
            };
            _window.MouseDown += (sender, eventArgs) =>
            {
                var mouseButtonEventArgs = (MouseButtonEventArgs)eventArgs;
                _gameController.GameController.MouseDown(mouseButtonEventArgs);
                if (!mouseButtonEventArgs.Handled)
                {
                    _gameController.GameController.KeyDown((KeyEventArgs)eventArgs);
                }
            };
            _window.MouseUp += (sender, eventArgs) =>
            {
                var mouseButtonEventArgs = (MouseButtonEventArgs)eventArgs;
                _gameController.GameController.MouseUp(mouseButtonEventArgs);
                if (!mouseButtonEventArgs.Handled)
                {
                    _gameController.GameController.KeyUp((KeyEventArgs)eventArgs);
                }
            };
            _window.MouseMove += (sender, eventArgs) =>
            {
                MouseScreenPosition = new Vector2(eventArgs.X, eventArgs.Y);
                _gameController.GameController.MouseMove((MouseMoveEventArgs)eventArgs);
            };
            _window.MouseWheel += (sender, eventArgs) =>
            {
                _gameController.GameController.MouseWheel((MouseWheelEventArgs)eventArgs);
            };
            _window.KeyPress += (sender, eventArgs) =>
            {
                // If this is a surrogate it has to be specifically handled and I'm not doing that yet.
                DebugTools.Assert(!char.IsSurrogate(eventArgs.KeyChar));

                _gameController.GameController.TextEntered(new TextEventArgs(eventArgs.KeyChar));
            };

            using (var iconFile = _resourceCache.ContentFileRead("/Textures/Logo/icon.ico"))
            {
                _window.Icon = new Icon(iconFile);
            }

            _initOpenGL();
        }
Ejemplo n.º 7
0
        private void _initWindow()
        {
            var width  = _configurationManager.GetCVar <int>("display.width");
            var height = _configurationManager.GetCVar <int>("display.height");

            _window = new GameWindow(
                width,
                height,
                GraphicsMode.Default,
                "Space Station 14",
                GameWindowFlags.Default,
                DisplayDevice.Default,
                3, 3,
#if DEBUG
                GraphicsContextFlags.Debug | GraphicsContextFlags.ForwardCompatible
#else
                GraphicsContextFlags.ForwardCompatible
#endif
                )
            {
                Visible = true
            };

            _windowSize = new Vector2i(_window.Width, _window.Height);

            _mainThread = Thread.CurrentThread;

            _window.KeyDown += (sender, eventArgs) =>
            {
                _gameController.GameController.KeyDown((KeyEventArgs)eventArgs);
            };

            _window.KeyUp  += (sender, eventArgs) => { _gameController.GameController.KeyUp((KeyEventArgs)eventArgs); };
            _window.Closed += (sender, eventArgs) => { _gameController.GameController.Shutdown("Window closed"); };
            _window.Resize += (sender, eventArgs) =>
            {
                var oldSize = _windowSize;
                _windowSize = new Vector2i(_window.Width, _window.Height);
                GL.Viewport(0, 0, _window.Width, _window.Height);
                OnWindowResized?.Invoke(new WindowResizedEventArgs(oldSize, _windowSize));
            };
            _window.MouseDown += (sender, eventArgs) =>
            {
                var mouseButtonEventArgs = (MouseButtonEventArgs)eventArgs;
                _gameController.GameController.MouseDown(mouseButtonEventArgs);
                if (!mouseButtonEventArgs.Handled)
                {
                    _gameController.GameController.KeyDown((KeyEventArgs)eventArgs);
                }
            };
            _window.MouseUp += (sender, eventArgs) =>
            {
                var mouseButtonEventArgs = (MouseButtonEventArgs)eventArgs;
                _gameController.GameController.MouseUp(mouseButtonEventArgs);
                if (!mouseButtonEventArgs.Handled)
                {
                    _gameController.GameController.KeyUp((KeyEventArgs)eventArgs);
                }
            };
            _window.MouseMove += (sender, eventArgs) =>
            {
                MouseScreenPosition = new Vector2(eventArgs.X, eventArgs.Y);
                _gameController.GameController.MouseMove((MouseMoveEventArgs)eventArgs);
            };
            _window.MouseWheel += (sender, eventArgs) =>
            {
                _gameController.GameController.MouseWheel((MouseWheelEventArgs)eventArgs);
            };
            _window.KeyPress += (sender, eventArgs) =>
            {
                // If this is a surrogate it has to be specifically handled and I'm not doing that yet.
                DebugTools.Assert(!char.IsSurrogate(eventArgs.KeyChar));

                _gameController.GameController.TextEntered(new TextEventArgs(eventArgs.KeyChar));
            };

            _initOpenGL();
        }
Ejemplo n.º 8
0
        private void _initWindow()
        {
            _window = new GameWindow(
                800,
                600,
                GraphicsMode.Default,
                "Space Station 14",
                GameWindowFlags.Default,
                DisplayDevice.Default,
                4, 1,
#if DEBUG
                GraphicsContextFlags.Debug | GraphicsContextFlags.ForwardCompatible
#else
                GraphicsContextFlags.ForwardCompatible
#endif
                )
            {
                Visible = true
            };

            _windowSize = new Vector2i(_window.Width, _window.Height);

            _mainThread = Thread.CurrentThread;

            _window.KeyDown += (sender, eventArgs) =>
            {
                _gameController.GameController.KeyDown((KeyEventArgs)eventArgs);
            };

            _window.KeyUp  += (sender, eventArgs) => { _gameController.GameController.KeyUp((KeyEventArgs)eventArgs); };
            _window.Closed += (sender, eventArgs) => { _gameController.GameController.Shutdown("Window closed"); };
            _window.Resize += (sender, eventArgs) =>
            {
                var oldSize = _windowSize;
                _windowSize = new Vector2i(_window.Width, _window.Height);
                GL.Viewport(0, 0, _window.Width, _window.Height);
                OnWindowResized?.Invoke(new WindowResizedEventArgs(oldSize, _windowSize));
            };
            _window.MouseDown += (sender, eventArgs) =>
            {
                var mouseButtonEventArgs = (MouseButtonEventArgs)eventArgs;
                _gameController.GameController.MouseDown(mouseButtonEventArgs);
                if (!mouseButtonEventArgs.Handled)
                {
                    _gameController.GameController.KeyDown((KeyEventArgs)eventArgs);
                }
            };
            _window.MouseUp += (sender, eventArgs) =>
            {
                var mouseButtonEventArgs = (MouseButtonEventArgs)eventArgs;
                _gameController.GameController.MouseUp(mouseButtonEventArgs);
                if (!mouseButtonEventArgs.Handled)
                {
                    _gameController.GameController.KeyUp((KeyEventArgs)eventArgs);
                }
            };
            _window.MouseMove += (sender, eventArgs) =>
            {
                MouseScreenPosition = new Vector2(eventArgs.X, eventArgs.Y);
                _gameController.GameController.MouseMove((MouseMoveEventArgs)eventArgs);
            };
            _window.MouseWheel += (sender, eventArgs) =>
            {
                _gameController.GameController.MouseWheel((MouseWheelEventArgs)eventArgs);
            };
            _window.KeyPress += (sender, eventArgs) =>
            {
                _gameController.GameController.TextEntered(new TextEventArgs(eventArgs.KeyChar));
            };

            _initOpenGL();
        }