示例#1
0
 protected override void OnRendering(IHostScreen screen, ref FBO currentFbo)
 {
     currentFbo = _gBuffer.FBO;
     FBO.Bind(currentFbo, FBO.Target.FrameBuffer);
     ElffyGL.Clear(ClearMask.ColorBufferBit | ClearMask.DepthBufferBit);
     _gBuffer.ClearColorBuffers();
 }
示例#2
0
 internal FrameTimingPoint(IHostScreen screen, FrameTiming timing)
 {
     Debug.Assert(timing.IsSpecified());
     _screen     = screen;
     _eventQueue = new AsyncEventQueueCore();
     _timing     = timing;
 }
示例#3
0
 private ComputeShaderDispatcher(ProgramObject program, IHostScreen screen, IComputeShader shader)
 {
     Debug.Assert(program.IsEmpty == false);
     _program = program;
     _screen  = screen;
     _shader  = shader;
 }
 internal static void ThrowIfContextNotEqual(IHostScreen actual, IHostScreen expected)
 {
     Debug.Assert(actual != null);
     Debug.Assert(expected != null);
     if(actual != expected) {
         Throw(actual, expected);
     }
 }
        /// <summary>
        /// NavService setup where vm is HostScreen
        /// NOTE: Must be initiated in the hostscreen constructor
        /// </summary>
        /// <param name="vm">HostScreen</param>
        public void Setup(IHostScreen vm)
        {
            // Set hostscreen
            HostScreen = vm;

            // Initialize stack
            ViewModels ??= new List <IViewModel>();
        }
示例#6
0
 internal RenderingArea(IHostScreen screen)
 {
     _state              = RenderingAreaLifeState.New;
     OwnerScreen         = screen;
     TimingPoints        = new FrameTimingPointList(screen);
     Lights              = new LightManager(screen);
     Layers              = new LayerCollection(this);
     _runningTokenSource = new CancellationTokenSource();
 }
示例#7
0
 protected override void OnSizeChanged(IHostScreen screen)
 {
     base.OnSizeChanged(screen);
     _isSizeChangeRequested       = true;
     _sizeChangeRequestedFrameNum = screen.FrameNum;
     if (_isSizeChangeObserved == false)
     {
         _isSizeChangeObserved = true;
         StartObserveSizeChanged(screen);
     }
 }
示例#8
0
        private protected sealed override void RenderOverride(IHostScreen screen, ref FBO currentFbo)
        {
            var timingPoints = TimingPoints;

            timingPoints.BeforeRendering.DoQueuedEvents();
            if (IsVisible)
            {
                RenderPostProcess(screen, ref currentFbo);
            }
            timingPoints.AfterRendering.DoQueuedEvents();
        }
示例#9
0
 internal FrameTimingPointList(IHostScreen screen)
 {
     _screen = screen;
     _frameInitializingPoint = new FrameTimingPoint(screen, FrameTiming.FrameInitializing);
     _earlyUpdatePoint       = new FrameTimingPoint(screen, FrameTiming.EarlyUpdate);
     _updatePoint            = new FrameTimingPoint(screen, FrameTiming.Update);
     _lateUpdatePoint        = new FrameTimingPoint(screen, FrameTiming.LateUpdate);
     _beforeRenderingPoint   = new FrameTimingPoint(screen, FrameTiming.BeforeRendering);
     _afterRenderingPoint    = new FrameTimingPoint(screen, FrameTiming.AfterRendering);
     _internalEndOfFrame     = new FrameTimingPoint(screen, FrameTiming.Internal_EndOfFrame);
 }
示例#10
0
文件: Startup.cs 项目: ikorin24/Elffy
        private static async UniTask Start(IHostScreen screen)
        {
            UniTask.Void(async() =>
            {
                await foreach (var _ in screen.Frames(FrameTiming.Update))
                {
                    if (screen.Keyboard.IsPress(Elffy.InputSystem.Keys.Escape))
                    {
                        screen.Close();
                    }
                }
            });
            var(drLayer, wLayer, uiLayer) =
                await LayerPipelines.CreateBuilder(screen).Build(
                    () => new DeferredRenderingLayer(),
                    () => new WorldLayer(),
                    () => new UILayer());

            InitializeLights(screen);
            var uiRoot  = uiLayer.UIRoot;
            var timings = screen.TimingPoints;

            uiRoot.Background = Color4.Black;
            try {
                await ParallelOperation.WhenAll(
                    //Sample.CreateUI(uiLayer.UIRoot),
                    CreateDice2(drLayer),
                    CreateCameraMouse(wLayer, new Vector3(0, 3, 0)),
                    CreateDice(wLayer),
                    CreateModel2(wLayer),
                    CreateBox(wLayer),
                    CreateFloor(wLayer),
                    //CreateFloor2(wLayer),
                    CreateSky(wLayer),
                    timings.Update.DelayTime(800));

                var time = TimeSpanF.FromMilliseconds(200);
                await foreach (var frame in timings.Update.Frames())
                {
                    if (frame.Time >= time)
                    {
                        break;
                    }
                    uiRoot.Background.A = 1f - frame.Time / time;
                }
            }
            finally {
                uiRoot.Background = Color4.Transparent;
            }
        }
示例#11
0
文件: Startup.cs 项目: ikorin24/Elffy
        private static void InitializeLights(IHostScreen screen)
        {
            ReadOnlySpan <Vector4> pos = stackalloc Vector4[]
            {
                new(1, 1, 1, 0),
                //new(1, 0, 0, 0),
            };
            ReadOnlySpan <Color4> color = stackalloc Color4[]
            {
                Color4.White,
                //Color4.OrangeRed,
            };

            screen.Lights.Initialize(pos, color);
        }
示例#12
0
        protected override void OnRendered(IHostScreen screen, ref FBO currentFbo)
        {
            var targetFbo = FBO.Empty;

            var gBuffer    = _gBuffer;
            var screenSize = screen.FrameBufferSize;
            var gBufSize   = gBuffer.Size;

            Debug.Assert(_postProcess is not null);
            Debug.Assert(_ppProgram is not null);
            FBO.Bind(targetFbo, FBO.Target.FrameBuffer);
            if (IsVisible)
            {
                _ppProgram.Render(screenSize, (Vector2)screenSize / (Vector2)gBufSize);
            }
            currentFbo = targetFbo;
        }
示例#13
0
 private void StartObserveSizeChanged(IHostScreen screen)
 {
     screen.StartCoroutine(this, static async(co, self) =>
     {
         while (co.CanRun)
         {
             if (self._isSizeChangeRequested && co.Screen.FrameNum - self._sizeChangeRequestedFrameNum > 1)
             {
                 // TODO: when height is 0.
                 self._gBuffer.Resize();
                 Debug.WriteLine("Resize !!!!!!!!!!!!");
                 self._isSizeChangeRequested = false;
             }
             await co.TimingPoints.FrameInitializing.Next();
         }
     }, FrameTiming.FrameInitializing).Forget();
 }
示例#14
0
        private static async void OnScreenInitialized(IHostScreen screen)
        {
            //Timing.Initialize(screen);
            //Game.Initialize(screen);
            ExceptionDispatchInfo?edi = null;

            try {
                await(_func?.Invoke(screen) ?? throw new InvalidOperationException("func is null"));
            }
            catch (Exception ex) {
                edi = ExceptionDispatchInfo.Capture(ex);
                await screen.TimingPoints.Update.Next();
            }
            finally {
                screen.Close();
                //Timing.Clear();
                //Game.Clear();
                _func = null;
            }
            edi?.Throw();
        }
示例#15
0
 protected override void SelectMatrix(IHostScreen screen, out Matrix4 view, out Matrix4 projection)
 {
     Debug.Fail("This method should not be called.");
     throw new NotSupportedException("This method should not be called.");
 }
示例#16
0
 protected sealed override void OnRendered(IHostScreen screen, ref FBO currentFbo)
 {
     Debug.Fail("This method should not be called.");
     throw new NotSupportedException("This method should not be called.");
 }
示例#17
0
 protected abstract void RenderPostProcess(IHostScreen screen, ref FBO currentFbo);
示例#18
0
 internal ComputeShaderContext(IHostScreen screen)
 {
     _screen = screen;
 }
示例#19
0
 protected override void OnAlive(IHostScreen screen)
 {
     // nop
 }
示例#20
0
 protected override void OnSizeChanged(IHostScreen screen)
 {
     // nop
 }
示例#21
0
 public static UniTask StartCoroutine(this IHostScreen parent, Func <CoroutineState, UniTask> coroutine)
 {
     return(Coroutine.Start(parent, coroutine));
 }
示例#22
0
 public static void StartOrReserveCoroutine <TState>(this IHostScreen parent, TState state, Func <CoroutineState, TState, UniTask> coroutine)
 {
     Coroutine.StartOrReserve(parent, state, coroutine);
 }
示例#23
0
 internal LayerPipelineBuilder(IHostScreen screen)
 {
     ArgumentNullException.ThrowIfNull(screen);
     _screen = screen;
 }
示例#24
0
 protected override void OnRendered(IHostScreen screen, ref FBO currentFbo)
 {
     // nop
 }
示例#25
0
 protected override void OnRendering(IHostScreen screen, ref FBO currentFbo)
 {
     FBO.Bind(FBO.Empty, FBO.Target.FrameBuffer);
     currentFbo = FBO.Empty;
 }
 public AbstractPage(IHostScreen parent, InstagramSession session)
 {
     this.parent  = parent;
     this.session = session;
 }
示例#27
0
            public static ProgramObject GetCacheOrCompile(IHostScreen screen, SourceKey key)
            {
                _dictionaries ??= new();

                ref var dic = ref CollectionsMarshal.GetValueRefOrAddDefault(_dictionaries, screen, out _);
示例#28
0
 public static UniTask StartCoroutine <TState>(this IHostScreen parent, TState state, Func <CoroutineState, TState, UniTask> coroutine, FrameTiming timing)
 {
     return(Coroutine.Start(parent, state, coroutine, timing));
 }
示例#29
0
 public static void StartOrReserveCoroutine(this IHostScreen parent, Func <CoroutineState, UniTask> coroutine, FrameTiming timing)
 {
     Coroutine.StartOrReserve(parent, coroutine, timing);
 }
示例#30
0
 public bool TryGetScreen([MaybeNullWhen(false)] out IHostScreen screen)
 {
     screen = _screen;
     return(_screen is not null);
 }