示例#1
0
        public void TryRender()
        {
            if (DrawSplashScreen)
            {
                return;
            }

            if (!IsAllowRender())
            {
                ////!!!!new
                //DestroyRenderTarget();

                return;
            }


            UpdateInput();


            //!!!!в OnPaint рисовать?

            //create render window
            if (needCreateRenderWindow && allowCreateRenderWindow && !disableRecreationRenderWindow && EngineApp.Instance != null && EngineApp.Created)
            {
                if (CreateRenderTarget())
                {
                    needCreateRenderWindow = false;
                }
            }

            //!!!!где еще такое RendererWorld.ViewportsDuringUpdate.Contains(viewport)

            if (renderWindow != null && !RenderingSystem.ViewportsDuringUpdate.Contains(viewport))
            {
                //!!!!?
                double time = EngineApp.GetSystemTime();
                //double time = EngineApp.Instance.EngineTime;
                if (lastRenderTime == 0)
                {
                    lastRenderTime = time;
                }

                double step = time - lastRenderTime;

                float invFPS = 0;
                if (automaticUpdateFPS != 0)
                {
                    invFPS = 1.0f / automaticUpdateFPS;
                }

                if (automaticUpdateFPS == 0 || step >= invFPS)
                {
                    lastRenderTime = time;

                    OneFrameChangeCursor = viewport.MouseRelativeMode ? GetHidedCursor() : Cursors.Default;
                    //OneFrameChangeCursor = Cursors.Default;

                    //!!!!new. тут?
                    EngineApp.DoTick();

                    //!!!!так ли. где еще
                    if (!DrawSplashScreen)
                    {
                        viewport.PerformTick((float)step);
                    }

                    //!!!!
                    ////tick and entity world tick
                    //if( WinFormsAppEngineApp.Instance != null )
                    //	WinFormsAppEngineApp.Instance.DoTick();

                    //!!!!!было
                    //if( renderWindow.Size.X != 0 && renderWindow.Size.Y != 0 )
                    //	camera.AspectRatio = (float)renderWindow.Size.X / (float)renderWindow.Size.Y;
                    //if( renderWindow.Size.X != 0 && renderWindow.Size.Y != 0 )
                    //	guiRenderer.AspectRatio = (float)renderWindow.Size.X / (float)renderWindow.Size.Y;

                    //update
                    //!!!!так?
                    viewport.Update(true, OverrideCameraSettings);                      // false );

                    //!!!!возможно надо свапать только раз. делать цепь из всех существующих.

                    //!!!!wait vsync?
                    //viewport.Parent.SwapBuffers( false );
                    //!!!!
                    //Log.Fatal( "viewport.Parent.SwapBuffers( true )" );
                    //viewport.Parent.SwapBuffers( true );
                    //renderWindow.Update( true );

                    //!!!!так?
                    if (Cursor != OneFrameChangeCursor)
                    {
                        Cursor = OneFrameChangeCursor;
                    }

                    OneFrameChangeCursor = viewport.MouseRelativeMode ? GetHidedCursor() : Cursors.Default;
                    //OneFrameChangeCursor = Cursors.Default;

                    WinFormsUtility.InvalidateParentComposedStyleControl(this);
                }
            }
        }