Version 1 (modified by bknecht, 17 years ago) (diff) |
---|
TextEngine
This page is very old and the content is not up to date.
Not everything (if any) which is written here will be in the final game!
An engine, that renders text on openGLTextures, and displays them on the screen.
usage
- simple:
#include "text.h" ... // create a new Text. Text* newText = new Text("fontfile.ttf", 16); // set some color (red, green, blue [0-1]) newText->setColor(1, 0, 0); // set some blending, and everything will shine through. newText->setBlending(.8); // set another alignment newText->setAlignment(TEXT_ALIGN_LEFT); // and display some text newText->setText("wow... so easy??"); ...
- advanced:
- Text implements Element2D from Render2D
- you can reload fonts using
newText->setFont(const char* fontFile, unsigned int fontSize);
- if you like to be quick, and handle the char-array externally (the text wont delete the array, and will segfault, if the char-array is deleted) use something like: (notice the true)
char* textPointerHandledExternally = "blabla"; newText->setText(textPointerHandledExternally, true);
- Hiding text:
(this is Element2D-functionality)
newText->setVisibility(false);