//////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// !load a texture @param szFileName the texture file path @return the texture id if succeded nil if failed */
| 999 | @return the texture id if succeded nil if failed |
| 1000 | */ |
| 1001 | int CScriptObjectSystem::LoadTexture(IFunctionHandler *pH) |
| 1002 | { |
| 1003 | // CHECK_PARAMETERS(1); |
| 1004 | const char *szFileName; |
| 1005 | int nTid=0; |
| 1006 | pH->GetParam(1,szFileName); |
| 1007 | |
| 1008 | int nLoadAsCubeMap=0; |
| 1009 | bool bClamp = false; |
| 1010 | if (pH->GetParamCount()>=2) |
| 1011 | { |
| 1012 | pH->GetParam(2,nLoadAsCubeMap); |
| 1013 | pH->GetParam(3,bClamp); |
| 1014 | } |
| 1015 | |
| 1016 | ITexPic * pPic = 0; |
| 1017 | if(nLoadAsCubeMap) |
| 1018 | pPic = m_pSystem->GetIRenderer()->EF_LoadTexture((char*)szFileName, 0, FT2_FORCECUBEMAP, eTT_Cubemap); |
| 1019 | else |
| 1020 | pPic = m_pRenderer->EF_LoadTexture((char*)szFileName,FT_CLAMP | FT_NOREMOVE,0,eTT_Base); |
| 1021 | |
| 1022 | if (pPic && pPic->IsTextureLoaded()) |
| 1023 | { |
| 1024 | nTid=pPic->GetTextureID(); |
| 1025 | m_pSystem->GetIRenderer()->SetTexture(nTid); |
| 1026 | m_pSystem->GetIRenderer()->SetTexClampMode(bClamp); |
| 1027 | |
| 1028 | if(nLoadAsCubeMap) |
| 1029 | return pH->EndFunction(nTid); |
| 1030 | |
| 1031 | |
| 1032 | USER_DATA ud=m_pScriptSystem->CreateUserData((int)nTid,USER_DATA_TEXTURE); |
| 1033 | return pH->EndFunction(ud); |
| 1034 | } |
| 1035 | return pH->EndFunctionNull(); |
| 1036 | } |
| 1037 | |
| 1038 | ///////////////////////////////////////////////////////////////////////////////// |
| 1039 | ///////////////////////////////////////////////////////////////////////////////// |
no test coverage detected