本文整理汇总了C++中HardwarePixelBufferSharedPtr类的典型用法代码示例。如果您正苦于以下问题:C++ HardwarePixelBufferSharedPtr类的具体用法?C++ HardwarePixelBufferSharedPtr怎么用?C++ HardwarePixelBufferSharedPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HardwarePixelBufferSharedPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateTerPrv
/// update terrain generator preview texture
//--------------------------------------------------------------------------------------------------------------------------
void App::updateTerPrv(bool first)
{
if (!first && !ovTerPrv) return;
if (terPrvTex.isNull()) return;
HardwarePixelBufferSharedPtr pbuf = terPrvTex->getBuffer();
pbuf->lock(HardwareBuffer::HBL_DISCARD);
const PixelBox& pb = pbuf->getCurrentLock(); using Ogre::uint8;
uint8* p = static_cast<uint8*>(pb.data);
const static float fB[2] = { 90.f, 90.f}, fG[2] = {255.f,160.f}, fR[2] = { 90.f,255.f};
const float s = TerPrvSize * 0.5f, s1 = 1.f/s;
const float ox = pSet->gen_ofsx, oy = pSet->gen_ofsy;
for (int y = 0; y < TerPrvSize; ++y)
for (int x = 0; x < TerPrvSize; ++x)
{ float fx = ((float)x - s)*s1, fy = ((float)y - s)*s1; // -1..1
float c = Noise(x*s1-oy, y*s1+ox, pSet->gen_freq, pSet->gen_oct, pSet->gen_persist) * 0.8f; // par fit
bool b = c >= 0.f;
c = b ? powf(c, pSet->gen_pow) : -powf(-c, pSet->gen_pow);
int i = b ? 0 : 1; c = b ? c : -c;
//c *= pSet->gen_scale; //no
uint8 bR = c * fR[i], bG = c * fG[i], bB = c * fB[i];
*p++ = bR; *p++ = bG; *p++ = bB; *p++ = 255;//bG > 32 ? 255 : 0;
}
pbuf->unlock();
}
示例2: generateRandomVelocityTexture
TexturePtr RandomTools::generateRandomVelocityTexture()
{
// PPP: Temp workaround for DX 11 which does not seem to like usage dynamic
// TextureUsage usage = (Root::getSingletonPtr()->getRenderSystem()->getName()=="Direct3D11 Rendering Subsystem") ?
// TU_DEFAULT : TU_DYNAMIC;
TexturePtr texPtr = TextureManager::getSingleton().createManual(
"RandomVelocityTexture",
// ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
"General",
TEX_TYPE_1D,
1024, 1, 1,
0,
PF_FLOAT32_RGBA);//,
//usage);
HardwarePixelBufferSharedPtr pixelBuf = texPtr->getBuffer();
// Lock the buffer so we can write to it.
pixelBuf->lock(HardwareBuffer::HBL_DISCARD);
const PixelBox &pb = pixelBuf->getCurrentLock();
float *randomData = static_cast<float*>(pb.data);
// float randomData[NUM_RAND_VALUES * 4];
for(int i = 0; i < NUM_RAND_VALUES * 4; i++)
{
randomData[i] = float( (rand() % 10000) - 5000 );
}
// PixelBox pixelBox(1024, 1, 1, PF_FLOAT32_RGBA, &randomData[0]);
// pixelBuf->blitFromMemory(pixelBox);
pixelBuf->unlock();
return texPtr;
}
示例3: blit
//-----------------------------------------------------------------------------
void HardwarePixelBuffer::blit(const HardwarePixelBufferSharedPtr &src)
{
blit(src,
Box(0,0,0,src->getWidth(),src->getHeight(),src->getDepth()),
Box(0,0,0,mWidth,mHeight,mDepth)
);
}
示例4: blit
void HardwarePixelBuffer::blit(const HardwarePixelBufferSharedPtr &src, const Image::Box &srcBox, const Image::Box &dstBox)
{
if (isLocked() || src->isLocked())
{
WIND_EXCEPT(Exception::ERR_INTERNAL_ERROR,
"Source and destination buffer may not be locked!",
"HardwarePixelBuffer::blit");
}
if (src.get() == this)
{
WIND_EXCEPT(Exception::ERR_INVALIDPARAMS,
"Source must not be the same object",
"HardwarePixelBuffer::blit");
}
const PixelBox &srclock = src->lock(srcBox, HBL_READ_ONLY);
LockOptions method = HBL_NORMAL;
if (dstBox.left == 0 && dstBox.top == 0 && dstBox.front == 0 && dstBox.right == mWidth && dstBox.bottom == mHeight && dstBox.back == mDepth)
{
method = HBL_DISCARD;
}
const PixelBox &dstlock = lock(dstBox, method);
if (dstlock.getWidth() != srclock.getWidth() || dstlock.getHeight() != srclock.getHeight() || dstlock.getDepth() != srclock.getDepth())
{
Image::scale(srclock, dstlock);
}
else
{
PixelUtil::bulkPixelConversion(srclock, dstlock);
}
unlock();
src->unlock();
}
示例5: updateTexture
void CoverageMap::updateTexture()
{
// write the edit buffer into the texture's pixel buffer
HardwarePixelBufferSharedPtr buffer = mTexture->getBuffer();
PixelBox pixelBox (mWidth, mHeight, 1, getFormat(mChannels), mData);
Image::Box imageBox (0, 0, mWidth, mHeight);
buffer->blitFromMemory(pixelBox, imageBox);
}
示例6: if
void WebView::createMaterial()
{
if(opacity > 1) opacity = 1;
else if(opacity < 0) opacity = 0;
if(!Bitwise::isPO2(viewWidth) || !Bitwise::isPO2(viewHeight))
{
if(Root::getSingleton().getRenderSystem()->getCapabilities()->hasCapability(RSC_NON_POWER_OF_2_TEXTURES))
{
if(Root::getSingleton().getRenderSystem()->getCapabilities()->getNonPOW2TexturesLimited())
compensateNPOT = true;
}
else compensateNPOT = true;
#ifdef __APPLE__
//cus those fools always report #t when I ask if they support this or that
//and then fall back to their buggy and terrible software driver which has never once in my life rendered a single correct frame.
compensateNPOT=true;
#endif
if(compensateNPOT)
{
texWidth = Bitwise::firstPO2From(viewWidth);
texHeight = Bitwise::firstPO2From(viewHeight);
}
}
// Create the texture
#if defined(HAVE_AWESOMIUM) || !defined(__APPLE__)
TexturePtr texture = TextureManager::getSingleton().createManual(
viewName + "Texture", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
TEX_TYPE_2D, texWidth, texHeight, 0, PF_BYTE_BGRA,
TU_DYNAMIC_WRITE_ONLY_DISCARDABLE, this);
HardwarePixelBufferSharedPtr pixelBuffer = texture->getBuffer();
pixelBuffer->lock(HardwareBuffer::HBL_DISCARD);
const PixelBox& pixelBox = pixelBuffer->getCurrentLock();
texDepth = Ogre::PixelUtil::getNumElemBytes(pixelBox.format);
texPitch = (pixelBox.rowPitch*texDepth);
uint8* pDest = static_cast<uint8*>(pixelBox.data);
memset(pDest, 128, texHeight*texPitch);
pixelBuffer->unlock();
#endif
MaterialPtr material = MaterialManager::getSingleton().create(viewName + "Material",
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
matPass = material->getTechnique(0)->getPass(0);
matPass->setSceneBlending(SBT_TRANSPARENT_ALPHA);
matPass->setDepthWriteEnabled(false);
baseTexUnit = matPass->createTextureUnitState(viewName + "Texture");
baseTexUnit->setTextureFiltering(texFiltering, texFiltering, FO_NONE);
if(texFiltering == FO_ANISOTROPIC)
baseTexUnit->setTextureAnisotropy(4);
}
示例7: createHalftoneTexture
bool gkOgreCompositorHelper::createHalftoneTexture()
{
using namespace Ogre;
try
{
if (TextureManager::getSingleton().resourceExists(COMP_HALFTONE_TEX_NAME))
return true; //already created
TexturePtr tex = TextureManager::getSingleton().createManual(
COMP_HALFTONE_TEX_NAME,
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
TEX_TYPE_3D,
64,64,64,
0,
PF_A8
);
HardwarePixelBufferSharedPtr ptr = tex->getBuffer(0,0);
ptr->lock(HardwareBuffer::HBL_DISCARD);
const PixelBox &pb = ptr->getCurrentLock();
uint8 *data = static_cast<uint8*>(pb.data);
size_t height = pb.getHeight();
size_t width = pb.getWidth();
size_t depth = pb.getDepth();
size_t rowPitch = pb.rowPitch;
size_t slicePitch = pb.slicePitch;
for (size_t z = 0; z < depth; ++z)
{
for (size_t y = 0; y < height; ++y)
{
for(size_t x = 0; x < width; ++x)
{
float fx = 32-(float)x+0.5f;
float fy = 32-(float)y+0.5f;
float fz = 32-((float)z)/3+0.5f;
float distanceSquare = fx*fx+fy*fy+fz*fz;
data[slicePitch*z + rowPitch*y + x] = 0x00;
if (distanceSquare < 1024.0f)
data[slicePitch*z + rowPitch*y + x] += 0xFF;
}
}
}
ptr->unlock();
}
catch (Exception &e)
{
gkPrintf("[CMP] FAILED - Halftone Texture Creation. %s", e.getFullDescription().c_str());
return false;
}
return true;
}
示例8: createMaterial
void FlashControl::createMaterial()
{
texture.setNull();
MaterialManager::getSingletonPtr()->remove(name + "Material");
TextureManager::getSingletonPtr()->remove(name + "Texture");
texWidth = width;
texHeight = height;
if(!Bitwise::isPO2(width) || !Bitwise::isPO2(height))
{
if(Root::getSingleton().getRenderSystem()->getCapabilities()->hasCapability(RSC_NON_POWER_OF_2_TEXTURES))
{
if(Root::getSingleton().getRenderSystem()->getCapabilities()->getNonPOW2TexturesLimited())
compensateNPOT = true;
}
else compensateNPOT = true;
if(compensateNPOT)
{
texWidth = Bitwise::firstPO2From(width);
texHeight = Bitwise::firstPO2From(height);
}
}
// Create the texture
texture = TextureManager::getSingleton().createManual(
name + "Texture", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
TEX_TYPE_2D, (uint)texWidth, (uint)texHeight, 0, isTransparent? PF_BYTE_BGRA : PF_BYTE_BGR,
TU_DYNAMIC_WRITE_ONLY_DISCARDABLE, this);
HardwarePixelBufferSharedPtr pixelBuffer = texture->getBuffer();
pixelBuffer->lock(HardwareBuffer::HBL_DISCARD);
const PixelBox& pixelBox = pixelBuffer->getCurrentLock();
texDepth = Ogre::PixelUtil::getNumElemBytes(pixelBox.format);
texPitch = (pixelBox.rowPitch*texDepth);
uint8* pDest = static_cast<uint8*>(pixelBox.data);
memset(pDest, 128, texHeight*texPitch);
pixelBuffer->unlock();
materialName = name + "Material";
MaterialPtr material = MaterialManager::getSingleton().create(materialName, ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
Pass* matPass = material->getTechnique(0)->getPass(0);
matPass->setSceneBlending(SBT_TRANSPARENT_ALPHA);
matPass->setDepthWriteEnabled(false);
texUnit = matPass->createTextureUnitState(name + "Texture");
texUnit->setTextureFiltering(FO_NONE, FO_NONE, FO_NONE);
invalidateTotally();
}
示例9: update
//-----------------------------------------------------------------------
void PagingLandScapeHorizon::update()
{
if (material_enabled)
{
const PixelBox srcBox = mVisImage.getPixelBox();
HardwarePixelBufferSharedPtr Texbuffer = mVisTex->getBuffer (0, 0);
const PixelBox lock = Texbuffer->lock (srcBox, HardwareBuffer::HBL_DISCARD);
// lock.data can now be freely accessed
PixelUtil::bulkPixelConversion(srcBox, lock);
Texbuffer->unlock();
}
}
示例10: SaveImage
void SaveImage(TexturePtr TextureToSave, String filename)
{
HardwarePixelBufferSharedPtr readbuffer;
readbuffer = TextureToSave->getBuffer(0, 0);
readbuffer->lock(HardwareBuffer::HBL_NORMAL );
const PixelBox &readrefpb = readbuffer->getCurrentLock();
uchar *readrefdata = static_cast<uchar*>(readrefpb.data);
Image img;
img = img.loadDynamicImage (readrefdata, TextureToSave->getWidth(),
TextureToSave->getHeight(), TextureToSave->getFormat());
img.save(filename);
readbuffer->unlock();
}
示例11: blit
//-----------------------------------------------------------------------------
void GLESTextureBuffer::blit(const HardwarePixelBufferSharedPtr &src, const Image::Box &srcBox, const Image::Box &dstBox)
{
GLESTextureBuffer *srct = static_cast<GLESTextureBuffer *>(src.getPointer());
// TODO: Check for FBO support first
// Destination texture must be 2D
// Source texture must be 2D
if((src->getUsage() & TU_RENDERTARGET) == 0 && (srct->mTarget == GL_TEXTURE_2D))
{
blitFromTexture(srct, srcBox, dstBox);
}
else
{
GLESHardwarePixelBuffer::blit(src, srcBox, dstBox);
}
}
示例12: getMaterial
MaterialPtr Visuals::getMaterial(std::string name, int red, int green, int blue, int alpha) {
// Create the texture
TexturePtr texture = TextureManager::getSingleton().createManual(
name, // name
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
TEX_TYPE_2D, // type
256, 256, // width & height
0, // number of mipmaps
PF_BYTE_BGRA, // pixel format
TU_DEFAULT); // usage; should be TU_DYNAMIC_WRITE_ONLY_DISCARDABLE for
// textures updated very often (e.g. each frame)
// Get the pixel buffer
HardwarePixelBufferSharedPtr pixelBuffer = texture->getBuffer();
// Lock the pixel buffer and get a pixel box
pixelBuffer->lock(HardwareBuffer::HBL_NORMAL); // for best performance use HBL_DISCARD!
const PixelBox& pixelBox = pixelBuffer->getCurrentLock();
uint8* pDest = static_cast<uint8*>(pixelBox.data);
// Fill in some pixel data. This will give a semi-transparent blue,
// but this is of course dependent on the chosen pixel format.
for (size_t j = 0; j < 256; j++) {
for(size_t i = 0; i < 256; i++)
{
*pDest++ = blue; // B
*pDest++ = green; // G
*pDest++ = red; // R
*pDest++ = alpha; // A
}
}
// Unlock the pixel buffer
pixelBuffer->unlock();
MaterialPtr material = MaterialManager::getSingleton().create(name, ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
material->getTechnique(0)->getPass(0)->createTextureUnitState(name);
material->getTechnique(0)->getPass(0)->setSceneBlending(SBT_TRANSPARENT_ALPHA);
return material;
}
示例13: return
/* static MaterialPtr MakeDefaultMaterial()
{
const int def_width=256;
const int def_height=256;
const char*defTexName="DefaultTexture";
const char*defMatName="DefaultMaterial";
if( MaterialManager::getSingleton().resourceExists(defMatName))
return (MaterialPtr)MaterialManager::getSingleton().getByName(defMatName);
TexturePtr texture = TextureManager::getSingleton().createManual(
defTexName, // name
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
TEX_TYPE_2D, // type
def_width, def_height, // width & height
0, // number of mipmaps
PF_BYTE_RGBA, // pixel format
TU_DEFAULT); // usage; should be TU_DYNAMIC_WRITE_ONLY_DISCARDABLE for
// textures updated very often (e.g. each frame)
// Get the pixel buffer
HardwarePixelBufferSharedPtr pixelBuffer = texture->getBuffer();
// Lock the pixel buffer and get a pixel box
pixelBuffer->lock(HardwareBuffer::HBL_NORMAL); // for best performance use HBL_DISCARD!
const PixelBox& pixelBox = pixelBuffer->getCurrentLock();
uint8* pDest = static_cast<uint8*>(pixelBox.data);
// Fill in some pixel data. This will give a semi-transparent blue,
// but this is of course dependent on the chosen pixel format.
for (size_t j = 0; j < def_height; j++)
for(size_t i = 0; i < def_width; i++)
{
*pDest++ = 255; // R
*pDest++ = 0; // G
*pDest++ = 255; // B
*pDest++ = 255; // A
}
// Unlock the pixel buffer
pixelBuffer->unlock();
// Create a material using the texture
MaterialPtr material = MaterialManager::getSingleton().create(
defMatName, // name
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
material->getTechnique(0)->getPass(0)->createTextureUnitState(defTexName);
//material->getTechnique(0)->getPass(0)->setSceneBlending(SBT_TRANSPARENT_ALPHA);
return material;
}
MaterialPtr GetLodMaterial(const std::string& name)
{
std::string matname(name + ".Material");
std::string texname(name + ".Texture");
if( MaterialManager::getSingleton().resourceExists(matname))
return (MaterialPtr)MaterialManager::getSingleton().getByName(matname);
TexturePtr texture;
int alpha = 0;
if(TextureManager::getSingleton().resourceExists(texname))
{
texture=TextureManager::getSingleton().getByName(texname);
}else
{
angel::pLodData ldata=angel::LodManager.LoadFile( name );
BYTE*data= &((*ldata)[0]);
if(!data)
return MakeDefaultMaterial();
int size = (int)ldata->size();
int psize = *(int*)(data+0x14);
unsigned int unpsize1 = *(int*)(data+0x10);
unsigned long unpsize2 = *(int*)(data+0x28);
if( psize+0x30+0x300 != size )
return MakeDefaultMaterial();
if( unpsize2 && unpsize2 < unpsize1)
return MakeDefaultMaterial();
BYTE* pal = data + 0x30 + psize;
BYTE*unpdata = new BYTE[unpsize2 ];
boost::scoped_array<BYTE> sunpdata(unpdata);
if ( uncompress( unpdata, &unpsize2 , data + 0x30, psize ) != Z_OK )
return MakeDefaultMaterial();
int width = *(WORD*)(data+0x18);
int height = *(WORD*)(data+0x1a);
int imgsize = width*height;
BYTE *pSrc=unpdata;
// Create the texture
texture = TextureManager::getSingleton().createManual(
name + ".Texture", // name
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
TEX_TYPE_2D, // type
width, height, // width & height
0, // number of mipmaps
PF_BYTE_BGRA, // pixel format
TU_DEFAULT); // usage; should be TU_DYNAMIC_WRITE_ONLY_DISCARDABLE for
//.........这里部分代码省略.........
示例14: createDitherTexture
bool gkOgreCompositorHelper::createDitherTexture(int width, int height)
{
using namespace Ogre;
try
{
if (TextureManager::getSingleton().resourceExists(COMP_DITHER_TEX_NAME))
return true; //already created
TexturePtr tex = TextureManager::getSingleton().createManual(
COMP_DITHER_TEX_NAME,
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
TEX_TYPE_2D,
width, height, 1,
0,
PF_A8
);
HardwarePixelBufferSharedPtr ptr = tex->getBuffer(0,0);
ptr->lock(HardwareBuffer::HBL_DISCARD);
const PixelBox &pb = ptr->getCurrentLock();
uint8 *data = static_cast<uint8*>(pb.data);
size_t height = pb.getHeight();
size_t width = pb.getWidth();
size_t rowPitch = pb.rowPitch;
for (size_t y = 0; y < height; ++y)
for(size_t x = 0; x < width; ++x)
data[rowPitch*y + x] = (uint8)Ogre::Math::RangeRandom(64.0,192);
ptr->unlock();
}
catch (Exception &e)
{
gkPrintf("[CMP] FAILED - Dither Texture Creation. %s", e.getFullDescription().c_str());
return false;
}
return true;
}
示例15: setPanelColor
void OgreText::setPanelColor(int R, int G, int B, int I)
{
// Get the pixel buffer
HardwarePixelBufferSharedPtr pixelBuffer = texture_->getBuffer();
//directly modify pixel buffer in texture to change color
// Lock the pixel buffer and get a pixel box
pixelBuffer->lock(HardwareBuffer::HBL_NORMAL); // for best performance use HBL_DISCARD!
const PixelBox& pixelBox = pixelBuffer->getCurrentLock();
uint8* pDest = static_cast<uint8*>(pixelBox.data);
*pDest++ = R;
*pDest++ = G;
*pDest++ = B;
*pDest++ = I;
// Unlock the pixel buffer
pixelBuffer->unlock();
}