A need to draw some text in openGL and then make rotations and translations over it. Need to use just objective-c. Any help?
Asked
Active
Viewed 3,103 times
2 Answers
4
Use Photoshop or something to create a texture file like below.
|ABCDEFGH|
|IJKLMNOP|
|QRSTU...|
sample.png
Calculate UV position of each character.
float eachCharHeight = 0.125f;
float eachCharWidth = 0.125f;
char charToDraw = 'a';
int indexOfChar = charToDraw - 65; // 'a' = 65
float uValueForCharA = (float)(indexOfChar / 8) * eachCharHeight;
float vValueForCharA = (float)(indexOfChar % 8) * eachCharWidth;
Set texcoords and draw.
glPushMatrix();
glRotatef(...); // or translate
glEnable(GL_TEXTURE_2D);
glBindTexture(texture);
float vertices[8] = {0.0f, 0.0f, 1.0f, 0.0f, ...};
float texcoords[8] = {uValueForCharA, vValueForCharA,
uValueForCharA + eachCharWidth, ...};
...
glPopMatrix();

fish potato
- 5,319
- 6
- 27
- 32
2
-
1The problem is that I need to draw text as an object and then rotate and translate it. 2D solutions are solutions. Thanks any way :) – António Jun 19 '10 at 19:10