void DrawGLText(string text, float loc_x, float loc_y) {
glColor4f(1.0, 1.0, 1.0, 0.5);
glRasterPos3f(loc_x, loc_y, 1);
glutBitmapString(GLUT_BITMAP_HELVETICA_18), text.c_str());
}这是用于在特定位置绘制文本的my代码。我想调整它来绘制居中(loc_x,loc_y)而不是左对齐的文本。
发布于 2013-02-28 07:10:31
使用glutBitmapWidth()或glutBitmapLength()找到字符串的宽度,并使用-textWidth / 2.0f沿X轴进行平移。
https://stackoverflow.com/questions/15124254
复制相似问题