在Ogre3D中,如何将纹理像素值导出到物理内存

时间:2014-11-14 06:40:46

标签: ogre ogre3d

我正在使用Ogre3D。

我的纹理定义为:

rtt_texture = Ogre::TextureManager::getSingleton().createManual("RttTex", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, texWidth, texHeight, 0, Ogre::PF_R8G8B8, Ogre::TU_RENDERTARGET);

我正在尝试使用以下代码将其像素值复制到内存中,但我获得的数据与呈现的数据不同:

unsigned char* data = new unsigned char[texWidth * texHeight * 3];
data = (unsigned char*)rtt_texture->getBuffer()->lock(0, texWidth*texHeight*3, Ogre::HardwareBuffer::HBL_READ_ONLY);

这里有错误吗?

1 个答案:

答案 0 :(得分:0)

我发现我确实需要更换

texWidth * texHeight * 3

到处都是

texWidth * texHeight * 4
相关问题