#include <stdlib.h>
#include <GL/glut.h>
/*字母F*/
GLubyte f_rasters[12] = {0xc0,0xc0,0xc0,0xc0,0xc0,0xfc,
0xfc,0xc0,0xc0,0xc0,0xff,0xff};
/*字母I*/
GLubyte i_rasters[12] = {0xff,0xff,0x18,0x18,0x18,0x18,
0x18,0x18,0x18,0x18,0xff,0xff};
/*字母L*/
GLubyte l_rasters[12] = {0xff,0xff,0xc0,0xc0,0xc0,0xc0,
0xc0,0xc0,0xc0,0xc0,0xc0,0xc0};
/*字母E*/
GLubyte e_rasters[12] = {0xff,0xff,0xc0,0xc0,0xc0,0xff,
0xff,0xc0,0xc0,0xc0,0xff,0xff};
void myInit(void)
{
glPixelStorei(GL_UNPACK_ALIGNMENT,1);//設定像素儲存模式
glClearColor(1.0,1.0,1.0,1.0);//設定背景為白色
}
void myDisplay()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.0,0.0,0.0);//設定像素顏色為黑色
glRasterPos2i(20,20);//為像素指定位置
/*繪製位元影像*/
glBitmap(8,12,0.0,0.0,14.0,0.0,f_rasters);
glBitmap(8,12,0.0,0.0,14.0,0.0,i_rasters);
glBitmap(8,12,0.0,0.0,14.0,0.0,l_rasters);
glBitmap(8,12,0.0,0.0,14.0,0.0,e_rasters);
glFlush();
}
void myReshape(int w,int h)
{
glViewport(0,0,(GLsizei)w,(GLsizei)h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0,w,0,h,-1.0,1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
int main(int argc,char ** argv)
{
/*初始化*/
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowSize(500,400);
glutInitWindowPosition(100,100);
/*建立視窗*/
glutCreateWindow(" BitMap");
/*繪製圖形*/
myInit();
glutReshapeFunc(myReshape);
glutDisplayFunc(myDisplay);
glutMainLoop();//進入GLUT事件處理迴圈
return 0;
} |