lace_opengl_0.1.0_672a6415/source/lean/text/private/opengl-fontimpl-texture.ads

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
with
     openGL.FontImpl,
     openGL.Texture,
     openGL.GlyphImpl.texture,

     freetype_c.FT_GlyphSlot,

     ada.Containers.Vectors;

private
with
     GL;

package openGL.FontImpl.texture
--
--  Implements a texture font.
--
is
   type Item is new FontImpl.item with private;
   type View is access all Item'Class;


   ---------
   --  Forge
   --

   function  to_FontImpl_texture (ftFont            : access openGL.Font.item'Class;
                                  fontFilePath      : in     String)  return fontImpl.texture.item;

   function new_FontImpl_texture (ftFont            : access openGL.Font.item'Class;
                                  fontFilePath      : in     String)  return access fontImpl.texture.item'Class;

   function  to_FontImpl_texture (ftFont            : access openGL.Font.item'Class;
                                  pBufferBytes      : in     unsigned_char_Pointer;
                                  bufferSizeInBytes : in     Natural) return fontImpl.texture.item;

   function new_FontImpl_texture (ftFont            : access openGL.Font.item'Class;
                                  pBufferBytes      : in     unsigned_char_Pointer;
                                  bufferSizeInBytes : in     Natural) return access fontImpl.texture.item'Class;
   overriding
   procedure destruct (Self : in out Item);


   --------------
   --  Attributes
   --

   overriding
   function FaceSize (Self : access Item;   Size     : in Natural;
                                            x_Res,
                                            y_Res    : in Natural := 72) return Boolean;
   --
   --  Set the char size for the current face.
   --
   --  Returns True if size was set correctly.


   function render   (Self : access Item;   Text     : in String;
                                            Length   : in Integer;
                                            Position : in Vector_3;
                                            Spacing  : in Vector_3;
                                            Mode     : in renderMode) return Vector_3;

   function Quad     (Self : access Item;   for_Character : in Character) return openGL.GlyphImpl.Texture.Quad_t;


   ---------------
   --- 'Protected'
   --

   function MakeGlyphImpl (Self : access Item;   ftGlyph : in freetype_c.FT_GlyphSlot.item) return access Glyph.item'Class;
   --
   --  Create an FTTextureGlyph object for the base class.


   function gl_Texture    (Self : in     Item) return openGL.Texture.texture_Name;



private

   use type openGL.Texture.texture_Name;
   package texture_name_Vectors is new ada.Containers.Vectors (Positive, openGL.Texture.texture_Name);


   type Item is new FontImpl.item with
      record
         maximumGLTextureSize : aliased gl.GLsizei := 0;   -- The max texture dimension on this openGL implemetation.

         textureWidth         :         gl.GLsizei := 0;   -- The min texture width  required to hold the glyphs.
         textureHeight        :         gl.GLsizei := 0;   -- The min texture height required to hold the glyphs.
         textureIDList        :         texture_name_Vectors.Vector;
                                                           -- An array of texture ids.

         glyphHeight          :         Integer    := 0;   -- The max height for glyphs in the current font.
         glyphWidth           :         Integer    := 0;   -- The max width  for glyphs in the current font.

         Padding              :         Natural    := 3;   -- A value to be added to the height and width to ensure that
         numGlyphs            :         Natural;           -- glyphs don't overlap in the texture.
         remGlyphs            :         Natural;

         xOffset, yOffset     :         Integer    := 0;
      end record;


   procedure CalculateTextureSize (Self : in out Item);
   --
   --  Get the size of a block of memory required to layout the glyphs
   --
   --  Calculates a width and height based on the glyph sizes and the
   --  number of glyphs. It over estimates.


   function CreateTexture (Self : access Item) return openGL.Texture.texture_Name;
   --
   --  Creates a 'blank' openGL texture object.
   --
   --  The format is GL_ALPHA and the params are
   --     * GL_TEXTURE_WRAP_S = GL_CLAMP
   --     * GL_TEXTURE_WRAP_T = GL_CLAMP
   --     * GL_TEXTURE_MAG_FILTER = GL_LINEAR
   --     * GL_TEXTURE_MIN_FILTER = GL_LINEAR
   --     * Note that mipmapping is NOT used


   procedure free_Textures (Self : in out Item);

end openGL.FontImpl.Texture;