本文整理汇总了C++中ogre::TexturePtr::freeInternalResources方法的典型用法代码示例。如果您正苦于以下问题:C++ TexturePtr::freeInternalResources方法的具体用法?C++ TexturePtr::freeInternalResources怎么用?C++ TexturePtr::freeInternalResources使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::TexturePtr
的用法示例。
在下文中一共展示了TexturePtr::freeInternalResources方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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.");
}
}