本文整理汇总了C++中ogre::TexturePtr::setHeight方法的典型用法代码示例。如果您正苦于以下问题:C++ TexturePtr::setHeight方法的具体用法?C++ TexturePtr::setHeight怎么用?C++ TexturePtr::setHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::TexturePtr
的用法示例。
在下文中一共展示了TexturePtr::setHeight方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Refresh
void EC_ChatBubble::Refresh()
{
if (renderer_.expired() || !billboardSet_ || !billboard_)
return;
// If no messages in the log, hide the chat bubble.
if (messages_.isEmpty())
{
billboardSet_->setVisible(false);
return;
}
else
billboardSet_->setVisible(true);
// Get image buffer and texture
QImage buffer = GetChatBubblePixmap().toImage();
Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().getByName(texture_name_);
if (buffer.isNull() || texture.isNull())
return;
// Check texture size
if ((int)texture->getWidth() != buffer.width() || (int)texture->getHeight() != buffer.height())
{
texture->freeInternalResources();
texture->setWidth(buffer.width());
texture->setHeight(buffer.height());
texture->createInternalResources();
}
// Update texture buffer
Ogre::Box update_box(0,0, buffer.width(), buffer.height());
Ogre::PixelBox pixel_box(update_box, Ogre::PF_A8R8G8B8, (void*)buffer.bits());
if (!texture->getBuffer().isNull())
texture->getBuffer()->blitFromMemory(pixel_box, update_box);
}
示例2: Resize
void RenderWindow::Resize(int width, int height)
{
renderWindow->resize(width, height);
renderWindow->windowMovedOrResized();
if (Ogre::TextureManager::getSingletonPtr() && Ogre::OverlayManager::getSingletonPtr())
{
PROFILE(RenderWindow_Resize);
// recenter the overlay
// int left = (renderWindow->getWidth() - width) / 2;
// int top = (renderWindow->getHeight() - height) / 2;
// resize the container
// overlayContainer->setDimensions(width, height);
// overlayContainer->setPosition(left, top);
overlayContainer->setDimensions((Ogre::Real)width, (Ogre::Real)height);
overlayContainer->setPosition(0,0);
// resize the backing texture
Ogre::TextureManager &mgr = Ogre::TextureManager::getSingleton();
Ogre::TexturePtr texture = mgr.getByName(rttTextureName);
assert(texture.get());
texture->freeInternalResources();
texture->setWidth(width);
texture->setHeight(height);
texture->createInternalResources();
}
}
示例3: ResizeOverlay
void QOgreWorldView::ResizeOverlay(int width, int height)
{
if (Ogre::TextureManager::getSingletonPtr() && Ogre::OverlayManager::getSingletonPtr())
{
PROFILE(QOgreWorldView_ResizeOverlay);
// recenter the overlay
int left = (win_->getWidth() - width) / 2;
int top = (win_->getHeight() - height) / 2;
// resize the container
ui_overlay_container_->setDimensions(width, height);
ui_overlay_container_->setPosition(left, top);
// resize the backing texture
Ogre::TextureManager &mgr = Ogre::TextureManager::getSingleton();
Ogre::TexturePtr texture = mgr.getByName(texture_name_);
assert(texture.get());
texture->freeInternalResources();
texture->setWidth(width);
texture->setHeight(height);
texture->createInternalResources();
}
}
示例4: Update
void EC_WidgetCanvas::Update()
{
if (framework->IsHeadless())
return;
if (!widget_.data() || texture_name_.empty())
return;
if (widget_->width() <= 0 || widget_->height() <= 0)
return;
try
{
Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().getByName(texture_name_);
if (texture.isNull())
return;
if (buffer_.size() != widget_->size())
buffer_ = QImage(widget_->size(), QImage::Format_ARGB32_Premultiplied);
if (buffer_.width() <= 0 || buffer_.height() <= 0)
return;
QPainter painter(&buffer_);
widget_->render(&painter);
// Set texture to material
if (update_internals_ && !material_name_.empty())
{
Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().getByName(material_name_);
if (material.isNull())
return;
// Just for good measure, this is done once in the ctor already if everything went well.
OgreRenderer::SetTextureUnitOnMaterial(material, texture_name_);
UpdateSubmeshes();
update_internals_ = false;
}
if ((int)texture->getWidth() != buffer_.width() || (int)texture->getHeight() != buffer_.height())
{
texture->freeInternalResources();
texture->setWidth(buffer_.width());
texture->setHeight(buffer_.height());
texture->createInternalResources();
}
Blit(buffer_, texture);
}
catch (Ogre::Exception &e) // inherits std::exception
{
LogError("Exception occurred while blitting texture data from memory: " + std::string(e.what()));
}
catch (...)
{
LogError("Unknown exception occurred while blitting texture data from memory.");
}
}
示例5: onSlotSelected
void SaveGameDialog::onSlotSelected(MyGUI::ListBox *sender, size_t pos)
{
if (pos == MyGUI::ITEM_NONE)
{
mCurrentSlot = NULL;
mInfoText->setCaption("");
mScreenshot->setImageTexture("");
return;
}
if (mSaving)
mSaveNameEdit->setCaption(sender->getItemNameAt(pos));
mCurrentSlot = NULL;
unsigned int i=0;
for (MWState::Character::SlotIterator it = mCurrentCharacter->begin(); it != mCurrentCharacter->end(); ++it, ++i)
{
if (i == pos)
mCurrentSlot = &*it;
}
assert(mCurrentSlot && "Can't find selected slot");
std::stringstream text;
time_t time = mCurrentSlot->mTimeStamp;
struct tm* timeinfo;
timeinfo = localtime(&time);
// Use system/environment locale settings for datetime formatting
setlocale(LC_TIME, "");
const int size=1024;
char buffer[size];
if (std::strftime(buffer, size, "%x %X", timeinfo) > 0)
text << buffer << "\n";
text << "Level " << mCurrentSlot->mProfile.mPlayerLevel << "\n";
text << mCurrentSlot->mProfile.mPlayerCell << "\n";
// text << "Time played: " << slot->mProfile.mTimePlayed << "\n";
int hour = int(mCurrentSlot->mProfile.mInGameTime.mGameHour);
bool pm = hour >= 12;
if (hour >= 13) hour -= 12;
if (hour == 0) hour = 12;
text
<< mCurrentSlot->mProfile.mInGameTime.mDay << " "
<< MWBase::Environment::get().getWorld()->getMonthName(mCurrentSlot->mProfile.mInGameTime.mMonth)
<< " " << hour << " " << (pm ? "#{sSaveMenuHelp05}" : "#{sSaveMenuHelp04}");
mInfoText->setCaptionWithReplacing(text.str());
// Decode screenshot
std::vector<char> data = mCurrentSlot->mProfile.mScreenshot; // MemoryDataStream doesn't work with const data :(
Ogre::DataStreamPtr stream(new Ogre::MemoryDataStream(&data[0], data.size()));
Ogre::Image image;
image.load(stream, "jpg");
const std::string textureName = "@savegame_screenshot";
Ogre::TexturePtr texture;
texture = Ogre::TextureManager::getSingleton().getByName(textureName);
mScreenshot->setImageTexture("");
if (texture.isNull())
{
texture = Ogre::TextureManager::getSingleton().createManual(textureName,
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Ogre::TEX_TYPE_2D,
image.getWidth(), image.getHeight(), 0, Ogre::PF_BYTE_RGBA, Ogre::TU_DYNAMIC_WRITE_ONLY);
}
texture->unload();
texture->setWidth(image.getWidth());
texture->setHeight(image.getHeight());
texture->loadImage(image);
mScreenshot->setImageTexture(textureName);
}