/// <summary> /// Initialise /// </summary> public override void Initialise() { base.Initialise(); m_Shader.Initialise(); GL.GenTextures(1, out m_FontTexture); GL.GenBuffers(1, out m_CoordBuffer); // // This is important as we the font bitmaps are not 4 byte aligned. We have to tell GL about that. // GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1); // create texture atlas. GL.BindTexture(TextureTarget.Texture2D, m_FontTexture); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear); // Bitmap data is just 1 byte. For OpenGL we could use GL_RED. but in ES we use Luminance. GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Alpha, TEX_WIDTH, TEX_HEIGHT, 0, PixelFormat.Alpha, PixelType.UnsignedByte, IntPtr.Zero); // load buffers for displaying a texture. LoadBuffers(); // load a unicode font . if (FreeType.TryLoadFont(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "arialuni.ttf"), 250)) { // write some messages. LoadFontChars(RenderMode.Glyph, 10, TEX_HEIGHT - 10, "A"); } }
/// <summary> /// Initialise /// </summary> public override void Initialise() { base.Initialise(); m_Shader.Initialise(); GL.GenTextures(1, out m_FontTexture); GL.GenBuffers(1, out m_CoordBuffer); // // This is important as we the font bitmaps are not 4 byte aligned. We have to tell GL about that. // GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1); // create texture atlas. GL.BindTexture(TextureTarget.Texture2D, m_FontTexture); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear); // Bitmap data is just 1 byte. For OpenGL we could use GL_RED. but in ES we use Luminance. GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Alpha, 512, 256, 0, PixelFormat.Alpha, PixelType.UnsignedByte, IntPtr.Zero); // load buffers for displaying a texture. LoadBuffers(); // load a unicode font . if (FreeType.TryLoadFont(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "arialuni.ttf"), 12)) { // write some messages. LoadFontChars(10, 50, "Hello there"); LoadFontChars(10, 75, "This has got some こんにちは unicode characters"); LoadFontChars(10, 100, "But you have to make sure you use a unicode font set"); LoadFontChars(10, 125, "We are using arialuni.ttf"); } else { System.Diagnostics.Debug.WriteLine("Could not load fonts"); } }