Пример #1
0
        private void RenderScreen()
        {
            Profiler.BeginSample("RPM.RenderScreen [" + activePage.name + "]");

            RenderTexture backupRenderTexture = RenderTexture.active;

            if (!screenTexture.IsCreated())
            {
                screenTexture.Create();
            }
            screenTexture.DiscardContents();
            RenderTexture.active = screenTexture;

            if (resourceDepleted || noCommConnection)
            {
                // If we're out of electric charge, we're drawing a blank screen.
                GL.Clear(true, true, emptyColorValue);
            }
            else
            {
                // This is the important witchcraft. Without that, DrawTexture does not print where we expect it to.
                // Cameras don't care because they have their own matrices, but DrawTexture does.
                GL.PushMatrix();
                GL.LoadPixelMatrix(0, screenPixelWidth, screenPixelHeight, 0);

                // Actual rendering of the background is delegated to the page object.
                activePage.RenderBackground(screenTexture);

                if (!string.IsNullOrEmpty(activePage.Text))
                {
                    textRenderer.Render(screenTexture, activePage);
                }

                activePage.RenderOverlay(screenTexture);
                GL.PopMatrix();
            }

            RenderTexture.active = backupRenderTexture;
            Profiler.EndSample();
        }
        private void RenderScreen()
        {
            RenderTexture backupRenderTexture = RenderTexture.active;

            if (!screenTexture.IsCreated())
            {
                screenTexture.Create();
            }
            screenTexture.DiscardContents();
            RenderTexture.active = screenTexture;

            if (needsElectricCharge && electricChargeReserve < 0.01d)
            {
                // If we're out of electric charge, we're drawing a blank screen.
                GL.Clear(true, true, emptyColorValue);
                RenderTexture.active = backupRenderTexture;
                return;
            }

            // This is the important witchcraft. Without that, DrawTexture does not print where we expect it to.
            // Cameras don't care because they have their own matrices, but DrawTexture does.
            GL.PushMatrix();
            GL.LoadPixelMatrix(0, screenPixelWidth, screenPixelHeight, 0);

            // Actual rendering of the background is delegated to the page object.
            activePage.RenderBackground(screenTexture);

            if (!string.IsNullOrEmpty(activePage.Text))
            {
                textRenderer.Render(screenTexture, screenBuffer, activePage);
            }

            activePage.RenderOverlay(screenTexture);
            GL.PopMatrix();

            RenderTexture.active = backupRenderTexture;
        }