Esempio n. 1
0
        private void CreateRenderTargets(GraphicsDevice device)
        {
            int stringWidth = (int)(Font().MeasureString(text).X) + 2;    // +2 for good Karma.

            // Create the diffuse texture.
            int width  = margin.X + stringWidth;
            int height = margin.Y + Font().LineSpacing;

            if (checkbox)
            {
                width += UIGridTextListElement.Checkbox.Width + UIGridTextListElement.Margin.X;
            }

            if (BokuGame.RequiresPowerOf2)
            {
                width  = MyMath.GetNextPowerOfTwo(width);
                height = MyMath.GetNextPowerOfTwo(height);
            }

            diffuse = new RenderTarget2D(device,
                                         width, height,
                                         false, // Mip levels
                                         SurfaceFormat.Color,
                                         DepthFormat.None);
            InGame.GetRT("TextLine", diffuse);

            RefreshTexture();
        }
        private void CreateRenderTargets(GraphicsDevice device)
        {
            // Create the diffuse texture.
            diffuse = new RenderTarget2D(device, w, h, false, SurfaceFormat.Color, DepthFormat.None);
            InGame.GetRT("UIGridModularPictureListElement", diffuse);

            // Refresh the texture.
            dirty = true;
            RefreshTexture();
        }
Esempio n. 3
0
        private void CreateRenderTargets(GraphicsDevice device)
        {
            const int dpi = 96;
            int       w   = (int)(dpi * 2.0f);
            int       h   = (int)(dpi * 2.0f);

            rt = new RenderTarget2D(device, w, h, false, SurfaceFormat.Color, DepthFormat.None);
            InGame.GetRT("UIGridLevelElement", rt);

            dirty = true;   // Ensure a refresh of the texture.
        }
Esempio n. 4
0
        private void CreateRenderTargets(GraphicsDevice device)
        {
            int w, h;

            GetWH(out w, out h);

            diffuse = new RenderTarget2D(device, 512, h, false, SurfaceFormat.Color, DepthFormat.None);
            InGame.GetRT("ModularMenu", diffuse);

            dirty = true;
            RefreshTexture();
        }
        private void CreateRenderTargets(GraphicsDevice device)
        {
            // Note this really works best if w = 5 * h
            int h = 128;
            int w = (int)(width / height * h);

            // Create the diffuse texture.
            diffuse = new RenderTarget2D(device, w, h, false, SurfaceFormat.Color, DepthFormat.None);
            InGame.GetRT("UIGridModularButtonElement", diffuse);

            // Refresh the texture.
            dirty = true;
            RefreshTexture();
        }
Esempio n. 6
0
        private void CreateRenderTargets(GraphicsDevice device)
        {
            const int dpi = 128;
            int       w   = (int)(dpi * width);
            int       h   = (int)(dpi * height);

            // Create the diffuse texture.
            diffuse = new RenderTarget2D(device, w, h, false, SurfaceFormat.Color, DepthFormat.None);
            InGame.GetRT("UIGrid2DBaseSliderElement", diffuse);

            // Refresh the texture.
            dirty = true;
            RefreshTexture();
        }
        private void CreateRenderTargets(GraphicsDevice device)
        {
            int w = (int)(dpi * width);
            int h = (int)(dpi * height);

            if (BokuGame.RequiresPowerOf2)
            {
                w = MyMath.GetNextPowerOfTwo(w);
                h = MyMath.GetNextPowerOfTwo(h);
            }

            diffuse = new RenderTarget2D(device, w, h, false, SurfaceFormat.Color, DepthFormat.None);
            InGame.GetRT("UIGridPictureListElement", diffuse);

            dirty = true;
        }
        private void CreateRenderTargets(GraphicsDevice device)
        {
            int w, h;

            GetWH(out w, out h);

            diffuse = new RenderTarget2D(
                device,
                w, h,
                false,      // mipmaps
                SurfaceFormat.Color,
                DepthFormat.None);

            InGame.GetRT("UIGridModularRadioBoxElement", diffuse);

            dirty = true;
            RefreshTexture();
        }
        private void CreateRenderTargets(GraphicsDevice device)
        {
            // Note this really works best if w = 5 * h
            int h = 64 + 128; //64 for title, 128 for body
            int w = (int)(width / height * h);

            diffuse = new RenderTarget2D(
                device,
                w, h,
                false,      // mip levels
                SurfaceFormat.Color,
                DepthFormat.None);

            InGame.GetRT("UIGridModularNextLevelElement", diffuse);

            // Refresh the texture.
            dirty = true;
            RefreshTexture();
        }
            private void CreateRenderTargets(GraphicsDevice device)
            {
                if (gradient != null)
                {
                    // Create the rendertarget.
                    int size = 64;
                    rt = new RenderTarget2D(device, size, size, false, SurfaceFormat.Color, DepthFormat.None);
                    InGame.GetRT("UIGridPictureListElement", rt);

                    // Render the gradient into the rendertarget.
                    InGame.SetRenderTarget(rt);

                    ScreenSpaceQuad quad = ScreenSpaceQuad.GetInstance();
                    quad.RenderGradient(gradient);

                    // Restore backbuffer.
                    InGame.RestoreRenderTarget();
                }
            }
Esempio n. 11
0
        private void CreateRenderTargets(GraphicsDevice device)
        {
            const int dpi = 128;
            int       w   = (int)(dpi * width);
            int       h   = (int)(dpi * height);

            // Create the diffuse texture.  Leave it null if we have no text to render.
            int originalWidth  = w;
            int originalHeight = h;

            if (BokuGame.RequiresPowerOf2)
            {
                w = MyMath.GetNextPowerOfTwo(w);
                h = MyMath.GetNextPowerOfTwo(h);
            }

            // Create the diffuse texture.  Leave it null if we have no text to render.
            diffuse = new RenderTarget2D(device, w, h, false, SurfaceFormat.Color, DepthFormat.None, 1, RenderTargetUsage.PlatformContents);
            InGame.GetRT("UIGrid2DTextElement", diffuse);

            InGame.SetRenderTarget(diffuse);
            InGame.Clear(Color.Transparent);

            if (label != null && label.Length > 0)
            {
                // Render the label text into the texture.
                int margin    = 24;
                int x         = 0;
                int y         = (int)((originalHeight - Font().LineSpacing) / 2.0f) - 2;
                int textWidth = (int)(Font().MeasureString(label).X);

                x = TextHelper.CalcJustificationOffset(margin, originalWidth, textWidth, justify);

                SpriteBatch batch = UI2D.Shared.SpriteBatch;
                batch.Begin();
                TextHelper.DrawStringWithShadow(Font, batch, x, y, label, textColor, dropShadowColor, invertDropShadow);
                batch.End();
            }

            // Restore backbuffer.
            InGame.RestoreRenderTarget();
        }
Esempio n. 12
0
        }   // end of DeviceReset()

        private static void CreateRenderTarget()
        {
            if (rt == null)
            {
                // Calc rt height to allow for 4 lines of text using our font of choice.
                // Calc rt width to match screen ratio.

                int height = 4 * font().LineSpacing;
                // int width = (int)(height * BokuGame.bokuGame.GraphicsDevice.Viewport.Width / (float)BokuGame.bokuGame.GraphicsDevice.Viewport.Height / (1.0f - kScreenFraction));
                //width = (int)MathHelper.Min(width, BokuGame.bokuGame.GraphicsDevice.Viewport.Width);
                int width = (int)BokuGame.ScreenSize.X;

                rt = new RenderTarget2D(
                    BokuGame.bokuGame.GraphicsDevice,
                    width, height, false,
                    SurfaceFormat.Color,
                    DepthFormat.None);
                InGame.GetRT("TutorialRT", rt);
            }
        }   // end of CreateRenderTarget()
Esempio n. 13
0
        private void CreateRenderTargets(GraphicsDevice device)
        {
            const int dpi = 96;
            int       w   = (int)(dpi * width);
            int       h   = (int)(dpi * height);

            // Create the diffuse texture.
            int originalWidth  = w;
            int originalHeight = h;

            if (BokuGame.RequiresPowerOf2)
            {
                w = MyMath.GetNextPowerOfTwo(w);
                h = MyMath.GetNextPowerOfTwo(h);
            }

            diffuse = new RenderTarget2D(device, w, h, false, SurfaceFormat.Color, DepthFormat.None);
            InGame.GetRT("UIGrid2DCheckBoxElement", diffuse);

            // Refresh the texture.
            dirty = true;
            RefreshTexture();
        }
Esempio n. 14
0
        private static void CreateRenderTargets(GraphicsDevice device)
        {
            int width  = 1024;
            int height = 768;

            renderTarget1024_768 = new RenderTarget2D(
                device,
                width, height, false,
                SurfaceFormat.Color,
                DepthFormat.Depth24Stencil8,
                0,
                RenderTargetUsage.PlatformContents);
            InGame.GetRT("UI2D.Shared:renderTargetDepth1024_768", renderTargetDepthStencil1024_768);

            width  = 1280;
            height = 720;
            if (renderTargetDepthStencil1280_720 == null)
            {
                int numSamples = BokuSettings.Settings.AntiAlias ? 8 : 1;
#if NETFX_CORE
                numSamples = 0;
#endif
                renderTargetDepthStencil1280_720 = new RenderTarget2D(
                    device,
                    width, height, false,
                    SurfaceFormat.Color,
                    DepthFormat.Depth24Stencil8, numSamples,
                    RenderTargetUsage.PlatformContents);
                InGame.GetRT("UI2D.Shared:renderTargetDepthStencil1280_720", renderTargetDepthStencil1280_720);
            }

            width  = 1920;
            height = 540;
            if (renderTarget1920_540 == null)
            {
                renderTarget1920_540 = new RenderTarget2D(
                    BokuGame.bokuGame.GraphicsDevice,
                    width, height, false,
                    SurfaceFormat.Color,
                    DepthFormat.None, 0,
                    RenderTargetUsage.PlatformContents);
                InGame.GetRT("UI2D.Shared:renderTarget1920_540", renderTarget1920_540);
            }

            width  = 1024;
            height = 768;
            renderTarget1024_768 = new RenderTarget2D(
                device,
                width, height, false,
                SurfaceFormat.Color,
                DepthFormat.None,
                0,
                RenderTargetUsage.PlatformContents);
            InGame.GetRT("UI2D.Shared:renderTarget1024_768", renderTarget1024_768);

            width  = 512;
            height = 512;
            renderTarget512_512 = new RenderTarget2D(
                device,
                width, height, false,
                SurfaceFormat.Color,
                DepthFormat.None, 0,
                RenderTargetUsage.PlatformContents);
            InGame.GetRT("UI2D.Shared:renderTarget512_512", renderTarget512_512);

            if (renderTarget512_302 == null)
            {
                width  = 512;
                height = 302;
                renderTarget512_302 = new RenderTarget2D(
                    device,
                    width, height, false,
                    SurfaceFormat.Color,
                    DepthFormat.None, 0,
                    RenderTargetUsage.PlatformContents);
                InGame.GetRT("UI2D.Shared:renderTarget512_302", renderTarget512_302);
            }

            width  = 256;
            height = 256;
            renderTarget256_256 = new RenderTarget2D(
                device,
                width, height, false,
                SurfaceFormat.Color,
                DepthFormat.None, 0,
                RenderTargetUsage.PlatformContents);
            InGame.GetRT("UI2D.Shared:renderTarget256_256", renderTarget256_256);

            if (renderTarget128_128 == null)
            {
                width  = 128;
                height = 128;
                renderTarget128_128 = new RenderTarget2D(
                    device,
                    width, height, false,
                    SurfaceFormat.Color,
                    DepthFormat.None, 0,
                    RenderTargetUsage.PlatformContents);
                InGame.GetRT("UI2D.Shared:renderTarget128_128", renderTarget128_128);
            }

            width             = 64;
            height            = 64;
            renderTarget64_64 = new RenderTarget2D(
                device,
                width, height, false,
                SurfaceFormat.Color,
                DepthFormat.None, 0,
                RenderTargetUsage.PlatformContents);
            InGame.GetRT("UI2D.Shared:renderTarget64_64", renderTarget64_64);
        }
        private void CreateRenderTargets(GraphicsDeviceManager graphics)
        {
            GraphicsDevice device = graphics.GraphicsDevice;

            const int margin = 24;
            int       w      = (int)width;
            int       h      = (int)height;

            int backgroundWidth  = w;
            int backgroundHeight = h;

            // Create the diffuse texture.
            if (BokuGame.RequiresPowerOf2)
            {
                w = MyMath.GetNextPowerOfTwo(w);
                h = MyMath.GetNextPowerOfTwo(h);
            }

            diffuse = new RenderTarget2D(
                device,
                w, h,
                1,
                SurfaceFormat.Color,
                MultiSampleType.None, 0,
                RenderTargetUsage.PlatformContents);
            InGame.GetRT("MessageBoxElement", diffuse);

            // Save off the current depth buffer.
            InGame.SetRenderTarget(diffuse);
            InGame.Clear(Color.Transparent);

            // Render the backdrop.
            ScreenSpaceQuad ssquad = ScreenSpaceQuad.GetInstance();

            ssquad.Render(background, Vector2.Zero, new Vector2(512, 512), @"TexturedPreMultAlpha");

            SpriteFont font = Font();

            List <string> lineList = new List <string>();

            TextHelper.SplitMessage(label, backgroundWidth - margin * 2, font, false, lineList);

            // Calc center of display.
            int y  = (int)((backgroundHeight - font.LineSpacing) / 2.0f) - 2;
            int dy = font.LineSpacing;

            // Offset based on number of lines.
            y -= (int)(dy * (lineList.Count - 1) / 2.0f);

            SpriteBatch batch = UI2D.Shared.SpriteBatch;

            batch.Begin();

            for (int i = 0; i < lineList.Count; i++)
            {
                string line = lineList[i];

                // Render the label text into the texture.
                int     x        = 0;
                Vector2 textSize = font.MeasureString(line);

                x = TextHelper.CalcJustificationOffset(margin, backgroundWidth, (int)textSize.X, justify);

                if (useDropShadow)
                {
                    TextHelper.DrawStringWithShadow(font, batch, x, y, line, textColor, dropShadowColor, invertDropShadow);
                }
                else
                {
                    batch.DrawString(font, line, new Vector2(x, y), textColor);
                }

                y += dy;
            }   // end of i loop over lines in list.

            // Load button textures.
            Texture BButton = ButtonTextures.BButton;

            // Render the 'B' button.
            Vector2 size     = new Vector2(56.0f, 56.0f);
            Vector2 position = new Vector2(w - 150, h - 40 - margin);

            // Hack for X600 compat.
            if (BokuGame.RequiresPowerOf2)
            {
                position = new Vector2(backgroundWidth - 350, backgroundHeight - size.Y - margin);
            }
            ssquad.Render(BButton, position, size, @"TexturedRegularAlpha");

            // And the text with it.
            {
                int x = (int)(position.X + 40);
                y = (int)(position.Y);
                String buttonLabel = @"Back";
                if (useDropShadow)
                {
                    TextHelper.DrawStringWithShadow(font, batch, x, y, buttonLabel, textColor, dropShadowColor, false);
                }
                else
                {
                    batch.DrawString(font, buttonLabel, new Vector2(x, y), textColor);
                }
            }

            batch.End();


            // Restore backbuffer and depth buffer.
            InGame.RestoreRenderTarget();
        }
Esempio n. 16
0
            private void CreateRenderTargets(GraphicsDevice device)
            {
                int shadowOffset = Scoreboard.ShadowOffset;

                int surfaceWidth  = MyMath.GetNextPowerOfTwo(charWidth);
                int surfaceHeight = MyMath.GetNextPowerOfTwo(charHeight);

                string str = String.Format("{0}", ch);

                if (surface == null || surface.IsDisposed || surface.GraphicsDevice.IsDisposed)
                {
                    surface = new RenderTarget2D(
                        BokuGame.bokuGame.GraphicsDevice,
                        surfaceWidth,
                        surfaceHeight,
                        false,
                        SurfaceFormat.Color,
                        DepthFormat.None);
                    InGame.GetRT("Scoreboard", surface);
                }

                InGame.SetRenderTarget(surface);
                InGame.Clear(Color.Transparent);

                SpriteBatch batch = UI2D.Shared.SpriteBatch;

                try
                {
                    try
                    {
                        batch.Begin();

                        TextHelper.DrawString(
                            ScoreBoardFont,
                            str,
                            new Vector2(shadowOffset + (surfaceWidth - charWidth) / 2, shadowOffset + (surfaceHeight - charHeight) / 2),
                            Color.Black);
                        TextHelper.DrawString(
                            ScoreBoardFont,
                            str,
                            new Vector2((surfaceWidth - charWidth) / 2, (surfaceHeight - charHeight) / 2),
                            Color.White);
                    }
                    catch (Exception e)
                    {
                        if (e != null)
                        {
                        }
                    }
                    finally
                    {
                        batch.End();
                    }
                }
                catch
                {
                }
                finally
                {
                    InGame.RestoreRenderTarget();
                }
            }
Esempio n. 17
0
 private void ReleaseRenderTargets()
 {
     InGame.GetRT("UIGridLevelElement", rt);
     BokuGame.Release(ref rt);
 }