【发布时间】:2010-11-08 07:42:31
【问题描述】:
嘿,这是我的场景: 使用视觉工作室 2008。 项目在c#中 使用 Tao 框架和 ISE.FreeType 来呈现文本。 字体已经加载并转换为纹理位图:
//Creamos la fuente
fuenteActual = new FTFont(fuentes.FontMap[fuente], out ultimoError);
//Convierte la fuente a textura. Estos valores se usan en el ejemplo, creo que tiene que ver con la calidad/eficiencia.
fuenteActual.ftRenderToTexture(64, 96);
//Ponemos la alineacion por defecto como centrada.
fuenteActual.FT_ALIGN = FTFontAlign.FT_ALIGN_CENTERED;
直截了当,这是我渲染一些文本的代码。
Gl.glLoadIdentity();
float tamaño = texto.Tamaño;
double tan = texto.Orientacion.Y / texto.Orientacion.X;
float angulo = (float)Math.Atan(tan);
Gl.glColor3f(texto.getRFloat(), texto.getGFloat(), texto.getBFloat());
Gl.glScalef(tamaño, tamaño, tamaño);
Gl.glTranslatef((float)texto.Posicion.X, (float)texto.Posicion.Y, (float)texto.Posicion.Z);
Gl.glRotatef(angulo,0,1,0);
if (texto.Alineacion == Align.left)
fuenteActual.FT_ALIGN = FTFontAlign.FT_ALIGN_LEFT;
if (texto.Alineacion == Align.center)
fuenteActual.FT_ALIGN = FTFontAlign.FT_ALIGN_CENTERED;
if (texto.Alineacion == Align.right)
fuenteActual.FT_ALIGN = FTFontAlign.FT_ALIGN_RIGHT;
fuenteActual.ftBeginFont();
fuenteActual.ftWrite(texto.Text);
fuenteActual.ftEndFont();
1) 控件第一次绘制文字,正确检测到位置 第二次重绘控件时,X 位置是 ingored 并且文本是水平居中的。只有高度(Y 位置)有效。
2) 旋转不起作用。尽管旋转了模型视图矩阵,但文本始终水平显示。为什么是这样?我认为纹理字体被视为与任何其他 OpenGL 原语一样。
【问题讨论】: