本文整理汇总了C++中CTexture::Load方法的典型用法代码示例。如果您正苦于以下问题:C++ CTexture::Load方法的具体用法?C++ CTexture::Load怎么用?C++ CTexture::Load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTexture
的用法示例。
在下文中一共展示了CTexture::Load方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Initalise
void CPickup::Initalise(CVector3f p)
{
m_isActive = true;
m_theta = 0.0f;
m_position = p;
CTexture texture;
// Texture - https://www.textures.com/download/cliffs0174/56219?secure=login
texture.Load("Resources\\Textures\\rock.jpg", false);
m_textureID = texture.m_textureID;
}
示例2: Create
bool CSkybox::Create(const char *bmpDirectory, const float fSize)
{
// Load textures
CTexture texture;
//skybox texture "grave" from redsorceress.com
texture.Load("Resources\\Textures\\grave_back.bmp", true);
m_textureIDs[SKYBOX_BACK_ID] = texture.m_textureID;
texture.Load("Resources\\Textures\\grave_front.bmp", true);
m_textureIDs[SKYBOX_FRONT_ID] = texture.m_textureID;
texture.Load("Resources\\Textures\\grave_top.bmp", true);
m_textureIDs[SKYBOX_BOTTOM_ID] = texture.m_textureID;
texture.Load("Resources\\Textures\\grave_top.bmp", true);
m_textureIDs[SKYBOX_TOP_ID] = texture.m_textureID;
texture.Load("Resources\\Textures\\grave_right.bmp", true);
m_textureIDs[SKYBOX_LEFT_ID] = texture.m_textureID;
texture.Load("Resources\\Textures\\grave_left.bmp", true);
m_textureIDs[SKYBOX_RIGHT_ID] = texture.m_textureID;
return true;
}
示例3: CNamed
CMaterial::CMaterial(CXMLTreeNode &TreeNode) : CNamed(TreeNode)
{
std::string l_EffectTechnique = TreeNode.GetPszProperty("effect_technique");
m_EffectTechnique = CEngine::GetSingletonPtr()->GetEffectManager()->GetResource(l_EffectTechnique);
if (l_EffectTechnique == "diffuse_technique")
{
for (int i = 0; i < TreeNode.GetNumChildren(); ++i)
{
CXMLTreeNode l_Texture = TreeNode(i);
CTexture * Texture = new CTexture();
Texture->Load(l_Texture.GetPszProperty("filename"));
m_Textures.push_back(Texture);
}
}
}
示例4: ExtractTexture
bool CStaticMesh::ExtractTexture(FILE* modelFile, std::vector<CTexture*>& textVector)
{
assert(modelFile);
uint16 length = 0;
char* path;
std::string sPath = "";
//Read Length of the texture path
fread(&length, sizeof(uint16), 1, modelFile);
path = new char[length];
memset(path, 0, length);
//Read Path
fread(path, 1, length, modelFile);
sPath = std::string(path);
CHECKED_DELETE(path);
std::string texName = m_MeshName + "_" + sPath;
CTexture* texture = CORE->GetTextureManager()->GetResource(texName);
if(texture == NULL)
{
texture = new CTexture();
texture->SetName(texName);
if(!texture->Load(sPath))
{
CHECKED_DELETE(texture);
texture = CORE->GetTextureManager()->GetNoTexture();
std::string err = "CStaticMesh::ExtractTexture->No se ha podido crear la textura: " + sPath;
LOGGER->AddNewLog(ELL_WARNING, err.c_str() );
}
}
textVector.push_back(texture);
return true;
}
示例5: if
//--------------------------------------------------------------------------------------------------------------
CTexture* CResourceManager::_CreateTexture (LPCSTR _Name)
{
// DBG_VerifyTextures ();
if (0==xr_strcmp(_Name,"null")) return 0;
R_ASSERT (_Name && _Name[0]);
string_path Name;
strcpy_s (Name,_Name); //. andy if (strext(Name)) *strext(Name)=0;
fix_texture_name (Name);
// ***** first pass - search already loaded texture
LPSTR N = LPSTR(Name);
map_TextureIt I = m_textures.find (N);
if (I!=m_textures.end()) return I->second;
else
{
CTexture * T = xr_new<CTexture>();
T->dwFlags |= xr_resource_flagged::RF_REGISTERED;
m_textures.insert (mk_pair(T->set_name(Name),T));
T->Preload ();
if (Device.b_is_Ready && !bDeferredLoad) T->Load();
return T;
}
}
示例6: Load
CTexture* CTextureResources::Load( const char* filePath, bool isCubeMap )
{
int hash = CUtil::MakeHash(filePath);
auto it = textureMap.find(hash);
CTexture* tex = nullptr;
if (it == textureMap.end()) {
//�V�K
tex = new CTexture;
if (tex->Load(filePath, isCubeMap) ){
textureMap.insert(std::pair<int, CTexture*>(hash, tex));
}
else {
delete tex;
return nullptr;
}
}
else {
tex = it->second;
}
return tex;
}
示例7: ParsePass
CPass* CMaterialLoader::ParsePass(Json::Value& json, Json::Value& root) {
const char* szVertexProgram = json["vertex_program"].asCString();
const char* szFragmentProgram = json["fragment_program"].asCString();
Json::Value& diffuseJson = json["diffuse"];
Json::Value& ambientJson = json["ambient"];
Json::Value& specularJson = json["specular"];
Json::Value& emissiveJson = json["emissive"];
Json::Value& textureUnitJson = json["texture_unit"];
// 创建颜色
CColorF diffuse = CColorF(diffuseJson[0].asFloat(),
diffuseJson[1].asFloat(),
diffuseJson[2].asFloat(),
diffuseJson[3].asFloat());
CColorF ambient = CColorF(ambientJson[0].asFloat(),
ambientJson[1].asFloat(),
ambientJson[2].asFloat(),
ambientJson[3].asFloat());
CColorF specular = CColorF(specularJson[0].asFloat(),
specularJson[1].asFloat(),
specularJson[2].asFloat(),
specularJson[3].asFloat());
CColorF emissive = CColorF(emissiveJson[0].asFloat(),
emissiveJson[1].asFloat(),
emissiveJson[2].asFloat(),
emissiveJson[3].asFloat());
// 创建纹理
CTexture* pTexture = NULL;
if (!textureUnitJson.isNull()) {
const char* texture = textureUnitJson["texture"].asCString();
std::string filter_mode = textureUnitJson["filter_mode"].asString();
std::string address_mode = textureUnitJson["address_mode"].asString();
pTexture = XENEW(CTexture);
if (!pTexture) {
return NULL;
}
if (filter_mode == "nearest") {
pTexture->SetFilter(ITexture::E_Nearest);
} else if (filter_mode == "linear") {
pTexture->SetFilter(ITexture::E_Linear);
}
if (address_mode == "repeat") {
pTexture->SetAddress(ITexture::E_Repeat);
} else if (address_mode == "clamp") {
pTexture->SetAddress(ITexture::E_Clamp);
}
if (!pTexture->Load(texture)) {
XELOG("material parse pass load texture error: %s", texture);
XEDELETE(pTexture);
return NULL;
}
}
// 创建program
CCgProgram* pProgram = XENEW(CCgProgram);
if (!pProgram) {
XEDELETE(pTexture);
return NULL;
}
// 创建vertex
CCg* pVertex = ParseVertex(szVertexProgram, root);
if (!pVertex) {
XELOG("material parse pass load vertex error: %s", szVertexProgram);
XEDELETE(pTexture);
XEDELETE(pProgram);
return NULL;
}
pProgram->AddCg(pVertex);
// 创建fragment
CCg* pFragment = ParseFragment(szFragmentProgram, root);
if (!pFragment) {
XELOG("material parse pass load fragment error: %s", szFragmentProgram);
XEDELETE(pTexture);
XEDELETE(pProgram);
XEDELETE(pVertex);
return NULL;
}
pProgram->AddCg(pFragment);
pProgram->Compile();
// 创建pass
CPass* pPass = XENEW(CPass);
if (!pPass) {
XEDELETE(pTexture);
XEDELETE(pProgram);
XEDELETE(pVertex);
XEDELETE(pFragment);
return NULL;
}
pPass->Init(pTexture, diffuse, ambient, specular, emissive, pProgram);
//.........这里部分代码省略.........