kengine2 glCallLists

GLuint index = glGenLists(10);  // create 10 display lists
GLubyte lists[10];              // allow maximum 10 lists to be rendered

glNewList(index, GL_COMPILE);   // compile the first one
...
glEndList();

...// compile more display lists

glNewList(index+9, GL_COMPILE); // compile the last (10th)
...
glEndList();
...

// draw odd placed display lists only (1st, 3rd, 5th, 7th, 9th)
lists[0]=0; lists[1]=2; lists[2]=4; lists[3]=6; lists[4]=8;
glListBase(index);              // set base offset
glCallLists(5, GL_UNSIGNED_BYTE, lists);

For convenience, OpenGL provides glListBase() to specify the offset that is added to the display list indices when

glCallLists() is executed. In the above example, only 5 display lists are rendered; 1st, 3rd, 5th, 7th and 9th of

display lists. Therefore the offset from index value is index+0, index+2, index+4, index+6, and index+8. These

offset values are stored in the index array to be rendered. If the index value is 3 returned by glGenLists(),

then the actual display lists to be rendered by glCallLists() are, 3+0, 3+2, 3+4, 3+6 and 3+8.

glCallLists() is very useful to display texts with the offsets corresponding ASCII value in the font.

 

在wglUseFontBitmaps中的使用glCallLists的第三个参数是字符串,实际上是每个字符的ASCII值加上listbase,如ASCII为49也就是

字符1,则实际上调用的是listbase+49,也就是第五十个显示列表,第一个显示列表时listbase。wglUseFontBitmaps的第二个参数表

示的是从ASCII的十进制值多少开始,比如如果第二个参数是32,则表示是从字符空格开始构建显示列表这时候空格对应的是第一个显示列

表,也就是listbase,这是如果调用glCallLists的第三个参数其中一个字符为空格的话,则是listbase+32,调用的不是空格字符对应的

显示列表,这时就要调用glListBase(listbase -32),重设listbase为listbase-32,即为listbase-32 + 32=listbase,也就是调用的

是第一个显示列表,也就是空格字符对应的那个显示列表。

 

还有就是,glRasterPos2f和glColor3f,分别设置字体的输出位置和字体的颜色,字体的类型通过CreateFont函数调用时设置。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值