public void TestTextRendering()
        {
            var game = new DX11Game();

            game.InitDirectX();
            var wrapper = new DX11FontWrapper(game.Device);

            game.GameLoopEvent += delegate
            {
                wrapper.Draw("Welcome!", 128, 10, 10, new Color4(1, 0, 0));
                wrapper.Draw("Welcome!", 128, 10, 210, new Color4(0, 1, 0));
                wrapper.Draw("Welcome!", 128, 10, 410, new Color4(0, 0, 1));

                //TODO: game.MarkFrameBuffer();
            };

            game.Run();
        }
예제 #2
0
        private void render()
        {
            TW.Graphics.Device.ImmediateContext.OutputMerger.BlendState = TW.Graphics.HelperStates.AlphaBlend;
            foreach (var a in TW.Data.Objects.OfType<Textarea>())
            {
                if (!a.Visible) continue;

                var pxSize = a.FontSize/12f*16f;

                var txt = a.Text ?? ""; // Causes memory exception when string is null, could also be fixed in the C++ wrapepr

                TW.Graphics.TextureRenderer.DrawColor(a.BackgroundColor, a.Position, a.Size);
                
                fontWrapper.Draw(txt, pxSize , (int)a.Position.X, (int)a.Position.Y, a.Color);
            }
        }
예제 #3
0
        private void saveBackbuffer()
        {
            Texture2D.SaveTextureToFile(TW.Graphics.Device.ImmediateContext,
                                        TW.Graphics.Form.BackBuffer, ImageFileFormat.Bmp,
                                        ActiveRecordingDirectory.FullName + "/img" +
                                        ActiveRecordingFrameCount + ".bmp");
            ActiveRecordingFrameCount++;



            TW.Graphics.Device.ImmediateContext.OutputMerger.BlendState = TW.Graphics.HelperStates.AlphaBlend;


            var pxSize = 20;

            var txt = "RECORDING " + ActiveRecordingFrameCount;

            //TW.Graphics.TextureRenderer.DrawColor(Color.Red.dx(), a.Position, a.Size);

            fontWrapper.Draw(txt, pxSize, TW.Graphics.Form.BackBuffer.Description.Width - 200, TW.Graphics.Form.BackBuffer.Description.Height - 30, Color.Red.dx());
        }