| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 671 人关注过本帖
标题:opengl里字符显示问题
只看楼主 加入收藏
点线面
Rank: 8Rank: 8
来 自:NO.-1
等 级:蝙蝠侠
帖 子:525
专家分:980
注 册:2011-1-3
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:1 
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 编辑 ]
2011-01-10 13:06
wujieru
Rank: 10Rank: 10Rank: 10
等 级:青峰侠
威 望:1
帖 子:1108
专家分:1939
注 册:2010-10-9
收藏
得分:14 
SB  还在吗?
收到的鲜花
  • 点线面2011-01-16 19:35 送鲜花  -2朵   附言:内容不符
  • 点线面2011-01-17 00:35 送鲜花  -2朵   附言:结果不满意
  • 点线面2011-01-17 00:36 送鲜花  -2朵  
  • 点线面2011-01-17 00:37 送鲜花  -2朵   附言:扣到14分为止
  • 点线面2011-01-17 00:38 送鲜花  -2朵  
  • 点线面2011-01-17 00:38 送鲜花  -2朵  
  • 点线面2011-01-17 00:38 送鲜花  -2朵  
2011-01-16 19:10
快速回复:opengl里字符显示问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.050123 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved