一 、初始化
1、void glutInit(int* argc,char** argv)
这个函数用来初始化GLUT库。对应main函数的形式应是:
int main(int argc,char* argv[]);
这个函数从main函数获取其两个参数。
2、void glutInitWindowSize(int width,int height);
void glutInitWindowPosition(int x,int y);
这两个函数很好理解是设置glut程序要产生的窗口的大小和位置(左上角)。以像素为单位。
3、void glutInitDisplayMode(unsigned int mode);
设置图形显示模式。参数mode的可选值为:
GLUT_RGBA:当未指明GLUT—RGBA或GLUT—INDEX时,是默认使用的模式。
表明欲建立RGBA模式的窗口。
GLUT_RGB:与GLUT—RGBA作用相同。
GLUT_INDEX:指明为颜色索引模式。
GLUT_SINGLE:只使用单缓存
GLUT_DOUBLE:使用双缓存。以避免把计算机作图的过程都表现出来,或者为了平滑地实现动画。
GLUT_ACCUM:让窗口使用累加的缓存。
GLUT_ALPHA:让颜色缓冲区使用alpha组件。
GLUT_DEPTH:使用深度缓存。
GLUT_STENCIL:使用模板缓存。
GLUT_MULTISAMPLE:让窗口支持多例程。
GLUT_STEREO:使窗口支持立体。
GLUT_LUMINACE:luminance是亮度的意思。但是很遗憾,在多数OpenGL平台上,不被支持。
________________________________________
二、事件处理(Event Processing)
1、void glutMainLoop(void)
让glut程序进入事件循环。在一个glut程序中最多只能调用一次。一旦调用,会直到程序结束才返回。
2、glutReshapeFunc(void (GLUTCALLBACK *func)(int width, int height))
注册当前窗口的形状变化回调函数。当改变窗口大小时,该窗口的形状改变回调函数将被调用。
3、glutDisplayFunc(void (GLUTCALLBACK *func)(void))
注册当前窗口的显示回调函数,当一个窗口的图像层需要重新绘制时,GLUT将调用该窗口的的显示回调函数。显示回调函数不带任何参数,它负责整个图像层的绘制。我们的大部分工作将集中在这个函数中。
4、glutMouseFunc(void (GLUTCALLBACK *func)(int button, int state, int x, int y))
设置鼠标器按键回调函数,当鼠标的左键、右键或中键被按下时触发被注册的函数执行。
5、glutMotionFunc(void (GLUTCALLBACK *func)(int x, int y))
设置鼠标器移动回调函数,当鼠标发生移动时执行被注册的函数。
6、glutKeyboardFunc(void (GLUTCALLBACK *func)(unsigned char key, int x, int y))
设置键盘回调函数,当键盘有键被按下是调用所注册的函数。
7、glutIdleFunc(void (GLUTCALLBACK *func)(void))
设置空闲回调函数,当CPU空闲时调用该函数。
三、窗口管理(Window Management)
1、int glutCreateWindow(char* name);
产生一个顶层的窗口。name 作为窗口的名字,也就是窗口标题栏显示的内容。
返回值是生成窗口的标记符,可用函数glutGetWindow()加以引用。
2、int glutCreateSubWindow(int win,int x,int y,int width,int height);
创建一个子窗口。win是其父窗口的标记符。x,y是相对父窗口的位移,以像素表示。
width,height是子窗口的宽和高。
3、void glutSetWindow(int win)
int glutGetWindow(void)
功能分别是:设置标记符为win的窗口为当前窗口;返回当前窗口的标记符。
4、void glutDestroyWindow(int win)
销毁以win标记的窗口。
5、void glutPostRedisplay(void)
将当前窗口打上标记,标记其需要再次显示。
6、void glutSwapBuffers(void)
当窗口模式为双缓存时,此函数的功能就是把后台缓存的内容交换到前台显示。当然,只有单缓存时,使用它的功能跟用glFlush()一样。
而使用双缓存是为了把完整图画一次性显示在窗口上,或者是为了实现动画。
7、void glutPositionWindow(int x,int y)
改变当前窗口的位置:当前窗口是顶层窗口时,x,y是相对于屏幕的的位移;当前窗口若是子窗口时,x,y是相对其父窗口原点的位移。
8、void glutReshapeWindow(int width,int height)
改变当前窗口的大小。
width,height是当前窗口新的宽度和高度值,当然只能是正值。
9、void glutFullscreen(void)
让当前窗口全屏显示。当前窗口是顶层窗口时才有效。
10、void glutPopWindow(void)
void glutPushWindow(void)
对顶层窗口和子窗口均有效。改变当前窗口在栈中相对于其它窗口的次序。
11、void glutShowWindow(void)
void glutHideWindow(void)
void glutIconifyWindow(void)
这三个函数作用是改变当前窗口的显示状态。
glutShowWindow让当前窗口可视(这时它还是可能被其它窗口挡住)。
glutHideWindow让当前窗口成为不可视状态。
glutIconifyWindow让当前窗口成为一个图标,也即是最小化。
12、glutSetWindowTitle(char* name);
glutSetIconTitle(char* name);
设置当前窗口(必须是顶层窗口)的标题和图标化时的标题。
13、glutSetCursor(int cursor);
设置当前窗口的光标样式。
cursor可选值有许多:如GLUT_CURSOR_RIGHT_ARROW指向右边的光标,
GLUT_CURSOR_LEFT_ARROW指向左边的光标,GLUT_CURSOR_INFO成为手状。
GLUT_CURSOR_DESTROY呈叉状,GLUT_CURSOR_HELP呈现问号的形状。

四、窗口的覆盖管理
1、void glutEstablishOverlay(void);
对当前窗口创建覆盖图层。该覆盖图的模式由初始化显示模式函数glutDisplayMode()决定。glutLayerGet(GLUT_OVERLAY_POSSIBLE)可用以设置对于当前窗口,是否允许产生由初始化显示模式函数规定其模式的覆盖图层。
2、void glutUserLayer(GLenum layer);
枚举量layer可选值为:GLUT_NORMAL,GLUT_OVERLAY.分别选取正常位平面或覆盖平面。
3、void glutRemoveLayer(void);
除去覆盖图。当没有覆盖图层时,调用这条语句也是安全的,这时系统不做任何事。
4、void glutPostOverlayRedisplay(void);
标记该覆盖图层为需要重新显示的状态。
5、void glutShowOverlay(void);
void glutHideOverlay(void);
显示当前窗口的覆盖图层;隐藏覆盖图层。这两条语句即时执行。注意一下,只有窗口可视时,使用glutShowOverlay才能使其覆盖图层可视。当窗口被其他窗口遮挡时,其覆盖图层也被遮挡从而不可视。

 

glut库下的主要函数:
一。初始化

void glutInit(int* argc,char** argv)

这个函数用来初始化GLUT库。对应main函数的形式应是:int main(int argc,char* argv[]);

这个函数从main函数获取其两个参数。

 

void glutInitWindowSize(int width,int height);

void glutInitWindowPosition(int x,int y);

这两个函数很好理解是设置glut程序要产生的窗口的大小和位置(左上角)。以像素为单位。
void glutInitDisplayMode(unsigned int mode);

设置图形显示模式。参数mode的可选值为:

GLUT_RGBA:当未指明GLUT—RGBA或GLUT—INDEX时,是默认使用的模式。表明欲建立RGBA模式的窗口。

GLUT_RGB:与GLUT—RGBA作用相同。

GLUT_INDEX:指明为颜色索引模式。

GLUT_SINGLE:只使用单缓存

GLUT_DOUBLE:使用双缓存。以避免把计算机作图的过程都表现出来,或者为了平滑地实现动画。

GLUT_ACCUM:让窗口使用累加的缓存。

GLUT_ALPHA:让颜色缓冲区使用alpha组件。

GLUT_DEPTH:使用深度缓存。

GLUT_STENCIL:使用模板缓存。

GLUT_MULTISAMPLE:让窗口支持多例程。

GLUT_STEREO:使窗口支持立体。

GLUT_LUMINACE:luminance是亮度的意思。但是很遗憾,在多数OpenGL平台上,不被支持。


--------------------------------------------------------------------------------


二。事件处理(Event Processing)

void glutMainLoop(void)

让glut程序进入事件循环。在一个glut程序中最多只能调用一次。一旦调用,会直到程序结束才返回。
--------------------------------------------------------------------------------


三。窗口管理(Window Management)

int glutCreateWindow(char* name);

产生一个顶层的窗口。name 作为窗口的名字,也就是窗口标题栏显示的内容。

返回值是生成窗口的标记符,可用函数glutGetWindow()加以引用。

int glutCreateSubWindow(int win,int x,int y,int width,int height);

创建一个子窗口。win是其父窗口的标记符。x,y是相对父窗口的位移,以像素表示。

width,height是子窗口的宽和高。

void glutSetWindow(int win);

int glutGetWindow(void);

功能分别是:设置标记符为win的窗口为当前窗口;返回当前窗口的标记符。

void glutDestroyWindow(int win);

销毁以win标记的窗口。

void glutPostRedisplay(void);

将当前窗口打上标记,标记其需要再次显示。

void glutSwapBuffers(void);

当窗口模式为双缓存时,此函数的功能就是把后台缓存的内容交换到前台显示。当然,只有单缓存时,使用它的功能跟用glFlush()一样。

而使用双缓存是为了把完整图画一次性显示在窗口上,或者是为了实现动画。

void glutPositionWindow(int x,int y);

改变当前窗口的位置:当前窗口是顶层窗口时,x,y是相对于屏幕的的位移;当前窗口若是子窗口时,x,y是相对其父窗口原点的位移。

void glutReshapeWindow(int width,int height);

改变当前窗口的大小。

width,height是当前窗口新的宽度和高度值,当然只能是正值。

void glutFullscreen(void);

让当前窗口全屏显示。当前窗口是顶层窗口时才有效。

void glutPopWindow(void);

void glutPushWindow(void);

对顶层窗口和子窗口均有效。改变当前窗口在栈中相对于其它窗口的次序。

void glutShowWindow(void);

void glutHideWindow(void);

void glutIconifyWindow(void);

这三个函数作用是改变当前窗口的显示状态。

glutShowWindow让当前窗口可视(这时它还是可能被其它窗口挡住)。

glutHideWindow让当前窗口成为不可视状态。

glutIconifyWindow让当前窗口成为一个图标,也即是最小化。

glutSetWindowTitle(char* name);

glutSetIconTitle(char* name);

设置当前窗口(必须是顶层窗口)的标题和图标化时的标题。

glutSetCursor(int cursor);

设置当前窗口的光标样式。

cursor可选值有许多:如GLUT_CURSOR_RIGHT_ARROW指向右边的光标,GLUT_CURSOR_LEFT_ARROW指向左边的光标,GLUT_CURSOR_INFO成为手状。

GLUT_CURSOR_DESTROY呈叉状,GLUT_CURSOR_HELP呈现问号的形状。

等等。
--------------------------------------------------------------------------------

 

四。窗口的覆盖管理

void glutEstablishOverlay(void);

对当前窗口创建覆盖图层。该覆盖图的模式由初始化显示模式函数glutDisplayMode()决定。glutLayerGet(GLUT_OVERLAY_POSSIBLE)可用以设置对于当前窗口,是否允许产生由初始化显示模式函数规定其模式的覆盖图层。

void glutUserLayer(GLenum layer);

枚举量layer可选值为:GLUT_NORMAL,GLUT_OVERLAY.分别选取正常位平面或覆盖平面。

void glutRemoveLayer(void);

除去覆盖图。当没有覆盖图层时,调用这条语句也是安全的,这时系统不做任何事。

void glutPostOverlayRedisplay(void);

标记该覆盖图层为需要重新显示的状态。

void glutShowOverlay(void);

void glutHideOverlay(void);

显示当前窗口的覆盖图层;隐藏覆盖图层。这两条语句即时执行。注意一下,只有窗口可视时,使用glutShowOverlay才能使其覆盖图层可视。当窗口被其他窗口遮挡时,其覆盖图层也被遮挡从而不可视。

 

 

二。事件处理(Event Processing)
void glutMainLoop(void)
让glut程序进入事件循环。在一个glut程序中最多只能调用一次。一旦调用,会直到程序结束才返回。
三。窗口管理(Window Management)
int glutCreateWindow(char* name);
产生一个顶层的窗口。name 作为窗口的名字,也就是窗口标题栏显示的内容。
返回值是生成窗口的标记符,可用函数glutGetWindow()加以引用。
int glutCreateSubWindow(int win,int x,int y,int width,int height);
创建一个子窗口。win是其父窗口的标记符。x,y是相对父窗口的位移,以像素表示。
width,height是子窗口的宽和高。
void glutSetWindow(int win);
int glutGetWindow(void);
功能分别是:设置标记符为win的窗口为当前窗口;返回当前窗口的标记符。
void glutDestroyWindow(int win);
销毁以win标记的窗口。
void glutPostRedisplay(void);
将当前窗口打上标记,标记其需要再次显示。
void glutSwapBuffers(void);
当窗口模式为双缓存时,此函数的功能就是把后台缓存的内容交换到前台显示。当然,只有单缓存时,使用它的功能跟用glFlush()一样。
而使用双缓存是为了把完整图画一次性显示在窗口上,或者是为了实现动画。
void glutPositionWindow(int x,int y);
改变当前窗口的位置:当前窗口是顶层窗口时,x,y是相对于屏幕的的位移;当前窗口若是子窗口时,x,y是相对其父窗口原点的位移。
void glutReshapeWindow(int width,int height);
改变当前窗口的大小。
width,height是当前窗口新的宽度和高度值,当然只能是正值。
void glutFullscreen(void);
让当前窗口全屏显示。当前窗口是顶层窗口时才有效。
void glutPopWindow(void);
void glutPushWindow(void);
对顶层窗口和子窗口均有效。改变当前窗口在栈中相对于其它窗口的次序。
void glutShowWindow(void);
void glutHideWindow(void);
void glutIconifyWindow(void);
这三个函数作用是改变当前窗口的显示状态。
glutShowWindow让当前窗口可视(这时它还是可能被其它窗口挡住)。
glutHideWindow让当前窗口成为不可视状态。
glutIconifyWindow让当前窗口成为一个图标,也即是最小化。
glutSetWindowTitle(char* name);
glutSetIconTitle(char* name);
设置当前窗口(必须是顶层窗口)的标题和图标化时的标题。
glutSetCursor(int cursor);
设置当前窗口的光标样式。
cursor可选值有许多:如GLUT_CURSOR_RIGHT_ARROW指向右边的光标,GLUT_CURSOR_LEFT_ARROW指向左边的光标,GLUT_CURSOR_INFO成为手状。
GLUT_CURSOR_DESTROY呈叉状,GLUT_CURSOR_HELP呈现问号的形状。
等等。
四。窗口的覆盖管理
void glutEstablishOverlay(void);
对当前窗口创建覆盖图层。该覆盖图的模式由初始化显示模式函数glutDisplayMode()决定。glutLayerGet(GLUT_OVERLAY_POSSIBLE)可用以设置对于当前窗口,是否允许产生由初始化显示模式函数规定其模式的覆盖图层。

void glutUserLayer(GLenum layer);
枚举量layer可选值为:GLUT_NORMAL,GLUT_OVERLAY.分别选取正常位平面或覆盖平面。

void glutRemoveLayer(void);
除去覆盖图。当没有覆盖图层时,调用这条语句也是安全的,这时系统不做任何事。

void glutPostOverlayRedisplay(void);
标记该覆盖图层为需要重新显示的状态。

void glutShowOverlay(void);
void glutHideOverlay(void);
显示当前窗口的覆盖图层;隐藏覆盖图层。这两条语句即时执行。注意一下,只有窗口可视时,使用glutShowOverlay才能使其覆盖图层可视。当窗口被其他窗口遮挡时,其覆盖图层也被遮挡从而不可视。

http://pyopengl.sourceforge.net/documentation/manual/index.xml
III. GLUT
glut - an introduction to the OpenGL Utility Toolkit
glutAddMenuEntry - adds a menu entry to the bottom of the current menu.
glutAddSubMenu - adds a sub-menu trigger to the bottom of the current menu.
glutAttachMenu - attaches/detaches a mouse button for the current window to the identifier of the current menu
glutBitmapCharacter - renders a bitmap character using OpenGL.
glutBitmapWidth - returns the width/length of a bitmap character/string.
glutButtonBoxFunc - sets the dial & button box button callback for the current window.
glutChangeToMenuEntry - changes the specified menu item in the current menu into a menu entry.
glutChangeToSubMenu - changes the specified menu item in the current menu into a sub-menu trigger.
glutCopyColormap - copies the logical colormap for the layer in use from a specified window to the current window.
glutCreateMenu - creates a new pop-up menu.
glutCreateSubWindow - creates a subwindow.
glutCreateWindow - creates a top-level window.
glutDestroyMenu - destroys the specified menu.
glutDestroyWindow - destroys the specified window.
glutDeviceGet - retrieves GLUT device information represented by integers.
glutDialsFunc - sets the dial & button box dials callback for the current window.
glutDisplayFunc - sets the display callback for the current window.
glutEnterGameMode - enters and leaves GLUT's game mode.
glutEntryFunc - sets the mouse enter/leave callback for the current window.
glutEstablishOverlay - establishes an overlay (if possible) for the current window.
glutExtensionSupported - helps to easily determine whether a given OpenGL extension is supported.
glutForceJoystickFunc - forces current window's joystick callback to be called.
glutFullScreen - requests that the current window be made full screen.
glutGameModeGet - retrieves GLUT game mode information represented by integers.
glutGameModeString - sets the game mode configuration via a string.
glutGet - retrieves simple GLUT state represented by integers.
glutGetColor - retrieves a red, green, or blue component for a given color index colormap entry for the layer in use's logical colormap for the current window.
glutGetModifiers - returns the modifier key state when certain callbacks were generated.
glutIdleFunc - sets the global idle callback.
glutIgnoreKeyRepeat - determines if auto repeat keystrokes are reported to the current window
glutInit - initialize the GLUT library.
glutInitDisplayMode - sets the initial display mode.
glutInitDisplayString - sets the initial display mode via a string.
glutInitWindowPosition - set the initial window position and size respectively.
glutJoystickFunc - sets the joystick callback for the current window.
glutKeyboardFunc - sets the keyboard callback for the current window.
glutKeyboardUpFunc - sets the keyboard up (key release) callback for the current window.
glutLayerGet - retrieves GLUT state pertaining to the layers of the current window.
glutMainLoop - enters the GLUT event processing loop.
glutMenuStatusFunc - sets the global menu status callback.
glutMotionFunc - set the motion and passive motion callbacks respectively for the current window.
glutMouseFunc - sets the mouse callback for the current window.
glutOverlayDisplayFunc - sets the overlay display callback for the current window.
glutPopWindow - change the stacking order of the current window relative to its siblings.
glutPositionWindow - requests a change to the position of the current window.
glutPostOverlayRedisplay - marks the overlay of the current or specified window as needing to be redisplayed.
glutPostRedisplay - marks the current or specified window as needing to be redisplayed.
glutRemoveMenuItem - remove the specified menu item.
glutRemoveOverlay - removes the overlay (if one exists) from the current window.
glutReportErrors - for debugging purposes; prints out OpenGL run-time errors.
glutReshapeFunc - sets the reshape callback for the current window.
glutReshapeWindow - requests a change to the size of the current window.
glutSetColor - sets the color of a colormap entry in the layer of use for the current window.
glutSetCursor - changes the cursor p_w_picpath of the current window.
glutSetKeyRepeat - sets the key repeat mode
glutSetMenu - set/get the current menu
glutSetWindow - set/get the current window
glutSetWindowTitle - change the window or icon title respectively of the current top-level window.
glutShowOverlay - shows or hides the overlay of the current window
glutShowWindow - change the display status of the current window.
glutSolidCone - render a solid or wireframe cone respectively.
glutSolidCube - render a solid or wireframe cube respectively.
glutSolidDodecahedron - render a solid or wireframe dodecahedron (12-sided regular solid) respectively.
glutSolidIcosahedron - render a solid or wireframe icosahedron (20-sided regular solid) respectively.
glutSolidOctahedron - render a solid or wireframe octahedron (8-sided regular solid) respectively.
glutSolidSphere - render a solid or wireframe sphere respectively.
glutSolidTeapot - render a solid or wireframe teapot respectively.
glutSolidTetrahedron - render a solid or wireframe tetrahedron (4-sided regular solid) respectively.
glutSolidTorus - render a solid or wireframe torus (doughnut) respectively.
glutSpaceballButtonFunc - sets the Spaceball button callback for the current window.
glutSpaceballMotionFunc - sets the Spaceball motion callback for the current window.
glutSpaceballRotateFunc - sets the Spaceball rotation callback for the current window.
glutSpecialFunc - sets the special keyboard callback for the current window.
glutSpecialUpFunc - sets the special keyboard up (key release) callback for the current window.
glutStrokeCharacter - renders a stroke character using OpenGL.
glutStrokeWidth - returns the width/length of a stroke character/string.
glutSwapBuffers - swaps the buffers of the current window if double buffered.
glutTabletButtonFunc - sets the special keyboard callback for the current window.
glutTabletMotionFunc - sets the special keyboard callback for the current window.
glutTimerFunc - registers a timer callback to be triggered in a specified number of milliseconds.
glutUseLayer - changes the layer in use for the current window.
glutVideoResizeGet - retrieves GLUT video resize information represented by integers.
glutVisibilityFunc - sets the visibility callback for the current window.
glutWarpPointer -
glutWindowStatusFunc - sets the window status callback for the current window.