锘??xml version="1.0" encoding="utf-8" standalone="yes"?>欧美精品一区二区三区很污很色的,国产色产综合产在线视频,欧美国产三区http://www.shnenglu.com/helloqinglan/category/11786.html韜姭鍗婁歡闀垮伐琛o紝鎬鎻d竴棰楀湴涓誨績(jī)zh-cnSun, 04 Apr 2010 02:08:57 GMTSun, 04 Apr 2010 02:08:57 GMT60娓告垙鍒板簳鏈夊璧氶挶http://www.shnenglu.com/helloqinglan/archive/2010/04/04/111554.html鐧戒簯鍝?/dc:creator>鐧戒簯鍝?/author>Sat, 03 Apr 2010 17:18:00 GMThttp://www.shnenglu.com/helloqinglan/archive/2010/04/04/111554.htmlhttp://www.shnenglu.com/helloqinglan/comments/111554.htmlhttp://www.shnenglu.com/helloqinglan/archive/2010/04/04/111554.html#Feedback0http://www.shnenglu.com/helloqinglan/comments/commentRss/111554.htmlhttp://www.shnenglu.com/helloqinglan/services/trackbacks/111554.html銆銆娓告垙鏈夊璧氶挶錛岀湅涓涓嬩笂甯?jìng)娓告垙鍏徃鐨勮储鎶q煡閬撲簡(jiǎn)銆?a target="_blank">http://tech.163.com/caibao錛岃繖閲屾湁鍥藉唴浜掕仈緗戝叕鍙歌儲(chǔ)鎶ユ眹鎬伙紝鎽樺綍09騫寸鍥涘搴﹀嚑瀹跺叕鍙哥殑娓告垙涓氬姟璧㈠埄鎯呭喌錛岃涓嬭〃錛?/font>

鍏徃 娓告垙钀ユ敹(涓囧厓) 姣涘埄娑?涓囧厓) 姣涘埄鐜?/td>
鐩涘ぇ 133600 80200 60%
瀹岀編 54000 52600 86.60%
鐣呮父 48250 28800 92%
宸ㄤ漢 27300 23200 83.90%

 

銆銆褰撶劧錛岃繖鏄崰鎹簡(jiǎn)鍥藉唴娓告垙琛屼笟鏀跺叆涓澶у崐鐨勫嚑瀹跺ぇ鍏徃錛屼笉榪囧氨綆楁槸灝忓叕鍙革紝鍙鑳芥垚鍔熻浜у搧涓婄嚎錛屽埄娑︾巼涔熸槸涓鏍風(fēng)殑銆?/font>

 

銆銆浠庝笂甯?jìng)鍏徃鐨勮储鎶ラ噷鍙互鐪嬪垘图屼竴鑸琈MORPG鐨勬瘡媧昏穬浠樿垂鐢ㄦ埛騫沖潎姣忔湀璐$尞鏀跺叆澶ц嚧鍦?0鍏冨乏鍙籌紝鏈変簺娓告垙浼?xì)楂樺緢澶氬Q屾湁浜涚◢浣庝竴浜涖備篃灝辨槸璇達(dá)紝鍙鏈?涓囨椿璺冧粯璐圭敤鎴鳳紝浠?5%鐨勫埄娑︾巼鏉ヨ綆楋紝鎵i櫎榪愯惀鎴愭湰鍚庣殑鏈堝埄娑﹀氨鑳借揪鍒?00涓囥?/font>

 

銆銆涓嶈繃錛岀洰鍓嶆父鎴忕殑綾誨瀷鍩烘湰涓婇兘鏄亾鍏鋒敹璐癸紝榪欐牱涓嶆槸姣忎釜鐜╂父鎴忕殑浜洪兘浼?xì)鎺忛挶銆傛寜鐓х晠娓歌儲(chǔ)鎶ヤ腑鎶湶鐨勪俊鎭紝闈炰粯璐圭敤鎴峰悜浠樿垂鐢ㄦ埛鐨勮漿鍖栨瘮渚嬩負(fù)18%錛屽叾浠栨父鎴忕殑榪欎釜姣斾緥搴旇涔熶笉浼?xì)鐩稿樊澶锛? * 18%錛屾湀鏀跺叆100涓囧氨闇瑕佹湁11涓囩殑媧昏穬鐢ㄦ埛銆?/font>

 

銆銆媧昏穬鐢ㄦ埛鐨勭粺璁℃柟娉曚竴鑸槸濡傛灉璇ヨ處鍙峰湪涓澶╁唴绱鍦ㄧ嚎鏃墮棿瓚呰繃2灝忔椂錛屽垰璇ョ帺瀹剁殑媧昏穬澶╂暟灝卞姞1錛屽鏋滃湪綰挎椂闂村湪鍗婂皬鏃跺埌2灝忔椂涔嬮棿錛屽垯媧昏穬澶╂暟鍔?.5錛屽湪綰挎椂闂村皬浜庡崐灝忔椂鐨勪笉綆楁椿璺冨ぉ鏁般傚綋鐒?dòng)灱寴q欐槸姣忔棩媧昏穬鐢ㄦ埛鏁扮殑緇熻鏂規(guī)硶銆?/font>

 

銆銆鎴戜滑浠?灝忔椂涓哄崟浣嶏紝鍙鍦ㄦ瘡涓椂闂村崟浣嶅唴鏈?1 / 12涓囩敤鎴峰湪綰匡紝鍒欏氨杈懼埌浜?0涓囨椿璺冪敤鎴楓備篃灝辨槸璇達(dá)紝騫沖潎鍦ㄧ嚎鍙涓嶅埌涓涓囦漢灝辮揪鍒頒簡(jiǎn)鏈堝叆100涓囩殑鐩爣銆?/font>

 

銆銆榪欎釜鏁板瓧鍩烘湰涓婃槸鍙俊鐨勩傚彲浠ュ啀鐪嬩竴鐪嬪畬緹庣殑璐㈡姤錛屽畬緹嶲4璐㈡姤鏄劇ず錛屽鉤鍧囧悓鏃跺湪綰匡紙ACU錛変負(fù)115.7涓囦漢錛岀綉娓告敹鍏ヤ負(fù)5.4浜垮厓錛屽鉤鍧囨瘡鏈堜負(fù)1.8浜匡紝榪欐牱姣?涓囧鉤鍧囧湪綰胯礎(chǔ)鐚殑鏀跺叆涓?18000 / 115.7 = 155涓囷紝榪欎釜鏁板瓧姣斿墠闈㈣綆楃殑涓嶅埌涓涓囧悓鏃跺湪綰胯礎(chǔ)鐚敹鍏?00涓囪繕瑕侀珮錛岃繖鏄洜涓哄畬緹庣殑ARPU鍊兼瘮鐣呮父楂橈紝涓烘瘡鏈?4鍏冦?/font>

 

銆銆鎵浠ワ紝姣忓綋璺熷埆浜轟粙緇嶆垜鏄仛娓告垙鏃訛紝鍒漢閮戒細(xì)鎰熷徆涓涓嬶紝娓告垙鍟婏紝鎸鴻禋閽辯殑錛屾垜涔熺瑧絎戯紝紜疄鏄尯璧氶挶鐨勩傚彲鏄紝濡傛璧氶挶鐨勪駭鍝侊紝寮鍙戜漢鍛樼殑鍥炴姤鍙堟湁澶氬皯鍛紵

 

銆銆鍐嶆潵鐪嬩竴涓嬩笂甯?jìng)鍏徃鐨勮储鎶ャ備緷鐒舵槸鐣呮父鐨勶紝“闈炵編鍥介氱敤浼?xì)璁″噯鍒欎骇鍝佸紑鍙戣垂鐢ㄤ負(fù)510涓囩編鍏冿紝鐜瘮澧為暱5%錛屽悓姣斿噺灝?2%銆傜幆姣斿闀夸富瑕佹槸鐢變簬鑱樼敤浜?jiǎn)鏇村鐨勬父鎴忕爺鍙戜汉鍛樿屽鑷村憳宸ヨ柂閰笌紱忓埄璐圭敤鐨勫鍔犮傚悓姣斿噺灝戜富瑕佹槸鐢變簬鍏徃綆$悊灞傚閲戞柟妗堢殑璋冩暣鈥斺斾箣鍓嶆巿浜堢殑鑲℃潈嬋鍔卞湪IPO鍚庝環(huán)鍊兼彁楂橈紝鍥犺屽叕鍙稿噺灝戝叾鐜伴噾濂栧姳銆?#8221;

銆銆浠庤繖鍙ヨ瘽涓婂彲浠ョ湅鍑烘潵錛岃繖涓爺鍙戣垂鐢ㄤ笉浠呬粎鍙槸寮鍙戜漢鍛樼殑宸ヨ祫錛岃繕鍖呮嫭浜?jiǎn)鐢变簬鍛樺伐鐨勭浉鍏臣洀鍒╁Q屼篃鍖呭惈浜?jiǎn)湄?fù)鍛樺伐鎵緙寸撼鐨勪繚闄╋紝鍏Н閲戠瓑璐圭敤銆傚彟澶栦篃榪樺寘鎷簡(jiǎn)濂栭噾錛屼互鍙?qiáng)鑲℃潈濂栧娹q瓑絳夈傚氨榪?20涓囷紝涔熷彧鍗犲埌浜?jiǎn)钀ユ敹鐨?%銆?/font>

銆銆鍦ㄥ叕鍙哥鐞嗗眰瑙h璐㈡姤鐨勬椂鍊欐湁鍙﹀涓鍙ヨ瘽錛?#8220;鎴鍒?009騫?2鏈?1鏃ワ紝鍏辨湁520浣嶅伐紼嬪笀銆傚湴闈㈡帹騫垮洟闃熶腑姝e紡鍛樺伐鏈?0浜猴紝鍙﹀榪樻湁涓存椂闆囧憳澶х害榪樻湁600浜恒?#8221;涓嶇煡閬撹繖510涓囩殑鐮斿彂璐圭敤鏄惁鍖呮嫭浜?jiǎn)涓婇潰鎻愬埌鐨勫湴闈㈡帹骞夸汉鍛樺拰鋸?fù)鏃墮泧鍛橈紝鏆傛椂璁や負(fù)鍏朵笉鍖呭惈鍚э紝鍋囧畾榪欎簺閽遍兘鑺卞湪浜?20浣嶅紑鍙戜漢鍛樿韓涓娿?/font>

銆銆鍙﹀涔熶笉鐭ラ亾榪?10涓囨槸鍚﹀寘鍚爺鍙戠浉宸殑鍔炲叕瀹ょ閲戠瓑璐圭敤錛岃繖涓及璁″簲璇ュ寘鍚惂銆?/font>

銆銆鍏徃涓哄憳宸ョ即綰崇殑淇濋櫓錛屽叕縐噾璺熸垜浠氦鐨勪竴鏍鳳紝浼?xì)鍗犲伐璧勭?0%澶氾紝鍔炲叕寮鏀笉澶уソ綆楋紝鍙﹀紱忓埄涔熶笉濂借錛屾瘮濡傝仛槨愶紝緇勭粐鍑哄幓鐜╃瓑錛岃繖浜涗笉濂界粺璁★紝榪樹笉鎺掗櫎鏈変竴浜涙棤娉曠粺璁″埌鐨勭伆鑹插唴瀹廣傜畝鍗曚竴鐐癸紝灝辯畻榪?10涓囨湁50%鏈鍚庝互money鐨勫艦寮忓彂鍒頒簡(jiǎn)寮鍙戜漢鍛樻墜涓婂惂錛屽寘鎷瘡鏈堝浐瀹氬伐璧勪笌濂栭噾銆傝繖鏍鳳紝騫沖潎姣忎漢姣忔湀鏄?600緹庡厓銆?/font>

銆銆鍥犱負(fù)澶ч儴鍒嗗叕鍙哥殑濂栭噾閮芥槸浠ュ鍙戜竴涓垨鑰呭嚑涓湀鐨勫伐璧勫艦寮忔潵鍙戞斁鐨勶紝鎹鐣呮父姣忓勾鐩稿綋浜庤兘鍙?6涓湀宸ヨ祫錛?600 * 12 / 16 = 1200緹庡厓銆傚鉤鍧?000鍏冪殑鏈堣柂錛屽彲鑳藉ぇ閮ㄥ垎浜轟細(xì)鎰熻鍒拌嚜宸卞茍娌℃湁榪欎箞澶氥傚綋鐒?dòng)灱屽洜湄?fù)鏈変竴灝忛儴鍒嗕漢鏈夎偂鏉冪殑濂栧姳錛屼粬浠殑鏀跺叆榪滆秴榪囦簡(jiǎn)8000 * 16錛屾墍璋?0%鐨勭簿鑻辮幏寰椾簡(jiǎn)80%鐨勫埄鐩?:) 鍏跺疄涔熸槸宸笉澶氱殑銆?/font>

 

銆銆濡傛楂樺埄娑︾巼鐨勬父鎴忎駭鍝侊紝鍒板ご鏉ョ敓浜ц呬滑鐨勫洖鎶ュ嵈涔熻繕鏄竴鏍楓傛墍浠ワ紝鍐嶅惉鍒頒漢璇存父鎴忓緢璧氶挶鏃訛紝鏈夊繀瑕佸ソ濂藉鍏惰В閲婁竴鐣?:) 娓告垙紜疄鏄禋閽憋紝鍙挶騫朵笉鍦ㄦ垜浠繖浜涗漢鐨勫彛琚嬮噷銆?/font>

 

銆銆鍐嶆潵鐪嬭繎鏈熺綉鏄撶殑澶ц瘽浜屽洟闃熼泦浣撶鑱岋紝澶ф槑榫欐潈寮鍙戝洟闃熼泦浣撹煩妲藉畬緹庯紝榪樻湁鍗庝箟鎴愰兘宸笉澶氭暣涓叕鍙歌煩鍒拌吘璁紝閲戝北鐨勫洟闃熷埌緗戞槗鍘誨紑鍙戝ぇ鍞愶紝鐩涘ぇ鐨勮嫳闆勫勾浠e洟闃熷嚭璧板緛閫旂瓑絳夛紝榪欎笉鑳借鏄憳宸ヤ笉澶熷繝璇氾紝瀹炲湪鏄埄鐩婂垎閰嶇殑涓嶅悎鐞嗐傛柊鐨勮佹澘鍙鑲鎷垮嚭涓涓敋鑷沖崐涓櫨鍒嗙偣錛屽垎鍒板紑鍙戜漢鍛樼殑鎵嬩腑灝辨槸娌夌敻鐢哥殑璇辨儜浜?jiǎn)銆?/font>

 

銆銆鑰屼笖榪樻湁鍙﹀涓鏉″緢閲嶈鐨勫洜绱狅紝娓告垙鐨勬垚鍔熶笌鍚﹀緢澶х▼搴︿笂鏉ヨ嚜浜庨偅鍑犱釜寮鍙戜漢鍛樸傜旱瑙傚浗鍐呮父鎴忓巶鍟嗭紝鍩烘湰涓婇兘鏄彧闈犵潃寮鍙戝洟闃熷仛鐨勪竴嬈炬父鎴忓氨鎾戣搗浜?jiǎn)鏁翠釜鍏徃锛岃鍏徃鎸q涗簩綰褲佷竴綰挎父鎴忓巶鍟嗚鍒楋紝鐢氳嚦闈犵潃榪欎竴嬈炬父鎴忓幓璧氱編鍥借偂姘戠殑閽便傚綋鐒惰繖縐嶆垚鍔熶篃鏈夊緢澶х殑鍋剁劧鎬с?/font>

銆銆灝卞儚涓涓鍦ㄥ垱涓氳礬涓婄殑鏈嬪弸鎵璇達(dá)紝娓告垙鏄兘璁╀綘榪呴熶粠鏉ㄧ櫧鍔沖彉鎴愰粍涓栦粊鐨勬渶濂介夋嫨銆傚綋鍓嶏紝鍓嶆彁鏄綘涓嶆槸鍦ㄤ負(fù)鍒漢鎵撳伐銆?/font>



]]>
FXComposer涓殑Annotations涓嶴emanticshttp://www.shnenglu.com/helloqinglan/archive/2009/09/28/97415.html鐧戒簯鍝?/dc:creator>鐧戒簯鍝?/author>Sun, 27 Sep 2009 16:02:00 GMThttp://www.shnenglu.com/helloqinglan/archive/2009/09/28/97415.htmlhttp://www.shnenglu.com/helloqinglan/comments/97415.htmlhttp://www.shnenglu.com/helloqinglan/archive/2009/09/28/97415.html#Feedback3http://www.shnenglu.com/helloqinglan/comments/commentRss/97415.htmlhttp://www.shnenglu.com/helloqinglan/services/trackbacks/97415.htmlDXSAS : DirectX Standard Annotations and Semantics錛孌irectX寮曞叆鐨勪竴欏瑰湪Shader浠g爜涓庡簲鐢ㄧ▼搴忎箣闂磋繘琛屾暟鎹粦瀹氱殑瑙勮寖錛屽綋鍑哄埌0.8鏃惰騫挎硾鐢ㄤ簬鍚勭搴旂敤紼嬪簭涓紝鍚庢潵浠嶮S鐨勪駭鍝佺嚎涓縐樻秷澶憋紝鏈夊叧DXSAS鐨勮鑼冩枃妗h浠嶮SDN涓Щ闄わ紝鍙暀涓嬪嚑欏靛紩鐢ㄨ鏄庛傘傘?/font>

 

綆鍗曟潵璇達(dá)紝褰撴垜浠湪DX涓嬌鐢⊿hader鐨勬椂鍊欙紝鎴戜滑浼?xì)鋴社敤涓涓父閲忚〃鏉ヨ緗悇縐嶅弬鏁板鹼紝鍏朵腑鏈閲嶈鐨勫綋灞炰笘鐣屽彉鎹㈢煩闃典簡(jiǎn)銆傝繖鍦ㄧ敤DX鍐欐父鎴忕▼搴忔椂娌℃湁闂錛屼絾鏄湪鍏朵粬涓浜汼hader緙栬緫宸ュ叿涓棶棰樺氨鍑烘潵浜?jiǎn)锛屽浣曡畡〗畼q欎簺鍙橀噺錛熷綋鐒?dòng)灱屾瘡绉嶅伐鍏峰彲浠ユ彁渚涜嚜宸辩殑鏂规硶锛屾瘮濡傜幇鍦∕ax錛孧aya閮芥彁渚涗簡(jiǎn)鑷繁鐨勬柟娉曞湪Shader涓粦瀹氫笘鐣屽彉鎹㈢煩闃碉紝浣嗛棶棰樻槸姣忕宸ュ叿鎻愪緵鐨勬柟娉曢兘涓嶄竴鏍鳳紝榪欐牱鍐欏嚭鏉ョ殑Shader鏂囦歡灝遍夯鐑?chǔ)浜?jiǎn)銆傘傘?/font>

 

浜庢槸錛孧S榪欐椂绔欏嚭鏉ワ紝鎻愬嚭浜?jiǎn)涓涓爣鍑嗭細(xì)DXSAS銆傝繖鏄洰鍓嶈繕鑳芥壘鍒扮殑DXSAS鐨勪竴孌墊弿榪幫細(xì)

Standard annotations and semantics (DXSAS) provide a method of using shaders in a standard way that enables shaders to be used with tools, applications, and game engines. DXSAS defines a set of semantics and annotations that are attached to host application values and effect parameters for the purpose of sharing effects.

鍦板潃錛?a target="_blank">http://msdn.microsoft.com/en-us/library/bb173004(VS.85).aspx

 

鏈夋爣鍑嗘槸濂戒簨錛岃屼笖鎴戜滑涔熻兘鐪嬪埌錛屽ぇ閲忕殑Shader宸ュ叿鍙?qiáng)娓告垙寮曟搸涔熶娇鐢ㄥ堫C簡(jiǎn)SAS錛屾瘮濡侳XComposer錛屾瘮濡俁enderMonkey錛屾瘮濡侰ryEngine銆傘傘傚綋鐒?dòng)灱屽悇宸ュ叿鍙兘瀵筍AS閮戒細(xì)鏈夎嚜宸辯殑鎵╁睍錛屼絾澶ч儴鍒嗚繕閮芥槸鎸夌収鏍囧噯鏉ョ殑銆?/font>

 

鍙槸錛屼負(fù)浠涔圡S紿佺劧灝卞皢榪欐爣鍑嗙Щ闄や簡(jiǎn)銆傘傘傝屼笖錛屾病鏈変換浣曠悊鐢辯殑銆傘傘備互鑷充簬FXComposer1.8鐗堟湰浠ュ墠鐨勬枃妗d腑闄勫甫鐨凷AS鎻忚堪绔犺妭涔熻窡鐫涓騫跺垹闄わ紝鎴戝湪FXComposer2.5涓婃壘閬嶄簡(jiǎn)鏁翠釜鎵嬪唽涔熸病鎵懼埌榪欎釜 WorldViewProjection 浠庡摢閲屾潵錛岀炕閬嶄簡(jiǎn)MSDN涓奌LSL鏈夊叧鐨勫唴瀹逛篃娌℃湁鐪嬪埌榪欏嚑涓叧閿瓧銆傛棤濂圙oogle涔嬶紝鍘熸潵鍙楁鍥版儜鐨勪漢榪樼湡涓嶅皯銆?/font>

 

濂藉湪錛孨vidia鎺ㄥ嚭浜?jiǎn)涓浠芥柊鐨勬枃妗o紝鎻忚堪SAS鐨勪嬌鐢ㄦ柟娉曪紝鎴栬Nvidia涔熷緢鍥版儜錛?#8220;which came from DirectX 9, and are sometimes hard to find”銆傘傘備絾鏄柊鐨凢XComposer鎵嬪唽涓榪欎簺鍙瓧鏈彁鍗存槸鎴戜粛鐒跺緢鍥版儜鐨勶紝瀵逛簬鍍忔垜榪欐牱鐨勪竴涓柊鎵嬫潵璇達(dá)紝瀹屽叏涓嶅彲鑳界煡閬撹繖浜涗笢瑗挎槸濡備綍鏉ョ殑錛屽浣曞幓鎵捐繖浜汼emantics鐨勫畾涔夈?/font>

 

Nvidia緗戠珯涓婄殑SAS璇存槑鏂囨。錛?a target="_blank">http://developer.nvidia.com/object/using_sas.html

 

浠ュ強(qiáng)FXComposor瀹樻柟璁哄潧涓婄疆欏剁殑鍏充簬SAS鏂囨。鐨勮鏄庤創(chuàng)錛屽綋鏃舵垜绔熺劧娌$湅鍒拌繖涓疆欏惰創(chuàng) :(  http://developer.nvidia.com/forums/index.php?showtopic=1358

 

鍏朵粬浜烘彁鍑虹殑涓浜涚浉鍏崇枒闂細(xì)

http://developer.nvidia.com/forums/index.php?showtopic=750

http://developer.nvidia.com/forums/index.php?showtopic=31

http://developer.nvidia.com/forums/index.php?showtopic=1061

http://developer.nvidia.com/forums/index.php?showtopic=1347

http://developer.nvidia.com/forums/index.php?showtopic=1394

 

鐣欎笅榪欎簺璁板綍錛屼篃璁告湁璺熸垜涓鏍風(fēng)殑鍒濆摜浠紝灝戠偣鍥版儜 :)



]]>
Structuring the Main Loophttp://www.shnenglu.com/helloqinglan/archive/2009/09/14/Structuring_the_Main_Loop.html鐧戒簯鍝?/dc:creator>鐧戒簯鍝?/author>Mon, 14 Sep 2009 12:29:00 GMThttp://www.shnenglu.com/helloqinglan/archive/2009/09/14/Structuring_the_Main_Loop.htmlhttp://www.shnenglu.com/helloqinglan/comments/96154.htmlhttp://www.shnenglu.com/helloqinglan/archive/2009/09/14/Structuring_the_Main_Loop.html#Feedback2http://www.shnenglu.com/helloqinglan/comments/commentRss/96154.htmlhttp://www.shnenglu.com/helloqinglan/services/trackbacks/96154.html    鐪嬪埌CppBlog涓婄炕璇戠殑涓綃?a href="http://www.shnenglu.com/Charlib/services/trackbacks/94403.aspx" target="_blank">娓告垙涓誨驚鐜?/a>錛屾兂璧蜂箣鍓嶄篃鐪嬪埌榪囦竴綃囩被浼肩殑鏂囩珷錛屽洜涓虹瑪璁版湰涓婄涓綃囪褰曞氨鏄繖涓富寰幆鐨勭畝鐭炕璇戯紝瀵規(guī)瘮浜?jiǎn)涓涓嬶紝鍙戠幇榪欑瘒鏂囩珷瀵瑰疄鐜扮粏鑺傜殑鎻忚堪鏇村涓浜涳紝涔熷彂涓婃潵涓庡ぇ瀹跺叡浜?/font>

    榪欑瘒鏂囩珷鏈鏃╂槸鍑虹幇鍦╢lipcode鐨勮鍧涗笂錛?a target="_blank">鍦板潃鍦ㄨ繖閲?/a>錛屽悗鏉ユ湁浜烘暣鐞嗕簡(jiǎn)涓涓嬶紝騫舵坊鍔犱簡(jiǎn)鏇村鐨勬弿榪幫紝涔熷氨鏄笅闈㈢殑鍐呭銆?a target="_blank">鍘熻創(chuàng)鍦板潃鍦ㄨ繖閲?/a>銆?/font>

    鏂囩珷涓叧浜庣綉緇滅殑鎻忚堪鏄寚灞鍩熺綉鐜涓嬬殑鎯呭喌錛屽彟澶栬繖涓富寰幆涔熸病鏈夎冭檻鍒皐indows鐜涓嬩笌Windows Message Loop鐨勭粨鍚堬紝濡傛灉鏄簲鐢ㄥ湪windows鐜涓嬶紝鍙互鍐?a target="_blank">鍙傝冧笅榪欓噷錛屾妸涓よ呯粨鍚堝熀鏈笂灝卞樊涓嶅浜?jiǎn)銆?/font>

    緲昏瘧騫舵湭涓ユ牸閬電収鍘熸枃錛屼負(fù)浜?jiǎn)璇昏典h潵嫻佺晠錛屽緢澶氬彞瀛愰兘鏄寜鐓ф垜涓漢鐨勭悊瑙f潵鎻忚堪銆?/font>

 

This article is about a way of structuring a game's main loop. It includes techniques for handling view drawing with interpolation for smooth animation matched to the frame-rate with fixed-step game logic updating for deterministic game logic. A lot of this is still pretty much a work-in-progress as I muddle my way through, learning better ways of doing things or new tricks to add to my bag, so please bear with me.

榪欑瘒鏂囩珷鎻忚堪鐨勬槸濡備綍緇勭粐娓告垙涓誨驚鐜殑涓縐嶆柟娉曘傚唴瀹瑰寘鎷簡(jiǎn)濡備綍澶勭悊騫蟲粦鐨勫姩鐢葷粯鍒訛紝騫朵笖鑳藉鏍規(guī)嵁褰撳墠甯х巼鍋氭紜殑鍔ㄧ敾鎻掑鹼紝鍙﹀榪樿淇濊瘉鍥哄畾鐨勬父鎴忛昏緫鏇存柊甯х巼錛屼互紜繚娓告垙閫昏緫鐨勮綆楃粨鏋滄槸紜畾鐨勩?/font>

榪欎簺鍐呭鐨勫疄鐜版湁寰堝閮借繕鍦ㄨ繘琛屼腑錛屾垜涔熷湪涓嶆柇鍦板涔?fàn)鏇村ソ鐨勬栆?guī)硶錛屼互鍙?qiáng)灏嗕竴浜涙柊鐨勬妧宸ф坊鍔犺繘鏉ワ紝鎵浠ワ紝甯屾湜鑳藉緇欐垜涓浜涜愬績(jī)涓庡瀹廣?/font>

The heart of a game, any game, is the game loop. This is where the action takes place, where the guns fire and the fireball spells fly. In some games, the concept of the game loop may be diffused among different components or game states, which implement their own version of the game loop to be exectued at the proper time, but the idea is still there.

浠諱綍娓告垙鐨勬牳蹇?jī)閮芥槸娓告垙涓诲惊鐜傛父鎴忕殑鍔ㄤ綔鎵ц銆佸瓙寮圭殑灝勫嚮浠ュ強(qiáng)鐏悆欖旀硶鐨勯琛岀瓑絳夐兘鏄湪榪欓噷瀹炵幇銆?/font>

鍦ㄤ竴浜涙父鎴忎腑錛屼綘鍙兘浼?xì)鎵句笉鍒颁竴涓敮涓鐨勬父鎴忎富寰幆錛屽彇鑰屼唬涔嬬殑鏄紝浣犱細(xì)鍦ㄤ竴浜涚粍浠跺強(qiáng)鐘舵佹満涓壘鍒板悇涓笉鍚岀増鏈殑涓誨驚鐜?/font>

鍏跺疄榪欎釜鍘熺悊涔熸槸涓鏍風(fēng)殑錛屽彧涓嶈繃鏄妸鍘熸潵鐨勪竴涓富寰幆鎷嗗垎鎴愪簡(jiǎn)澶氫釜錛岃繖鏍峰彲浠ユ帶鍒舵父鎴忓湪涓嶅悓鐨勬椂闂村強(qiáng)鐘舵佷笅鎵ц涓嶅悓鐨勫驚鐜繃紼嬨?/font>

 

The game loop is just that: a loop. It is a repeating sequence of steps or actions which are executed in a timely and (hopefully) efficient manner, parceling out CPU time to all of the myriad tasks the game engine is required to perform: logic, physics, animation, rendering, handling of input. It must be constructed in a deterministic, predictable fashion so as to give expected behavior on a wide array of hardware configurations. Classic failures in this regard include old pre-Pentium DOS-based games that were synchronized to run well on old hardware, but which did not have the controls in place to control the speed on newer hardware, and consequently ran so rapidly that they became unplayable on new hardware. With such a broad diversity of hardware as now exists, there must be tighter controls on the game loop to keep it running at a consistent speed, while still taking advantage of more powerful hardware to render smoother animation at higher framerates.

綆鍗曟潵璇達(dá)紝娓告垙涓誨驚鐜氨鏄竴涓驚鐜繃紼嬨?/font>

鍦ㄨ繖涓笉鏂噸澶嶆墽琛岀殑榪囩▼涓紝鎴戜滑闇瑕佹妸CPU鏃墮棿鎸夌収涓瀹氱殑瑙勫垯鍒嗛厤鍒頒笉鍚岀殑浠誨姟涓婏紝榪欎簺浠誨姟鍖呮嫭錛氶昏緫銆佺墿鐞嗐佸姩鐢匯佹覆鏌撱佽緭鍏ュ鐞嗙瓑絳夈?/font>

娓告垙鐨勪富寰幆蹇呴』淇濊瘉鏄互涓縐嶇‘瀹氱殑銆佸彲棰勬祴鐨勬柟寮忔潵鎵ц錛岃繖鏍鋒墠鑳藉湪澶ч噺鐨勪笉鍚岀‖浠墮厤緗幆澧冧笅閮藉緱鍒版垜浠墍鏈熸湜鐨勭浉鍚岃涓恒?/font>

浠ュ墠鐨凞OS娓告垙鏇劇粡鍑虹幇榪囪繖鏍風(fēng)殑闂錛屽畠浠湪鏃х殑紜歡涓婅繍琛岀殑寰堝ソ錛屼絾鏄斁鍒版柊鐨勭‖浠朵笂浠ュ悗灝卞け鍘繪帶鍒朵簡(jiǎn)錛屾父鎴忕殑榪愯閫熷害鍙樼殑濡傛涔嬪揩錛屼互鑷充簬鏍規(guī)湰鏃犳硶鍘葷帺瀹冦?/font>

鐜板湪甯?jìng)鍦轰笂瀛樺湪杩欎箞澶氱殑纭欢绉嵕c伙紝鎵浠ュ氨蹇呴』瑕佺揣绱у湴鎺у埗浣忔父鎴忕殑涓誨驚鐜紝淇濊瘉浠栦滑浠ヤ竴涓浐瀹氱殑閫熷害榪愯錛屼絾鍚屾椂鍙堣兘鑾峰緱榪欎簺寮哄ぇ鐨勭‖浠舵墍甯︽潵鐨勫ソ澶勶細(xì)浠ュ敖鍙兘楂樼殑甯х巼鏉ユ覆鏌撳嚭鏇村鉤婊戠殑鍔ㄧ敾銆?/font>

 

Older games frequently tied the rendering of the view very closely to the game loop, drawing the view exactly once per logic update and waiting for a signal from the display system indicating a vertical retrace period, when the electron gun in the CRT monitor was resetting after drawing the screen. This synchronized loops to a predictable rate based on the refresh rate of the monitor, but with the advent of customizable refresh settings this leads again to unpredictable loop behavior. Retrace synchronization is still useful, especially to avoid visual artifacts when rendering the view, but is less useful as a means for synchronizing the game logic updating, which may require finer control.

浠ュ墠鐨勬父鎴忕粡甯稿皢娓叉煋榪囩▼涓庢父鎴忓驚鐜揣瀵嗗湴緇戝湪涓璧鳳紝棣栧厛鎵ц涓嬈¢昏緫鏇存柊錛岀劧鍚庣粯鍒剁敾闈紝鎺ョ潃絳夊緟鏄劇ず緋葷粺瑙﹀彂涓涓瀭鐩村悓姝ヤ俊鍙鳳紝涔嬪悗灝辨槸涓嬩竴杞驚鐜懆鏈燂細(xì)閫昏緫鏇存柊銆佹覆鏌撱佺瓑寰?#8230;…鍛ㄨ屽濮嬨?/font>

榪欑鍚屾鐨勫驚鐜柟娉曞湪鏄劇ず鍣ㄧ殑鍒鋒柊鐜囧彲棰勬祴鐨勬儏鍐典笅鏄湁鏁堢殑錛屼絾鏄綋鍙互鑷畾涔夊埛鏂扮巼浠ュ悗錛岃繖縐嶈涓哄張鍙樺緱涓嶅彲棰勬祴浜?jiǎn)銆?/font>

鍨傜洿鍚屾浠嶇劧鏄湁鐢ㄧ殑錛屽挨鍏舵槸鍦ㄩ伩鍏嶇敾闈㈢殑娓叉煋鍑虹幇鎾曡鐨勬儏鍐典笅錛屼絾鏄敤鏉ュ悓姝ユ父鎴忕殑閫昏緫鏇存柊灝辨病澶氬ぇ鐢ㄤ簡(jiǎn)錛岃繖鏃跺彲鑳介渶瑕佹洿濂界殑鎺у埗鏂規(guī)硶銆?/font>

 

The trick, then, is to separate game logic from rendering, and perform them in two separate sub-systems only marginally tied to each other. The game logic updates at it's own pace, and the rendering code draws the screen as fast as it possibly with the most accurate, up-to-date data the logic component can provide.

榪欑鏂規(guī)硶灝辨槸灝嗘父鎴忛昏緫鏇存柊涓庡睆騫曟覆鏌撹繃紼嬪垎紱誨紑錛屽皢浠栦滑鏀懼埌涓や釜鍒嗙鐨勫瓙緋葷粺涓幓澶勭悊錛屽彧鏄湪闇瑕佺殑鏃跺欐墠涓庡彟涓涓墦浜ら亾銆?/font>

娓告垙鐨勯昏緫鏇存柊涓ユ牸鎸夌収璁″垝鏉ユ墽琛岋紝浣嗘槸灞忓箷娓叉煋鍒欎互瀹冩墍鑳借揪鍒扮殑鏈澶ч熺巼鏉ヨ繘琛屻?/font>

 

The system I am accustomed to using is based on a Tip of the Day ( http://www.flipcode.com/cgi-bin/msg.cgi?showThread=Tip-MainLoopTimeSteps&forum=totd&id=-1 ) posted to http://www.flipcode.com by Javier Arevalo. It implements a loop wherein the game logic is set to update a fixed number of times per second, while the rendering code is allowed to draw as rapidly as possible, using interpolation to smooth the transition from one visual frame to the next.

榪欓噷鎻忚堪鐨勬柟娉曞熀浜嶫avier Arevalo鍙戣〃鍦?/font>flipcode Tip of the Day 涓婄殑浠g爜鏉ュ疄鐜般?/font>

鍦ㄨ繖涓父鎴忎富寰幆閲岋紝娓告垙閫昏緫鏇存柊琚緗負(fù)姣忕鎵ц鍥哄畾嬈℃暟錛屼絾鍚屾椂娓叉煋浠g爜琚厑璁告墽琛屽敖鍙兘澶氭錛屽茍涓旇繕浣跨敤浜?jiǎn)鎻掑兼潵浣垮緱涓や釜娓叉煋甯т箣闂寸殑鍔ㄧ敾鍙樺寲灝藉彲鑳界殑騫蟲粦銆?/font>

 

Briefly, here is the code. I will then attempt in my own crude fashion to explain the workings, though I suggest you check out the original tip at the above link to read Javier's explanation, as well as the forum posts accompanying it which offer up insights and suggestions on how the performance of the loop may be improved.

闂茶瘽灝戣錛屼笅闈㈤鍏堟槸浠g爜錛岀劧鍚庢垜浼?xì)绠鍗曠殑鎸夋垜鐨勬柟寮忔弿榪頒竴涓嬩唬鐮佺殑宸ヤ綔鍘熺悊錛屽悓鏃舵垜寤鴻浣犻槄璇諱竴涓嬩笂闈㈤摼鎺ュ湴鍧鎵緇欏嚭鐨勫唴瀹癸紝鍏朵腑鏈塉avier鐨勮В閲婏紝騫朵笖璁哄潧涓婄殑鍥炶創(chuàng)涔熸湁涓浜涗笉閿欑殑鍐呭錛屽寘鎷埆浜虹殑璇勮鍜屼竴浜涘叧浜庡浣曟彁楂樻晥鐜囩殑寤鴻銆?/font>

(娉細(xì)flipcode璁哄潧鏃╁氨宸茬粡鍏抽棴錛屼笂闈㈢殑閾炬帴鍦板潃宸茬粡澶辨晥錛宖lipcode涓婂彧淇濈暀鏈変竴浜涗紭縐鍐呭鐨?a >archives錛?a target="_blank">鍦ㄨ繖閲岃兘鎵懼埌榪欑瘒鍘熸枃錛屽叾涓寘鎷琂avier鐨勮В閲?

 

time0 = getTickCount();
do
{
  time1 = getTickCount();
  frameTime = 0;
  int numLoops = 0;

  while ((time1 - time0) > TICK_TIME && numLoops < MAX_LOOPS)
  {
    GameTickRun();
    time0 += TICK_TIME;
    frameTime += TICK_TIME;
    numLoops++;
  }
  IndependentTickRun(frameTime);

  // If playing solo and game logic takes way too long, discard pending time.
  if (!bNetworkGame && (time1 - time0) > TICK_TIME)
    time0 = time1 - TICK_TIME;

  if (canRender)
  {
    // Account for numLoops overflow causing percent > 1.
    float percentWithinTick = Min(1.f, float(time1 - time0)/TICK_TIME);
    GameDrawWithInterpolation(percentWithinTick);
  }
}
while (!bGameDone);
 

Structurally, the loop is very simple. The above snippet of code can encapsulate the entire workings of your game.

浠庣粨鏋勪笂鏉ヨ錛岃繖涓富寰幆闈炲父綆鍗曘備笂闈㈢殑浠g爜鐗囨鍩烘湰涓婅兘澶熷泭鎷綘鐨勬父鎴忕殑鏁翠釜宸ヤ綔榪囩▼銆?/font>

 

First of all, the main loop portion is embodied as the do{} while(!bGameDone); block. This causes the loop to run endlessly, until some game condition indicates that it is finished and it is time to exit the program, at which point the loop ends and the game can be properly shut down. Each time through the loop, we perform game logic updates, input updating and handling, and rendering. Now, for a breakdown of the sections of the loop.

棣栧厛錛屼富寰幆鐨勬墽琛岃繃紼嬭鍖呭湪do…while寰幆鍧椾腑錛岃繖浣垮緱娓告垙涓誨驚鐜皢姘鎬笉緇撴潫鍦拌繍琛岋紝鐩村埌娓告垙鏄庣‘鍦拌鍛婄煡闇瑕佺粨鏉熷茍涓旈鍑虹▼搴忔椂涓烘銆?/font>

鍦ㄦ瘡嬈¤繘鍏ュ驚鐜殑鏃跺欙紝鎴戜滑浼?xì)鎵ц娓告垙閫昏緫鐨勬洿鏂幫紝杈撳叆鏇存柊涓庡鐞嗭紝榪樻湁娓叉煋銆傛帴涓嬫潵錛屾妸寰幆鍒嗕負(fù)鍑犱釜鐗囨鏉ユ弿榪般?/font>

 

time1 = getTickCount();
frameTime = 0;
int numLoops = 0;

while ((time1 - time0) > TICK_TIME && numLoops < MAX_LOOPS)
{
    GameTickRun();
    time0 += TICK_TIME;
    frameTime += TICK_TIME;
    numLoops++;
}
 

This portion is the game logic update sequence that forces the game logic (physics updates, object motion, animation cycling, etc...) to update a set number of times per second. This rate is controlled by the TICK_TIME constant, which specifies the number of milliseconds the logic update is supposed to represent in real time. It probably won't take that long to perform, in which case the update won't be performed again until enough time has passed. For example, with TICK_TIME=40, each logic represents 40 milliseconds, thus forcing the code to update game objects at a rate of 25 times per second.

榪欓儴鍒嗕唬鐮佸鐞嗘父鎴忛昏緫鐨勬洿鏂幫紝騫朵笖寮哄埗瑕佹眰娓告垙閫昏緫姣忕鎵ц鍥哄畾嬈℃暟銆?/font>

娓告垙鐨勯昏緫澶勭悊鍖呮嫭鐗╃悊鏇存柊銆佸璞¤涓恒佸姩鐢誨驚鐜瓑絳夈傛洿鏂伴熺巼閫氳繃TICK_TIME甯擱噺鎸囧畾錛屽叾鍚箟涓轟袱嬈¢昏緫鏇存柊鐨勬椂闂撮棿闅旓紝鍗崇粡榪嘥ICK_TIME鍚庡簲璇ュ啀嬈¤繘琛屾洿鏂幫紝鑰屼笉鏄涓嬈¢昏緫鏇存柊瑕佹寔緇繖涔堥暱鏃墮棿銆?/font>

渚嬪錛孴ICK_TIME = 40錛屽叾鍚箟涓烘瘡嬈℃父鎴忛昏緫鏇存柊鍚庤〃鐜?0姣錛岃繖灝嗕嬌寰楁瘡縐掓父鎴忓璞′細(xì)琚洿鏂?5嬈°?/font>

 

The logic is encapsulated in it's own while loop. It is possible during a given frame that game logic will take too long. If a logic update cycle goes overtime, we can delay rendering for a bit to give ourselves a little extra time to catch up. The while loop will continue to process game logic updates until we are no longer overtime, at which point we can go ahead and continue on with drawing the view. This is good for handling the occasional burp in logic updating, smoothing out the updates and keeping them consistent and deterministic; but in the case that the logic repeatedly goes overtime, it is possible to accumulate more time-debt than the loop can handle. Thus, the MAX_LOOPS constant is in place to dictate a maximum number of times the loop can repeat to try to catch up. It will force the loop to dump out periodically to handle other tasks such as input handling and rendering. A loop that is constantly running at the MAX_LOOPS limit runs like hell and is about as responsive as a tractor with four flat tires, but at least it keeps the loop operating, allowing the user to pass input to terminate the program. Without the MAX_LOOPS failsafe, it would be entirely possible for a slow computer to lock up with no way to exit as it chokes on the loop, trying to catch up but getting further and further behind.

閫昏緫鏇存柊鐨勪唬鐮佽鍖呭湪浠栬嚜宸辯殑while寰幆涓?/font>

鍙兘鍦ㄦ煇涓甯ч噷娓告垙閫昏緫鐨勫鐞嗘椂闂翠細(xì)闈炲父闀匡紝鐢氳嚦浼?xì)瓒呮椨灱寴q欐椂鎴戜滑鍙互紼嶇◢鏆傚仠涓涓嬪睆騫曠殑娓叉煋錛屼嬌寰楁父鎴忛昏緫鏇存柊鑳藉鍦ㄨ繖孌墊椂闂撮噷璧朵笂鏉ャ?/font>

榪欎釜while寰幆灝辨槸鐢ㄦ潵璁╂父鎴忛昏緫緇х畫鏇存柊錛岀洿鍒版垜浠笉鍐嶈秴鏃訛紝涔嬪悗鎴戜滑緇х畫娓告垙鐨勪富寰幆騫朵笖榪涜灞忓箷娓叉煋銆?/font>榪欏彲浠ュ緢濂藉湴澶勭悊紿佸彂鐨勯昏緫鏇存柊瓚呮椂錛屼嬌寰楁垜浠殑鏇存柊鏇村姞騫蟲粦錛屽茍淇濊瘉閫昏緫鐨勪竴鑷存у拰鍙嫻嬫с?/font>

浣嗘槸濡傛灉娓告垙閫昏緫澶勭悊鎸佺畫鍦拌秴鏃訛紝鐢氳嚦浣垮緱鎴戜滑鐨勪富寰幆鏃犳硶澶勭悊榪囨潵錛岃繖鏃禡AX_LOOPS灝嗕細(xì)璧峰埌浣滅敤錛屼粬灝嗕嬌娓告垙鎺у埗鏉冧粠閫昏緫鏇存柊涓煩鍑烘潵錛屽幓鎵ц濡傝緭鍏ュ鐞嗗拰灞忓箷娓叉煋絳夊叾浠栦換鍔°?/font>

MAX_LOOP甯擱噺闄愬埗浜?jiǎn)杩欓噷鐨剋hile寰幆鐢ㄦ潵榪借刀閫昏緫澶勭悊鏃墮棿鏃舵渶澶氳兘閲嶅鐨勬鏁般?/font>榪欐牱褰撴父鎴忕湡鐨勫嚭鐜板畬鍏ㄦ棤娉曞鐞嗗畬閫昏緫鏇存柊鐨勬椂鍊欙紝鐢ㄦ埛涔熸湁鏈轟細(xì)緇撴潫紼嬪簭銆?/font>

濡傛灉娌℃湁MAX_LOOP鐨勬嫻嬶紝寰堟湁鍙兘浼?xì)鍑虹庮C竴鍙板緢鎱㈢殑鐢?shù)鑴戣瘯鍥緲q戒笂閫昏緫澶勭悊鏃墮棿錛屼絾鏄嵈瓚婅拷瓚婅繙錛岃屽張娌℃湁鏈轟細(xì)閫鍑?guó)櫩欎釜杩嚱E嬶紝鏈鍚庨櫡鍦ㄤ簡(jiǎn)榪欎釜姝誨驚鐜腑……

 

IndependentTickRun(frameTime);
 

This section is where input is gathered, events are pumped from the event queue, interface elements such as life bars are updated, and so forth. Javier allows for passing how much time the logic updates took, which can be used for updating on-screen clock or timer displays and the like if necessary. I've never found occasion to use it, but I regularly pass it anyway on the off-chance I'll need it someday. frameTime basically gives the amount of time that was spent in the logic loop performing updates.

榪欓儴鍒嗕唬鐮佺敤鏉ュ鐞嗙敤鎴瘋緭鍏ョ殑鎹曡幏錛屼簨浠朵細(xì)浠庝簨浠墮槦鍒椾腑琚彇鍑烘潵澶勭悊錛岀晫闈㈠厓绱狅紝濡傝鏉$瓑錛屼細(xì)鍦ㄨ繖閲岃鏇存柊錛岃繕鏈夊叾浠栫被浼肩殑澶勭悊銆?/font>

Javier鍦ㄨ繖閲岀暀浜?jiǎn)涓涓猣rameTime鍙傛暟錛岀敤鏉ユ寚鏄庨昏緫鏇存柊鎵鑺辯殑鏃墮棿銆傚彲浠ョ敤榪欎釜鍊兼潵鏇存柊娓告垙灞忓箷涓婄殑鏃墮挓鎴栧畾鏃跺櫒絳夌被浼間俊鎭?/font>

铏界劧鎴戠洰鍓嶈繕娌℃湁鎵懼埌鏈轟細(xì)鐢ㄥ畠錛屼絾鎴戣繕鏄範(fàn)鎯у湴鎶婂畠甯︿笂浜?jiǎn)锛屼篃璁告煇澶╂垜浼?xì)闇瑕併?/font>

 

In order for the game loop to run predictably, you should not modify anything in this step that will affect the game logic. This portion of the loop does not run at a predictable rate, so changes made here can throw off the timing. Only things that are not time-critical should be updated here.

涓轟簡(jiǎn)浣挎父鎴忓驚鐜殑榪愯鏄彲棰勬祴鐨勶紝浣犱笉搴旇鍦ㄨ繖閲屼慨鏀逛換浣曞彲鑳藉獎(jiǎng)鍝嶆父鎴忛昏緫鐨勪笢瑗匡紝鍥犱負(fù)姝ら儴鍒嗗湪娓告垙涓誨驚鐜腑鐨勬墽琛屾鏁版槸涓嶅彲棰勬祴鐨勶紝鎵浠ュ湪榪欓噷鍙兘鍋氫竴浜涙椂闂存棤鍏崇殑鏇存柊銆?/font>

 

// If playing solo and game logic takes way too long, discard pending time.
if (!bNetworkGame && (time1 - time0) > TICK_TIME) time0 = time1 - TICK_TIME;
 

This is where we can shave off our time debt if MAX_LOOPS causes us to dump out of the logic loop, and get things square again--as long as we are not running in a network game. If it is a single-player game, the occasional error in the timing of the game is not that big of a deal, so sometimes it might be simpler when the game logic overruns it's alloted time to just discard the extra time debt and start fresh. Technically, this makes the game "fall behind" where it should be in real time, but in a single player game this has no real effect. In a network game, however, all computers must be kept in synchronization, so we can't just cavalierly discard the pending time. Instead, it sticks around until the next time we enter the logic update loop, where the loop has to repeat itself that many more times to try to catch up. If the time burp is an isolated instance, this is no big deal, as with one or two cycle overruns the loop can catch up. But, again, if the logic is consistently running overtime, the performance of the game will be poor and will lag farther and farther behind. In a networked game, you might want to check for repeated bad performance and logic loop overruns here, to pinpoint slow computers that may be bogging the game down and possibly kick them from the game.

褰撶敱浜庢弧瓚充簡(jiǎn)MAX_LOOP鏉′歡鑰岃煩鍑洪昏緫寰幆鏃訛紝鍙互鍦ㄨ繖閲屽噺鎺夊鍔犵殑涓奣ICK_TIME鏃墮棿錛屽茍涓斿彧鍦ㄥ崟鏈烘父鎴忔椂鎵嶈繖鏍峰仛銆?/font>

濡傛灉鏄湪鍗曟満娓告垙涓紝鍋跺皵鍑虹幇鏃墮棿涓婄殑閿欒鏄笉浼?xì)鏈変粈涔堝ぇ闂鐨勶紝鎵浠ュ綋娓告垙閫昏緫鎵ц瓚呮椂鍚庝篃娌℃湁澶氬ぇ鍏崇郴錛屾垜浠畝鍗曠殑鎶婂鑺辯殑鏃墮棿鍑忔帀錛岀劧鍚庨噸鏂板紑濮嬨備粠鎶鏈笂鏉ヨ錛岃繖浼?xì)鋴慑緱娓告垙鏈変竴鐐圭偣鏃墮棿涓婄殑钀藉悗錛屼絾鍦ㄥ崟鏈烘父鎴忛噷榪欎笉浼?xì)鏈変粈涔堝疄闄呯殑褰卞搷銆?/font>

浣嗘槸鍦ㄧ綉緇滄父鎴忎腑榪欐牱鍋氬嵈涓嶈錛屾墍鏈夎繛緗戠殑鐢?shù)鑴戦兘蹇厵寤瑕佷繚鎸佹棄櫁翠笂鐨勫悓姝ャ?/font>

鍦ㄧ綉緇滄父鎴忎腑錛屽鏋滄煇鍙扮數(shù)鑴戣惤鍚庝簡(jiǎn)錛屼粬搴旇淇濇寔鍏惰惤鍚庣殑鐘舵侊紝鐒跺悗鍦ㄤ笅涓嬈¤繘鍏ラ昏緫鏇存柊寰幆鏃訛紝鑷繁璁╄嚜宸卞閲嶅鍑犳錛屼互渚胯拷璧朵笂鏉ャ?/font>

濡傛灉鏃墮棿寤惰繜鍙槸涓绔嬩簨浠訛紝榪欏皢涓嶄細(xì)鏈夊澶ч棶棰橈紝緇忚繃涓涓ゆ瓚呴熷氨浼?xì)杩借刀涓婃潵锛屼絾鏄鏋滄父鎴忛昏緫鏇存柊鎬繪槸瓚呮椂錛屾父鎴忕殑琛ㄧ幇灝嗕細(xì)闈炲父緋熺硶錛屽茍涓旀渶緇堝皢浼?xì)瓒婃潵瓒婃粸鍚庛?/font>

鍦ㄧ綉緇滄父鎴忎腑錛屼綘鍙兘闇瑕佹鏌ュ嚭榪欎簺鎸佺畫瓚呮椂錛岃〃鐜版繪槸寰堝樊鐨勭數(shù)鑴戯紝騫跺皢榪欎簺鍙兘鎷栨參鏁翠釜娓告垙鐜鐨勭數(shù)鑴戣涪鍑哄幓銆?/font>

 

// Account for numLoops overflow causing percent > 1.
float percentWithinTick = Min(1.f, float(time1 - time0)/TICK_TIME);
GameDrawWithInterpolation(percentWithinTick);
 

This is where the real magic happens, in my opinion. This section performs the rendering of the view. In the case of a loop where TICK_TIME=40, the logic is updating at 25 FPS. However, most video cards today are capable of far greater framerates, so it makes no sense to cripple the visual framerate by locking it to 25 FPS. Instead, we can structure our code so that we can smoothly interpolate from one logic state to the next. percentWithinTick is calculated as a floating point value in the range of [0,1], representing how far conceptually we are into the next game logic tick.

鍦ㄨ繖閲屾垜浠皢榪涜灞忓箷緇樺埗銆?/font>

褰揟ICK_TIME = 40鏃訛紝閫昏緫鏇存柊甯х巼涓?5FPS錛屼絾鏄幇鍦ㄥぇ澶氭暟鏄懼崱閮借兘鏀寔鏇撮珮鐨勬覆鏌撳撫鐜囷紝鎵浠ユ垜浠病蹇呰鍙嶈岄攣瀹氭覆鏌撳撫鐜囦負(fù)25FPS銆?/font>

鎴戜滑鍙互緇勭粐鎴戜滑鐨勪唬鐮侊紝璁╂垜浠兘澶熷鉤婊戠殑浠庝竴涓昏緫鐘舵佸埌涓嬩竴涓姸鎬佸仛鎻掑箋?/font>percentWithinTick涓轟竴涓?鍒?涔嬮棿鐨勬誕鐐規(guī)暟錛岃〃紺烘垜浠簲璇ュ悜涓嬩竴涓昏緫甯ц蛋澶氳繙銆?/font>

 

Every object in the game has certain state regarding LastTick and NextTick. Each object that can move will have a LastPosition and a NextPosition. When the logic section updates the object, then the objects LastPosition is set to it's currentNextPostion and a new NextPosition is calculated based on how far it can move in one logic frame. Then, when the rendering portion executes, percentWithinTick is used to interpolate between these Last and Next positions:

姣忎釜鍙Щ鍔ㄧ殑瀵硅薄閮芥湁LastPosition鍜孨extPosition銆傞昏緫鏇存柊閮ㄥ垎鐨勪唬鐮佸湪鎵ц鏃朵細(xì)灝嗗璞$殑LastPosition璁劇疆涓哄綋鍓嶇殑NextPosition錛屽啀鏍規(guī)嵁瀹冩瘡涓甯ф墍鑳界Щ鍔ㄧ殑璺濈鏉ヨ綆楀嚭NextPosition銆?/font>

鐒跺悗錛屽湪娓叉煋瀵硅薄鐨勬椂鍊欙紝鍙互鍐嶇敤percentWithTick鏉ュ湪Last鍜孨ext浣嶇疆涔嬮棿榪涜鎻掑箋?/font>

璇戞敞錛?/font>

time0涓烘渶鍚庝竴涓昏緫甯ф墍鍦ㄧ殑鏃墮棿鐐癸紝time1涓哄綋鍓嶅疄闄呮椂闂達(dá)紝(time1 – time0) / TICK_TIME琛ㄧず褰撳墠鏃墮棿姣旀渶鍚庝竴涓昏緫甯ф墍鍦ㄦ椂闂磋秴鍑轟簡(jiǎn)澶氬皯鐧懼垎姣旓紝鐢ㄨ繖涓櫨鍒嗘瘮鏉ュ悜涓嬩竴閫昏緫甯у仛鎻掑箋?/font>

濡傛灉鏈哄櫒姣旇緝蹇紝鍦ㄤ袱涓昏緫鏇存柊鏃墮棿鐐逛箣闂存墽琛屼簡(jiǎn)澶氭灞忓箷娓叉煋錛岃繖鏍鋒彃鍊煎氨鏈夋晥浜?jiǎn)銆傛鏃秚ime0涓嶅彉錛宼ime1涓鐩村湪澧為暱錛屽彲浠ユ牴鎹闀跨殑鐧懼垎姣旀潵璁$畻鍔ㄧ敾搴旇浠庢渶鍚庝竴嬈℃墽琛岄昏緫鏇存柊鐨勪綅緗悜涓嬩竴嬈¢昏緫鏇存柊鎵鍦ㄧ殑浣嶇疆璧板榪溿?/font>

涔熷氨鏄笂鏂囨墍璇寸殑錛屽湪Last鍜孨ext浣嶇疆涔嬮棿榪涜鎻掑箋傛彃鍊煎悗鐨勫疄闄呬綅緗紝鍗矰rawPosition鐨勮綆楁柟娉曞涓嬶細(xì)

鍔ㄧ敾鎾斁鐨勬彃鍊間篃鏄被浼箋?/font>

 

DrawPosition = LastPosition + percentWithinTick * (NextPosition - LastPosition);
 

The main loop executes over and over as fast as the computer is able to run it, and for a lot of the time we will not be performing logic updates. During these loop cycles when no logic is performed, we can still draw, and as the loop progresses closer to the time of our next logic update, percentWithinTick will increase toward 1. The closer percentWithinTick gets to 1, the closer the a ctual DrawPosition of the object will get to NextPosition. The effect is that the object smoothly moves from Last to Next on the screen, the animation as smooth as the hardware framerate will allow. Without this smooth interpolation, the object would move in a jerk from LastPosition to NextPosition, each time the logic updates at 25FPS. So a lot of drawing cycles would be wasted repeatedly drawing the same exact image over and over, and the animation would be locked to a 25FPS rate that would look bad.

娓告垙鐨勪富寰幆浠ョ數(shù)鑴戞墍鑳藉杈懼埌鐨勬渶澶ч熷害涓嶅仠鍦拌繍琛岋紝鍦ㄥぇ澶氭暟鏃墮棿閲岋紝鎴戜滑灝嗕笉闇瑕佹墽琛岄昏緫鏇存柊銆?/font>

浣嗘槸鍦ㄨ繖浜涗笉鎵ц閫昏緫鏇存柊鐨勫懆鏈熼噷錛屾垜浠粛鐒跺彲浠ユ墽琛屽睆騫曟覆鏌撱傚綋寰幆鐨勮繘紼嬭秺鎺ヨ繎鎴戜滑鐨勪笅涓嬈¢昏緫鏇存柊鏃墮棿錛宲ercentWithinTick灝辨帴榪?錛沺ercentWithinTick瓚婃帴榪?錛孌rawPosition鐨勪綅緗氨瓚婃帴榪慛extPosition銆?/font>

鏈鍚庣殑鏁堟灉灝辨槸娓告垙瀵硅薄鍦ㄥ睆騫曚笂鎱㈡參鐨勩佸鉤婊戝湴浠嶭ast浣嶇疆縐誨姩鍒癗ext浣嶇疆錛屽姩浣滃皢浠ョ‖浠跺撫鐜囨墍鑳藉厑璁哥殑紼嬪害灝藉彲鑳界殑騫蟲粦銆?/font>

濡傛灉娌℃湁榪欎釜騫蟲粦鎻掑艱繃紼嬶紝瀵硅薄浣嶇疆灝嗕細(xì)浠庝笂涓甯ф墍鍦ㄧ殑LastPosition鐩存帴璺沖埌涓嬩竴甯ф墍鍦ㄧ殑浣嶇疆NextPosition銆傚ぇ閲忕殑娓叉煋鍛ㄦ湡閮借嫻垂鍦ㄦ妸瀵硅薄鍙嶅娓叉煋鍒扮浉鍚岀殑浣嶇疆涓婏紝騫朵笖鍔ㄧ敾涔熷彧鑳借閿佸畾鍦?5FPS錛屼嬌寰楃湅璧鋒潵鏁堟灉闈炲父宸?/font>

 

With this technique, logic and drawing are separated. It is possible to perform updates as infrequently as 14 or 15 times per second, far below the threshold necessary for smooth, decent looking visual framerate, yet still maintain the smooth framerate due to interpolation. Low logic update rates such as this are common in games such as real-time strategy games, where logic can eat up a lot of time in pathfinding and AI calculations that would choke a higher rate. Yet, the game will still animate smoothly from logic state to logic state, without the annoying visual hitches of a 15FPS visual framerate. Pretty danged nifty, I must say.

浣跨敤浜?jiǎn)杩櫃逡?guī)妧鏈箣鍚庯紝閫昏緫鏇存柊涓庡睆騫曟覆鏌撹鍒嗙寮浜?jiǎn)銆?/font>

榪欏皢鍏佽鎴戜滑鎶婇昏緫鏇存柊甯х巼闄嶄綆鍒?4鎴?5FPS錛岃繖榪滆繙浣庝簬騫蟲粦鐨勫姩鐢繪覆鏌撴墍闇瑕佺殑甯х巼錛屼絾鏄湪浣跨敤鍔ㄧ敾鎻掑間箣鍚庡嵈浠嶇劧鑳界淮鎸佸鉤婊戠殑娓叉煋甯х巼銆?/font>

鍦ㄥ疄鏃剁瓥鐣ョ被娓告垙涓彲鑳戒細(xì)浣跨敤榪欐牱浣庣殑閫昏緫鏇存柊甯х巼錛岃繖閲岄昏緫鏇存柊浼?xì)鍥犲璧\鍜孉I璁$畻鑰屽崰鐢ㄥぇ閲忕殑鏃墮棿錛屽湪榪欑鎯呭喌涓嬩嬌鐢ㄩ珮鐨勯昏緫鏇存柊甯х巼鏄劇劧涓嶈銆?/font>

浣嗘槸錛屾父鎴忓嵈浠嶇劧鑳藉鍦ㄤ笉鍚岀殑閫昏緫鐘舵佷箣闂村仛騫蟲粦鐨勫姩鐢昏繃娓★紝涓嶄細(xì)鍥犱負(fù)鍙湁15FPS鐨勬覆鏌撳撫鐜囪屽嚭鐜伴偅浜涗護(hù)浜虹敓鍘岀殑鍔ㄧ敾璺寵穬鐜拌薄銆?/font>

闈炲父鐨勬紓浜紝鎴戜笉寰椾笉璇淬?/font>

 

I've created a simple program in C to demonstrate this loop structure. It requires SDL ( http://www.libsdl.org ) and OpenGL. It's a basic bouncy ball program. The controls are simple: Press q to exit the program or press SPACE to toggle interpolation on and off. With interpolation on, the loop executes exactly as described to smooth out the movement from one logic update to the next. With interpolation off, the interpolation factor percentWithinTick is always set to 1 to simulate drawing without interpolation, in essence locking the visual framerate to the 25FPS of the logic update section. In both cases, the ball moves at exactly the same speed (16 units per update, 25 updates per second), but with interpolation the motion is much smoother and easier on the eyes. Compile and link with SDL and OpenGL to see it in action: http://legion.gibbering.net/golem/files/interp_demo.c



]]>
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
      <noscript id="pjuwb"></noscript>
            <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
              <dd id="pjuwb"></dd>
              <abbr id="pjuwb"></abbr>
              99亚洲一区二区| 亚洲性图久久| 久久手机精品视频| 亚洲欧洲av一区二区| 国产美女精品免费电影| 久久国产毛片| 免费日韩av| 一本色道久久综合亚洲二区三区 | 亚洲与欧洲av电影| 亚洲综合日韩在线| 国产真实乱偷精品视频免| 欧美成人69av| 欧美日韩色综合| 欧美在线一级视频| 免费久久精品视频| 午夜电影亚洲| 另类综合日韩欧美亚洲| 一区二区毛片| 久久精品成人欧美大片古装| 亚洲欧洲日产国产综合网| 99在线精品视频在线观看| 国产专区欧美精品| 亚洲乱码一区二区| 国产一区二区你懂的| 亚洲精品免费一二三区| 国产三级精品三级| 亚洲人成啪啪网站| 激情欧美一区二区| 亚洲视频二区| 99精品视频一区二区三区| 欧美在线不卡| 亚洲在线视频一区| 免费视频一区二区三区在线观看| 欧美一级网站| 欧美日韩一区高清| 亚洲国产精选| 一区二区三区中文在线观看| 亚洲综合精品四区| 亚洲图片激情小说| 欧美黄在线观看| 欧美 日韩 国产在线| 国产伦理一区| 亚洲校园激情| 亚洲天堂av图片| 欧美韩国一区| 亚洲电影av在线| 亚洲第一网站| 久久精品欧美日韩精品| 久久久久.com| 国产视频一区在线观看一区免费| 99国产麻豆精品| 性久久久久久久久久久久| 欧美一区二区啪啪| 性刺激综合网| 国产精品福利av| 亚洲精品国产精品久久清纯直播 | 国产亚洲一区二区在线观看| 国产精品99久久久久久久女警| 夜夜嗨av一区二区三区网页| 欧美黑人在线播放| 亚洲高清在线观看一区| 亚洲国产精品免费| 美女性感视频久久久| 欧美国产日本高清在线| 91久久在线视频| 欧美高清视频一区| 亚洲欧洲视频| 在线视频精品| 国产精品女人网站| 亚洲欧美综合国产精品一区| 欧美专区18| 一区二区在线看| 蜜桃久久av一区| 亚洲精品久久嫩草网站秘色| 亚洲特级毛片| 国产视频亚洲| 久久人人爽人人爽| 91久久精品国产91久久性色tv | 亚洲欧美日韩精品久久| 欧美另类久久久品| 一区二区三区四区五区精品| 午夜老司机精品| 韩日欧美一区| 欧美高清视频一区二区| 日韩亚洲综合在线| 欧美一区影院| 最新亚洲激情| 国产精品久久久久久影院8一贰佰| 亚洲欧美日韩精品久久| 卡一卡二国产精品| 日韩天堂av| 国产精品都在这里| 久久久国产精品一区| 亚洲精品乱码久久久久久黑人| 午夜国产不卡在线观看视频| 在线观看久久av| 99re这里只有精品6| 国产综合视频| 亚洲狠狠婷婷| 亚洲欧美日韩一区在线观看| 美女日韩在线中文字幕| 在线视频你懂得一区| 韩国欧美一区| 欧美日韩亚洲激情| 久久久久国产精品厨房| 一区二区三欧美| 农村妇女精品| 欧美一区二区三区在线观看视频| 91久久国产综合久久| 国产欧美日韩专区发布| 欧美成ee人免费视频| 欧美成人首页| 久久久噜噜噜久久久| 在线欧美日韩| 国产欧美精品一区二区三区介绍| 欧美黄色免费| 久久精品日产第一区二区三区| 91久久精品国产91性色tv| 有码中文亚洲精品| 中文日韩欧美| 亚洲欧美成人一区二区在线电影 | 99精品热视频| 久久视频国产精品免费视频在线| 一本大道久久a久久精二百| 伊人久久av导航| 国产一区二区精品丝袜| 国产精品久久久久一区二区三区| 欧美精品v国产精品v日韩精品| 久久久久久久综合日本| 久久精品国产99精品国产亚洲性色| 中日韩男男gay无套| 亚洲美洲欧洲综合国产一区| 亚洲国产1区| 欧美国产精品| 欧美不卡一卡二卡免费版| 欧美影院在线| 欧美视频中文字幕| 一区二区日韩精品| 亚洲日本在线观看| 亚洲国产欧美不卡在线观看| 狠狠做深爱婷婷久久综合一区| 国产在线视频欧美| 韩国v欧美v日本v亚洲v| 国语自产精品视频在线看一大j8| 国产一区美女| 激情久久久久久久| 在线观看不卡| 亚洲欧洲精品一区| 日韩亚洲综合在线| 亚洲九九精品| 亚洲少妇一区| 久久丁香综合五月国产三级网站| 久久狠狠婷婷| 久久亚洲一区二区| 亚洲国产精品久久精品怡红院| 亚洲国产一区二区三区青草影视 | 欧美一区二区视频免费观看| 欧美在线观看天堂一区二区三区| 久久精品人人做人人爽电影蜜月| 久久激五月天综合精品| 米奇777在线欧美播放| 欧美黄色免费网站| 99国产精品视频免费观看一公开| 亚洲欧美成人| 女人香蕉久久**毛片精品| 欧美激情一区二区在线 | 国产精品素人视频| 黄色成人在线网站| 亚洲另类一区二区| 亚洲午夜高清视频| 久久久久这里只有精品| 欧美国产免费| 亚洲视频在线一区观看| 亚洲视频免费看| 麻豆久久精品| 欧美制服丝袜| 精品动漫一区| 欧美成人一品| 欧美激情1区2区| 国产精品一区二区三区久久| 一区二区三区在线免费播放| 亚洲午夜精品久久| 欧美成人精品| 亚洲一区二区动漫| 蜜桃av一区| 国产亚洲一本大道中文在线| 亚洲美女区一区| 久久先锋影音| 国产精品一区二区你懂的| 亚洲精品综合在线| 久久综合九色| 亚洲一区在线播放| 欧美成人精品在线视频| 国内外成人免费视频| 亚洲一级黄色片| 91久久精品美女| 狂野欧美激情性xxxx欧美| 国产欧美日韩综合一区在线观看| 日韩视频免费观看| 麻豆精品在线视频|