Ejemplo n.º 1
0
        private static void InitializeRuntime(GameStartInfo gameStartInfo)
        {
            if (gameStartInfo.Adapter == null)
            {
                var adapters = GpuAdapter.EnumerateGraphicsAdapter();

                LogEmitter.Assert(adapters.Count > 0, LogLevel.Error, "[Initialize Graphics Device Failed without Support Adapter] from [GameSystems]");

                GpuDevice = new GpuDevice(adapters[0]);
            }
            else
            {
                GpuDevice = new GpuDevice(gameStartInfo.Adapter);
            }

            EngineWindow = new EngineWindow(
                gameStartInfo.WindowName,
                gameStartInfo.IconName,
                gameStartInfo.WindowSize);
            EngineWindow.Show();

            PresentRender = new PresentRender(GpuDevice, EngineWindow.Handle, EngineWindow.Size);

            //init resize event
            EngineWindow.OnSizeChangeEvent += (sender, eventArg) =>
            {
                PresentRender.ReSize(eventArg.After);
                VisualGuiSystem.Area = new Rectangle <int>(0, 0, eventArg.After.Width, eventArg.After.Height);
            };
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Set Transform, Result is Transform = Matrix
        /// </summary>
        /// <param name="matrix">Transform</param>
        public virtual void SetTransform(Matrix4x4 matrix)
        {
            mMatrix = matrix;

            bool result = Matrix4x4.Invert(mMatrix, out mInvert);

            LogEmitter.Assert(result, LogLevel.Error, "[Invert Gui Transform Failed]");
        }
Ejemplo n.º 3
0
        public void CopyFromImage(Point2 destination, Image image, Rectangle region)
        {
            var copySize = new Size(
                region.Right - region.Left,
                region.Bottom - region.Top);

            LogEmitter.Assert(
                image.Size.Width >= region.Right &&
                image.Size.Height >= region.Bottom &&
                destination.X + copySize.Width <= Size.Width &&
                destination.Y + copySize.Height <= Size.Height,
                LogLevel.Warning, "[Copy From Image Failed with Invalid Size]");

            //do not need copy, because the size is zero
            if (region.Left == region.Right || region.Top == region.Bottom)
            {
                return;
            }

            mTexture.CopyFromGpuTexture2D(destination, image.mTexture, region);
        }
Ejemplo n.º 4
0
        private static void InitializeRuntime(GameStartInfo gameStartInfo)
        {
            if (gameStartInfo.Adapter == null)
            {
                var adapters = GpuAdapter.EnumerateGraphicsAdapter();

                LogEmitter.Assert(adapters.Count > 0, LogLevel.Error, "[Initialize Graphics Device Failed without Support Adapter] from [GameSystems]");

                GpuDevice = new GpuDevice(adapters[0]);
            }
            else
            {
                GpuDevice = new GpuDevice(gameStartInfo.Adapter);
            }

            EngineWindow = new EngineWindow(
                gameStartInfo.Window.Name,
                gameStartInfo.Window.Icon,
                gameStartInfo.Window.Size);
            EngineWindow.Show();

            PresentRender = new PresentRender(GpuDevice, EngineWindow.Handle, EngineWindow.Size);
        }