本文整理汇总了C++中ogre::TexturePtr::load方法的典型用法代码示例。如果您正苦于以下问题:C++ TexturePtr::load方法的具体用法?C++ TexturePtr::load怎么用?C++ TexturePtr::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::TexturePtr
的用法示例。
在下文中一共展示了TexturePtr::load方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _createTexture
bool TextureManager::_createTexture(Ogre::TexturePtr &Texture, const Ogre::String &Name, const Size &Size)
{
try
{
Ogre::TextureManager::getSingleton().remove(Name);
Texture = Ogre::TextureManager::getSingleton().
createManual(Name,
HYDRAX_RESOURCE_GROUP,
Ogre::TEX_TYPE_2D,
Size.Width, Size.Height,
0,
Ogre::PF_BYTE_BGRA,
Ogre::TU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
Texture->load();
}
catch(Ogre::Exception &e)
{
HydraxLOG(e.getFullDescription());
return false;
}
return true;
}
示例2: showTexture
TexturePair AssetsManager::showTexture(const std::string textureName)
{
// if (!mOgreCEGUITexture) {
// S_LOG_WARNING("You must first create a valid OgreCEGUITexture instance.");
// return;
// }
if (Ogre::TextureManager::getSingleton().resourceExists(textureName)) {
Ogre::TexturePtr texturePtr = static_cast<Ogre::TexturePtr>(Ogre::TextureManager::getSingleton().getByName(textureName));
if (!texturePtr.isNull()) {
if (!texturePtr->isLoaded()) {
try {
texturePtr->load();
} catch (...) {
S_LOG_WARNING("Error when loading " << textureName << ". This texture will not be shown.");
return TexturePair();
}
}
std::string textureName(texturePtr->getName());
std::string imageSetName(textureName + "_AssetsManager");
return createTextureImage(texturePtr, imageSetName);
// mOgreCEGUITexture->setOgreTexture(texturePtr);
}
}
return TexturePair();
}
示例3: load
Ogre::TexturePtr LodTextureManager::load(const Ogre::String &name, const Ogre::String &group)
{
Ogre::ResourceManager::ResourceCreateOrRetrieveResult res = Ogre::TextureManager::getSingleton().createOrRetrieve(name, group, true, this);
Ogre::TexturePtr tex = res.first;
tex->load();
return tex;
}
示例4: getIcon
Icon* IconManager::getIcon(int, EmberEntity* entity)
{
std::string key = "entity_" + entity->getId();
if (mIconStore.hasIcon(key)) {
return mIconStore.getIcon(key);
} else {
IconActionCreator actionCreator(*entity);
std::unique_ptr<EntityMapping::EntityMapping> modelMapping(Mapping::EmberEntityMappingManager::getSingleton().getManager().createMapping(*entity, actionCreator, &EmberOgre::getSingleton().getWorld()->getView()));
std::string modelName;
if (modelMapping.get()) {
modelMapping->initialize();
modelName = actionCreator.getModelName();
}
//if there's no model defined for this use the placeholder model
if (modelName == "") {
modelName = "placeholder";
}
Ogre::ResourcePtr modelDefPtr = Model::ModelDefinitionManager::getSingleton().getByName(modelName);
if (!modelDefPtr.isNull()) {
Model::ModelDefinition* modelDef = static_cast<Model::ModelDefinition*> (modelDefPtr.get());
const std::string& iconPath(modelDef->getIconPath());
if (iconPath != "") {
Ogre::TexturePtr texPtr;
try {
if (Ogre::TextureManager::getSingleton().resourceExists(iconPath)) {
texPtr = static_cast<Ogre::TexturePtr> (Ogre::TextureManager::getSingleton().getByName(iconPath));
//try to load it to make sure that's it a working image
texPtr->load();
}
if (texPtr.isNull()) {
texPtr = Ogre::TextureManager::getSingleton().load(iconPath, "Gui");
}
} catch (...) {
S_LOG_WARNING("Error when trying to load the icon " << iconPath <<". The icon will be rendered dynamically.");
texPtr.setNull();
}
if (!texPtr.isNull()) {
Icon* icon = mIconStore.createIcon(key, texPtr);
return icon;
}
}
}
Icon* icon = mIconStore.createIcon(key);
if (icon) {
//update the model preview window
// Model::Model* model = Model::Model::createModel(mIconRenderer.getRenderContext()->getSceneManager(), modelName);
render(*icon, modelName);
// mIconRenderer.getRenderContext()->getSceneManager()->destroyMovableObject(model);
}
return icon;
}
return 0;
}
示例5: render
void GlobalMap::render (Loading::Listener* loadingListener)
{
Ogre::TexturePtr tex;
const MWWorld::ESMStore &esmStore =
MWBase::Environment::get().getWorld()->getStore();
// get the size of the world
MWWorld::Store<ESM::Cell>::iterator it = esmStore.get<ESM::Cell>().extBegin();
for (; it != esmStore.get<ESM::Cell>().extEnd(); ++it)
{
if (it->getGridX() < mMinX)
mMinX = it->getGridX();
if (it->getGridX() > mMaxX)
mMaxX = it->getGridX();
if (it->getGridY() < mMinY)
mMinY = it->getGridY();
if (it->getGridY() > mMaxY)
mMaxY = it->getGridY();
}
mWidth = mCellSize*(mMaxX-mMinX+1);
mHeight = mCellSize*(mMaxY-mMinY+1);
loadingListener->loadingOn();
loadingListener->setLabel("Creating map");
loadingListener->setProgressRange((mMaxX-mMinX+1) * (mMaxY-mMinY+1));
loadingListener->setProgress(0);
std::vector<Ogre::uchar> data (mWidth * mHeight * 3);
for (int x = mMinX; x <= mMaxX; ++x)
{
for (int y = mMinY; y <= mMaxY; ++y)
{
ESM::Land* land = esmStore.get<ESM::Land>().search (x,y);
if (land)
{
int mask = ESM::Land::DATA_WNAM;
if (!land->isDataLoaded(mask))
land->loadData(mask);
}
for (int cellY=0; cellY<mCellSize; ++cellY)
{
for (int cellX=0; cellX<mCellSize; ++cellX)
{
int vertexX = static_cast<int>(float(cellX)/float(mCellSize) * 9);
int vertexY = static_cast<int>(float(cellY) / float(mCellSize) * 9);
int texelX = (x-mMinX) * mCellSize + cellX;
int texelY = (mHeight-1) - ((y-mMinY) * mCellSize + cellY);
unsigned char r,g,b;
float y = 0;
if (land && land->mDataTypes & ESM::Land::DATA_WNAM)
y = (land->mLandData->mWnam[vertexY * 9 + vertexX] << 4) / 2048.f;
else
y = (SCHAR_MIN << 4) / 2048.f;
if (y < 0)
{
r = static_cast<unsigned char>(14 * y + 38);
g = static_cast<unsigned char>(20 * y + 56);
b = static_cast<unsigned char>(18 * y + 51);
}
else if (y < 0.3f)
{
if (y < 0.1f)
y *= 8.f;
else
{
y -= 0.1f;
y += 0.8f;
}
r = static_cast<unsigned char>(66 - 32 * y);
g = static_cast<unsigned char>(48 - 23 * y);
b = static_cast<unsigned char>(33 - 16 * y);
}
else
{
y -= 0.3f;
y *= 1.428f;
r = static_cast<unsigned char>(34 - 29 * y);
g = static_cast<unsigned char>(25 - 20 * y);
b = static_cast<unsigned char>(17 - 12 * y);
}
data[texelY * mWidth * 3 + texelX * 3] = r;
data[texelY * mWidth * 3 + texelX * 3+1] = g;
data[texelY * mWidth * 3 + texelX * 3+2] = b;
}
}
loadingListener->increaseProgress();
if (land)
land->unloadData();
}
}
//.........这里部分代码省略.........
示例6: SetUpCustomContent
void SetUpCustomContent()
{
Ogre::String CustomCameraName = "TestRenderTargetCamera";
Ogre::String CustomTextureName = "TestRenderTargetTexture";
Ogre::String CustomMaterialName = "CustomRenderTargetMaterial";
Ogre::String CustomWorkSpaceName = "TestCustomRenderTargetWorkSpaceName";
m_CustomRTTCamera = mSceneManager->createCamera(CustomCameraName);
m_CustomRTTCamera->setPosition(0, 30, 0);
m_CustomRTTCamera->lookAt(0, 0, 0);
m_CustomRTTCamera->setFarClipDistance(1000);
m_CustomRTTCamera->setNearClipDistance(0.1);
m_CustomRenderTexture = Ogre::TextureManager::getSingleton().createManual(CustomTextureName,
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D,
512, 512, 1, Ogre::PF_A8B8G8R8, Ogre::TU_RENDERTARGET);
m_CustomRenderTexture->load();
Ogre::RenderTexture* rtt = m_CustomRenderTexture->getBuffer(0)->getRenderTarget();
Ogre::CompositorManager2 *compositorManager = mRoot->getCompositorManager2();
const Ogre::IdString workspaceName(CustomWorkSpaceName);
if( !compositorManager->hasWorkspaceDefinition( workspaceName ) )
{
compositorManager->createBasicWorkspaceDef( workspaceName, mBackgroundColour,
Ogre::IdString() );
}
m_CustomRenderTarget = compositorManager->addWorkspace( mSceneManager, (Ogre::RenderTarget*)rtt, m_CustomRTTCamera,
workspaceName, false );
//m_CustomRenderTarget->setEnabled(false); // not auto update
#if 0
// create manual object
Ogre::MaterialPtr CustomMaterial = Ogre::MaterialManager::getSingleton().create(CustomMaterialName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
CustomMaterial->getTechnique(0)->removeAllPasses();
Ogre::Pass* pass = CustomMaterial->getTechnique(0)->createPass();
Ogre::TextureUnitState* tu = pass->createTextureUnitState();
tu->setTextureName(CustomTextureName);
#endif
Ogre::HlmsManager *hlmsManager = Ogre::Root::getSingleton().getHlmsManager();
Ogre::Hlms *hlms = hlmsManager->getHlms( Ogre::HLMS_UNLIT );
Ogre::HlmsDatablock *datablock = hlms->createDatablock( CustomMaterialName, CustomMaterialName,
Ogre::HlmsMacroblock(), Ogre::HlmsBlendblock(), Ogre::HlmsParamVec() );
Ogre::HlmsUnlitDatablock *unlitDb = static_cast<Ogre::HlmsUnlitDatablock*>( datablock );
unlitDb->setTexture( 0, 0, m_CustomRenderTexture );
#if 1
Ogre::ManualObject* CustomManualObject = mSceneManager->createManualObject();
CustomManualObject->begin(CustomMaterialName);
CustomManualObject->position(-100, -100, -100);
CustomManualObject->textureCoord(0, 0);
CustomManualObject->position(100, -100, -100);
CustomManualObject->textureCoord(1, 0);
CustomManualObject->position(100, 100, -100);
CustomManualObject->textureCoord(1, 1);
CustomManualObject->position(-100, 100, -100);
CustomManualObject->textureCoord(0, 1);
CustomManualObject->quad(0, 1, 2, 3);
CustomManualObject->end();
// CustomManualObject->setDatablock(0, CustomMaterialName);
Ogre::SceneNode *sceneNodeLines = mSceneManager->getRootSceneNode( Ogre::SCENE_DYNAMIC )->
createChildSceneNode( Ogre::SCENE_DYNAMIC );
sceneNodeLines->attachObject(CustomManualObject);
sceneNodeLines->scale(0.4f, 0.4f, 0.4f);
sceneNodeLines->translate(0.0f, 0.0f, 0.0f, Ogre::SceneNode::TS_WORLD);
#endif
}