• <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>

            李錦俊(mybios)的blog

            游戲開發(fā) C++ Cocos2d-x OpenGL DirectX 數(shù)學(xué) 計算機(jī)圖形學(xué) SQL Server

              C++博客 :: 首頁 :: 聯(lián)系 :: 聚合  :: 管理
              86 Posts :: 0 Stories :: 370 Comments :: 0 Trackbacks

            公告

            QQ:30743734
            EMain:mybios@qq.com

            常用鏈接

            留言簿(16)

            我參與的團(tuán)隊

            最新隨筆

            搜索

            •  

            積分與排名

            • 積分 - 371365
            • 排名 - 67

            最新評論

            閱讀排行榜

            評論排行榜

            一個快速開方的函數(shù)
            				
            						
            								/* 來至 Quake 3 的源碼 */
            						
            				
            				
            						float
            				 CarmSqrt(float x){union{int intPart;
            		float floatPart;
            	} convertor;
            	union{int intPart;
            		float floatPart;
            	} convertor2;
            	convertor.floatPart = x;
            	convertor2.floatPart = x;
            	convertor.intPart = 0x1FBCF800 + (convertor.intPart >> 1);
            	convertor2.intPart = 0x5f3759df - (convertor2.intPart >> 1);
            	return0.5f*(convertor.floatPart + (x * convertor2.floatPart));
            }

            參考鏈接:[External Link]http://greatsorcerer.go2.icpcn.com/info/fastsqrt.html

            快速 double 轉(zhuǎn)整型
            union luai_Cast {double l_d; long l_l; };
            #define lua_number2int(i,d) \{volatileunion luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; }

            參考鏈接:[InterWiki]double to int 神奇的 magic number

            RGB565 的 alpha 混合
            unsignedshort alpha_blender(unsignedint x,unsignedint y,unsignedint alpha){
            	x = (x | (x<<16)) & 0x7E0F81F;
            	y = (y | (y<<16)) & 0x7E0F81F;
            	unsignedint result = ((x - y) * alpha / 32 + y) & 0x7E0F81F;
            	return(unsignedshort)((result&0xFFFF) | (result>>16));
            }

            參考鏈接:[InterWiki]64K 色的 Alpha 混合

            一個不錯的字符串 hash 函數(shù)
            unsignedlong hash(constchar *name,size_t len){unsignedlong h=(unsignedlong)len;
            	size_t step = (len>>5)+1;
            	for(size_t i=len; i>=step; i-=step)
            	    h = h ^ ((h<<5)+(h>>2)+(unsignedlong)name[i-1]);
            	return h;
            }

            一個方便的 hash 函數(shù)應(yīng)該散列的比較開,計算速度跟字符串長度關(guān)系不大,又不能只計算字符串的開頭或末尾。這里的算法是從 Lua 中看來的。

            關(guān)于臟矩形技術(shù)的演示
            由于代碼過長,單起一頁:臟矩形 demo
            參考鏈接:[External Link]Blog上的帖子:臟矩形演示demo

            UTF8 到 UTF16 的轉(zhuǎn)換(單個字符)
            int UTF8toUTF16(int c){signedchar *t=(signedchar*)&c;
            	int ret=*t &(0x0f | ((*t>>1) &0x1f) | ~(*t>>7));
            	int i;
            	assert ((*t & 0xc0) != 0x80);
            	for(i=1;i<3;i++){if((t[i] & 0xc0)!=0x80){break;
            		}
            		ret=ret<<6 | (t[i] & 0x3f);
            	}return ret;
            }

            這只是一個字符的轉(zhuǎn)換,如果轉(zhuǎn)換字符串,可以再做一點優(yōu)化。
            posted on 2006-11-18 15:17 李錦俊(mybios) 閱讀(2738) 評論(4)  編輯 收藏 引用 所屬分類: C++

            Feedback

            # re: 【轉(zhuǎn)貼】一些高效代碼片段 2010-08-02 07:15 SheliaBates
            Make your own life time more simple take the <a href="http://bestfinance-blog.com/topics/personal-loans">personal loans</a> and all you require.   回復(fù)  更多評論
              

            # re: 【轉(zhuǎn)貼】一些高效代碼片段 2010-08-11 17:59 buy research paper
            I was so fortunate to find your page exactly one day before the deadline of my buy research paper and buy research paper. I know that you are a well-recognized and reliable source on the Internet.  回復(fù)  更多評論
              

            # re: 【轉(zhuǎn)貼】一些高效代碼片段 2010-08-12 06:33 custom essays
            Your outcome is hot! Therefore students not have to compose the custom essays and research paper by their efforts, they could take your help.   回復(fù)  更多評論
              

            久久精品国产精品亚洲下载| 99热都是精品久久久久久| yy6080久久| 午夜久久久久久禁播电影| 久久精品99久久香蕉国产色戒| 久久91精品国产91久久户| 精品久久久久久无码人妻热| 漂亮人妻被中出中文字幕久久 | 日日狠狠久久偷偷色综合免费| 伊人久久精品影院| 精品国产福利久久久| 久久久综合香蕉尹人综合网| 婷婷综合久久中文字幕蜜桃三电影| 国产精品久久自在自线观看| 伊人色综合久久天天人守人婷 | 久久人人爽人人爽人人片av高请| 亚洲午夜久久久精品影院| 日本久久久久亚洲中字幕| 久久天天躁狠狠躁夜夜不卡| 99久久99这里只有免费的精品| 伊人久久五月天| 久久人人爽人人爽人人片AV麻豆| 精品久久久久久无码中文字幕一区| 久久国产欧美日韩精品免费| 久久这里只有精品久久| 久久婷婷五月综合色奶水99啪| 国产美女亚洲精品久久久综合| 国产伊人久久| 久久国产精品一区| 精品久久久久久无码中文野结衣| 久久99精品国产一区二区三区| 久久夜色精品国产欧美乱| 亚洲中文字幕无码久久精品1| 久久天天躁狠狠躁夜夜avapp| 中文精品久久久久人妻| 91精品国产高清久久久久久91| 久久国产精品久久国产精品| 久久99国产精品99久久| 色噜噜狠狠先锋影音久久| 国产69精品久久久久99尤物| 国产99久久九九精品无码|