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))
            {
                RenderText(screenBuffer);
            }

            // If we have a text overlay, that's where we print it.
            if (activePage.textOverlayBuffer.Length > 0)
            {
                RenderText(activePage.textOverlayBuffer, true);
            }

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

            RenderTexture.active = backupRenderTexture;
        }
예제 #2
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();
        }