glRasterPos2f(x,y)其实就相当于是glVertex2f(x,y)的坐标,只是glRasterPos2f(x,y)用于显示[字体]时设置字符的起始位置,而glVertex2f(x,y)是绘制一个2D点.且glRasterPos2f(x,y)仍受当前模视矩阵的影响,即glTranslatef()可改变字符显示的位置, glRasterPos2f(x,y)显示字体时,其位置可随模视矩阵的改变而改变.
如:
glViewport(0,0,width,height); // 设置当前的视口
// width=640,height=480
gluPerspective(45.0f* 2,(GLfloat)width/(GLfloat)height,0.1f,1000.0f);
glTranslatef(0.0f,0.0f, -480); //当前局部坐标为(0,0,-480)
glRasterPos2f( -640, -480);//在视口的左下角显示字体
glPrint(“hello”);//显示字符