【发布时间】:2013-10-27 16:55:18
【问题描述】:
我正在尝试在 GLUT 中绘制字符串。我需要将int 值转换为unsigned char*,然后才能在glutBitmapString 中使用它。但是当我喜欢这样的时候
glBegin(GL_POINTS);
glRasterPos2i(15, 20);
char text[10];
sprintf(text, "%d", 5);
glutBitmapString(GLUT_BITMAP_HELVETICA_18, (unsigned char*)text);
glEnd();
屏幕上没有文字。但在调试器中text 包含5 的值。
怎么了?
【问题讨论】:
-
这可能和这个问题是同一个问题:stackoverflow.com/questions/16873561/…
-
另外,我认为 glutBitmapString 不能在任何
glBegin/glEnd语句之间调用。 -
是的。
glBegin/glEnd之间好像不行。 -
glBegin/glEnd之间有效的东西列表,大概单手能数。如果它与指定顶点属性无关,则它不属于它们之间。glutBitmapString (...)是一个栅格函数(管道中完全不同的阶段),所以它与顶点无关。