本文整理汇总了C++中ogre::HardwarePixelBufferSharedPtr::unlock方法的典型用法代码示例。如果您正苦于以下问题:C++ HardwarePixelBufferSharedPtr::unlock方法的具体用法?C++ HardwarePixelBufferSharedPtr::unlock怎么用?C++ HardwarePixelBufferSharedPtr::unlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::HardwarePixelBufferSharedPtr
的用法示例。
在下文中一共展示了HardwarePixelBufferSharedPtr::unlock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: render
void VideoVisual::render(const cv::Mat& image)
{
// Fix image size if necessary
const cv::Mat* image_ptr = ℑ
cv::Mat converted_image;
if (image_ptr->rows != height_ || image_ptr->cols != width_)
{
cv::resize(*image_ptr, converted_image, cv::Size(width_, height_));
image_ptr = &converted_image;
}
// Get the pixel buffer
Ogre::HardwarePixelBufferSharedPtr pixelBuffer =
this->texture_->getBuffer();
// Lock the pixel buffer and get a pixel box
pixelBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD);
const Ogre::PixelBox& pixelBox = pixelBuffer->getCurrentLock();
uint8_t* pDest = static_cast<uint8_t*>(pixelBox.data);
memcpy(pDest, image_ptr->data, height_ * width_ * 4);
// Unlock the pixel buffer
pixelBuffer->unlock();
}
示例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: _copyImagePerPixel
//------------------------------------------------------------------------------
void OgreVideoTexture::_copyImagePerPixel(const IplImage *_image
,Ogre::HardwarePixelBufferSharedPtr _pixelBuffer)
{
// Lock the pixel buffer and get a pixel box
_pixelBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD); // for best performance use HBL_DISCARD!
const Ogre::PixelBox& pixelBox = _pixelBuffer->getCurrentLock();
Ogre::uint32* pDest = static_cast<Ogre::uint32*>(pixelBox.data);
size_t w, h, widthStep;
w = _image->width;
h = _image->height;
widthStep = _image->widthStep;
Ogre::uint32 pixelBGRA;
for(size_t i=0 ; i < h ; i++)
{
size_t offset = i*widthStep;
for (size_t j=0 ; j < w ; j++)
{
memcpy(&pixelBGRA, _image->imageData + offset +j*3, sizeof(Ogre::uint32));
pDest[i *1024 + j] = pixelBGRA;
}
}
_pixelBuffer->unlock();
}
示例4: _copyImagePerChannel
//------------------------------------------------------------------------------
void OgreVideoTexture::_copyImagePerChannel(const IplImage *_image
,Ogre::HardwarePixelBufferSharedPtr _pixelBuffer)
{
// Lock the pixel buffer and get a pixel box
_pixelBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD); // 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 < _image->height; j++)
for(size_t i = 0; i < _image->width ; i++)
{
char pixelR = CV_IMAGE_ELEM(_image, char, j, i*3+2 );
char pixelG = CV_IMAGE_ELEM(_image, char, j, i*3+1);
char pixelB = CV_IMAGE_ELEM(_image, char, j, i*3 );
int w = mVideoTexture->getWidth();
pDest[j*1024*4 + i*4] = pixelB;
pDest[j*1024*4 + i*4+1] = pixelG;
pDest[j*1024*4 + i*4+2] = pixelR;
//pDest[j*w*4 + i*4+3] = 255;
}
_pixelBuffer->unlock();
}
示例5: OnPaint
void RenderHandler::OnPaint(CefRefPtr<CefBrowser> browser, PaintElementType type, const RectList &dirtyRects, const void *buffer, int width, int height)
{
Ogre::HardwarePixelBufferSharedPtr texBuf = m_texture->getBuffer();
texBuf->lock(Ogre::HardwareBuffer::HBL_DISCARD);
memcpy(texBuf->getCurrentLock().data, buffer, width*height*4);
texBuf->unlock();
}
示例6: _updateVolTextureData
void DataManager::_updateVolTextureData(Cell ***c, const VolTextureId& TexId, const int& nx, const int& ny, const int& nz)
{
Ogre::HardwarePixelBufferSharedPtr buffer = mVolTextures[TexId]->getBuffer(0,0);
buffer->lock(Ogre::HardwareBuffer::HBL_DISCARD);
const Ogre::PixelBox &pb = buffer->getCurrentLock();
Ogre::uint32 *pbptr = static_cast<Ogre::uint32*>(pb.data);
size_t x, y, z;
for (z=pb.front; z<pb.back; z++)
{
for (y=pb.top; y<pb.bottom; y++)
{
for (x=pb.left; x<pb.right; x++)
{
Ogre::PixelUtil::packColour(c[x][y][z].dens/* TODO!!!! */, c[x][y][z].light, 0, 0, pb.format, &pbptr[x]);
}
pbptr += pb.rowPitch;
}
pbptr += pb.getSliceSkip();
}
buffer->unlock();
}
示例7: _updateNormalMap
bool TextureManager::_updateNormalMap(Image &Image)
{
if (!mCreated)
{
HydraxLOG("Error in TextureManager::_updateNormalMap, create() does not called.");
return false;
}
if (Image.getType() != Image::TYPE_RGB)
{
HydraxLOG("Error in TextureManager::_updateNormalMap, Image type isn't correct.");
return false;
}
Ogre::TexturePtr &Texture = getTexture(TEX_NORMAL_ID);
Size ImageSize = Image.getSize();
if (Texture->getWidth() != ImageSize.Width ||
Texture->getHeight() != ImageSize.Height)
{
HydraxLOG("Error in TextureManager::update, Update size doesn't correspond to " + getTextureName(TEX_NORMAL_ID) + " texture size");
return false;
}
Ogre::HardwarePixelBufferSharedPtr pixelBuffer = Texture->getBuffer();
pixelBuffer->lock(Ogre::HardwareBuffer::HBL_NORMAL);
const Ogre::PixelBox& pixelBox = pixelBuffer->getCurrentLock();
Ogre::uint8* pDest = static_cast<Ogre::uint8*>(pixelBox.data);
int x, y;
for (x = 0; x < ImageSize.Width; x++)
{
for (y = 0; y < ImageSize.Height; y++)
{
*pDest++ = Image.getValue(x,y,2); // B
*pDest++ = Image.getValue(x,y,1); // G
*pDest++ = Image.getValue(x,y,0); // R
*pDest++ = 255; // A
}
}
pixelBuffer->unlock();
return true;
}
示例8: renderIntoTexture
void UiManager::renderIntoTexture(const Ogre::TexturePtr &aTexture)
{
assert(!aTexture.isNull());
assert(isViewSizeMatching(aTexture));
Ogre::HardwarePixelBufferSharedPtr hwBuffer = aTexture->getBuffer(0, 0);
hwBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD);
const Ogre::PixelBox &pb = hwBuffer->getCurrentLock();
// render into texture buffer
QImage textureImg((uchar *)pb.data, pb.getWidth(), pb.getHeight(), QImage::Format_ARGB32);
textureImg.fill(0);
QPainter painter(&textureImg);
mWidgetView->render(&painter, QRect(QPoint(0, 0), mWidgetView->size()), QRect(QPoint(0, 0), mWidgetView->size()));
hwBuffer->unlock();
}
示例9: _copyImagePerLine
//------------------------------------------------------------------------------
void OgreVideoTexture::_copyImagePerLine(const IplImage *_image
,Ogre::HardwarePixelBufferSharedPtr _pixelBuffer)
{
// Lock the pixel buffer and get a pixel box
_pixelBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD); // for best performance use HBL_DISCARD!
const Ogre::PixelBox& pixelBox = _pixelBuffer->getCurrentLock();
//Ogre::uint32* pDest = static_cast<Ogre::uint32*>(pixelBox.data);
Ogre::uint8* pDest = static_cast<Ogre::uint8*>(pixelBox.data);
for (size_t i = 0 ; i < _image->height ; i++)
{
memcpy(pDest + i*1024*4
, (_image->imageData) + i*_image->width * 3
, _image->width * 3);
}
_pixelBuffer->unlock();
}
示例10: cleanTextureContents
void DirectShowMovieTexture::cleanTextureContents()
{
unsigned int idx;
int x, y;
// OGRE TEXTURE LOCK
// get the texture pixel buffer
int texw=mTexture->getWidth();
int texh=mTexture->getHeight();
Ogre::HardwarePixelBufferSharedPtr pixelBuffer = mTexture->getBuffer();
// lock the pixel buffer and get a pixel box
pixelBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD);
const Ogre::PixelBox& pixelBox = pixelBuffer->getCurrentLock();
Ogre::uint8* pDest = static_cast<Ogre::uint8*>(pixelBox.data);
// FILL!
for (x=0, y=0; y<texh; ){
idx=(x*4)+y*pixelBox.rowPitch*4;
// paint
pDest[idx]=0;//b
pDest[idx+1]=0;//g
pDest[idx+2]=0;//r
pDest[idx+3]=255;//a
x++;
if (x>=texw)
{
x=0;
y++;
}
}
// UNLOCK EVERYTHING!
// unlock the pixel buffer
pixelBuffer->unlock();
// OGRE END
}
示例11: mView
//-----------------------------------------------------------------------
CoherentUIView::CoherentUIView(Ogre::CoherentUIViewListener* listener, int width, int height, bool enableDepthWrite)
: mView(NULL)
{
mViewListener = OGRE_NEW CoherentUIViewListenerBridge(this, listener);
static int _textureCounter = 0;
Ogre::StringStream ss;
ss << "CoherentDynamicTexture" << ++_textureCounter;
Ogre::String textureName = ss.str();
ss << "_Mat";
Ogre::String materialName = ss.str();
// Create a texture
mTexture = TextureManager::getSingleton().createManual(
textureName,
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
TEX_TYPE_2D,
width,
height,
1,
PF_BYTE_BGRA,
TU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
// Clear the texture
Ogre::HardwarePixelBufferSharedPtr pixelBuffer = mTexture->getBuffer();
pixelBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD);
const Ogre::PixelBox& pixelBox = pixelBuffer->getCurrentLock();
Ogre::uint32* dest = static_cast<Ogre::uint32*>(pixelBox.data);
std::memset(dest, 0, (width * 4 + pixelBox.getRowSkip()) * height);
pixelBuffer->unlock();
// Create a material using the texture
mTextureMaterial = MaterialManager::getSingleton().create(
materialName,
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
mTextureMaterial->getTechnique(0)->getPass(0)->createTextureUnitState(textureName);
mTextureMaterial->getTechnique(0)->getPass(0)->setSceneBlending(SBF_ONE, SBF_ONE_MINUS_SOURCE_ALPHA);
mTextureMaterial->getTechnique(0)->getPass(0)->setDepthWriteEnabled(enableDepthWrite);
}
示例12: test
void test(const std::vector<std::vector<TxzFileSerializer::rgba>>& data)
{
//Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().load("clf_l.png.png", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
// kWorldResourceGroup
Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().createManual("BackgroundTex",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Ogre::TEX_TYPE_2D,
640, 256, 0,
Ogre::PF_B8G8R8, Ogre:: TU_DYNAMIC);
Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create("BackgroundMat",Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
material->getTechnique(0)->getPass(0)->createTextureUnitState("BackgroundTex");
//material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_COLOUR);
Ogre::HardwarePixelBufferSharedPtr pixelBuffer = texture->getBuffer();
pixelBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD);
const Ogre::PixelBox& pixelBox = pixelBuffer->getCurrentLock();
Ogre::uint8* pDest = static_cast<Ogre::uint8*>(pixelBox.data);
for(size_t i=0; i < 256; i++)
{
for(size_t j=0; j < 640; j++)
{
*pDest++ = data[i][j].b;
*pDest++ = data[i][j].g;
*pDest++ = data[i][j].r;
*pDest++ = 0;
}
}
pixelBuffer->unlock();
}
示例13: getRenderingOutput
/*!
Get the result of the rendering loop.
\param I : The image on which to copy the result of the rendering loop.
\param cMo : The desired camera pose.
*/
void vpAROgre::getRenderingOutput(vpImage<vpRGBa> &I, const vpHomogeneousMatrix &cMo)
{
updateCameraParameters(cMo);
Ogre::TexturePtr dynTexPtr = Ogre::TextureManager::getSingleton().getByName("rtf");
//#if ( OGRE_VERSION >= (1 << 16 | 9 << 8 | 0) )
// .dynamicCast<Ogre::Texture>();
//#else
// ;
//#endif
Ogre::RenderTexture* RTarget = dynTexPtr->getBuffer()->getRenderTarget();
mWindow->update();
RTarget->update();
if(I.getHeight() != mWindow->getHeight() || I.getWidth() != mWindow->getWidth()){
I.resize(mWindow->getHeight(), mWindow->getWidth());
}
Ogre::HardwarePixelBufferSharedPtr mPixelBuffer = dynTexPtr->getBuffer();
mPixelBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD);
const Ogre::PixelBox& pixelBox = mPixelBuffer->getCurrentLock();
dynTexPtr->getBuffer()->blitToMemory(pixelBox);
Ogre::uint8* pDest = static_cast<Ogre::uint8*>(pixelBox.data);
#if 1 // if texture in BGRa format
for(unsigned int i=0; i<I.getHeight(); i++){
for(unsigned int j=0; j<I.getWidth(); j++){
// Color Image
I[i][j].B = *pDest++; // Blue component
I[i][j].G = *pDest++; // Green component
I[i][j].R = *pDest++; // Red component
I[i][j].A = *pDest++; // Alpha component
}
}
#else // if texture in RGBa format which is the format of the input image
memcpy(I.bitmap, pDest, I.getHeight()*I.getWidth()*sizeof(vpRGBa));
#endif
// Unlock the pixel buffer
mPixelBuffer->unlock();
}
示例14: updateMovieTexture
void DirectShowMovieTexture::updateMovieTexture()
{
HRESULT hr;
unsigned int i, idx;
int x, y;
BYTE* bmpTmp;
// only do this if there is a graph that has been set up
if (!dsdata->pGraph)
return;
// Find the required buffer size.
long cbBuffer = 0;
hr = dsdata->pGrabber->GetCurrentBuffer(&cbBuffer, NULL);
if (cbBuffer<=0)
{
// nothing to do here yet
return;
}
char *pBuffer = new char[cbBuffer];
if (!pBuffer)
{
// out of memory!
throw("[DSHOW] Out of memory or empty buffer");
}
hr = dsdata->pGrabber->GetCurrentBuffer(&cbBuffer, (long*)pBuffer);
if (hr==E_INVALIDARG || hr==VFW_E_NOT_CONNECTED || hr==VFW_E_WRONG_STATE)
{
// we aren't buffering samples yet, do nothing
delete[] pBuffer;
return;
}
if (FAILED(hr)) throw("[DSHOW] Failed at GetCurrentBuffer!");
// OGRE BEGIN
// OGRE TEXTURE LOCK
// get the texture pixel buffer
int texw=mTexture->getWidth();
int texh=mTexture->getHeight();
Ogre::HardwarePixelBufferSharedPtr pixelBuffer = mTexture->getBuffer();
bmpTmp=(BYTE*)pBuffer;
// lock the pixel buffer and get a pixel box
pixelBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD);
const Ogre::PixelBox& pixelBox = pixelBuffer->getCurrentLock();
Ogre::uint8* pDest = static_cast<Ogre::uint8*>(pixelBox.data);
// FILL!
// check for mirroring...
bool shouldBeMirrored=mHorizontalMirroring;
if (shouldBeMirrored){
x=dsdata->videoWidth-1; y=dsdata->videoHeight-1;
}else{
x=0; y=dsdata->videoHeight-1;
}
// go set all bits...
for (i=0; i<(dsdata->videoWidth*dsdata->videoHeight*3); i+=3){
idx=(x*4)+y*pixelBox.rowPitch*4;
// paint
pDest[idx]=bmpTmp[i];//b
pDest[idx+1]=bmpTmp[i+1];//g
pDest[idx+2]=bmpTmp[i+2];//r
pDest[idx+3]=255;//a
if (shouldBeMirrored){
x--;
if (x<0){
x=dsdata->videoWidth-1;
y--; if (y<0) y=0;
}
}else{
x++;
if (x>=dsdata->videoWidth){
x=0;
y--; if (y<0) y=0;
}
}
}
// UNLOCK EVERYTHING!
// unlock the pixel buffer
pixelBuffer->unlock();
// OGRE END
// bye
delete[] pBuffer;
}
示例15: font
int
main( int argc, char *argv[] )
{
Ogre::Root* root;
Ogre::RenderWindow* window;
root = new Ogre::Root( "", "" );
#ifndef _DEBUG
root->loadPlugin( "RenderSystem_GL.dll" );
#else
root->loadPlugin( "RenderSystem_GL_d.dll" );
#endif
root->setRenderSystem( root->getAvailableRenderers()[ 0 ] );
root->initialise( false );
Ogre::NameValuePairList misc;
misc[ "title" ] = "FFVII Exporter";
window = root->createRenderWindow( "QGearsWindow", 800, 600, false, &misc );
FILESYSTEM = new FileSystem();
LOGGER = new Logger( "game.log" );
state = GAME;
{
BinGZipFile* file = new BinGZipFile( "data/en/WINDOW.BIN" );
File* font_graf = file->ExtractGZip( 1 );
File* font_padding = file->ExtractGZip( 2 );
FontFile font( font_padding );
font.Export( "export_en/ui/fonts/ffvii_en.xml", true );
//font_graf->WriteFile( "font.tim" );
Vram* vram = new Vram();
LoadTimFileToVram( font_graf, 0, vram );
//vram->Save( "text" );
Ogre::TexturePtr ptex;
Ogre::HardwarePixelBufferSharedPtr buffer;
ptex = Ogre::TextureManager::getSingleton().createManual( "DynaTex", "General", Ogre::TEX_TYPE_2D, 256, 256, 0, Ogre::PF_R8G8B8A8, Ogre::TU_STATIC );
buffer = ptex->getBuffer( 0, 0 );
buffer->lock( Ogre::HardwareBuffer::HBL_DISCARD );
const Ogre::PixelBox& pb = buffer->getCurrentLock();
CreateTextureFromVram( pb, vram, 0, 0, 0x80, 0x1f7, 0x380, 0x100, BPP_4 , false );
Ogre::Image image;
image.loadDynamicImage( ( Ogre::uchar* )pb.data, 256, 256, Ogre::PF_R8G8B8A8 );
image.save( "export_en/ui/fonts/ffvii_en.png" );
buffer->unlock();
delete vram;
delete file;
}
{
BinGZipFile* file = new BinGZipFile( "data/jp/WINDOW.BIN" );
File* font_graf = file->ExtractGZip( 1 );
File* font_graf2 = file->ExtractGZip( 2 );
File* font_padding = file->ExtractGZip( 3 );
font_padding->WriteFile( "font_padding.dat" );
FontFile font( font_padding );
font.Export( "export_jp/ui/fonts/ffvii_jp.xml", false );
font_graf->WriteFile( "font.tim" );
font_graf2->WriteFile( "font2.tim" );
Vram* vram = new Vram();
LoadTimFileToVram( font_graf, 0, vram );
LoadTimFileToVram( font_graf2, 0, vram );
//vram->Save( "text" );
Ogre::TexturePtr ptex;
Ogre::HardwarePixelBufferSharedPtr buffer;
ptex = Ogre::TextureManager::getSingleton().createManual( "DynaTex", "General", Ogre::TEX_TYPE_2D, 512, 256, 0, Ogre::PF_R8G8B8A8, Ogre::TU_STATIC );
buffer = ptex->getBuffer( 0, 0 );
buffer->lock( Ogre::HardwareBuffer::HBL_DISCARD );
const Ogre::PixelBox& pb = buffer->getCurrentLock();
CreateTextureFromVram( pb, vram, 0, 0, 0x80, 0x1f7, 0x380, 0x100, BPP_4 , false );
CreateTextureFromVram( pb, vram, 256, 0, 0x90, 0x1f7, 0x380, 0x100, BPP_4 , false );
Ogre::Image image;
image.loadDynamicImage( ( Ogre::uchar* )pb.data, 512, 256, Ogre::PF_R8G8B8A8 );
image.save( "export_jp/ui/fonts/ffvii_jp.png" );
buffer->unlock();
delete vram;
delete file;
}
{
File sword( "sword.tim" );
Vram* vram = new Vram();
LoadTimFileToVram( &sword, 0, vram );
//vram->Save( "sword" );
Ogre::TexturePtr ptex;
Ogre::HardwarePixelBufferSharedPtr buffer;
ptex = Ogre::TextureManager::getSingleton().createManual( "DynaTex", "General", Ogre::TEX_TYPE_2D, 256, 256, 0, Ogre::PF_R8G8B8A8, Ogre::TU_STATIC );
buffer = ptex->getBuffer( 0, 0 );
buffer->lock( Ogre::HardwareBuffer::HBL_DISCARD );
//.........这里部分代码省略.........