mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-27 12:35:46 +00:00
code is shorter, thanks scrawl
This commit is contained in:
parent
465914c77c
commit
11922dc53a
@ -109,23 +109,11 @@ bool CSVRender::PagedWorldspaceWidget::adjustCells()
|
|||||||
texture = Ogre::TextureManager::getSingleton().createManual("CellBillboardTexture" + iter->getId(mWorldspace),
|
texture = Ogre::TextureManager::getSingleton().createManual("CellBillboardTexture" + iter->getId(mWorldspace),
|
||||||
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
|
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
|
||||||
Ogre::TEX_TYPE_2D, 1024, 1024, 1, Ogre::PF_X8R8G8B8, Ogre::TU_DEFAULT);
|
Ogre::TEX_TYPE_2D, 1024, 1024, 1, Ogre::PF_X8R8G8B8, Ogre::TU_DEFAULT);
|
||||||
Ogre::HardwarePixelBufferSharedPtr pixelBuffer = texture->getBuffer();
|
|
||||||
pixelBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD);
|
|
||||||
const Ogre::PixelBox& pixBox = pixelBuffer->getCurrentLock();
|
|
||||||
|
|
||||||
Ogre::uint8* pDest = static_cast<Ogre::uint8*>(pixBox.data);
|
int w = 1024;
|
||||||
for (size_t i = 0, width = texture->getWidth(); i < width; ++i)
|
int h = 1024;
|
||||||
{
|
Ogre::DataStreamPtr stream(new Ogre::MemoryDataStream((void*)image.constBits(), w*h*Ogre::PixelUtil::getNumElemBytes(Ogre::PixelFormat::PF_R8G8B8), false));
|
||||||
for (size_t j = 0, height = texture->getHeight(); j < height; ++j)
|
texture->loadRawData(stream, w, h, Ogre::PixelFormat::PF_R8G8B8);
|
||||||
{
|
|
||||||
QRgb color = image.pixel(QPoint(j,i));
|
|
||||||
*pDest++ = qBlue(color);
|
|
||||||
*pDest++ = qGreen(color);
|
|
||||||
*pDest++ = qRed(color);
|
|
||||||
*pDest++ = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pixelBuffer->unlock();
|
|
||||||
texture->load();
|
texture->load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user