BaseTextGL.kl

Types

TextTextVertexAttributes (struct)

Vertex attributes for text.

Members

Vec2 vertex  
Vec2 uvs  
Color color  
Vec3 stringPos  

BaseTextGL (object)

バージョン 2.4.0 で追加.

BaseTextGL extends FreeTypeGL to draw 2D text and 2D primitives with FabricOGL. It’s in charge of generating and binding the OpenGL buffers. It also provides high level methods to push or insert text to draw.

参考

FreeTypeGL, Text.

Members

UInt32 indexSize Size of the index.
UInt32 vertexSize Size of the vertex.
UInt32 maxVerticesCount Number max of vertices per element.
UInt32 elementCount Number of element to draw.
UInt32 programId Shader program id. Use to bind the buffers.
Ref<AtlasGL> atlas Reference to the atlas. Used to add text.
UInt32 attributesCount Number of GLSL attributes.
/*
** Example: BaseTextGL
*/

require Text;
  
operator entry() {

      
          UInt32 nbString = 10;
          UInt32 nbMaxCharacter = 3;
          Color color(1.0f, 0.0f, 0.0f, 1.0f);   
      
          // 1. Push text sequentially
          // Allocate the buffers and set the number of items to draw to zero.
          BaseTextGL.allocVertices((2*nbString+1)*(2*nbString+1), nbMaxCharacter);
          
          // Clear the previous content (set the number of items to draw to zero),
          // It doesn't re-allocate the buffers.
          BaseTextGL.clearVertices();
          
          // Push new text to draw
          BaseTextGL.setState(FreeTypeGL_FROZEN);
          for(SInt32 i=0; i<nbString; ++i)
          {
            Vec3 pos = Vec3(i, 0, 0);
            String str = String(i);
            // When pushing new text, the number of elements 
            // to draw is automatically updated.
            BaseTextGL.pushText(str, color, pos);
          } 
          BaseTextGL.setState(FreeTypeGL_DIRTY);
      
      
          // 2. Insert text in parallel
          // Allocates the buffers and set the number of items to draw
          // equals to buffersc capacity 
          BaseTextGL.allocAndSetVerticesSize(nbString, nbMaxCharacter);
          
          operator InsertText<<< i >>> (io BaseTextGL Text) {
            Vec3 pos = Vec3(i, 0, 0);
            String str = String(i);
            Color color(1.0f, 0.0f, 0.0f, 1.0f);   
            Text.insertText(i, str, color, pos);
          }
      
          // Insert new text to draw
          BaseTextGL.setState(FreeTypeGL_FROZEN);
          InsertText<<< nbString >>>(BaseTextGL);
          BaseTextGL.setState(FreeTypeGL_DIRTY);
        
  
}

/*
** Output:
(stdin):41:11: error: syntax error, unexpected operator


*/

Methods

  BaseTextGL ( in BaseTextGL other )
  BaseTextGL ()
  bindIndices ! ()
  bindVertices ! ()
BaseTextGL clone ? ()
  disableAttributes ! ()
  enableAttributes ! ()
  finishRender ! ()
  generateBuffers ! ()
Ref<AtlasGL> getAtlas ? ()
UInt32 getProgramId ? ()
  init ! ( in Ref<AtlasGL> atlas, in String attributes )
  init ! ( in UInt32 mode, in String attributes, in UInt32 vertexSize, in UInt32 indexSize )
  insertText ! ( in UInt32 index, in String text, in Color color, in Vec3 pos )
  prepareRender ! ()
  pushText ! ( in String text, in Color color, in Vec3 pos )
  render ! ()
  setAtlas ! ( in Ref<AtlasGL> atlas )
  setProgramId ! ( in UInt32 programId )