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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? d3dfont.cs

?? Particle System Test Application on C#
?? CS
?? 第 1 頁 / 共 2 頁
字號:
//-----------------------------------------------------------------------------
// 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);
    }



?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
岛国一区二区在线观看| 精品国产99国产精品| 日韩欧美国产综合| 亚洲国产成人在线| 日韩avvvv在线播放| 北条麻妃国产九九精品视频| 欧美二区乱c少妇| 亚洲国产成人在线| 蜜臀久久99精品久久久久宅男| 97久久精品人人澡人人爽| 日韩精品中文字幕在线不卡尤物| 亚洲精品免费视频| 国产suv精品一区二区6| 欧美成人综合网站| 肉色丝袜一区二区| 在线日韩一区二区| 中文字幕亚洲在| 国产麻豆精品theporn| 欧美一区二区三级| 亚洲成人免费看| 色综合天天天天做夜夜夜夜做| 日韩精品三区四区| 日本高清不卡在线观看| 亚洲欧洲日韩av| 国产成人综合精品三级| 精品99久久久久久| 精品一区二区三区在线视频| 欧美精品自拍偷拍动漫精品| 亚洲一区二区三区四区不卡| 一本到不卡免费一区二区| 欧美国产一区视频在线观看| 国产成人欧美日韩在线电影| 2014亚洲片线观看视频免费| 九九九精品视频| 精品国产伦一区二区三区观看体验 | 在线影院国内精品| 中文字幕一区在线| 成人av资源站| 国产精品第13页| 91网上在线视频| 亚洲欧美日韩国产手机在线| 一本久道中文字幕精品亚洲嫩| 亚洲人成精品久久久久| 91行情网站电视在线观看高清版| 亚洲欧美国产77777| 欧美最猛黑人xxxxx猛交| 亚洲一区在线播放| 91精品国产综合久久香蕉麻豆 | 国产成人啪免费观看软件| 久久久青草青青国产亚洲免观| 国产精品一区二区果冻传媒| 久久精品视频免费观看| 不卡的电影网站| 一区二区三区精品在线| 欧美日韩精品电影| 精品一区二区三区久久久| 国产午夜精品久久久久久免费视 | 久久理论电影网| 成人丝袜高跟foot| 亚洲一区中文日韩| 欧美一区二区福利在线| 国产福利精品一区二区| 成人免费在线观看入口| 欧美肥胖老妇做爰| 国产不卡在线播放| 亚洲一区中文日韩| 久久亚洲春色中文字幕久久久| va亚洲va日韩不卡在线观看| 性做久久久久久免费观看欧美| 欧美不卡一二三| 色综合久久中文综合久久牛| 免费高清成人在线| 中文字幕一区二| 日韩一区二区在线观看视频播放| 成人综合婷婷国产精品久久蜜臀 | 国产河南妇女毛片精品久久久| 亚洲乱码中文字幕综合| 欧美mv日韩mv| 色94色欧美sute亚洲线路二| 日本一不卡视频| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆 | 色视频成人在线观看免| 另类调教123区| 亚洲免费观看高清完整版在线观看| 91精品国产91久久久久久最新毛片 | 国产美女精品在线| 亚洲一区二区精品视频| 中文字幕乱码久久午夜不卡| 91精品在线免费观看| 99国产精品久久| 国产精品一区二区无线| 午夜欧美大尺度福利影院在线看| 国产精品婷婷午夜在线观看| 日韩午夜三级在线| 欧美日韩一区二区在线观看| 国产精品911| 激情综合色播五月| 午夜精品一区二区三区免费视频| 中文字幕在线观看不卡| 久久九九国产精品| 精品国产污污免费网站入口 | www.日韩av| 国产一区二三区好的| 麻豆精品视频在线观看视频| 亚洲愉拍自拍另类高清精品| 1区2区3区欧美| 国产欧美日韩在线看| 久久先锋影音av鲁色资源网| 91精品国产综合久久婷婷香蕉| 欧美午夜精品一区| 色综合夜色一区| 91免费国产在线观看| 99精品欧美一区二区三区综合在线| 国产一区激情在线| 国产一区二区不卡| 国产一区在线看| 国产揄拍国内精品对白| 国产一区二三区好的| 国产一区在线观看视频| 激情小说欧美图片| 国产精品1区2区| 国产99久久精品| 成人h版在线观看| heyzo一本久久综合| av亚洲精华国产精华精| 91天堂素人约啪| 在线看不卡av| 欧美日韩国产天堂| 欧美一卡二卡三卡四卡| 日韩一区二区三区视频在线| 日韩欧美激情在线| 久久婷婷国产综合国色天香| 久久精品欧美日韩精品| 国产精品久久99| 亚洲欧美日韩国产一区二区三区| 亚洲精品视频观看| 视频在线观看91| 精品制服美女久久| 成人免费毛片app| 一本色道久久加勒比精品| 精品视频在线免费| 精品裸体舞一区二区三区| 日本一区二区三级电影在线观看| 18涩涩午夜精品.www| 午夜精品一区在线观看| 国产一区三区三区| 一道本成人在线| 日韩三级高清在线| 国产精品国产三级国产aⅴ中文 | 亚洲国产裸拍裸体视频在线观看乱了| 亚洲成人av一区二区三区| 美洲天堂一区二卡三卡四卡视频| 激情综合网最新| 色婷婷亚洲精品| 日韩一级片网址| **网站欧美大片在线观看| 首页国产丝袜综合| 成人动漫一区二区在线| 91麻豆精品国产自产在线| 中文在线资源观看网站视频免费不卡 | 国产亚洲精品免费| 亚洲一区二区三区影院| 国产一区福利在线| 在线视频亚洲一区| 国产日韩精品久久久| 亚洲18女电影在线观看| 国产成人在线视频免费播放| 欧美日韩视频在线第一区| 中日韩av电影| 美女在线观看视频一区二区| 色综合久久久久久久久久久| 欧美sm美女调教| 亚洲va欧美va天堂v国产综合| 国产精品夜夜嗨| 日韩欧美中文字幕精品| 日韩国产欧美在线观看| 91片黄在线观看| 国产午夜精品在线观看| 日韩成人av影视| 91行情网站电视在线观看高清版| 久久久久久久网| 喷水一区二区三区| 欧美影院一区二区三区| 中文字幕亚洲欧美在线不卡| 国产精品综合久久| 日韩视频免费观看高清完整版在线观看 | 午夜日韩在线观看| 91免费在线视频观看| 国产精品久久久久四虎| 国产精品自拍三区| 精品剧情在线观看| 蜜臀精品久久久久久蜜臀| 欧美午夜一区二区| 一区二区三区在线免费观看| 99久久免费国产| 国产精品进线69影院| 成人性生交大片免费看视频在线| 久久夜色精品国产噜噜av| 精品一区二区在线视频| 精品国产一区二区三区久久影院|