Ejemplo n.º 1
0
        /// <summary>
        /// 文字列用テクスチャをキャッシュから探し、もしなければ読み込みます。
        /// </summary>
        public TextTexture GetTextTexture(string text,
                                          TextTextureFont textureFont)
        {
            if (this.context != GraphicsContext.CurrentContext)
            {
                throw new GLException(
                          "OpenGLコンテキストが正しく設定れていません><");
            }

            if (text == null)
            {
                throw new ArgumentNullException("text");
            }

            if (textureFont == null)
            {
                throw new ArgumentNullException("textureFont");
            }

            try
            {
                var key = new TextTextureKey(text, textureFont);

                return(this.cache.GetOrCreate(key));
            }
            catch (Exception ex)
            {
                Util.ThrowIfFatal(ex);
                Log.ErrorException(ex,
                                   "文字列テクスチャの作成に失敗しました。");

                return(null);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 指定のフォントで指定の文字列を描画するためのテクスチャを取得します。
        /// </summary>
        public static TextTexture GetTextTexture(string text,
                                                 TextTextureFont font)
        {
            var context = GraphicsContext.CurrentContext;
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if (text == null)
            {
                throw new ArgumentNullException("text");
            }

            if (font == null)
            {
                throw new ArgumentNullException("font");
            }

            var cache = GetTextTextureCache(context);
            return cache.GetTextTexture(text, font);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 public TextTextureKey(string text, TextTextureFont textureFont)
 {
     Text        = text;
     TextureFont = textureFont;
 }