本文整理汇总了C++中ogre::TexturePtr::getWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ TexturePtr::getWidth方法的具体用法?C++ TexturePtr::getWidth怎么用?C++ TexturePtr::getWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::TexturePtr
的用法示例。
在下文中一共展示了TexturePtr::getWidth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mMainLight
SimpleRenderContext::SimpleRenderContext(const std::string& prefix, Ogre::TexturePtr texture) :
mMainLight(0), mSceneManager(0), mWidth(texture->getWidth()), mHeight(texture->getHeight()), mRenderTexture(0), mCameraNode(0), mCameraPitchNode(0), mEntityNode(0), mRootNode(0), mCamera(0), mViewPort(0), mResourceLoader(*this), mBackgroundColour(Ogre::ColourValue::Black), mCameraPositionMode(CPM_OBJECTCENTER), mTextureOwned(false)
{
setupScene(prefix);
setTexture(texture);
Ogre::Real aspectRatio = static_cast<float>(texture->getWidth()) / static_cast<float>(texture->getHeight());
S_LOG_VERBOSE("Setting aspect ratio of camera to " << aspectRatio);
mCamera->setAspectRatio(aspectRatio);
}
示例2: _initTexture
//------------------------------------------------------------------------------
void OgreVideoTexture::_initTexture(Ogre::TexturePtr _texture)
{
// Get the pixel buffer
Ogre::HardwarePixelBufferSharedPtr pixelBuffer = _texture->getBuffer();
// Lock the pixel buffer and get a pixel box
pixelBuffer->lock(Ogre::HardwareBuffer::HBL_NORMAL); // for best performance use HBL_DISCARD!
const Ogre::PixelBox& pixelBox = pixelBuffer->getCurrentLock();
Ogre::uint8* pDest = static_cast<Ogre::uint8*>(pixelBox.data);
for (size_t j = 0; j < _texture->getHeight(); j++)
for(size_t i = 0; i < _texture->getWidth() ; i++)
{
if (j<480-5 && i<640-5)
{
*pDest++ = 255; // B
*pDest++ = 0; // G
*pDest++ = 255; // R
}
else
{
*pDest++ = 255; // B
*pDest++ = 0; // G
*pDest++ = 0; // R
}
}
pixelBuffer->unlock();
}
示例3: createTextureImage
TexturePair AssetsManager::createTextureImage(Ogre::TexturePtr texturePtr, const std::string& imageSetName)
{
// if (mOgreCEGUITexture) {
// GUIManager::getSingleton().getGuiRenderer()->destroyTexture(mOgreCEGUITexture);
// mOgreCEGUITexture = 0;
// }
CEGUI::Imageset* textureImageset;
if (CEGUI::ImagesetManager::getSingleton().isDefined(imageSetName)) {
textureImageset = &CEGUI::ImagesetManager::getSingleton().get(imageSetName);
} else {
//create a CEGUI texture from our Ogre texture
S_LOG_VERBOSE("Creating new CEGUI texture from Ogre texture.");
CEGUI::Texture* ogreCEGUITexture = &GUIManager::getSingleton().getGuiRenderer()->createTexture(texturePtr);
//we need a imageset in order to create GUI elements from the ceguiTexture
S_LOG_VERBOSE("Creating new CEGUI imageset with name " << imageSetName);
textureImageset = &CEGUI::ImagesetManager::getSingleton().create(imageSetName, *ogreCEGUITexture);
//we only want one element: the whole texture
textureImageset->defineImage("full_image", CEGUI::Rect(0, 0, texturePtr->getWidth(), texturePtr->getHeight()), CEGUI::Point(0, 0));
}
//assign our image element to the StaticImage widget
const CEGUI::Image* textureImage = &textureImageset->getImage("full_image");
return TexturePair(texturePtr, textureImage, textureImageset);
}
示例4: processOutputImage
//!
//! Processes the node's input data to generate the node's output image.
//!
void BadPrintingNode::processOutputImage ()
{
// obtain input image
Ogre::TexturePtr inputTexture = getTextureValue("Input Map");
if (inputTexture.isNull()) {
//disable compositor (now that the input texture name was set)
if (m_compositor)
m_compositor->setEnabled(false);
//render and set output
m_renderTexture->getBuffer()->getRenderTarget()->update();
setValue("Image", m_defaultTexture);
Log::warning("No input image connected.", "BadPrintingNode::processOutputImage");
}
else if (!m_renderTexture.isNull()) {
//resize render texture
size_t width = inputTexture->getWidth();
size_t height = inputTexture->getHeight();
resizeRenderTexture(width, height);
//enable compositor (now that the input texture name was set)
if (m_compositor)
m_compositor->setEnabled(true);
m_renderTexture->getBuffer()->getRenderTarget()->update();
setValue("Image", m_renderTexture);
}
}
示例5: addTextureDebugOverlay
void GraphicsController::addTextureDebugOverlay(const Ogre::String& texname, size_t i)
{
using namespace Ogre;
Overlay* debugOverlay = OverlayManager::getSingleton().getByName("PRJZ/DebugOverlay");
MaterialPtr debugMat = MaterialManager::getSingleton().getByName("PRJZ/BasicTexture", "PROJECT_ZOMBIE");
if(debugMat.isNull())
OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "PRJZ/BasicTexture material was not found.", "GraphicsController::addTextureDebugOverlay");
debugMat->getTechnique(0)->getPass(0)->setLightingEnabled(false);
TextureUnitState *t = debugMat->getTechnique(0)->getPass(0)->createTextureUnitState(texname);
t->setTextureAddressingMode(TextureUnitState::TAM_CLAMP);
Ogre::TexturePtr tex = Ogre::TextureManager::getSingleton().getByName(texname);
Ogre::Real tWidth = tex->getWidth();
Ogre::Real tHeight = tex->getHeight();
//ratio
Ogre::Real ratio = tHeight / tWidth;
OverlayContainer* debugPanel = (OverlayContainer*)
(OverlayManager::getSingleton().createOverlayElement("Panel", "Ogre/DebugTexPanel" + StringConverter::toString(i)));
debugPanel->_setPosition(0.0, 0.0);
debugPanel->_setDimensions(0.5f, 0.5f * ratio);
debugPanel->setMaterialName(debugMat->getName());
debugOverlay->add2D(debugPanel);
}
示例6: video_display
void video_display(VideoState *is)
{
VideoPicture *vp;
vp = &is->pictq[is->pictq_rindex];
if (is->video_st->codec->width != 0 && is->video_st->codec->height != 0)
{
Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton ().getByName("VideoTexture");
if (texture.isNull () || texture->getWidth() != is->video_st->codec->width || texture->getHeight() != is->video_st->codec->height)
{
Ogre::TextureManager::getSingleton ().remove ("VideoTexture");
texture = Ogre::TextureManager::getSingleton().createManual(
"VideoTexture",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Ogre::TEX_TYPE_2D,
is->video_st->codec->width, is->video_st->codec->height,
0,
Ogre::PF_BYTE_RGBA,
Ogre::TU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
}
Ogre::PixelBox pb(is->video_st->codec->width, is->video_st->codec->height, 1, Ogre::PF_BYTE_RGBA, vp->data);
Ogre::HardwarePixelBufferSharedPtr buffer = texture->getBuffer();
buffer->blitFromMemory(pb);
}
free(vp->data);
}
示例7: 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);
}
示例8: setViewSize
void UiManager::setViewSize(const Ogre::TexturePtr &aTexture)
{
// make sure that the view size matches the texture size
if (!aTexture.isNull() && !isViewSizeMatching(aTexture))
{
mWidgetView->setGeometry(QRect(0, 0, aTexture->getWidth(), aTexture->getHeight()));
}
}
示例9: getRequestedSize
MyGUI::IntSize ImageButton::getRequestedSize()
{
Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().getByName(mImageNormal);
if (texture.isNull())
{
std::cerr << "ImageButton: can't find " << mImageNormal << std::endl;
return MyGUI::IntSize(0,0);
}
return MyGUI::IntSize (texture->getWidth(), texture->getHeight());
}
示例10: 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.");
}
}
示例11: getTextureWidth
/**
* Returns the texture width of a material or -1 if have not texture
*/
int GUIHelper::getTextureWidth(const Ogre::String &materialName)
{
Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().getByName(materialName);
if(mat.isNull() || /*!mat->getTechnique(0) ||
!mat->getTechnique(0)->getPass(0) ||*/
!mat->getTechnique(0)->getPass(0)->getTextureUnitState(0))
return -1;
Ogre::TexturePtr text = Ogre::TextureManager::getSingleton().getByName(
mat->getTechnique(0)->getPass(0)->getTextureUnitState(
0)->getTextureName());
if(text.isNull()) return -1;
return text->getWidth();
}
示例12: mImagesetName
/**
Constructor for when we already have a texture of the whole icon.
*/
IconImageStore::IconImageStore(const std::string& imagesetName, Ogre::TexturePtr texPtr)
: mImagesetName(imagesetName)
, mTexPtr(texPtr)
, mImageDataStream(nullptr)
, mCeguiTexture(nullptr)
{
mCeguiTexture = &GUIManager::getSingleton().createTexture(mTexPtr, imagesetName);
//we'll assume that height and width are the same
mImageSize = texPtr->getWidth();
mIconSize = mImageSize;
//this will only create one entry
createEntries();
}
示例13: string
skin::skin(const string &n):
_name(n),
_prefix("gui/skins/" + _name + "/" + _name)
{
txml::document doc;
doc.LoadFile((engine::DATA_DIR + _prefix + ".xml").c_str());
if (doc.Error())
{
engine::log("failed to load GUI skin " + _name);
return;
}
txml::element *rootElem = doc.RootElement();
for (txml::node *i = rootElem->FirstChild(); i; i = i->NextSibling())
{
pieceList &pl = _elements[i->Value()];
for (txml::node *j = i->FirstChild(); j; j = j->NextSibling())
{
txml::element *element = j->ToElement();
if (element)
{
piece &p = pl[element->Value()];
string tex = element->attrib<string>("image", string());
if (!tex.empty())
{
p.tex = "gui/skins/" + _name + "/" + tex;
Ogre::TexturePtr tex = gfx::getTexture(p.tex);
if (tex.get())
p.size = vec2(tex->getWidth(), tex->getHeight());
else
p.size = vec2(0, 0);
}
else
{
p.tex.clear();
p.size = vec2(0, 0);
}
}
}
}
}
示例14:
/**
* Create a new PanelOverlayElement
* @param matName The name of the material
* @param rSize The resulting size of the texture (width)
* @param name The name of the panel
*/
Ogre::PanelOverlayElement *GUIHelper::createPanel(const Ogre::String &matName,
int &rSize, const Ogre::String &name)
{
static int counter = 0;
Ogre::PanelOverlayElement *result = 0;
Ogre::String realName;
if(name.empty()){
realName = "pan" + Ogre::StringConverter::toString(counter);
counter++;
} else {
realName = name;
}
#ifdef DEBUG
// ensures the material exists
Ogre::MaterialPtr material;
material = Ogre::MaterialManager::getSingleton().getByName(matName);
if(material.isNull()){
debug("Material %s not found\n", matName.c_str());
}
// ASSERT(!material.isNull());
#endif
Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton();
result = static_cast<Ogre::PanelOverlayElement*>(
overlayManager.createOverlayElement("Panel", realName));
result->setMetricsMode(Ogre::GMM_RELATIVE);
result->setMaterialName(matName); // Optional background material
// get the texture size
Ogre::String text = result->getMaterial()->getTechnique(0)->getPass(0)->
getTextureUnitState(0)->getTextureName();
Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().getByName(text);
ASSERT(!texture.isNull());
rSize = texture->getWidth();
return result;
}
示例15: ResizePreviewImage
void CLASS::ResizePreviewImage()
{
MyGUI::IntSize imgSize(0, 0);
Ogre::TexturePtr t = Ogre::TextureManager::getSingleton().load(m_preview_image_texture, Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME);
if (!t.isNull())
{
imgSize.width = (int)t->getWidth() * 10;
imgSize.height = (int)t->getHeight() * 10;
}
if (imgSize.width != 0 && imgSize.height != 0)
{
MyGUI::IntSize maxSize = m_PreviewBox->getSize();
float imgRatio = imgSize.width / (float)imgSize.height;
float maxRatio = maxSize.width / (float)maxSize.height;
MyGUI::IntSize newSize(0, 0);
MyGUI::IntPoint newPosition(0, 0);
// scale with aspect ratio
if (imgRatio > maxRatio)
{
newSize.width = maxSize.width;
newSize.height = maxSize.width / imgRatio;
newPosition.left = 0;
newPosition.top = maxSize.height - newSize.height;
}
else
{
newSize.width = maxSize.height * imgRatio;
newSize.height = maxSize.height;
newPosition.left = maxSize.width - newSize.width;
newPosition.top = 0;
}
m_Preview->setSize(newSize);
m_Preview->setPosition(newPosition);
}
}