﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-小虫虫的书架-随笔分类-OpenGL</title><link>http://www.cppblog.com/percyph/category/9690.html</link><description /><language>zh-cn</language><lastBuildDate>Tue, 03 Mar 2009 11:15:29 GMT</lastBuildDate><pubDate>Tue, 03 Mar 2009 11:15:29 GMT</pubDate><ttl>60</ttl><item><title>（转）glut函数详解(13)--视频大小调整API</title><link>http://www.cppblog.com/percyph/archive/2009/03/03/75427.html</link><dc:creator>小虫虫</dc:creator><author>小虫虫</author><pubDate>Tue, 03 Mar 2009 07:41:00 GMT</pubDate><guid>http://www.cppblog.com/percyph/archive/2009/03/03/75427.html</guid><wfw:comment>http://www.cppblog.com/percyph/comments/75427.html</wfw:comment><comments>http://www.cppblog.com/percyph/archive/2009/03/03/75427.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/percyph/comments/commentRss/75427.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/percyph/services/trackbacks/75427.html</trackback:ping><description><![CDATA[*再次声明"glut"函数详解系列转自：<a href="http://old.blog.edu.cn/user3/zjdukang/archives/2007/1765182.shtml"><span id="blogname">阿杰－－江南暖冬</span></a><br>int glutVideoResizeGet(GLenum param);<br>返回glut视频大小调整的信息.<br>参数:<br>param:<br>&nbsp; GLUT_VIDEO_RESIZE_POSSIBLE:如果底层支持视频大小调整,则返回非0值,否则返回0.如果返回0,则其他视频大小调整函数的调用将不起作用.<br>&nbsp; GLUT_VIDEO_RESIZE_IN_USE<br>&nbsp; GLUT_VIDEO_RESIZE_X_DELTA<br>&nbsp; GLUT_VIDEO_RESIZE_Y_DELTA<br>&nbsp; GLUT_VIDEO_RESIZE_WIDTH_DELTA<br>&nbsp; GLUT_VIDEO_RESIZE_HEIGHT_DELTA<br>&nbsp; GLUT_VIDEO_RESIZE_X<br>&nbsp; GLUT_VIDEO_RESIZE_Y<br>&nbsp; GLUT_VIDEO_RESIZE_WIDTH<br>&nbsp; GLUT_VIDEO_RESIZE_HEIGHT<br>&nbsp;<br>后面几个常量值在网上没有搜到解释.<br><br>//*******************************************************************************************<br>void glutSetupVideoResizing(void);<br>&nbsp;<br>void glutStopVideoResizing(void);<br>&nbsp;<br>void glutVideoResize(int x, int y, int width, int height);<br>&nbsp;<br>void glutVideoPan(int x, int y, int width, int height);<br><br>我把glut的头文件中的所有函数都整理了一遍,只可惜 video resize sub-API中的几个函数网上都没有具体的介绍,本菜鸟也无能为力,幸好这些函数都不是常用的,我想一般用不着.除了和视频有关的API,前面几个帖子的内容已经基本把glut的所有函数都过了一遍,本专题也就算是完成了,以后如果找到相关资料,会把这里的补上,也希望达人能够指点一二.  <img src ="http://www.cppblog.com/percyph/aggbug/75427.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/percyph/" target="_blank">小虫虫</a> 2009-03-03 15:41 <a href="http://www.cppblog.com/percyph/archive/2009/03/03/75427.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>（转）glut函数详解(12)--游戏模式API</title><link>http://www.cppblog.com/percyph/archive/2009/03/03/75426.html</link><dc:creator>小虫虫</dc:creator><author>小虫虫</author><pubDate>Tue, 03 Mar 2009 07:38:00 GMT</pubDate><guid>http://www.cppblog.com/percyph/archive/2009/03/03/75426.html</guid><wfw:comment>http://www.cppblog.com/percyph/comments/75426.html</wfw:comment><comments>http://www.cppblog.com/percyph/archive/2009/03/03/75426.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/percyph/comments/commentRss/75426.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/percyph/services/trackbacks/75426.html</trackback:ping><description><![CDATA[所谓游戏模式其实就是一种全屏模式,这里可以对该模式下的屏幕显示方式进行简单设置.详见下面具体解释.<br>&nbsp;<br>//*******************************************************************************************<br>void glutGameModeString(const char *string);<br>通过一个字符串对game mode(游戏模式,也即全屏模式)进行设置,即对屏幕进行设置.<br>参数:<br>string:一个指向字符串的指针,字符串的内容即是对屏幕的设置.字符串的格式如下所示:<br>&nbsp; "W*H"<br>&nbsp; "W*H:Bpp"<br>&nbsp; "W*H@Rr"<br>&nbsp; "W*H:Bpp@Rr"<br>&nbsp; "@Rr"<br>&nbsp; ":Bpp"<br>&nbsp; "Bpp:@Rr"<br>(注:W:屏幕宽度,以像素单位;H:屏幕高度,以像素为单位;Bpp:每个像素的内存大小(位数);Rr:屏幕的刷新率.)<br>例子:<br>1.如果我们只关心屏幕大小(800*600)而不关心每个像素的内存占用和刷新频率,可以写成:<br>&nbsp;&nbsp;&nbsp; glutGameModeString("800*600");<br>2.如果只想把每个像素的内存占用设置成32位,可以写成:<br>&nbsp;&nbsp;&nbsp; glutGameModeString(":32");<br>3.如果只想把刷新率设置成75赫兹,可以写成:<br>&nbsp;&nbsp;&nbsp; glutGameModeString("@75");<br>4.如果前三种情况都考虑,可以写成:<br>&nbsp;&nbsp;&nbsp; glutGameModeString("800*600:32@75");<br>其他情况按照上面给出的字符串格式写出即可.<br>注:<br>&nbsp; 1.这个函数只是对硬件的请求,如果设置不合法,则将被忽略.<br>&nbsp; 2.这个函数并不返回错误值,如果要获得错误信息,则要用glutGameModeGet()函数.<br><br>//*******************************************************************************************<br>int glutEnterGameMode(void);<br><br>进入相应的game mode,即让glutGameModeString()的设置生效.<br><br>//*******************************************************************************************<br>void glutLeaveGameMode(void);<br><br>离开glutGameModeString()设置的game mode.<br><br>//*******************************************************************************************<br><br>int glutGameModeGet(GLenum mode);<br><br>检测设置的模式是否有效<br><br>参数:<br>mode:<br>&nbsp; GLUT_GAME_MODE_ACTIVE:如果程序运行在game mode,则返回非0值,如果运行在窗口模式,则返回0.<br>&nbsp; GLUT_GAME_MODE_POSSIBLE:判断glutAameModeString()的设置是否有效,如果有效则返回非0值,否则返回0.但是glut手册中有一个警告,即使这个设置是有效的,也不能保证屏幕设置可以一定成功生效.<br>&nbsp; GLUT_GAME_MODE_WIDTH:返回屏幕的宽度.<br>&nbsp; GLUT_GAME_MODE_HEIGHT:返回屏幕的高度.<br>&nbsp; GLUT_GAME_MODE_PIXEL_DEPTH:返回当前模式下每个像素所占用的内存空间(位数).<br>&nbsp; GLUT_GAME_MODE_REFRESH_RATE:返回实际的刷新率(单位赫兹).<br>&nbsp; GLUT_GAME_MODE_DISPLAY_CHANGED:正如前面所说,不能保证屏幕显示模式一定根据设置发生改变,这个常量可以用来测试是否真的进入了game mode(先前是窗口模式下的情况下),如果先前已经是game mode,则可以用来测试设置是否发生改变.返回非0值表示进入了game mode或设置已经发生改变,否则返回0.<br> <img src ="http://www.cppblog.com/percyph/aggbug/75426.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/percyph/" target="_blank">小虫虫</a> 2009-03-03 15:38 <a href="http://www.cppblog.com/percyph/archive/2009/03/03/75426.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>（转）glut函数详解(10)--设备控制API</title><link>http://www.cppblog.com/percyph/archive/2009/03/03/75424.html</link><dc:creator>小虫虫</dc:creator><author>小虫虫</author><pubDate>Tue, 03 Mar 2009 07:37:00 GMT</pubDate><guid>http://www.cppblog.com/percyph/archive/2009/03/03/75424.html</guid><wfw:comment>http://www.cppblog.com/percyph/comments/75424.html</wfw:comment><comments>http://www.cppblog.com/percyph/archive/2009/03/03/75424.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/percyph/comments/commentRss/75424.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/percyph/services/trackbacks/75424.html</trackback:ping><description><![CDATA[void glutIgnoreKeyRepeat(int ignore);<br><br>确认是否忽略自动的连续击键(即当一个键被长时间按下不松开时,判断其为一次击键或是多次击键).只对当前窗口有效.对glutKeyboardFunc()和glutSpecialFunc()两个回调函数起作用.<br><br>参数:<br>ignore:(相当于布尔值)<br>&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp; :不忽略,即认为是连续击键<br>&nbsp;&nbsp;&nbsp; 非0:忽略,即认为是一次击键<br>&nbsp;<br>//*******************************************************************************************<br>&nbsp;<br>void glutSetKeyRepeat(int repeatMode);<br><br>设置自动连续击键模式的状态<br><br>参数:repeatMode:<br>GLUT_KEY_REPEAT_OFF&nbsp;&nbsp;&nbsp; :关闭自动连续击键<br>GLUT_KEY_REPEAT_ON&nbsp;&nbsp;&nbsp;&nbsp; :打开自动连续击键<br>GLUT_KEY_REPEAT_DEFAULT:将自动连续击键模式重置为默认状态<br>注意:这个函数工作在全局范围内,即它会影响所有窗口而不仅仅是当前窗口,所以当关闭了自动连续击键模式后,确保在关闭当前程序销毁前,将自动连续击键模式重置为默认状态.<br><br>这个函数的安全性不好,最好使用安全性高的glutIgnoreKeyRepeat(),尽量将操作限制在当前窗口,而不要轻易使用工作在全局状态下的函数.<br>&nbsp;<br>//*******************************************************************************************<br><br><br>void glutForceJoystickFunc(void);<br>强制调用当前窗口注册的操纵杆回调函数glutJoystickFunc()一次. <img src ="http://www.cppblog.com/percyph/aggbug/75424.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/percyph/" target="_blank">小虫虫</a> 2009-03-03 15:37 <a href="http://www.cppblog.com/percyph/archive/2009/03/03/75424.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>（转）glut函数详解(11)--状态查询API</title><link>http://www.cppblog.com/percyph/archive/2009/03/03/75425.html</link><dc:creator>小虫虫</dc:creator><author>小虫虫</author><pubDate>Tue, 03 Mar 2009 07:37:00 GMT</pubDate><guid>http://www.cppblog.com/percyph/archive/2009/03/03/75425.html</guid><wfw:comment>http://www.cppblog.com/percyph/comments/75425.html</wfw:comment><comments>http://www.cppblog.com/percyph/archive/2009/03/03/75425.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/percyph/comments/commentRss/75425.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/percyph/services/trackbacks/75425.html</trackback:ping><description><![CDATA[int glutGet(GLenum state);<br><br>检索指定的GLUT状态<br><br>参数:<br>state:指定要检索的状态类型,为以下常量:<br>&nbsp; GLUT_WINDOW_X:当前窗口的x坐标,以像素为单位.<br>&nbsp; GLUT_WINDOW_Y:当前窗口的y坐标,以像素为单位.<br>&nbsp; GLUT_WINDOW_WIDTH:当其窗口的宽度,以像素为单位.<br>&nbsp; GLUT_WINDOW_HEIGHT:当前窗口的高度,以像素为单位.<br>&nbsp; GLUT_WINDOW_BUFFER_SIZE:当前窗口中,颜色分量占用的位数,即用多少bit表示颜色分量.<br>&nbsp; GLUT_WINDOW_STENCIL_SIZE:当前窗口中,蒙板分量占用的位数,即用多少bit表示蒙板分量.<br>&nbsp; GLUT_WINDOW_DEPTH_SIZE:当前窗口中,深度分量占用的位数,即用多少bit表示深度分量.<br>&nbsp; GLUT_WINDOW_RED_SIZE:当前窗口中,红色分量占用的位数,即用多少bit表示红色分量.<br>&nbsp; GLUT_WINDOW_GREEN_SIZE:当前窗口中,绿色分量占用的位数,即用多少bit表示绿色分量.<br>&nbsp; GLUT_WINDOW_BLUE_SIZE:当前窗口中,蓝色分量占用的位数,即用多少bit表示蓝色分量.<br>&nbsp; GLUT_WINDOW_ALPHA_SIZE:当前窗口中,alpha色分量占用的位数,即用多少bit表示alpha色分量.<br>&nbsp; GLUT_WINDOW_ACCUM_RED_SIZE:当前窗口累积缓存中,红色分量占用的位数,即用多少bit表示红色分量.<br>&nbsp; GLUT_WINDOW_ACCUM_GREEN_SIZE:当前窗口累积缓存中,绿色分量占用的位数,即用多少bit表示绿色分量.<br>&nbsp; GLUT_WINDOW_ACCUM_BLUE_SIZE:当前窗口累积缓存中,蓝色分量占用的位数,即用多少bit表示蓝色分量.<br>&nbsp; GLUT_WINDOW_ACCUM_ALPHA_SIZE:当前窗口累积缓存中,alpha色分量占用的位数,即用多少bit表示alpha色分量.<br>&nbsp; GLUT_WINDOW_DOUBLEBUFFER:如果窗口式双缓存模式,返回1,否则返回0.<br>&nbsp; GLUT_WINDOW_RGBA:如果窗口是RGBA模式,返回1,否则返回0.<br>&nbsp; GLUT_WINDOW_PARENT:查询当前窗口的父窗口个数,如果为顶层窗口返回0.<br>&nbsp; GLUT_WINDOW_NUM_CHILDREN:查询当前窗口的子窗口个数.<br>&nbsp; GLUT_WINDOW_NUM_SAMPLES:查询多重采样的采样点个数.<br>&nbsp; GLUT_WINDOW_STEREO:查询是否使用立体模式,是则返回1,否则返回0.<br>&nbsp; GLUT_WINDOW_CURSOR:返回光标的整数标示.<br>&nbsp; GLUT_SCREEN_HEIGHT:屏幕的高度,以像素为单位.<br>&nbsp; GLUT_SCREEN_WIDTH:屏幕的宽度,以像素为单位.<br>&nbsp; GLUT_SCREEN_WIDTH_MM:屏幕的宽度,以毫米为单位.<br>&nbsp; GLUT_SCREEN_HEIGHT_MM:屏幕的高度,以毫米为单位.<br>&nbsp; GLUT_MENU_NUM_ITEMS:查询当前菜单包含的菜单项的个数.<br>&nbsp; GLUT_DISPLAY_MODE_POSSIBLE:查询窗口系统是否支持当前的显示模式,1表示支持,0表示不支持.<br>&nbsp; GLUT_INIT_DISPLAY_MODE:初始窗口的显示模式.<br>&nbsp; GLUT_INIT_WINDOW_X:初始窗口的x坐标.<br>&nbsp; GLUT_INIT_WINDOW_Y:初始窗口的y坐标.<br>&nbsp; GLUT_INIT_WINDOW_WIDTH:初始窗口的宽度.<br>&nbsp; GLUT_INIT_WINDOW_HEIGHT:初始窗口的高度.<br>&nbsp; GLUT_ELAPSED_TIME:返回两次调用glutGet(GLUT_ELAPSED_TIME)的时间间隔,单位为毫秒,返回值根据查询的内容返回相应的值,无效的状态名返回-1.<br>&nbsp; GLUT_WINDOW_COLORMAP_SIZE:返回颜色索引表的大小.<br><br>//*******************************************************************************************<br><br>int glutDeviceGet(GLenum type);<br><br>检索设备信息<br><br>参数:<br>type:要检索的设备信息的名字,为以下常量:<br>&nbsp; GLUT_HAS_KEYBOARD 如果键盘可用,返回非0值,否则,返回0.<br>&nbsp; GLUT_HAS_MOUSE 如果鼠标可用,返回非0值,否则,返回0.<br>&nbsp; GLUT_NUM_MOUSE_BUTTONS 返回鼠标支持的按键数,如果鼠标不可用,返回0,返回值0,表示检索的设备不存在,非0表示设备可用.<br>&nbsp; GLUT_HAS_SPACEBALL:如果spaceball可用,返回非0值,否则,返回0.<br>&nbsp; GLUT_HAS_DIAL_AND_BUTTON_BOX:如果拨号按键盒可用,返回非0值,否则,返回0.<br>&nbsp; GLUT_HAS_TABLET:如果图形板可用,返回非0值,否则,返回0.<br>&nbsp; GLUT_NUM_SPACEBALL_BUTTONS:返回spaceball支持的按键数,如果spaceball不存在,返回0.<br>&nbsp; GLUT_NUM_BUTTON_BOX_BUTTONS:返回拨号按键盒支持的按键数,如果拨号按键盒不存在,返回0.<br>&nbsp; GLUT_NUM_DIALS:返回拨号按键盒支持的拨号数,如果拨号按键盒不存在,返回0.<br>&nbsp; GLUT_NUM_TABLET_BUTTONS:返回图形板支持的按键数,如果图形板不存在,返回0.<br>&nbsp; GLUT_DEVICE_IGNORE_KEY_REPEAT:如果当前窗口被设置成关闭自动重复按键,则返回非0值.<br>&nbsp; GLUT_DEVICE_KEY_REPEAT:返回自动重复按键的设置状态.(说明文件上说是返回连续击键的速率,其实此说法有误.)<br>&nbsp; GLUT_HAS_JOYSTICK:如果操纵杆可用,返回非0值,否则,返回0.<br>&nbsp; GLUT_OWNS_JOYSTICK:如果glut认为已经成功获得操纵杆的使用权,则返回非0值.否则,返回0.<br>&nbsp; GLUT_JOYSTICK_BUTTONS:返回操纵杆支持的按键数,如果操纵杆不存在,返回0.<br>&nbsp; GLUT_JOYSTICK_AXES:返回操纵杆支持的操纵轴数,如果操纵杆不存在,返回0.<br>&nbsp; GLUT_JOYSTICK_POLL_RATE:返回当前窗口操纵杆被拉动的速率.<br>(注:对操纵杆的查询限制在操纵杆的数量为1;鼠标被默认为存在,并且其按键数默认是3.)<br><br>&nbsp;//******************************************************************************************<br>int glutExtensionSupported(const char *name);<br><br>判定是否支持特定的OpenGL扩展<br><br>参数:<br>extension:指定要测试的OpenGL扩展的名称,如果给定扩展获得支持,函数返回非0,否则返回0.<br>必须要有一个有效的当前窗口来调用glutExtensionSupported().它只返回OpenGL扩展信息,这意味着窗口系统依赖的扩展不被glutExtensionSupported()反映.<br>例子:<br>if(!glutExtensionSupported("GL_EXT_texture"))<br>{<br>&nbsp;fprintf(stderr, "Missing the texture extension!");<br>&nbsp;exit(1);<br>}<br><br>&nbsp;//******************************************************************************************<br>&nbsp;int glutGetModifiers(void);<br><br>返回组合功能键的状态<br><br>返回值为以下定义的常量<br>&nbsp; GLUT_ACTIVE_SHIFT:当按下shift键时<br>&nbsp; GLUT_ACTIVE_CTRL:当按下ctrl键时<br>&nbsp; GLUT_ACTIVE_ALT:当按下alt键时<br><br>&nbsp;//******************************************************************************************<br>&nbsp;int glutLayerGet(GLenum type);<br><br>查询属于当前窗口的重叠层的状态<br><br>参数:<br>type:查询的重叠层状态常量:<br>&nbsp; GLUT_OVERLAY_POSSIBLE:在给定的初始显示模式下,能否为当前窗口创建重叠层.如果能,返回1;如果不能,返回0.<br>&nbsp; GLUT_LAYER_IN_USE:返回当前的使用层,为GLUT_NORMAL(使用正常的颜色层)或GLUT_OVERLAY(使用重叠层).<br>&nbsp; GLUT_HAS_OVERLAY:判断当前窗口是否创建了重叠层.<br>&nbsp; GLUT_NORMAL_DAMAGED:如果当前窗口的图像层在上一次显示回调函数调用后已经破坏,则返回TRUE.<br>&nbsp; GLUT_OVERLAY_DAMAGED:如果当前窗口的重叠层在上一次显示回调函数调用后已经破坏,则返回TRUE.<br>&nbsp; GLUT_TRANSPARENT_INDEX:返回当前窗口覆盖层的透明颜色索引值,如果没有覆盖层则返回-1.<br><br><br> <img src ="http://www.cppblog.com/percyph/aggbug/75425.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/percyph/" target="_blank">小虫虫</a> 2009-03-03 15:37 <a href="http://www.cppblog.com/percyph/archive/2009/03/03/75425.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>（转）glut函数详解(9)--回调API</title><link>http://www.cppblog.com/percyph/archive/2009/03/03/75423.html</link><dc:creator>小虫虫</dc:creator><author>小虫虫</author><pubDate>Tue, 03 Mar 2009 07:36:00 GMT</pubDate><guid>http://www.cppblog.com/percyph/archive/2009/03/03/75423.html</guid><wfw:comment>http://www.cppblog.com/percyph/comments/75423.html</wfw:comment><comments>http://www.cppblog.com/percyph/archive/2009/03/03/75423.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/percyph/comments/commentRss/75423.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/percyph/services/trackbacks/75423.html</trackback:ping><description><![CDATA[void glutDisplayFunc(void (*func)(void));<br><br>注册当前窗口的显示回调函数<br><br>参数:<br>func:形为void func()的函数,完成具体的绘制操作<br><br>这个函数告诉GLUT当窗口内容必须被绘制时,那个函数将被调用.当窗口改变大小或者从被覆盖的状态中恢复,或者由于调用glutPostRedisplay()函数要求GLUT更新时,执行func参数指定的函数.<br>&nbsp;<br>&nbsp;<br>//*******************************************************************************************<br>&nbsp;<br>void glutReshapeFunc(void (*func)(int width, int height));<br><br>指定当窗口的大小改变时调用的函数<br><br>参数:<br>func:形如void func(int width, int height)<br>处理窗口大小改变的函数.<br>width,height:为窗口改变后长宽.<br><br>这个函数确定一个回调函数,每当窗口的大小或形状改变时(包括窗口第一次创建),GLUT将会调用这个函数,这个回调函数接受这个窗口新的长宽作为输入参数.<br>&nbsp;<br>&nbsp;<br>//*******************************************************************************************<br>&nbsp;<br>void glutKeyboardFunc(void (*func)(unsigned char key, int x, int y));<br><br>注册当前窗口的键盘回调函数<br><br>参数:<br>func:形如void func(unsigned char key, int x, int y)<br>key:按键的ASCII码<br>x,y:当按下键时鼠标的坐标,相对于窗口左上角,以像素为单位<br><br>当敲击键盘按键(除了特殊按键,即glutSpecialFunc()中处理的按键,详见glutSpecialFunc())时调用.<br><br><br>//******************************************************************************************<br>&nbsp;void glutMouseFunc(void (*func)(int button, int state, int x, int y));<br><br>注册当前窗口的鼠标回调函数<br><br>参数:<br>func:形如void func(int button, int state, int x, int y);<br>button:鼠标的按键,为以下定义的常量<br>&nbsp; GLUT_LEFT_BUTTON:鼠标左键<br>&nbsp; GLUT_MIDDLE_BUTTON:鼠标中键<br>&nbsp; GLUT_RIGHT_BUTTON:鼠标右键<br>state:鼠标按键的动作,为以下定义的常量<br>&nbsp; GLUT_UP:鼠标释放<br>&nbsp; GLUT_DOWN:鼠标按下<br>x,y:鼠标按下式,光标相对于窗口左上角的位置<br><br>当点击鼠标时调用.<br><br><br>//******************************************************************************************<br>void glutMotionFunc(void (*func)(int x, int y));<br><br>当鼠标在窗口中按下并移动时调用glutMotionFunc注册的回调函数<br><br>void glutPassiveMotionFunc(void (*func)(int x, int y));<br><br>当鼠标在窗口中移动时调用glutPassiveMotionFunc注册的回调函数<br><br>参数:<br>func:形如void func(int x, int y);<br>x,y:鼠标按下式,光标相对于窗口左上角的位置,以像素为单位<br><br><br>//*******************************************************************************************<br>void glutEntryFunc(void (*func)(int state));<br><br>设置鼠标的进出窗口的回调函数<br><br>参数:<br>func:形如void func(int state);注册的鼠标进出回调函数<br>state:鼠标的进出状态,为以下常量之一<br>&nbsp; GLUT_LEFT 鼠标离开窗口<br>&nbsp; GLUT_RIGHT 鼠标进入窗口<br><br>当窗口取得焦点或失去焦点时调用这个函数,当鼠标进入窗口区域并点击时,state为GLUT_RIGHT,当鼠标离开窗口区域点击其他窗口时,state为GLUT_LEFT.<br><br>//******************************************************************************************<br><br>void glutVisibilityFunc(void (*func)(int state));<br><br>设置当前窗口的可视回调函数<br><br>参数:<br>func:形如void func(int state);指定的可视回调函数<br>state:窗口的可视性,为以下常量<br>&nbsp; GLUT_NOT_VISIBLE 窗口完全不可见<br>&nbsp; GLUT_VISIBLE 窗口可见或部分可见<br><br>这个函数设置当前窗口的可视回调函数,当窗口的可视性改变时,该窗口的可视回调函数被调用.只要窗口中的任何一个像素是可见的,或者他的任意一个子窗口中任意一个像素是可见的,GLUT则认为窗口是可见的.<br><br>//*******************************************************************************************<br>void glutIdleFunc(void (*func)(void));<br><br>设置空闲回调函数<br><br>参数:<br>func:形如void func(void);<br><br>当系统空闲时调用.<br><br>//*******************************************************************************************<br>&nbsp;void glutTimerFunc(unsigned int millis, void (*func)(int value), int value);<br><br>注册一个回调函数,当指定时间值到达后,由GLUT调用注册的函数一次<br><br>参数:<br>millis:等待的时间,以毫秒为单位<br>unc:形如void func(int value)<br>value:指定的一个数值,用来传递到回调函数func中<br><br>这个函数注册了一个回调函数,当指定的毫秒数到达后,这个函数就调用注册的函数,value参数用来向这个注册的函数中传递参数. 但只能触发一次,若要连续触发,则需在func中重新设置计时函数glutTimerFunc();<br><br>//*******************************************************************************************<br>void glutMenuStateFunc(void (*func)(int state));<br><br>注册菜单状态回调函数<br><br>参数:<br>func:形如void func(int state);<br>state:<br>&nbsp; GLUT_MENU_IN_USE:菜单被使用.<br>&nbsp; GLUT_MENU_NOT_IN_USE:菜单不再被使用,即菜单被关闭.<br>如果state代入GLUT_MENU_IN_USE,则当菜单被使用时调用该函数;<br>如果state代入GLUT_MENU_NOT_IN_USE,则当菜单被关闭时调用该函数.<br><br>//*******************************************************************************************<br><br>void glutMenuStatusFunc(void (*func)(int status, int x, int y));<br>设置菜单状态回调函数<br>参数:<br>func:形如void func(int status, int x, int y);<br>status:当前是否使用菜单,为以下定义的常量<br>GLUT_MENU_IN_USE:菜单正在使用<br>GLUT_MENU_NOT_IN_USE:菜单未被使用<br>x,y:鼠标按下时,光标相对于窗口左上角的位置<br>这个函数调用时glut程序判定是否正在使用菜单,当弹出菜单时,调用注册的菜单状态回调函数,同时status设置为常量GLUT_MENU_IN_USE,当菜单使用完毕时,也调用菜单状态回调函数,此时status变量变为GLUT_MENU_NOT_IN_USE.从已弹出的菜单中再弹出的菜单不产生菜单状态回调过程.每个glut程序只有一个菜单状态回调函数. 此函数与上面一个函数相比,只是多传了一个光标位置,其他相同.<br><br>//*******************************************************************************************<br>void glutSpecialFunc(void (*func)(int key, int x, int y));<br><br>设置当前窗口的特定键的回调函数<br><br>参数:<br>Func:形如void func(int key, int x, int y);<br>key:按下的特定键,为以下定义的常量 <br>&nbsp; GLUT_KEY_F1:F1功能键<br>&nbsp; GLUT_KEY_F2:F2功能键<br>&nbsp; GLUT_KEY_F3:F3功能键<br>&nbsp; GLUT_KEY_F4:F4功能键<br>&nbsp; GLUT_KEY_F5:F5功能键<br>&nbsp; GLUT_KEY_F6:F6功能键<br>&nbsp; GLUT_KEY_F7:F7功能键<br>&nbsp; GLUT_KEY_F8:F8功能键<br>&nbsp; GLUT_KEY_F9:F9功能键<br>&nbsp; GLUT_KEY_F10:F10功能键<br>&nbsp; GLUT_KEY_F11:F11功能键<br>&nbsp; GLUT_KEY_F12:F12功能键<br>&nbsp; GLUT_KEY_LEFT:左方向键<br>&nbsp; GLUT_KEY_UP:上方向键<br>&nbsp; GLUT_KEY_RIGHT:右方向键<br>&nbsp; GLUT_KEY_DOWN:下方向键<br>&nbsp; GLUT_KEY_PAGE_UP:PageUp键<br>&nbsp; GLUT_KEY_PAGE_DOWN:PageDown键<br>&nbsp; GLUT_KEY_HOME:Home键<br>&nbsp; GLUT_KEY_END:End键<br>&nbsp; GLUT_KEY_INSERT:Insert键<br>x,y:当按下键时鼠标的坐标,相对于窗口左上角,以像素为单位<br><br>注意:ESC,回车和delete键由ASCII码产生,即可以用glutKeyboardFunc()处理. 当在键盘上敲击上述按键时调用该函数.注意与glutKeyboardFunc()的区别.<br><br>//*******************************************************************************************<br><br>void glutSpaceballMotionFunc(void (*func)(int x, int y, int z));<br><br>注册一个当前窗口的spaceball平移的回调函数<br><br>参数:<br>func:形如void func(int x, int y, int z);<br>x,y,z:spaceball的三维空间坐标.<br>paceball即一种特殊的带3D滚轮的鼠标,不仅可以前后转动,更可以在三维空间里滚动,具体图片,可以在百度里搜索.<br><br>当spaceball在当前注册的窗口内平移时,调用该函数.<br><br>//*******************************************************************************************<br>void glutSpaceballRotateFunc(void (*func)(int x, int y, int z));<br><br>注册一个当前窗口的spaceball转动的回调函数<br><br>参数:<br>func:形如void func(int x, int y, int z);<br>当spaceball在当前注册的窗口内滚动时调用.<br><br>//*******************************************************************************************<br><br>void glutSpaceballButtonFunc(void (*func)(int button, int state));<br><br>注册当前窗口的spaceball的按键回调函数.<br><br>参数:<br>func:形如void func(int button, int state);<br>button:按键编号,从1开始,可用的按键编号可以通过glutDeviceGet(GLUT_NUM_SPACEBALL_BUTTONS)查询.<br>state:按键状态<br>&nbsp; GLUT_UP:按键释放<br>&nbsp; GLUT_DOWN:按键按下<br><br>当spaceball在当前窗口中敲击相应的按键时调用.<br><br>//*******************************************************************************************<br><br>void glutButtonBoxFunc(void (*func)(int button, int state));<br><br>注册当前窗口的拨号按键盒按键回调函数<br><br>参数:<br>func:形如void func(int button, int state);<br>button:按键编号,从1开始,可用的按键号可通过glutDeviceGet(GLUT_NUM_BUTTON_BOX_BUTTONS)查询<br>state:按键状态<br>&nbsp; GLUT_UP:按键释放<br>&nbsp; GLUT_DOWN:按键按下<br><br>当拨号按键盒按键被按下时调用.<br><br><br>//*******************************************************************************************<br><br>void glutDialsFunc(void (*func)(int dial, int value));<br><br>注册当前窗口的拨号按键盒拨号回调函数.<br><br>参数:<br>func:形如void func(int dial, value);<br>dial:dial的编号,从1开始,可通过glutDeviceGet(GLUT_NUM_DIALS)查询可用编号.<br>value:dial所拨的值,value是每次所拨的值的累加,直到溢出.<br><br>当拨号按键盒拨号时被调用.<br><br>//*******************************************************************************************<br>void glutTabletMotionFunc(void (*func)(int x, int y));<br><br>注册图形板移动回调函数<br><br>参数:<br>func:形如void func(int x, int y);<br>x,y:图形板移动的坐标.<br><br>当图形板移动时调用.<br><br>&nbsp;//******************************************************************************************<br>void glutTabletButtonFunc(void (*func)(int button, int state, int x, int y));<br><br>注册当前窗口的图形板按键回调函数<br><br>参数:<br>func:形如void func(int button, int state, int x, int y);<br>button:按键号,通过glutDeviceGet(GLUT_NUM_TABLET_BUTTONS)查询可用键号.<br>state:按键状态.<br>&nbsp; GLUT_UP:按键被按下<br>&nbsp; GLUT_DOWN:按键被释放<br><br>x,y:当按键状态改变时,相对于窗口的坐标.<br><br>&nbsp;//******************************************************************************************<br>void glutOverlayDisplayFunc(void (*func)(void));<br><br>注册当前窗口的重叠层的显示回调函数<br><br>参数:<br>func:形如void func(void);指向重叠层的显示回调函数.<br><br>这个函数告诉GLUT当窗口内容必须被绘制时,那个函数将被调用.当窗口改变大小或者从被覆盖的状态中恢复,或者由于调用glutPostOverlayRedisplay()函数要求GLUT更新时,执行func参数指定的函数.<br><br>//*******************************************************************************************<br><br>void glutWindowStatusFunc(void (*func)(int state));<br><br>注册当前窗口状态的回调函数.<br><br>参数:<br>func:形如void func(int state);<br>state:窗口状态.<br>&nbsp; GLUT_HIDDEN:窗口不可见<br>&nbsp; GLUT_FULLY_RETAINED:窗口完全未被遮挡<br>&nbsp; GLUT_PARTIALLY_RETAINED:窗口部分遮挡<br>&nbsp; GLUT_FULLY_COVERED:窗口被全部遮挡<br><br>当窗口状态发生相应改变时调用.<br><br>//*******************************************************************************************<br><br>void glutKeyboardUpFunc(void (*func)(unsigned char key, int x, int y));<br><br>注册释放普通按键的回调函数<br><br>参数:<br>func:形如void func(unsigned char key, int x, int y);<br>key:按键的ASCII码.<br>x,y:释放按键时鼠标相对于窗口的位置,以像素为单位.<br><br>当普通按键被释放时调用.<br><br>//*******************************************************************************************<br><br><br>void glutSpecialUpFunc(void (*func)(int key, int x, int y));<br><br>注册释放特殊按键的回调函数<br><br>参数:<br>func:形如void func(int key, int x, int y);<br>key:特殊按键的标识<br>&nbsp; GLUT_KEY_F1:F1功能键<br>&nbsp; GLUT_KEY_F2:F2功能键<br>&nbsp; GLUT_KEY_F3:F3功能键<br>&nbsp; GLUT_KEY_F4:F4功能键<br>&nbsp; GLUT_KEY_F5:F5功能键<br>&nbsp; GLUT_KEY_F6:F6功能键<br>&nbsp; GLUT_KEY_F7:F7功能键<br>&nbsp; GLUT_KEY_F8:F8功能键<br>&nbsp; GLUT_KEY_F9:F9功能键<br>&nbsp; GLUT_KEY_F10:F10功能键<br>&nbsp; GLUT_KEY_F11:F11功能键<br>&nbsp; GLUT_KEY_F12:F12功能键<br>&nbsp; GLUT_KEY_LEFT:左方向键<br>&nbsp; GLUT_KEY_UP:上方向键<br>&nbsp; GLUT_KEY_RIGHT:右方向键<br>&nbsp; GLUT_KEY_DOWN:下方向键<br>&nbsp; GLUT_KEY_PAGE_UP:PageUp键<br>&nbsp; GLUT_KEY_PAGE_DOWN:PageDown键<br>&nbsp; GLUT_KEY_HOME:Home键<br>&nbsp; GLUT_KEY_END:End键<br>&nbsp; GLUT_KEY_INSERT:Insert键<br>x,y:释放特殊按键时鼠标相对于窗口的位置,以像素为单位.<br><br>当特殊按键被释放时调用.<br><br>//****************************************************************************************** <br>void glutJoystickFunc(void (*func)(unsigned int buttonMask, int x, int y, int z), int pollInterval);<br><br>注册操纵杆的回调函数<br><br>参数:<br>buttonMask:操纵杆按键<br>GLUT_JOYSTICK_BUTTON_A<br>GLUT_JOYSTICK_BUTTON_B<br>GLUT_JOYSTICK_BUTTON_C<br>GLUT_JOYSTICK_BUTTON_D<br>x,y,z:操纵杆在三维空间内移动的位移量<br>pollInterval:确定检测操纵杆的间隔时间,其单位为毫秒.<br><br>该函数在两种情况下被调用:<br>1.在pollInterval所规定的时间间隔内调用.<br>2.在调用glutForceJoystickFunc()函数时调用一次glutJoystickFunc(); <img src ="http://www.cppblog.com/percyph/aggbug/75423.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/percyph/" target="_blank">小虫虫</a> 2009-03-03 15:36 <a href="http://www.cppblog.com/percyph/archive/2009/03/03/75423.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>（转）glut函数详解(8)--调试API</title><link>http://www.cppblog.com/percyph/archive/2009/03/03/75422.html</link><dc:creator>小虫虫</dc:creator><author>小虫虫</author><pubDate>Tue, 03 Mar 2009 07:34:00 GMT</pubDate><guid>http://www.cppblog.com/percyph/archive/2009/03/03/75422.html</guid><wfw:comment>http://www.cppblog.com/percyph/comments/75422.html</wfw:comment><comments>http://www.cppblog.com/percyph/archive/2009/03/03/75422.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/percyph/comments/commentRss/75422.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/percyph/services/trackbacks/75422.html</trackback:ping><description><![CDATA[void glutReportErrors(void);<br><br>这个函数打印出OpenGL的运行时错误,它应该只被用在debug中,因为它的调用会降低OpenGL的速度,它所做的仅仅是不断调用glGetError()直到没有错误产生.每一个错误都以GLUT warning形式报告,并由gluErrorString()产生相应的错误信息.<br> <img src ="http://www.cppblog.com/percyph/aggbug/75422.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/percyph/" target="_blank">小虫虫</a> 2009-03-03 15:34 <a href="http://www.cppblog.com/percyph/archive/2009/03/03/75422.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>（转）glut函数详解(7)--字体处理API</title><link>http://www.cppblog.com/percyph/archive/2009/03/03/75421.html</link><dc:creator>小虫虫</dc:creator><author>小虫虫</author><pubDate>Tue, 03 Mar 2009 07:32:00 GMT</pubDate><guid>http://www.cppblog.com/percyph/archive/2009/03/03/75421.html</guid><wfw:comment>http://www.cppblog.com/percyph/comments/75421.html</wfw:comment><comments>http://www.cppblog.com/percyph/archive/2009/03/03/75421.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/percyph/comments/commentRss/75421.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/percyph/services/trackbacks/75421.html</trackback:ping><description><![CDATA[void glutBitmapCharacter(void *font, int character);<br><br>绘制一个图像字符<br><br>int glutBitmapWidth(void *font, int character);<br><br>返回一个图像字符的宽度<br><br>参数:<br>font:要使用的图像字体,如下表所示:<br>&nbsp; GLUT_BITMAP_8_BY_13:一种固定宽度字体,每个字符都放在一个8x13像素的矩形框内<br>&nbsp; GLUT_BITMAP_9_BY_15:一种固定宽度字体,每个字符都放在一个9x15像素的矩形框内<br>&nbsp; GLUT_BITMAP_TIMES_ROMAN_10:一种10点均匀间距的Times Roman字体<br>&nbsp; GLUT_BITMAP_TIMES_ROMAN_24:一种24点均匀间距的Times Roman字体<br>&nbsp; GLUT_BITMAP_HELVETICA_10:一种10点均匀间距的Helvetica字体<br>&nbsp; GLUT_BITMAP_HELVETICA_12:一种12点均匀间距的Helvetica字体<br>&nbsp; GLUT_BITMAP_HELVETICA_18:一种18点均匀间距的Helvetica字体&nbsp; character:绘制的字符的ASCII码.<br><br><br>int glutBitmapLength(void *font, const unsigned char *string);<br><br>获取一个图像字符串的宽度.<br><br>参数:<br>font:同上.<br>string:想要测量宽度的字符串.<br><br>&nbsp;<br>//*******************************************************************************************<br><br>void glutStrokeCharacter(void *font, int character);<br><br>绘制一个图形字符<br><br>int glutStrokeWidth(void *font, int character);<br><br>返回一个图形字体的宽度<br><br>参数:<br>font:要使用的图形字体,如下表所示:<br>&nbsp; GLUT_STROKE_ROMAN 一种等间距的Roman Simplex字体,仅包括32到127的ASCII字符<br>&nbsp; GLUT_STROKE_MONO_ROMAN 一种单一间距的Roman Simplex字体,仅包括32到127的ASCII字符<br>Character:绘制的字符的ASCII码.<br><br><br>int glutStrokeLength(void *font, const unsigned char *string);<br><br>获取一个图形字符串的宽度<br><br>参数:<br>font:同上.<br>string:想要测量宽度的字符串.<br> <img src ="http://www.cppblog.com/percyph/aggbug/75421.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/percyph/" target="_blank">小虫虫</a> 2009-03-03 15:32 <a href="http://www.cppblog.com/percyph/archive/2009/03/03/75421.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>（转）glut函数详解(6)--颜色索引表管理API</title><link>http://www.cppblog.com/percyph/archive/2009/03/03/75420.html</link><dc:creator>小虫虫</dc:creator><author>小虫虫</author><pubDate>Tue, 03 Mar 2009 07:31:00 GMT</pubDate><guid>http://www.cppblog.com/percyph/archive/2009/03/03/75420.html</guid><wfw:comment>http://www.cppblog.com/percyph/comments/75420.html</wfw:comment><comments>http://www.cppblog.com/percyph/archive/2009/03/03/75420.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/percyph/comments/commentRss/75420.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/percyph/services/trackbacks/75420.html</trackback:ping><description><![CDATA[void glutSetColor(int cell, GLfloat red, GLfloat green, GLfloat blue);<br><br>设置当前窗口当前层一个颜色表单元的颜色<br>参数:<br>cell:索引值,标记在颜色表中的位置,其值从0开始,并且必须小于颜色表的最大单元数.<br>当前颜色表的大小可通过调用glutGet(GLUT_WINDOW_COLORMAP_SIZE)获得.<br>red:红色成分<br>green:绿色成分<br>blue:蓝色成分<br><br>//*******************************************************************************************<br>GLfloat glutGetColor(int cell, int component);<br><br>获取指定的颜色索引的颜色值.<br>参数:<br>cell:索引值,标记在颜色表中的位置,其值从0开始,并且必须小于颜色表的最大单元数.<br>当前颜色表的大小可通过调用glutGet(GLUT_WINDOW_COLORMAP_SIZE)获得.<br>component:选择下列的值:<br>&nbsp; GLUT_RED:让函数返回该索引的红色成分.<br>&nbsp; GLUT_GREEN:让函数返回该索引的绿色成分.<br>&nbsp; GLUT_BLUE:让函数返回该索引的蓝色成分.<br><br>//*******************************************************************************************<br>void glutCopyColormap(int win);<br><br>将逻辑颜色表从指定的窗口拷贝到当前窗口<br>参数:win:窗口标识符,逻辑颜色表从该窗口拷贝到当前的窗口.<br> <img src ="http://www.cppblog.com/percyph/aggbug/75420.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/percyph/" target="_blank">小虫虫</a> 2009-03-03 15:31 <a href="http://www.cppblog.com/percyph/archive/2009/03/03/75420.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>（转）glut函数详解(5)--内建模型API</title><link>http://www.cppblog.com/percyph/archive/2009/03/03/75419.html</link><dc:creator>小虫虫</dc:creator><author>小虫虫</author><pubDate>Tue, 03 Mar 2009 07:30:00 GMT</pubDate><guid>http://www.cppblog.com/percyph/archive/2009/03/03/75419.html</guid><wfw:comment>http://www.cppblog.com/percyph/comments/75419.html</wfw:comment><comments>http://www.cppblog.com/percyph/archive/2009/03/03/75419.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/percyph/comments/commentRss/75419.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/percyph/services/trackbacks/75419.html</trackback:ping><description><![CDATA[void glutWireSphere(GLdouble radius, GLint slices, GLint stacks);<br><br>绘制线框球体<br><br>void glutSolidSphere(GLdouble radius, GLint slices, GLint stacks);<br><br>绘制实心球体<br><br>参数:<br>radius:球体的半径<br>slices:球体围绕z轴分割的数目<br>stacks:球体沿着z轴分割的数目<br>绘制中心在模型坐标原点,半径为radius的球体,球体围绕z轴分割slices次,球体沿着z轴分割stacks次<br><br>//*******************************************************************************************<br><br>void glutWireCone(GLdouble base, GLdouble height, GLint slices, GLint stacks);<br><br>绘制线框圆锥体<br><br>void glutSolidCone(GLdouble base, GLdouble height, GLint slices, GLint stacks);<br><br>绘制实心圆锥体<br><br>参数:<br>radius:圆锥体的半径<br>height:圆锥体的高<br>slices:圆锥体围绕z轴分割的数目<br>stacks:圆锥体沿着z轴分割的数目<br>圆锥体的轴为z轴方向,它的基底位于z=0的平面内,顶点z=height,圆锥体围绕z轴分割slices个数目,沿着z轴分割stacks个数目.<br><br>//*******************************************************************************************<br><br>void glutWireCube(GLdouble size);<br><br>绘制线框立方体<br><br>void glutSolidCube(GLdouble size);<br><br>绘制实心立方体<br><br>参数:size:立方体的边长<br><br>//*******************************************************************************************<br><br>void glutWireTorus(GLdouble innerRadius, GLdouble outerRadius, GLint sides, GLint rings);<br><br>绘制线框圆环<br><br>void glutSolidTorus(GLdouble innerRadius, GLdouble outerRadius, GLint sides, GLint rings);<br><br>绘制实心圆环<br><br>参数:<br>innerRadius:圆环的内半径<br>outerRadius:圆环的外半径<br>nsides:圆环腔的分割数<br>rings:圆环的环线数<br><br>//*******************************************************************************************<br><br>void glutWireDodecahedron(void);<br><br>绘制线框十二面体<br><br>void glutSolidDodecahedron(void);<br><br>绘制实心十二面体<br><br>//*******************************************************************************************<br><br>void glutWireTeapot(GLdouble size);<br><br>绘制线框茶壶<br><br>void glutSolidTeapot(GLdouble size);<br><br>绘制实心茶壶<br><br>参数:size:茶壶的相对大小<br><br>//*******************************************************************************************<br><br>void glutWireOctahedron(void);<br><br>绘制线框八面体<br><br>void glutSolidOctahedron(void);<br><br>绘制实心八面体<br><br>//*******************************************************************************************<br><br>void glutWireTetrahedron(void);<br><br>绘制线框四面体<br><br>void glutSolidTetrahedron(void);<br><br>绘制实心四面体<br><br>//*******************************************************************************************<br><br>void glutWireIcosahedron(void);<br><br>绘制线框二十面体<br><br>void glutSolidIcosahedron(void);<br><br>绘制实心二十面体<br><br><br> <img src ="http://www.cppblog.com/percyph/aggbug/75419.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/percyph/" target="_blank">小虫虫</a> 2009-03-03 15:30 <a href="http://www.cppblog.com/percyph/archive/2009/03/03/75419.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>（转）glut函数详解(4)--菜单API</title><link>http://www.cppblog.com/percyph/archive/2009/03/03/75418.html</link><dc:creator>小虫虫</dc:creator><author>小虫虫</author><pubDate>Tue, 03 Mar 2009 07:29:00 GMT</pubDate><guid>http://www.cppblog.com/percyph/archive/2009/03/03/75418.html</guid><wfw:comment>http://www.cppblog.com/percyph/comments/75418.html</wfw:comment><comments>http://www.cppblog.com/percyph/archive/2009/03/03/75418.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/percyph/comments/commentRss/75418.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/percyph/services/trackbacks/75418.html</trackback:ping><description><![CDATA[int glutCreateMenu(void (*func)(int value));<br><br>创建一个新的弹出示菜单<br>参数:<br>func:形如void func(int a);当点击菜单时,调用这个回调函数<br>value:传递给回调函数的数值,它由所选择的菜单条目对应的整数值所决定<br>这个函数创建一个新的弹出式菜单,并返回一个唯一的标识次菜单的整型标识符,并将新建的弹出菜单与func函数关联在一起,这样,当选择此菜单中的一个菜单条目时,调用回调函数func.<br><br>//******************************************************************************************<br>void glutDestroyMenu(int menu);<br><br>删除指定的菜单<br>menu:被删除的菜单的标识符<br><br>//******************************************************************************************<br><br>int glutGetMenu(void);<br><br>获取当前菜单的标识符<br><br>//****************************************************************************************** <br>void glutSetMenu(int menu);<br><br>设置为当前菜单<br>menu:被设置为当前菜单的标识符<br><br>//******************************************************************************************<br><br>void glutAddMenuEntry(const char *label, int value);<br><br>添加一个菜单条目<br>参数:<br>label:菜单条目的名称<br>value:传递到菜单处理函数的值,即在glutCreateMenu中注册的回调函数<br>如果用户选择了这个菜单条目,对应的菜单回调函数就被调用,并以value值作为传递给此回调函数的参数:<br><br>&nbsp;//*****************************************************************************************<br><br>void glutAddSubMenu(const char *label, int submenu);<br><br>在当前菜单的底部增加一个子菜单的触发条目<br>参数:<br>label:子菜单触发条目的名称<br>submenu:子菜单的标识符<br><br>&nbsp;//*****************************************************************************************<br><br>void glutChangeToMenuEntry(int item, const char *label, int value);<br><br>更改当前菜单中指定菜单项<br>参数:<br>item:更改菜单项的索引(最顶层的菜单项的索引为1)<br>label:菜单条目的名称<br>value:传递到菜单处理函数的值,即在glutCreateMenu中注册的回调函数<br><br>&nbsp;//*****************************************************************************************<br><br>void glutChangeToSubMenu(int item, const char *label, int submenu);<br><br>将指定的当前菜单中菜单项变为子菜单触发条目<br>参数:<br>item:更改菜单项的索引(最顶层的菜单项的索引为1)<br>label:子菜单触发条目的名称<br>submenu:子菜单的标识符<br><br>&nbsp;//*****************************************************************************************<br><br>void glutRemoveMenuItem(int item);<br><br>删除指定的菜单项<br>参数:<br>item:当前菜单中要删除的菜单项的索引(最顶层的菜单项的索引为1)<br><br>&nbsp;//*****************************************************************************************<br>void glutAttachMenu(int button);<br><br>把当前窗口的一个鼠标按键与当前菜单关联起来<br><br>void glutDetachMenu(int button);<br><br>解除鼠标按键与弹出式菜单的关联关系<br><br>参数:<br>button:指明何种鼠标按键,可用的符号为以下三种:<br>GLUT_LEFT_BUTTON 鼠标左键<br>GLUT_RIGHT_BUTTON 鼠标右键<br>GLUT_MIDDLE_BUTTON 鼠标中键 <br> <img src ="http://www.cppblog.com/percyph/aggbug/75418.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/percyph/" target="_blank">小虫虫</a> 2009-03-03 15:29 <a href="http://www.cppblog.com/percyph/archive/2009/03/03/75418.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>（转）glut函数详解(3)--重叠层API</title><link>http://www.cppblog.com/percyph/archive/2009/03/03/75417.html</link><dc:creator>小虫虫</dc:creator><author>小虫虫</author><pubDate>Tue, 03 Mar 2009 07:27:00 GMT</pubDate><guid>http://www.cppblog.com/percyph/archive/2009/03/03/75417.html</guid><wfw:comment>http://www.cppblog.com/percyph/comments/75417.html</wfw:comment><comments>http://www.cppblog.com/percyph/archive/2009/03/03/75417.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/percyph/comments/commentRss/75417.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/percyph/services/trackbacks/75417.html</trackback:ping><description><![CDATA[void glutEstablishOverlay(void);<br><br>创建当前窗口的重叠层,该重叠层的显示模式由初始显示模式决定,应在调用glutEstablishOverlay之前调用,glutInitDisplayMode函数来设置初始的显示模式. 实现重叠层需要硬件的支持,并不是所有的系统都提供该支持,如果系统不支持重叠层,那么对glutEstablishOverlay函数的调用就会引起运行错误,GLUT将终止程序的运行.可以调用glutLayerGet(GLUT_OVERPLAY_POSSIBLE)来判断系统是否支持在当前窗口中当前的显示模式下创建重叠层.<br><br>//*****************************************************************************************<br><br>void glutRemoveOverlay(void);<br><br>删除当前层的重叠层<br><br>//***************************************************************************************** <br>void glutUseLayer(GLenum layer);<br><br>改变当前窗口的使用层<br>参数:layer:指定窗口的使用层,为<br>GLUT_NORMAL:使用正常的颜色层<br>GLUT_OVERLAY:使用重叠层<br><br>&nbsp;//****************************************************************************************<br><br>void glutPostOverlayRedisplay(void);<br><br>标记当前窗口的重叠层需要重绘<br><br>//**************************************************************************************** <br>void glutPostWindowOverlayRedisplay(int win);<br><br>标记指定窗口的重叠层需要重绘<br>参数:win:需要重绘的窗口的重叠层的标识符<br><br>&nbsp;//***************************************************************************************<br><br>void glutShowOverlay(void);<br><br>显示当前窗口的重叠层<br><br>void glutHideOverlay(void);<br><br>隐藏当前窗口的重叠层<br><br>这两条语句即时执行.注意一下,只有窗口可视时,使用glutShowOverlay才能使其覆盖图层可视.当窗口被其他窗口遮挡时,其覆盖图层也被遮挡从而不可视.<br><br> <img src ="http://www.cppblog.com/percyph/aggbug/75417.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/percyph/" target="_blank">小虫虫</a> 2009-03-03 15:27 <a href="http://www.cppblog.com/percyph/archive/2009/03/03/75417.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>（转）glut函数详解(2)--窗口API</title><link>http://www.cppblog.com/percyph/archive/2009/03/03/75416.html</link><dc:creator>小虫虫</dc:creator><author>小虫虫</author><pubDate>Tue, 03 Mar 2009 07:26:00 GMT</pubDate><guid>http://www.cppblog.com/percyph/archive/2009/03/03/75416.html</guid><wfw:comment>http://www.cppblog.com/percyph/comments/75416.html</wfw:comment><comments>http://www.cppblog.com/percyph/archive/2009/03/03/75416.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/percyph/comments/commentRss/75416.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/percyph/services/trackbacks/75416.html</trackback:ping><description><![CDATA[<br>int glutCreateWindow(const char *title);<br><br>产生一个顶层的窗口.title作为窗口的名字,也就是窗口标题栏显示的内容.<br>返回值是生成窗口的标记符,可用函数glutGetWindow()加以引用.<br>&nbsp;<br>//******************************************************************************************<br>&nbsp;<br>int glutCreateSubWindow(int win, int x, int y, int width, int height);<br>&nbsp;<br>创建一个子窗口.win是其父窗口的标记符.x,y是子窗口左上角相对父窗口的位移,以像素表示.width,height是子窗口的宽和高.<br><br>&nbsp;//*****************************************************************************************<br>void glutDestroyWindow(int win);<br><br>销毁窗口,win是所要销毁的窗口的标识符.这个函数销毁指定的窗口以及与窗口关联的OpenGL上下文,重叠层,子窗口等一切与此窗口相关的内容.<br><br>&nbsp;//*****************************************************************************************<br>void glutPostRedisplay(void);<br><br>标记当前窗口的图像层需要重新绘制,在glutMainLoop函数的事件处理循环的下一个循环中,将调用该窗口的显示回调函数重绘该窗口的图像层.<br><br>&nbsp;//******************************************************************************************<br>void glutPostWindowRedisplay(int win);<br><br>标记指定的窗口需重绘,在glutMainLoop函数的事件处理循环的下一个循环中,将调用该窗口的显示回调函数重绘该窗口的图像层.<br>参数:win:需刷新的窗口标识符<br><br>//******************************************************************************************<br><br>void glutSwapBuffers(void);<br><br>当窗口模式为双缓存时,此函数的功能就是把后台缓存的内容交换到前台显示.当然,只有单缓存时,使用它的功能跟用glFlush()一样.而使用双缓存是为了把完整图画一次性显示在窗口上,或者是为了实现动画.<br><br>//******************************************************************************************<br><br>int glutGetWindow(void);<br><br>返回当前窗口的标识符<br><br>//*****************************************************************************************<br><br>void glutSetWindow(int win);<br><br>设置标记符为win的窗口为当前窗口<br><br>//****************************************************************************************<br><br>void glutSetWindowTitle(const char *title);<br><br>设置当前窗口（必须是顶层窗口）的标题,窗口一旦建立后,窗口标题就可以由这个函数来改变<br><br>//****************************************************************************************<br><br>&nbsp;void glutSetIconTitle(const char *title);<br><br>设置当前窗口（必须是顶层窗口）图标化时的标题.<br><br>&nbsp;//***************************************************************************************<br><br>&nbsp;void glutPositionWindow(int x, int y);<br><br>改变当前窗口的位置：当前窗口是顶层窗口时,x,y是相对于屏幕的的位移;当前窗口若是子窗口时,x,y是相对其父窗口原点的位移.<br><br>&nbsp;//***************************************************************************************<br><br>&nbsp;void glutReshapeWindow(int width, int height);<br><br>改变当前窗口的大小.width,height是当前窗口新的宽度和高度值,当然只能是正值.<br><br>&nbsp;//***************************************************************************************<br>&nbsp;void glutPopWindow(void);<br><br>在同一个父窗口的子窗口中,使当前的子窗口与排列在它前一个位置的子窗***换位置<br><br>void glutPushWindow(void);<br><br>在同一个父窗口的子窗口中,使当前的子窗口与排列在它后一个位置的子窗***换位置<br><br>这两个函数对顶层窗口和子窗口都起作用,但函数的结果并不立即发生,直到下一个事件循环.<br><br>&nbsp;//****************************************************************************************<br><br>&nbsp;void glutIconifyWindow(void);<br><br>让当前窗口成为一个图标,也即是最小化,使当前窗口图标化显示.<br><br>&nbsp;//****************************************************************************************<br><br>void glutShowWindow(void);<br><br>显示当前窗口（这时它还是可能被其它窗口挡住）.<br><br>//***************************************************************************************** <br>void glutHideWindow(void);<br><br>隐藏当前窗口<br><br>//**************************************************************************************** <br><br>void glutFullScreen(void);<br><br>把当前窗口用全屏显示,当前窗口是顶层窗口时才有效.<br><br>//**************************************************************************************** <br><br>&nbsp;void glutSetCursor(int cursor);<br><br>设置当前窗口的光标样式.<br>参数:<br>cursor:指定鼠标的形状,为下面的一种值光标的形状<br>/* Basic arrows. */<br>GLUT_CURSOR_RIGHT_ARROW<br>GLUT_CURSOR_LEFT_ARROW<br>/* Symbolic cursor shapes. */<br>GLUT_CURSOR_INFO<br>GLUT_CURSOR_DESTROY<br>GLUT_CURSOR_HELP<br>GLUT_CURSOR_CYCLE<br>GLUT_CURSOR_SPRAY<br>GLUT_CURSOR_WAIT<br>GLUT_CURSOR_TEXT<br>GLUT_CURSOR_CROSSHAIR<br>/* Directional cursors. */<br>GLUT_CURSOR_UP_DOWN<br>GLUT_CURSOR_LEFT_RIGHT<br>/* Sizing cursors. */<br>GLUT_CURSOR_TOP_SIDE<br>GLUT_CURSOR_BOTTOM_SIDE<br>GLUT_CURSOR_LEFT_SIDE<br>GLUT_CURSOR_RIGHT_SIDE<br>GLUT_CURSOR_TOP_LEFT_CORNER<br>GLUT_CURSOR_TOP_RIGHT_CORNER<br>GLUT_CURSOR_BOTTOM_RIGHT_CORNER<br>GLUT_CURSOR_BOTTOM_LEFT_CORNER<br>/* Fullscreen crosshair (if available). */<br>GLUT_CURSOR_FULL_CROSSHAIR:<br>(在全屏模式下使用,等同于GLUT_CURSOR_CROSSHAIR)<br>/* Blank cursor. */<br>GLUT_CURSOR_NONE:不显示鼠标<br>/* Inherit from parent window. */<br>GLUT_CURSOR_INHERIT:使用父窗口的鼠标<br><br>&nbsp;//****************************************************************************************<br><br>void glutWarpPointer(int x, int y);<br><br>这个函数将鼠标指针移动到一个相对于当前窗口左上角的新的位置,以窗口左上角为原点,右为X轴正方向,下为Y轴正方向,参数x,y是在这个坐标系中的点,可以为负值.如果坐标值超出屏幕可见范围,则将该值强行控制在屏幕可见范围以内.一般情况下这个函数最好不要使用, 因为鼠标动作还是留给用户控制比较人性化. <img src ="http://www.cppblog.com/percyph/aggbug/75416.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/percyph/" target="_blank">小虫虫</a> 2009-03-03 15:26 <a href="http://www.cppblog.com/percyph/archive/2009/03/03/75416.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>（转）glut函数详解(1)--glut初始化API</title><link>http://www.cppblog.com/percyph/archive/2009/03/03/75414.html</link><dc:creator>小虫虫</dc:creator><author>小虫虫</author><pubDate>Tue, 03 Mar 2009 07:15:00 GMT</pubDate><guid>http://www.cppblog.com/percyph/archive/2009/03/03/75414.html</guid><wfw:comment>http://www.cppblog.com/percyph/comments/75414.html</wfw:comment><comments>http://www.cppblog.com/percyph/archive/2009/03/03/75414.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/percyph/comments/commentRss/75414.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/percyph/services/trackbacks/75414.html</trackback:ping><description><![CDATA[*转自：<a href="http://www.blog.edu.cn/user3/zjdukang/archives/2007/1751751.shtml" onmousedown="return c({'fm':'as','f':'77b717ea','t':'1236064841','title':this.innerhtml,'url':this.href,'p1':4,'y':'ef6fef7f'})" target="_blank"><font size="3"></font></a>http://old.blog.edu.cn/user3/zjdukang/archives/2007/1751751.shtml<br>(1)&nbsp;&nbsp;&nbsp; void glutInit(int *argc, char **argv);<br>&nbsp;&nbsp;&nbsp;&nbsp; 这个函数用来初始化GLUT库.这个函数从main函数获取其两个参数.对应main函数的形式应是：int main(int argc,char* argv[]);<br>//*******************************************************************************************<br>(2)&nbsp;&nbsp;&nbsp; void glutInitDisplayMode(unsigned int mode);<br>设置图形显示模式.参数mode的可选值为:<br>&nbsp;&nbsp;&nbsp;&nbsp; GLUT_RGBA:当未指明GLUT—RGBA或GLUT—INDEX时,是默认使用的模式.表明欲建立RGBA模式的窗口.<br>&nbsp;&nbsp;&nbsp;&nbsp; GLUT_RGB:与GLUT—RGBA作用相同.<br>&nbsp;&nbsp;&nbsp;&nbsp; GLUT_INDEX:指明为颜色索引模式.<br>&nbsp;&nbsp;&nbsp;&nbsp; GLUT_SINGLE:只使用单缓存<br>&nbsp;&nbsp;&nbsp;&nbsp; GLUT_DOUBLE:使用双缓存.以避免把计算机作图的过程都表现出来,或者为了平滑地实现动画.<br>&nbsp;&nbsp;&nbsp;&nbsp; GLUT_ACCUM:让窗口使用累加的缓存.<br>&nbsp;&nbsp;&nbsp;&nbsp; GLUT_ALPHA:让颜色缓冲区使用alpha组件.<br>&nbsp;&nbsp;&nbsp;&nbsp; GLUT_DEPTH:使用深度缓存.<br>&nbsp;&nbsp;&nbsp;&nbsp; GLUT_STENCIL:使用模板缓存.<br>&nbsp;&nbsp;&nbsp;&nbsp; GLUT_MULTISAMPLE:让窗口支持多例程.<br>&nbsp;&nbsp;&nbsp;&nbsp; GLUT_STEREO:使窗口支持立体.<br>&nbsp;&nbsp;&nbsp;&nbsp; GLUT_LUMINACE:luminance是亮度的意思.但是很遗憾,在多数OpenGL平台上,不被支持.<br>//******************************************************************************************<br>(3)&nbsp;&nbsp;&nbsp; void glutInitWindowPosition(int x, int y);<br>设置初始窗口的位置(窗口左上角相对于桌面坐标(x,y))<br>//******************************************************************************************<br>(4)&nbsp;&nbsp;&nbsp; void glutInitWindowSize(int width, int height);<br>设置初始窗口的大小<br>//******************************************************************************************<br>(5)&nbsp;&nbsp;&nbsp; void glutMainLoop(void);<br>让glut程序进入事件循环.在一个glut程序中最多只能调用一次,且必须调用.一旦调用,会直到程序结束才返回.<br>//******************************************************************************************<br>(6)&nbsp;&nbsp;&nbsp; void glutInitDisplayString(const char *string);<br>通过一个字符串初始化display mode<br>参数:string:display mode的描述字符串<br>这个描述字符串用在创建顶级窗口,子窗口和重叠层时,给将要被创建的窗口或重叠层设置display mode.<br>这个字符串是由0个或多个功能描述参数组成,每个功能描述参数用空格或tab键隔开.(若未给参数限制缓存精度大小,则采用默认值)<br><br>例如:<br>glutInitDisplayString("stencil~2 rgb double depth&gt;=16 samples");<br>上例将窗口初始化为至少2位的模板缓存,RGB模式alpha占用位数为0,深度缓存至少为16位,如果平台支持的话使用mutlisampling技术.<br>可以使用的符号有:<br>=&nbsp;&nbsp; 等号<br>!=&nbsp; 不等号<br>&lt;&nbsp;&nbsp; 小于号(越小越好)<br>&gt;&nbsp;&nbsp; 大于号(越大越好)<br>&lt;=&nbsp; 小于等于(越小越好)<br>&gt;=&nbsp; 大于等于(尽可能选择大的数值,主要用于颜色缓存或深度缓存等对位数要求高的参数设置)<br>~&nbsp;&nbsp; 大于等于(但尽可能选择小的数值,有效利用资源,主要用于模板缓存等)<br>&nbsp;<br>主要参数:<br>alpha : alpaha缓存精度, 默认值&gt;=1,即大于等于1位;<br>acca&nbsp; : red, green, blue, 和alpha累积缓存精度, 默认值&gt;=1<br>acc&nbsp; :&nbsp; red, green, blue累积缓存精度, 默认值&gt;=1,alpha累积缓存精度为0;<br>blue :&nbsp; blue颜色缓存精度, 默认值&gt;=1;<br>buffer: 颜色索引缓存精度, 默认值&gt;=1;<br>conformant :布尔值,指示帧缓存配置是否一致,该值基于GLX的EXT_visual_rationg扩展的支持,若不支持,则默认为一致, 默认值=1;<br>depth : 深度缓存精度, 默认值&gt;=12;<br>double: 布尔值,指示颜色缓存是否是双倍缓存. 默认值=1;<br>green : green颜色缓存精度,默认值&gt;=1;<br>index : 布尔值,指示是否为颜色索引,true表示是颜色索引, 默认值&gt;=1;<br>num&nbsp; :&nbsp; 专用名词,指示数值表示的第n个帧缓存配置与这个描述字符串相符合的地方,当没有指定,则glutInitDisplayString也返回初始(最佳符合)配置.<br>red :&nbsp;&nbsp; red颜色缓存精度, 默认值&gt;=1;<br>rgba :&nbsp; rgba模式,颜色缓存精度默认值&gt;=1;<br>rgb :&nbsp;&nbsp; rgb模式,颜色缓存精度默认值&gt;=1,alpha精度=0;<br>luminance: 设置red颜色缓存精度,默认值&gt;=1,其他颜色缓存精度=0(alpha没有指定);<br>stencil: 模板缓存精度<br>single: 布尔值,指示颜色缓存是否为单缓存, 默认值=1;<br>stereo :布尔值,标示颜色缓存支持OpenGL的三维系统,默认值=1;<br>samples: 标示multisamples的值,这个值是基于GLX的SGIS_multisample的扩展.默认值&lt;=4.这个默认值表示如果支持的话可以在glutInitDisplayString中添加描述参数让glut请求multipsampling;<br>slow :&nbsp; 布尔值,标示帧缓存配置是否是slow的.对于X11对glut的执行,slow信息是基于GLX的EXT_visual_rating扩展的支持,如果不支持,就认为是fast;对于win32对glut的执行,slow是基于像素格式描述(pixel format Descriptor即PFD)被标记为"generic"并且未被标记为"accelerated",这说明Microsoft关于slow的OpenGL执行只用在PFD中.这个参数的作用是帮助程序避免对于当前机器的帧缓存配置越来越慢.默认值&gt;=0,表示slow visuals优先于fast visuals,但fast visuals仍然被允许.<br>win32pdf : 只在win32系统中识别glut的请求,这个参数与win32中的像素格式(pixel format)相匹配,它的值是个数字<br>xvisual: 只在X Window系统中识别glut的请求,这个参数与X visual ID相匹配,它的值是个数字<br>xstaticgray:&nbsp; 只在X Window系统中识别glut请求,是个布尔值,标示帧缓存配置的X visual是否是StaticGray. 默认值=1<br>xgrayscale&nbsp; : 只在X Window系统中识别glut的请求,是个布尔值,标示帧缓存配置的X visual是否是GrayScale. 默认值=1;<br>xstaticcolor:&nbsp; 只在X Window系统中识别glut的请求,是个布尔值,标示帧缓存配置的X visual是否是StaticColor. 默认值=1;<br>xpseudocolor : 只在X Window系统中识别glut的请求,是个布尔值,标示帧缓存配置的X visual是否是PsuedoColor. 默认值=1;<br>xtruecolor&nbsp; :&nbsp; 只在X Window系统中识别glut的请求,是个布尔值,标示帧缓存配置的X visual是否是TrueColor. 默认值=1;<br>xdirectcolor : 只在X Window系统中识别glut的请求,是个布尔值,标示帧缓存配置的X visual是否是DirectColor. 默认值=1;<br>//*******************************************************************************************<br>网上没有搜到关于glut的完整资料,于是下狠心自己花时间整理了一下.这里只是glut初始化的API,其中void glutInitDisplayString(const char *string);在国内网站上没搜到具体解释,是从国外网站上翻译过来的,本人英文水平有限,可能有错误,下面贴上英文原文,望达人指点.(其他API 会在以后分类后陆续给出).<br>&nbsp;<br>void glutInitDisplayString(const char *string)&nbsp; - sets the initial display mode via a string.<br>string:Display mode description string, see below.<br>Description:<br>The initial display mode description string is<br>used&nbsp; when creating top-level windows,subwindows,<br>and overlays to determine the OpenGL display mode<br>for the to-be-created window or overlay.<br>The string is a list of zero or more capability<br>descriptions separated by spaces and tabs.Each<br>capability description is a capability name that<br>is optionally followed by a comparator and a<br>numeric value.For example,"double" and "depth&gt;=12"<br>are both valid criteria.<br>The capability descriptions are translated into<br>a set of criteria used to select the appropriate<br>frame buffer&nbsp; configuration.<br>The criteria are matched in strict left to right<br>order of precdence.That is,the first specified<br>criteria(leftmost) takes precedence over the later<br>criteria for nonexact criteria (greater than,less<br>than,etc.comparators).Exact criteria (equal, not<br>equal compartors) must match exactly so precedence<br>is not relevant.<br>The numeric value is an integer that is parsed<br>according to ANSI C's strtol(str,strptr,0) behavior.<br>This means that decimal,octal(leading 0),and<br>hexidecimal values(leading 0x) are accepeted.<br>The valid compartors are:<br>=&nbsp; Equal.<br>!= Not equal.<br>&lt;&nbsp; Less than and preferring larger difference<br>&nbsp;&nbsp; (theleast is best).<br>&gt;&nbsp; Greater than and preferring larger differences<br>&nbsp;&nbsp; (the most is best).<br>&lt;= Less than or equal and preferring larger<br>&nbsp;&nbsp; difference(the least is best).<br>&gt;= Greater than or equal and preferring more<br>&nbsp;&nbsp; instead of less. This comparator is useful for<br>&nbsp;&nbsp; allocating resources like color precsion or<br>&nbsp;&nbsp; depth buffer precision where the maximum<br>&nbsp;&nbsp; precison is generally preferred.Contrast with<br>&nbsp;&nbsp; the tilde (~) comprator.<br>~&nbsp; Greater than or equal but preferring less<br>&nbsp;&nbsp; instead of more.This compartor is useful for<br>&nbsp;&nbsp; allocating resources such as stencil bits or<br>&nbsp;&nbsp; auxillary color buffers where you would rather<br>&nbsp;&nbsp; not over allocate.<br>&nbsp;&nbsp; When the compartor and numeric value are not<br>&nbsp;&nbsp; specified,each capability name has a different<br>&nbsp;&nbsp; default(one default is to require a compartor<br>&nbsp;&nbsp; and numeric value).<br>The valid capability names are:<br>alpha:Alpha color buffer precision in bits.Default<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; is "&gt;=1".<br>acca:Red,green,blue,and alpha accumulation buffer<br>&nbsp;&nbsp;&nbsp;&nbsp; precision in bits.Default is "&gt;=1" for red,<br>&nbsp;&nbsp;&nbsp;&nbsp; green,blue,and alpha capabilities.<br>acc:Red,green,and green accumulation buffer<br>&nbsp;&nbsp;&nbsp; precision in bits and zero bits of alpha<br>&nbsp;&nbsp;&nbsp; accumulation buffer precision.Default is "&gt;=1"<br>&nbsp;&nbsp;&nbsp; for red,green,and blue capabilities,and "~0"<br>&nbsp;&nbsp;&nbsp; for the alpha capability.<br>blue:Blue color buffer precision in bits.Default<br>&nbsp;&nbsp;&nbsp;&nbsp; is "&gt;=1".<br>buffer:Number of bits in the color index color<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; buffer.Default is "&gt;=1".<br>conformant:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Boolean indicating if the frame buffer<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; configuration is conformant or not.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Conformance information is based on GLX's<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EXT_visual_rating extension if supported.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If the extension is not supported,all<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; visuals are assumed conformat.Default is<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "=1".<br>depth:Number of bits of precsion in the depth<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; buffer.Default is "&gt;=12".<br>double:Boolean indicating if the color buffer is<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; double buffered.Default is "=1".<br>green:Green color buffer precision in bits.Default<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; is "&gt;=1".<br>index:Boolean if the color model is color index or<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; not.True is color index.Default is "&gt;=1".<br>num:A special capability name indicating where the<br>&nbsp;&nbsp;&nbsp; value represents the Nth frame buffer<br>&nbsp;&nbsp;&nbsp; configuration matching the description string.<br>&nbsp;&nbsp;&nbsp; When&nbsp; not specified,glutInitDisplayString also<br>&nbsp;&nbsp;&nbsp; returns the first(best matching) configuration.<br>&nbsp;&nbsp;&nbsp; num requires a compartor and numeric value.<br>red;Red color buffer precision in bits.Default is<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "&gt;=1".<br>rgba:Number of bits of red,green,blue,and&nbsp; alpha<br>&nbsp;&nbsp;&nbsp;&nbsp; in the RGBA color buffer.Default is "&gt;=1"<br>&nbsp;&nbsp;&nbsp;&nbsp; for red,green,blue,and alpha capabilities,<br>&nbsp;&nbsp;&nbsp;&nbsp; and "=1"&nbsp; for the RGBA color model capability.<br>rgb:Number of bits of red,green,and blue in the<br>&nbsp;&nbsp;&nbsp; RGBA color buffer and zero bits of alpha color<br>&nbsp;&nbsp;&nbsp; buffer precision.Default&nbsp; is "&gt;=1" for the red,<br>&nbsp;&nbsp;&nbsp; green,and blue capabilities,and "~0" for alpha<br>&nbsp;&nbsp;&nbsp; capability,and "=1" for the RGBA color model<br>&nbsp;&nbsp;&nbsp; capability.<br>luminance:<br>&nbsp;&nbsp;&nbsp; Number of bits of red in the RGBA and zero<br>&nbsp;&nbsp;&nbsp; bits of green,blue(alpha not specified) of<br>&nbsp;&nbsp;&nbsp; color buffer precision.Default is "&gt;=1"<br>&nbsp;&nbsp;&nbsp; for the red capabilitis,and "=0" for the green<br>&nbsp;&nbsp;&nbsp; and blue capabilities,and "=1" for the RGBA<br>&nbsp;&nbsp;&nbsp; color model capability,and,for X11,"=1" for the<br>&nbsp;&nbsp;&nbsp; StaticGray ("xstaticgray")capability.SGI<br>&nbsp;&nbsp;&nbsp; InfiniteReality(and other future machines)<br>&nbsp;&nbsp;&nbsp; support a 16-bit luminance (single channel)<br>&nbsp;&nbsp;&nbsp; display mode(an additional 16-bit alpha channel<br>&nbsp;&nbsp;&nbsp; can also be requested).The red channel maps to<br>&nbsp;&nbsp;&nbsp; gray scale and green and blue channels are not<br>&nbsp;&nbsp;&nbsp; available.A 16-bit precision luminance display<br>&nbsp;&nbsp;&nbsp; mode is often appropriate for medical imaging<br>&nbsp;&nbsp;&nbsp; applications.Do not expect many machines to<br>&nbsp;&nbsp;&nbsp; support extended precision luminance display<br>&nbsp;&nbsp;&nbsp; modes.<br>stencil:Number of bits in the stencil buffer.<br>single:Boolean indicate the color buffer is single<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; buffered.Double buffer capability "=1".<br>stereo:Boolean indicating the color buffer is<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; supports OpenGL-style stereo.Default is "=1".<br>samples:Indicates the number of multisamples to use<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; based on GLX's SGIS_multisample extension(for<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; antialiasing).Default is "&lt;=4". This default<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; means that a GLUT application can request<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; multipsampling if available by simply<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; specifying "samples".<br>slow:Boolean indicating if the frame buffer<br>&nbsp;&nbsp;&nbsp;&nbsp; configuration is slow or not.For the X11<br>&nbsp;&nbsp;&nbsp;&nbsp; implementation of GLUT,slowness information is<br>&nbsp;&nbsp;&nbsp;&nbsp; based on GLX's EXT_visual_rating extension if<br>&nbsp;&nbsp;&nbsp;&nbsp; supported.If the EXT_visual_rating extension is<br>&nbsp;&nbsp;&nbsp;&nbsp; not supported,all visuals are assumed fast.For<br>&nbsp;&nbsp;&nbsp;&nbsp; the Win32 implementation of GLUT,slowness is<br>&nbsp;&nbsp;&nbsp;&nbsp; based on if the underlying Pixel Format Descriptor<br>&nbsp;&nbsp;&nbsp;&nbsp; (PFD)is marked "generic" and not "accelerated".<br>&nbsp;&nbsp;&nbsp;&nbsp; This implies that Microsoft's relatively slow<br>&nbsp;&nbsp;&nbsp;&nbsp; software OpenGL implementation is used by this<br>&nbsp;&nbsp;&nbsp;&nbsp; PFD.Note that slowness is a relative designation<br>&nbsp;&nbsp;&nbsp;&nbsp; relative to other frame buffer configurations<br>&nbsp;&nbsp;&nbsp;&nbsp; available.The intent of the slow capability is to<br>&nbsp;&nbsp;&nbsp;&nbsp; help programs avoid frame buffer configurations<br>&nbsp;&nbsp;&nbsp;&nbsp; that are slower(but perhaps higher precision) for<br>&nbsp;&nbsp;&nbsp;&nbsp; the current machine.Default is "&gt;=0" if not<br>&nbsp;&nbsp;&nbsp;&nbsp; comparator and numeric value are provided.This<br>&nbsp;&nbsp;&nbsp;&nbsp; default means that slow visuals are used in<br>&nbsp;&nbsp;&nbsp;&nbsp; preference to fast visuals,but fast visuals will<br>&nbsp;&nbsp;&nbsp;&nbsp; still be allowed.<br>win32pfd:<br>&nbsp;&nbsp;&nbsp;&nbsp; Only recognized on GLUT implementations for Win32,<br>&nbsp;&nbsp;&nbsp;&nbsp; this&nbsp; capability name matches the Win32 Pixel For-<br>&nbsp;&nbsp;&nbsp;&nbsp; mat Descriptor by numer.&nbsp; win32pfd requires a com-<br>&nbsp;&nbsp;&nbsp;&nbsp; partor and numeric value.<br>xvisual:Only recongized on GLUT implementations for the<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; X Window System,this capability name matches<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the X visual ID by number.xvisual requires a<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; compartor and numeric value.<br>xstaticgray:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Only recongized on GLUT implementations for the<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; X Window System,boolean indicating if the frame<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; buffer configuration's X visual is of type Stat-<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; icGray.Default is "=1".<br>xgrayscale:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Only recongized on GLUT implementations for the<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; X Window System,boolean indicating if the frame<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; buffer configuration's X visual is of type<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GrayScale.Default is "=1".<br>xstaticcolor:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Only recongized on GLUT implementations for the<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; X Window System,boolean indicating if the frame<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; buffer configuration's X visual is of type<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; StaticColor.Default is "=1".<br>xpseudocolor:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Only recongized on GLUT implementations for the<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; X Window System,boolean indicating if the frame<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; buffer configuration's X visual is of type<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PsuedoColor.Default is "=1".<br>xtruecolor:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Only recongized on GLUT implementations for the<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; X Window System,boolean indicating if the frame<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; buffer configuration's X visual is of type<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TrueColor.Default is "=1".<br>xdirectcolor:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Only recongized on GLUT implementations for the<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; X Window System,boolean indicating if the frame<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; buffer configuration's X visual is of type<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DirectColor.Default is "=1".<br>Unspecifed capability descriptions will result in<br>unspecified criteria being generated.These unspecified<br>criteria help glutInitDisplayString behave sensibly<br>with terse display mode description strings.For<br>example,if no "slow" capability description is provided,<br>fast frame buffer configurations will be choosen in<br>preference to slow frame buffer configurations,but slow<br>frame&nbsp; buffer&nbsp; configurations will still be choosen if<br>no better fast frame buffer configuration is available.<br>Example:<br>Here is an examples using glutInitDisplayString:<br>glutInitDisplayString("stencil~2 rgb double depth&gt;=16 samples");<br>The above call requests a window with an RGBA color<br>model(but requesting no bits of alpha),a depth buffer<br>with at least 16 bits of precsion but preferring more,<br>mutlisampling if available,and at least 2 bits of<br>stencil(favoring less stencil to more as long as 2 bits<br>are available).<br>  <img src ="http://www.cppblog.com/percyph/aggbug/75414.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/percyph/" target="_blank">小虫虫</a> 2009-03-03 15:15 <a href="http://www.cppblog.com/percyph/archive/2009/03/03/75414.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>（转）glut中去掉控制台</title><link>http://www.cppblog.com/percyph/archive/2009/03/03/75412.html</link><dc:creator>小虫虫</dc:creator><author>小虫虫</author><pubDate>Tue, 03 Mar 2009 07:10:00 GMT</pubDate><guid>http://www.cppblog.com/percyph/archive/2009/03/03/75412.html</guid><wfw:comment>http://www.cppblog.com/percyph/comments/75412.html</wfw:comment><comments>http://www.cppblog.com/percyph/archive/2009/03/03/75412.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/percyph/comments/commentRss/75412.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/percyph/services/trackbacks/75412.html</trackback:ping><description><![CDATA[<strong><span style="font-size: 12pt;">*文章转自：<a href="http://old.blog.edu.cn/user3/zjdukang/archives/2007/1765297.shtml">http://old.blog.edu.cn/user3/zjdukang/archives/2007/1765297.shtml</a><br>&nbsp;&nbsp;&nbsp; glut是OpenGL应用工具包(OpenGL Utility Toolkit),它为OpenGL提供了一个简易的窗口平台,使程序员不用过多的关心与平台相关的窗口系统.</span></strong><span style="font-weight: bold;"><br></span><strong><span style="font-size: 12pt;">&nbsp;&nbsp;&nbsp; 建立工程时,我们一般都建立控制台程序(在vc6中即console win32 application)来使用glut库.但是在控制台程序下,运行时都会跳出控制台窗口,很不美观,我们可以用下面的方法将控制台窗口去掉:<br><span style="font-size: 10pt;">#pragma comment( linker,"/subsystem:\"windows\" /entry:\"mainCRTStartup\"" )</span><br>在主函数所在的.cpp文件的顶部加上上面的宏,就可以轻松将控制台窗口去掉,这样就只剩下glut窗口了.</span></strong><br>  <img src ="http://www.cppblog.com/percyph/aggbug/75412.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/percyph/" target="_blank">小虫虫</a> 2009-03-03 15:10 <a href="http://www.cppblog.com/percyph/archive/2009/03/03/75412.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>glut函数说明</title><link>http://www.cppblog.com/percyph/archive/2009/03/03/75411.html</link><dc:creator>小虫虫</dc:creator><author>小虫虫</author><pubDate>Tue, 03 Mar 2009 07:02:00 GMT</pubDate><guid>http://www.cppblog.com/percyph/archive/2009/03/03/75411.html</guid><wfw:comment>http://www.cppblog.com/percyph/comments/75411.html</wfw:comment><comments>http://www.cppblog.com/percyph/archive/2009/03/03/75411.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/percyph/comments/commentRss/75411.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/percyph/services/trackbacks/75411.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: Normal07.8 磅02falsefalsefalseMicrosoftInternetExplorer4st1\:*{behavior:url(#ieooui) }/* Style Definitions */table.MsoNormalT...&nbsp;&nbsp;<a href='http://www.cppblog.com/percyph/archive/2009/03/03/75411.html'>阅读全文</a><img src ="http://www.cppblog.com/percyph/aggbug/75411.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/percyph/" target="_blank">小虫虫</a> 2009-03-03 15:02 <a href="http://www.cppblog.com/percyph/archive/2009/03/03/75411.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>VC下OpenGL配置以及glut配置</title><link>http://www.cppblog.com/percyph/archive/2009/03/03/75409.html</link><dc:creator>小虫虫</dc:creator><author>小虫虫</author><pubDate>Tue, 03 Mar 2009 06:57:00 GMT</pubDate><guid>http://www.cppblog.com/percyph/archive/2009/03/03/75409.html</guid><wfw:comment>http://www.cppblog.com/percyph/comments/75409.html</wfw:comment><comments>http://www.cppblog.com/percyph/archive/2009/03/03/75409.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/percyph/comments/commentRss/75409.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/percyph/services/trackbacks/75409.html</trackback:ping><description><![CDATA[OpenGL官方网站（英文）<br><a href="http://www.opengl.org/">http://www.opengl.org</a><br><br>下面我将对Windows下的OpenGL编程进行简单介绍。 <br><br style="font-weight: bold;"><span style="color: #940000; font-weight: bold;">第一步：选择一个编译环境&nbsp;&nbsp;&nbsp; </span><br><br>现在Windows系统的主流编译环境有Visual Studio，Broland C++ Builder，Dev-C++等，它们都是支持OpenGL的。但这里我们选择VC++ 6.0作为学习OpenGL的环境。&nbsp;&nbsp;&nbsp; <br><br style="color: #ff0000;"><span style="color: #940000; font-weight: bold;">第二步：安装GLUT工具包&nbsp;</span><span style="font-weight: bold;">&nbsp;&nbsp; </span><br><br>GLUT不是OpenGL所必须的，但它会给我们的学习带来一定的方便，推荐安装。&nbsp;&nbsp;&nbsp; <br><br>Windows环境下的GLUT下载地址：（大小约为150k）&nbsp;&nbsp;&nbsp; <br>http://www.opengl.org/resources/libraries/glut/glutdlls37beta.zip&nbsp;&nbsp; <br><br>无法从以上地址下载的话请使用下面的连接:&nbsp;&nbsp;&nbsp; <br>http://upload.programfan.com/upfile/200607311626279.zip&nbsp;&nbsp;&nbsp;&nbsp; <br><br>Windows环境下安装GLUT的步骤：&nbsp;&nbsp;&nbsp; <br>1、将下载的压缩包解开，将得到5个文件 <br>2、以我的安装目录为例：&nbsp;&nbsp;&nbsp; <br>（1）&#8220;d:\Program Files\Microsoft Visual Studio\VC98\include\GL文件夹&#8221;。把解压得到的glut.h放到这个GL文件夹里。没有GL文件夹可以自己建一个，一般都有的。<br>（2）&#8220;d:\Program Files\Microsoft Visual Studio\VC98\lib文件夹&#8221;。把解压得到的glut.lib和glut32.lib放到静态函数库所在文件夹，即lib文件夹。<br>（3）把解压得到的glut.dll和glut32.dll放到操作系统目录下面的system32文件夹内。（典型的位置为：C:\Windows\System32）这是非常重要的动态链接库设置！&nbsp; <br><br style="color: #940000; font-weight: bold;"><span style="color: #940000; font-weight: bold;">第三步，创建工程，其步骤如下：</span><span style="font-weight: bold;">&nbsp;&nbsp;&nbsp; </span><br><br>（1）创建一个Win32 Console Application。（以我创建的为例，工程名为simpleGL）&nbsp;&nbsp;&nbsp; <br>（2）链接OpenGL libraries:在Visual C++中先单击Project，再单击Settings，再找到Link单击，最后在Object/library modules 的最前面加上opengl32.lib Glut32.lib Glaux.lib glu32.lib 。&nbsp;&nbsp;&nbsp; <br>（3）单击Project Settings中的C/C++标签，将Preprocessor definitions 中的_CONSOLE改为__WINDOWS。最后单击OK。&nbsp;&nbsp; <br><br>现在，准备工作基本上完成了，可不要轻视这一步，如果你没有设置好在编译及运行过程中总会出错的。 <br><br>对于VS2005可以如下设置：<br>1、把 glut.h 复制到 VC 安装路径下的 PlatFormSDK\include\gl 文件夹<br>2、把 glut32.lib 复制到 VC 安装路径下的 PlatFormSDK\lib 文件夹<br>3、把 glut32.dll 复制到 Windows\System32 文件夹<br>4、在 VC 中创建控制台应用程序，在选项中清除&#8220;使用预编译头&#8221;（以免影响可移植性）<br>5、在 VC 中打开项目-&gt;属性对话框进行如下设置：<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 将&#8220;配置&#8221;下拉框选则为&#8220;所有配置&#8221;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 打开 &#8220;链接器--输入&#8221;项<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 在&#8220;附加依赖项&#8221;中增加：<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OpenGL32.lib<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; glu32.lib<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; glut32.lib<br><br style="font-weight: bold;"><span style="color: #940000; font-weight: bold;">第四步，创建一个最简单的opengl程序</span><br><br>
<div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">#include &lt;GL/glut.h&gt;<br><br>void myDisplay(void)<br>{<br>&nbsp;&nbsp;&nbsp; glClear(GL_COLOR_BUFFER_BIT);<br>&nbsp;&nbsp;&nbsp; glRectf(-0.5f, -0.5f, 0.5f, 0.5f);<br>&nbsp;&nbsp;&nbsp; glFlush();<br>}<br><br>int main(int argc, char *argv[])<br>{<br>&nbsp;&nbsp;&nbsp; </span>glutInit<span style="color: #000000;">(&amp;argc, argv);<br>&nbsp;&nbsp;&nbsp; glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);<br>&nbsp;&nbsp;&nbsp; glutInitWindowPosition(100, 100);<br>&nbsp;&nbsp;&nbsp; glutInitWindowSize(400, 400);<br>&nbsp;&nbsp;&nbsp; glutCreateWindow("第一个OpenGL程序");<br>&nbsp;&nbsp;&nbsp; glutDisplayFunc(&amp;myDisplay);<br>&nbsp;&nbsp;&nbsp; glutMainLoop();<br>&nbsp;&nbsp;&nbsp; return 0;<br>}<br></span><span style="color: #000000;"></span></div>
<br>该程序的作用是在一个黑色的窗口中央画一个白色的矩形。下面对各行语句进行说明。 <br><br>首先，需要包含头文件#include&lt;GL/glut.h&gt;，这是GLUT的头文件。<br>本来OpenGL程序一般还要包含&lt;GL/gl.h&gt;和&lt;GL/glu.h&gt;，但GLUT的头文件中已经自动将这两个文件包含了，不必再次包含。<br><br>然后看main函数。<br>int main(int argc, char *argv[])，这个是带命令行参数的main函数，各位应该见过吧？没见过的同志们请多翻翻书，等弄明白了再往下看。<br>注意main函数中的各语句，除了最后的return之外，其余全部以glut开头。这种以glut开头的函数都是GLUT工具包所提供的函数，下面对用到的几个函数进行介绍。<br>1、glutInit，对GLUT进行初始化，这个函数必须在其它的GLUT使用之前调用一次。其格式比较死板，一般照抄这句glutInit(&amp;argc, argv)就可以了。<br>2、glutInitDisplayMode，设置显示方式，其中GLUT_RGB表示使用RGB颜色，与之对应的还有GLUT_INDEX（表示使用索引颜色）。GLUT_SINGLE表示使用单缓冲，与之对应的还有GLUT_DOUBLE（使用双缓冲）。更多信息，请自己Google。当然以后的教程也会有一些讲解。<br>3、glutInitWindowPosition，这个简单，设置窗口在屏幕中的位置。<br>4、glutInitWindowSize，这个也简单，设置窗口的大小。<br>5、glutCreateWindow，根据前面设置的信息创建窗口。参数将被作为窗口的标题。注意：窗口被创建后，并不立即显示到屏幕上。需要调用glutMainLoop才能看到窗口。<br>6、glutDisplayFunc，设置一个函数，当需要进行画图时，这个函数就会被调用。（这个说法不够准确，但准确的说法可能初学者不太好理解，暂时这样说吧）。<br>7、glutMainLoop，进行一个消息循环。（这个可能初学者也不太明白，现在只需要知道这个函数可以显示窗口，并且等待窗口关闭后才会返回，这就足够了。）<br><br>在glutDisplayFunc函数中，我们设置了&#8220;当需要画图时，请调用myDisplay函数&#8221;。于是myDisplay函数就用来画图。观察 myDisplay中的三个函数调用，发现它们都以gl开头。这种以gl开头的函数都是OpenGL的标准函数，下面对用到的函数进行介绍。<br>1、glClear，清除。GL_COLOR_BUFFER_BIT表示清除颜色，glClear函数还可以清除其它的东西，但这里不作介绍。<br>2、glRectf，画一个矩形。四个参数分别表示了位于对角线上的两个点的横、纵坐标。<br>3、glFlush，保证前面的OpenGL命令立即执行（而不是让它们在缓冲区中等待）。其作用跟fflush(stdout)类似。 <br>    <img src ="http://www.cppblog.com/percyph/aggbug/75409.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/percyph/" target="_blank">小虫虫</a> 2009-03-03 14:57 <a href="http://www.cppblog.com/percyph/archive/2009/03/03/75409.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>