GLUT - The OpenGL Utility Toolkit

GLUT (pronounced like the glut in gluttony) is the OpenGL Utility Toolkit, a window system independent toolkit for writing OpenGL programs. It implements a simple windowing application programming interface (API) for OpenGL. GLUT makes it considerably easier to learn about and explore OpenGL programming. GLUT provides a portable API so you can write a single OpenGL program that works across all PC and workstation OS platforms.

GLUT is designed for constructing small to medium sized OpenGL programs. While GLUT is well-suited to learning OpenGL and developing simple OpenGL applications, GLUT is not a full-featured toolkit so large applications requiring sophisticated user interfaces are better off using native window system toolkits. GLUT is simple, easy, and small.

The GLUT library has both C, C++ (same as C), FORTRAN, and Ada programming bindings. The GLUT source code distribution is portable to nearly all OpenGL implementations and platforms. The current version is 3.7. Additional releases of the library are not anticipated.

GLUT is not open source. Mark Kilgard maintains the copyright. There are a number of newer and open source alternatives.

窗口管理

GLUT通过几个函数执行初始化窗口所需要的任务:

glutInit(int *argc,char **argv)对GLUT进行初始化,并处理所有的命令行参数。glutInit()应该在调用其他任何GLUT函数之前调用。

glutInitDisplayMode(unsigned int mode)指定了是使用RGBA模式还是颜色索引模式。另外还可以指定是使用单缓冲还是使用双缓冲窗口。如果想使用颜色索引模式,就需要把一些颜色加载到颜色映射表中,这个任务可以用glutSetColor()完成。最后还可以使用这个函数表示希望窗口拥有相关联的深度、模板、多重采样和/或累积缓冲区。例如,如果需要一个双缓冲,RGBA颜色模式以及带有一个深度缓冲区的窗口,可以调用glutInitDisplay Mode(GLUT_GOUBLE|GLUT_RGBA|GLUT_DEPTH);

glutInitWindowPosition(int x,int y)指定了窗口左上角的屏幕位置;

glutInitWindowSize(int width,int size)指定了窗口的大小(以像素为单位);

 

显示回调函数

glutDisplayFunc(void (*func)(void)),每当GLUT确定一个窗口的内容需要重新显示时,通过glutDisplayFunc()注册的那个回调函数就会被执行。因此,应该把重绘场景所需要的所有代码都放在这个显示回调函数里。

转载于:https://www.cnblogs.com/yxnchinahlj/archive/2010/10/26/1861586.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值