|
|
发表于 2009-5-23 10:26:00
|
显示全部楼层
Re:openGL中如何输出一个变量的值
void DrawString(const char* str)
{
static int isFirstCall = 1;
static GLuint lists;
if(isFirstCall)
{
isFirstCall = 0;
lists = glGenLists(128);
wglUseFontBitmaps(wglGetCurrentDC(), 0, 128, lists);
}
for(; *str!='\0'; ++str)
glCallList(lists + *str);
}
这个函数可以输出英文字符串,真正显示还要把变量转换成字符串之后。比如下面:
void ShowText()
{
char tcount[2];
itoa(count,tcount,10);
glRasterPos3f(0,0,0);
DrawString(tcount);
}
count就是一个全局变量 |
|