亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? d3dfont.cs

?? Particle System Test Application on C#
?? CS
?? 第 1 頁 / 共 2 頁
字號(hào):
//-----------------------------------------------------------------------------
// File: D3DFont.cs
//
// Desc: Shortcut functions for using DX objects
//
// Copyright (c) Microsoft Corporation. All rights reserved
//-----------------------------------------------------------------------------
using System;
using System.Drawing;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
using Direct3D = Microsoft.DirectX.Direct3D;




/// <summary>
/// A generic font class 
/// </summary>
public class GraphicsFont
{
    public const int MaxNumfontVertices = 50*6;
  
    // Font rendering flags
    [System.Flags]
    public enum RenderFlags
    {
        Centered = 0x0001,
        TwoSided = 0x0002, 
        Filtered = 0x0004,
    }
    private System.Drawing.Font systemFont;

    private bool isZEnable = false;
    public bool ZBufferEnable { get { return isZEnable; } set { isZEnable = value; } }
    string ourFontName; // Font properties
    int ourFontHeight;

    private Direct3D.Device device;
    private TextureState textureState0;
    private TextureState textureState1;
    private Sampler samplerState0;
    private RenderStates renderState;
    private Direct3D.Texture fontTexture;
    private Direct3D.VertexBuffer vertexBuffer;
    private CustomVertex.TransformedColoredTextured[] fontVertices = new CustomVertex.TransformedColoredTextured[MaxNumfontVertices];

    private int textureWidth; // Texture dimensions
    private int textureHeight;
    private float textureScale;
    private int spacingPerChar;
    private float[,] textureCoords = new float[128-32,4];

    // Stateblocks for setting and restoring render states
    private StateBlock savedStateBlock;
    private StateBlock drawTextStateBlock;




    /// <summary>
    /// Create a new font object
    /// </summary>
    /// <param name="f">The font to use</param>
    public GraphicsFont(System.Drawing.Font f)
    {
        ourFontName = f.Name;
        ourFontHeight = (int)f.Size;
        systemFont = f;
    }

    
    
    /// <summary>
    /// Create a new font object
    /// </summary>
    public GraphicsFont(string fontName) : this(fontName, FontStyle.Regular, 12)
    {
    }


    
    
    /// <summary>
    /// Create a new font object
    /// </summary>
    public GraphicsFont(string fontName, FontStyle style) : this(fontName, style, 12)
    {
    }




    /// <summary>
    /// Create a new font object
    /// </summary>
    /// <param name="fontName">The name of the font</param>
    /// <param name="style">The style</param>
    /// <param name="size">Size of the font</param>
    public GraphicsFont(string fontName, FontStyle style, int size)
    {
        ourFontName = fontName;
        ourFontHeight = size;
        systemFont = new System.Drawing.Font(fontName, ourFontHeight, style);
    }




    /// <summary>
    /// Attempt to draw the systemFont alphabet onto the provided texture
    /// graphics.
    /// </summary>
    /// <param name="g"></param>Graphics object on which to draw and measure the letters</param>
    /// <param name="measureOnly">If set, the method will test to see if the alphabet will fit without actually drawing</param>
    public void PaintAlphabet(Graphics g, bool measureOnly)
    {
        string str;
        float x = 0;
        float y = 0;
        Point p = new Point(0, 0);
        Size size = new Size(0,0);
            
        // Calculate the spacing between characters based on line height
        size = g.MeasureString(" ", systemFont).ToSize();
        x = spacingPerChar = (int) Math.Ceiling(size.Height * 0.3);

        for (char c = (char)32; c < (char)127; c++)
        {
            str = c.ToString();
            // We need to do some things here to get the right sizes.  The default implemententation of MeasureString
            // will return a resolution independant size.  For our height, this is what we want.  However, for our width, we 
            // want a resolution dependant size.
            Size resSize = g.MeasureString(str, systemFont).ToSize();
            size.Height = resSize.Height + 1;

            // Now the Resolution independent width
            if (c != ' ') // We need the special case here because a space has a 0 width in GenericTypoGraphic stringformats
            {
                resSize = g.MeasureString(str, systemFont, p, StringFormat.GenericTypographic).ToSize();
                size.Width = resSize.Width;
            }
            else
                size.Width = resSize.Width;

            if ((x + size.Width + spacingPerChar) > textureWidth)
            {
                x = spacingPerChar;
                y += size.Height;
            }

            // Make sure we have room for the current character
            if ((y + size.Height) > textureHeight)
                throw new System.InvalidOperationException("Texture too small for alphabet");
                
            if (!measureOnly)
            {
                if (c != ' ') // We need the special case here because a space has a 0 width in GenericTypoGraphic stringformats
                    g.DrawString(str, systemFont, Brushes.White, new Point((int)x, (int)y), StringFormat.GenericTypographic);
                else
                    g.DrawString(str, systemFont, Brushes.White, new Point((int)x, (int)y));
                textureCoords[c-32,0] = ((float) (x + 0           - spacingPerChar)) / textureWidth;
                textureCoords[c-32,1] = ((float) (y + 0           + 0)) / textureHeight;
                textureCoords[c-32,2] = ((float) (x + size.Width  + spacingPerChar)) / textureWidth;
                textureCoords[c-32,3] = ((float) (y + size.Height + 0)) / textureHeight;
            }

            x += size.Width + (2 * spacingPerChar);
        }

    }




    /// <summary>
    /// Initialize the device objects
    /// </summary>
    /// <param name="dev">The grpahics device used to initialize</param>
    public void InitializeDeviceObjects(Device dev)
    {
        if (dev != null)
        {
            // Set up our events
            dev.DeviceReset += new System.EventHandler(this.RestoreDeviceObjects);
        }

        // Keep a local copy of the device
        device = dev;
        textureState0 = device.TextureState[0];
        textureState1 = device.TextureState[1];
        samplerState0 = device.SamplerState[0];
        renderState = device.RenderState;

        // Create a bitmap on which to measure the alphabet
        Bitmap bmp = new Bitmap(1, 1, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
        Graphics g = Graphics.FromImage(bmp);
        g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
        g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
        g.TextContrast = 0;
       
        // Establish the font and texture size
        textureScale  = 1.0f; // Draw fonts into texture without scaling

        // Calculate the dimensions for the smallest power-of-two texture which
        // can hold all the printable characters
        textureWidth = textureHeight = 128;
        for (;;)
        {
            try
            {
                // Measure the alphabet
                PaintAlphabet(g, true);
            }
            catch (System.InvalidOperationException)
            {
                // Scale up the texture size and try again
                textureWidth *= 2;
                textureHeight *= 2;
                continue;
            }

            break;
        }

        // If requested texture is too big, use a smaller texture and smaller font,
        // and scale up when rendering.
        Direct3D.Caps d3dCaps = device.DeviceCaps;

        // If the needed texture is too large for the video card...
        if (textureWidth > d3dCaps.MaxTextureWidth)
        {
            // Scale the font size down to fit on the largest possible texture
            textureScale = (float)d3dCaps.MaxTextureWidth / (float)textureWidth;
            textureWidth = textureHeight = d3dCaps.MaxTextureWidth;

            for(;;)
            {
                // Create a new, smaller font
                ourFontHeight = (int) Math.Floor(ourFontHeight * textureScale);      
                systemFont = new System.Drawing.Font(systemFont.Name, ourFontHeight, systemFont.Style);
                
                try
                {
                    // Measure the alphabet
                    PaintAlphabet(g, true);
                }
                catch (System.InvalidOperationException)
                {
                    // If that still doesn't fit, scale down again and continue
                    textureScale *= 0.9F;
                    continue;
                }

                break;
            }
        }

        // Release the bitmap used for measuring and create one for drawing
        bmp.Dispose();
        bmp = new Bitmap(textureWidth, textureHeight, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
        g = Graphics.FromImage(bmp);
        g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
        g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
        g.TextContrast = 0;

        // Draw the alphabet
        PaintAlphabet(g, false);

        // Create a new texture for the font from the bitmap we just created
        fontTexture = Texture.FromBitmap(device, bmp, 0, Pool.Managed);
        RestoreDeviceObjects(null, null);
    }




    /// <summary>
    /// Restore the font after a device has been reset
    /// </summary>
    public void RestoreDeviceObjects(object sender, EventArgs e)
    {
        vertexBuffer = new VertexBuffer(typeof(CustomVertex.TransformedColoredTextured), MaxNumfontVertices,
                                        device, Usage.WriteOnly | Usage.Dynamic, 0, Pool.Default);

        Surface surf = device.GetRenderTarget( 0 );
        bool bSupportsAlphaBlend = Manager.CheckDeviceFormat(device.DeviceCaps.AdapterOrdinal, 
            device.DeviceCaps.DeviceType, device.DisplayMode.Format, 
            Usage.RenderTarget | Usage.QueryPostPixelShaderBlending, ResourceType.Surface, 
            surf.Description.Format );

        // Create the state blocks for rendering text
        for (int which=0; which < 2; which++)
        {
            device.BeginStateBlock();
            device.SetTexture(0, fontTexture);

            if (isZEnable)
                renderState.ZBufferEnable = true;
            else
                renderState.ZBufferEnable = false;

            if( bSupportsAlphaBlend )
            {
                renderState.AlphaBlendEnable = true;
                renderState.SourceBlend = Blend.SourceAlpha;
                renderState.DestinationBlend = Blend.InvSourceAlpha;
            }
            else
            {
                renderState.AlphaBlendEnable = false;
            }
            renderState.AlphaTestEnable = true;
            renderState.ReferenceAlpha = 0x08;
            renderState.AlphaFunction = Compare.GreaterEqual;
            renderState.FillMode = FillMode.Solid;
            renderState.CullMode = Cull.CounterClockwise;
            renderState.StencilEnable = false;
            renderState.Clipping = true;
            device.ClipPlanes.DisableAll();
            renderState.VertexBlend = VertexBlend.Disable;
            renderState.IndexedVertexBlendEnable = false;
            renderState.FogEnable = false;
            renderState.ColorWriteEnable = ColorWriteEnable.RedGreenBlueAlpha;
            textureState0.ColorOperation = TextureOperation.Modulate;
            textureState0.ColorArgument1 = TextureArgument.TextureColor;
            textureState0.ColorArgument2 = TextureArgument.Diffuse;
            textureState0.AlphaOperation = TextureOperation.Modulate;
            textureState0.AlphaArgument1 = TextureArgument.TextureColor;
            textureState0.AlphaArgument2 = TextureArgument.Diffuse;
            textureState0.TextureCoordinateIndex = 0;
            textureState0.TextureTransform = TextureTransform.Disable; // REVIEW
            textureState1.ColorOperation = TextureOperation.Disable;
            textureState1.AlphaOperation = TextureOperation.Disable;
            samplerState0.MinFilter = TextureFilter.Point;
            samplerState0.MagFilter = TextureFilter.Point;
            samplerState0.MipFilter = TextureFilter.None;

            if (which==0)
                savedStateBlock = device.EndStateBlock();
            else
                drawTextStateBlock = device.EndStateBlock();
        }
    }




    /// <summary>
    /// Draw some text on the screen
    /// </summary>
    public void DrawText(float xpos, float ypos, Color color, string text)
    {
        DrawText(xpos, ypos, color, text, RenderFlags.Filtered);
    }



?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
不卡高清视频专区| 欧美在线视频你懂得| 洋洋av久久久久久久一区| 日韩免费一区二区| 99精品视频一区二区三区| 奇米在线7777在线精品| 中文字幕一区二区三区不卡| 精品久久人人做人人爰| 欧美日韩高清在线播放| 91麻豆成人久久精品二区三区| 精品一区二区三区在线观看国产| 一区二区三区日韩欧美精品| 欧美高清在线精品一区| 精品美女被调教视频大全网站| 欧美日韩精品系列| 色一情一乱一乱一91av| 成人免费观看男女羞羞视频| 精东粉嫩av免费一区二区三区| 爽爽淫人综合网网站| 依依成人精品视频| 最好看的中文字幕久久| 欧美韩日一区二区三区| 久久你懂得1024| 日韩欧美国产一区二区三区| 欧美一卡2卡三卡4卡5免费| 欧美日韩专区在线| 色综合亚洲欧洲| 99久久精品99国产精品| 99re热这里只有精品视频| 岛国一区二区三区| 国产福利91精品| 国产馆精品极品| 国产精品亚洲第一区在线暖暖韩国| 韩国中文字幕2020精品| 久久成人免费电影| 国内外精品视频| 国产在线播精品第三| 韩国成人精品a∨在线观看| 激情欧美一区二区三区在线观看| 老司机免费视频一区二区三区| 日韩一区欧美二区| 老汉av免费一区二区三区 | 国产传媒欧美日韩成人| 国产乱人伦精品一区二区在线观看| 久久97超碰国产精品超碰| 另类小说一区二区三区| 国产综合久久久久久鬼色| 国产一区二区三区免费| 成人免费视频视频在线观看免费| 不卡av在线免费观看| 色综合久久久网| 在线视频一区二区三| 欧美午夜精品久久久久久孕妇| 欧美日韩一级视频| 3atv一区二区三区| 日韩欧美亚洲国产精品字幕久久久| 日韩欧美中文字幕精品| 国产亚洲欧美一级| 成人欧美一区二区三区黑人麻豆| 一区二区三区中文免费| 日韩电影在线免费看| 韩国三级中文字幕hd久久精品| 国产成人亚洲综合a∨婷婷图片| 不卡的看片网站| 欧美日本一区二区在线观看| 精品国产乱子伦一区| 中文字幕视频一区| 亚洲一区二区在线免费观看视频 | 丝袜亚洲另类欧美综合| 久久国内精品自在自线400部| 成人福利视频网站| 欧美性高清videossexo| 精品欧美一区二区在线观看| 国产三区在线成人av| 亚洲美女区一区| 蜜桃视频免费观看一区| 成人精品视频一区| 欧美日韩亚洲综合| 国产三级欧美三级| 性做久久久久久免费观看| 国产成人精品影视| 欧美日韩久久一区二区| 久久久国产精品麻豆| 精品一区二区三区视频在线观看| 国产精品夜夜嗨| 欧美三级资源在线| 国产欧美一二三区| 午夜久久久久久久久久一区二区| 国产成人啪午夜精品网站男同| 欧美日韩三级一区二区| 日本一区二区在线不卡| 奇米影视一区二区三区| 色婷婷久久久亚洲一区二区三区| 精品免费视频.| 亚洲一区二区成人在线观看| 国产精品66部| 欧美一卡二卡三卡四卡| 洋洋av久久久久久久一区| 国产电影精品久久禁18| 欧美一卡二卡在线| 亚洲国产精品久久不卡毛片| 成人不卡免费av| 精品99一区二区三区| 亚洲gay无套男同| av在线播放一区二区三区| 久久美女高清视频| 性感美女极品91精品| 色婷婷综合久久久久中文| 国产亚洲一二三区| 蜜臀av性久久久久蜜臀aⅴ四虎| 日韩午夜激情免费电影| 一区二区三区四区不卡视频| 欧美午夜在线一二页| 日韩国产欧美在线观看| 日韩成人午夜电影| 91在线视频播放地址| 久久久综合九色合综国产精品| 亚洲成在人线在线播放| 91捆绑美女网站| 国产精品另类一区| 懂色av一区二区在线播放| 久久久久久久综合狠狠综合| 久久国产成人午夜av影院| 欧美一区二区大片| 日本不卡视频一二三区| 欧美日韩一区二区在线观看| 亚洲男人电影天堂| 色综合天天天天做夜夜夜夜做| 国产精品久久看| 成人激情小说乱人伦| 国产欧美精品一区| 成人av在线一区二区| 国产三级精品视频| 成人黄页在线观看| 中文字幕在线不卡一区| av成人老司机| 一区二区三区小说| 日本福利一区二区| 亚洲一线二线三线视频| 欧美少妇xxx| 午夜视频久久久久久| 欧美酷刑日本凌虐凌虐| 日韩经典中文字幕一区| 日韩精品一区二区三区视频| 激情综合色播激情啊| 久久久综合九色合综国产精品| 国产999精品久久久久久绿帽| 国产色91在线| 91色婷婷久久久久合中文| 亚洲精品高清在线| 欧美丰满高潮xxxx喷水动漫| 日韩av二区在线播放| 精品国一区二区三区| 国产精品一区二区果冻传媒| 亚洲国产精品传媒在线观看| 91麻豆免费视频| 亚洲成人第一页| 精品国产麻豆免费人成网站| 成人免费毛片app| 亚洲一区二区三区精品在线| 日韩精品一区二区三区三区免费 | 亚洲电影你懂得| 69av一区二区三区| 国产中文字幕精品| 欧美经典一区二区| 欧洲亚洲国产日韩| 乱一区二区av| 综合色中文字幕| 7878成人国产在线观看| 国产精品综合一区二区| 一区二区在线观看视频| 日韩一本二本av| 成人v精品蜜桃久久一区| 日韩电影在线看| 中文字幕一区二区三区不卡| 欧美一区二区三区在线电影| 成人午夜精品在线| 亚洲福利电影网| 国产午夜精品理论片a级大结局 | 另类小说色综合网站| 中文字幕一区二区日韩精品绯色| 制服丝袜亚洲色图| 成人一区二区三区中文字幕| 天堂va蜜桃一区二区三区漫画版| 久久影音资源网| 精品视频1区2区3区| 成人性生交大片免费看中文| 亚洲va欧美va国产va天堂影院| 国产香蕉久久精品综合网| 欧美日韩国产片| 成人激情动漫在线观看| 美腿丝袜在线亚洲一区| 亚洲欧美偷拍卡通变态| 久久奇米777| 欧美一区二区久久| 色菇凉天天综合网| 国产成人小视频| 久久爱www久久做| 丝袜美腿亚洲一区| 一级精品视频在线观看宜春院|