opengl里字符显示问题
程序代码:
#include<GL/glut.h> #include <windows.h> // Windows的头文件 GLubyte space [] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; GLubyte letters [][13]={ {0x00,0x00,0xc3,0xc3,0xc3,0xc3,0xff,0xc3,0xc3,0xc3,0x66,0xc3,0x18}, {0x00,0x00,0xfe,0xc7,0xc3,0xc3,0xc7,0xfe,0xc7,0xc3,0xc3,0xc7,0xfe}, {0x00,0x00,0x7e,0xe7,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xe7,0xc0}, {0x00,0x00,0xfe,0xce,0xc7,0xc3,0xc3,0xc3,0xc3,0xc3,0xc7,0xce,0xfc}, {0x00,0x00,0xff,0xc0,0xc0,0xc0,0xc0,0xfc,0xc0,0xc0,0xc0,0xc0,0xff}, {0x00,0x00,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xfc,0xc0,0xc0,0xc0,0xff}, {0x00,0x00,0x7e,0xe7,0xc3,0xc3,0xcf,0xc0,0xc0,0xc0,0xc0,0xe7,0x7e}, {0x00,0x00,0xc3,0xc3,0xc3,0xc3,0xc3,0xff,0xc3,0xc3,0xc3,0xc3,0xc3}, {0x00,0x00,0x7e,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x7e}, {0x00,0x00,0x7c,0xee,0xc6,0xD6,0x06,0x06,0x06,0x06,0x06,0x06,0x06}, {0x00,0x00,0xc3,0xc6,0xcc,0xd8,0xf0,0xe0,0xf0,0xd8,0xcc,0xc6,0xc3}, {0x00,0x00,0xff,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0}, {0x00,0x00,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xdb,0xff,0xff,0xe7,0xc3}, {0x00,0x00,0xc7,0xc7,0xcf,0xcf,0xdf,0xdb,0xfb,0xf3,0xf3,0xe3,0xe3}, {0x00,0x00,0x7e,0xef,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xe7,0x7e}, {0x00,0x00,0xc0,0xc0,0xc0,0xc0,0xc0,0xfe,0xc7,0xc3,0xc3,0xc7,0xfe}, {0x00,0x00,0x3f,0x6e,0xdf,0xdb,0xc3,0xc3,0xc3,0xc3,0xc3,0x66,0x3c}, {0x00,0x00,0xc3,0xc6,0xcc,0xd8,0xf0,0xfe,0xc7,0xc3,0xc3,0xc7,0xfe}, {0x00,0x00,0x7e,0xef,0x03,0x03,0x07,0x7e,0xe0,0xc0,0xc0,0xe7,0x7e}, {0x00,0x00,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xff}, {0x00,0x00,0x7e,0xef,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3}, {0x00,0x00,0x18,0x3c,0x3c,0x66,0x66,0xc3,0xc3,0xc3,0xc3,0xc3,0xc3}, {0x00,0x00,0xc3,0x66,0x66,0x3c,0x3c,0x18,0x3c,0x3c,0x66,0x66,0xc3}, {0x00,0x00,0x18,0x18,0x18,0x18,0x18,0x18,0x3c,0x3c,0x66,0x66,0xc3}, {0x00,0x00,0xff,0xc0,0xc0,0x60,0x30,0x7e,0x0c,0x06,0x03,0x03,0xff} }; GLuint fontoffset; void makeRasterFont(void) { GLuint i,j; glPixelStorei(GL_UNPACK_ALIGNMENT,1); fontoffset = glGenLists(128); for(i=0,j ='A';i<26;i++,j++) { glNewList(fontoffset +j,GL_COMPILE); glBitmap(8,13,0.0,2.0,10.0,0.0,letters[i]); glEndList(); } glNewList(fontoffset +' ',GL_COMPILE); glBitmap(8,13,0.0,2.0,10.0,0.0,space); glEndList(); } void init(void) { glShadeModel(GL_FLAT); makeRasterFont(); } void printstring(char *s) { glPushAttrib(GL_LIST_BIT); glListBase(fontoffset); glCallLists(strlen(s),GL_UNSIGNED_BYTE,(GLubyte *)s); glPopAttrib(); } void display(void) { GLfloat white [3] ={1.0,1.0,1.0}; glClear(GL_COLOR_BUFFER_BIT); glColor3fv(white); glRasterPos2i(20,60); printstring("THE QUICK BROWN FOX JUMPS"); glRasterPos2i(20,40); printstring("OVER A LAZY DOG"); glFlush(); } int main(int argc, char**argv) { FreeConsole(); glutInit(&argc,argv); //第一步初如化opengl glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB); //显示窗口的缓存和颜色模型等选项 glutInitWindowSize(500,500); //设定显示窗口的初始宽度和高度的像素数 glutInitWindowPosition(50,50); //显示窗口左上角的初始位置 glutCreateWindow("看一看"); //显示窗口在创建时给定一个标题 init(); glutDisplayFunc(display); //将图赋给显示窗口 glutMainLoop(); //显示初始图形并使程序 }只输出窗口,没有输出字符串,为什么,我用VS2010编译器
PS:我己经安装glut那些包,能够在小程序编译成功.
[ 本帖最后由 点线面 于 2011-1-10 13:10 编辑 ]