Code: Select all
abstract hlms BaseSettingsAlphaBlend unlit
{
scene_blend alpha_blend
depth_check off
depth_write off
cull_mode none
}
hlms radar_mat unlit : BaseSettingsAlphaBlend
{
diffuse_map radar.png
}
So I try to change some pixels in the texture like so:
Code: Select all
void DynamicOverlayElement::lock() {
const Ogre::TexturePtr &texture = datablock->getTexture(0);
const Ogre::v1::HardwarePixelBufferSharedPtr &hardwarePixelBuffer = texture->getBuffer();
currentBuffer = hardwarePixelBuffer.getPointer();
const Ogre::PixelBox &box = hardwarePixelBuffer->lock(Ogre::Image::Box(0, 0, 0,
hardwarePixelBuffer->getWidth(),
hardwarePixelBuffer->getHeight(), 1), Ogre::v1::HardwarePixelBuffer::LockOptions::HBL_NORMAL);
currentLock = (Ogre::PixelBox *) &box;
}
void DynamicOverlayElement::unlock() {
currentBuffer->unlock();
currentLock = NULL;
// lockPtr = NULL;
}
DynamicOverlayBox DynamicOverlayElement::setAreaToColor(Ogre::Box &rect,
std::vector<Ogre::ColourValue> &val,
bool overwriteTransparentPixels) {
if (rect.getWidth() * rect.getHeight() != val.size())
{
::Ogre::String errorStr("rect width: " + SSTR(rect.getWidth()) +
" height: " + SSTR(rect.getHeight()) +
" different from colour size: " + SSTR(val.size()));
LOGI("%s", errorStr.c_str());
exit(-1);
}
rect.left = std::max(rect.left, currentLock->left);
rect.top = std::max(rect.top, currentLock->top);
rect.front = std::max(rect.front, currentLock->front);
rect.right = std::min(rect.right, currentLock->right);
rect.bottom = std::min(rect.bottom, currentLock->bottom);
rect.back = std::min(rect.back, currentLock->back);
const Ogre::PixelBox &volume = currentLock->getSubVolume(rect);
size_t bytesPerPixel = Ogre::PixelUtil::getNumElemBytes(currentLock->format);
Hotshot::DynamicOverlayBox oldElement;
oldElement.rect = rect;
int colorPos = 0;
int* data = (int *) volume.data;
for (int y = 0; y < volume.bottom; ++y)
{
for (int x = 0; x < volume.right; ++x) {
Ogre::ColourValue oldCol;
int prevData = *data;
switch (currentLock->format) {
case Ogre::PF_A8R8G8B8:
#if O32_HOST_ORDER == O32_LITTLE_ENDIAN
oldCol.setAsBGRA(prevData);
#else
oldCol.setAsARGB(prevData);
#endif
break;
case Ogre::PF_R8G8B8A8:
#if O32_HOST_ORDER == O32_LITTLE_ENDIAN
oldCol.setAsABGR(prevData);
#else
oldCol.setAsRGBA(prevData);
#endif
break;
default:
LOGI("%s", "Only A8R8G8B8 and R8G8B8A8");
exit(-1);
}
// Add it anyway for corner cases when even though we don't
// overwrite we still need the value for when we reset the texture
oldElement.color.push_back(oldCol);
if (!overwriteTransparentPixels && oldCol.a == 0.0f) {
// Don't forget to add the offset!!!!!!
++data;
continue;
}
Ogre::ColourValue &newCol = val[colorPos];
int newData;
switch (currentLock->format) {
case Ogre::PF_A8R8G8B8:
#if O32_HOST_ORDER == O32_LITTLE_ENDIAN
newData = newCol.getAsBGRA();
#else
newData = newCol.getAsARGB();
#endif
break;
case Ogre::PF_R8G8B8A8:
#if O32_HOST_ORDER == O32_LITTLE_ENDIAN
newData = newCol.getAsABGR();
#else
newData = newCol.getAsRGBA();
#endif
break;
default:
LOGI("%s", "Only A8R8G8B8 and R8G8B8A8");
exit(-1);
}
*data++ = newData;
}
data += currentLock->getRowSkip();
}
return oldElement;
}
Is this normal behavior, not to be able to update textures once they get in a texture array?
EDIT: If I just lock the texture buffer I get
Code: Select all
D3D11 ERROR: ID3D11DeviceContext::CopySubresourceRegion: pSrcBox is not a valid box for the source subresource. *pSrcBox = { left:0, top:0, front:0, right:64, bottom:64, back:40 }. SrcSubresource = { left:0, top:0, front:0, right:64, bottom:64, back:1 }. [ RESOURCE_MANIPULATION ERROR #280: COPYSUBRESOURCEREGION_INVALIDSOURCEBOX]
D3D11 ERROR: ID3D11DeviceContext::CopySubresourceRegion: When offset by the destination coordinates, pSrcBox does not fit on the destination subresource. OffsetSrcBox = { left:0, top:0, front:0, right:64, bottom:64, back:40 }. DstSubresource = { left:0, top:0, front:0, right:64, bottom:64, back:1 }. [ RESOURCE_MANIPULATION ERROR #280: COPYSUBRESOURCEREGION_INVALIDSOURCEBOX]
D3D11 ERROR: ID3D11DeviceContext::CopySubresourceRegion: pSrcBox is not a valid box for the source subresource. *pSrcBox = { left:0, top:0, front:0, right:64, bottom:64, back:40 }. SrcSubresource = { left:0, top:0, front:0, right:64, bottom:64, back:1 }. [ RESOURCE_MANIPULATION ERROR #280: COPYSUBRESOURCEREGION_INVALIDSOURCEBOX]
D3D11 ERROR: ID3D11DeviceContext::CopySubresourceRegion: When offset by the destination coordinates, pSrcBox does not fit on the destination subresource. OffsetSrcBox = { left:0, top:0, front:0, right:64, bottom:64, back:40 }. DstSubresource = { left:0, top:0, front:0, right:64, bottom:64, back:1 }. [ RESOURCE_MANIPULATION ERROR #280: COPYSUBRESOURCEREGION_INVALIDSOURCEBOX]