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.
参考
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:7: 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 ) |
Methods in detail¶
BaseTextGL ( in BaseTextGL other )
copy constructor
BaseTextGL ()
default constructor
BaseTextGL.bindIndices! ()
Binds the indices buffers.
BaseTextGL.bindVertices! ()
Binds the vertices buffers.
BaseTextGL BaseTextGL.clone? ()
clone method
BaseTextGL.disableAttributes! ()
Disables the OpenGL vertex attributes.
BaseTextGL.enableAttributes! ()
Enables the OpenGL vertex attributes.
BaseTextGL.finishRender! ()
Implementation of Text. To override
BaseTextGL.generateBuffers! ()
Generates the OpenGL buffers (vertex and index).
Ref<AtlasGL> BaseTextGL.getAtlas? ()
Gets a reference to the atlas.
UInt32 BaseTextGL.getProgramId? ()
Gets the ID of the GLSL shader (program) used.
BaseTextGL.init! ( in Ref<AtlasGL> atlas, in String attributes )
Initializes a BaseTextGL to draw text.
atlas | A reference to an AtlasGL. Must be set to draw text. |
attributes | GLSL attributes list (as a string) |
BaseTextGL.init! ( in UInt32 mode, in String attributes, in UInt32 vertexSize, in UInt32 indexSize )
Constructs an OGLText to draw line or text primitives.
mode | GL drawing mode (GL_LINES, GL_TRIANGLES, ...) |
attributes | GLSL attributes list (as a string) |
vertexSize | Vertices size |
indexSize | Indices size |
BaseTextGL.insertText! ( in UInt32 index, in String text, in Color color, in Vec3 pos )
Inserts a string to render, thread-safe.
index | Index of the String to add |
text | The String to add |
color | Text color |
pos | Text position (in 3D space) |
BaseTextGL.prepareRender! ()
Implementation of Text. To override
BaseTextGL.pushText! ( in String text, in Color color, in Vec3 pos )
Pushs a string to render.
text | The text to add |
color | Text color |
pos | Text position (in 3D space) |
BaseTextGL.render! ()
Renders the buffers.
BaseTextGL.setAtlas! ( in Ref<AtlasGL> atlas )
Sets a reference to the atlas.
atlas | A reference to an AtlasGL. |
BaseTextGL.setProgramId! ( in UInt32 programId )
Gets the ID of the GLSL shader (program) used.
programId | Shader program ID. |