当前位置: 首页>>代码示例>>C++>>正文


C++ HardwarePixelBufferSharedPtr::lock方法代码示例

本文整理汇总了C++中HardwarePixelBufferSharedPtr::lock方法的典型用法代码示例。如果您正苦于以下问题:C++ HardwarePixelBufferSharedPtr::lock方法的具体用法?C++ HardwarePixelBufferSharedPtr::lock怎么用?C++ HardwarePixelBufferSharedPtr::lock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HardwarePixelBufferSharedPtr的用法示例。


在下文中一共展示了HardwarePixelBufferSharedPtr::lock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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();
	}
开发者ID:523793658,项目名称:directX,代码行数:32,代码来源:HardwarePixelBuffer.cpp

示例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;
}
开发者ID:LiberatorUSA,项目名称:GUCEF,代码行数:35,代码来源:RandomTools.cpp

示例3: 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();
}
开发者ID:dhwanivakhariya,项目名称:stuntrally,代码行数:33,代码来源:TerrainEdit.cpp

示例4: createMaterial

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);
}
开发者ID:danx0r,项目名称:sirikata,代码行数:57,代码来源:WebView.cpp

示例5: 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;
}
开发者ID:guozanhua,项目名称:OgreKit,代码行数:57,代码来源:gkOgreCompositorHelper.cpp

示例6: 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();

}
开发者ID:yingzhang536,项目名称:mrayy-Game-Engine,代码行数:55,代码来源:FlashControl.cpp

示例7: 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();  
        }
    }
开发者ID:holocronweaver,项目名称:python-ogre,代码行数:15,代码来源:OgrePagingLandScapeHorizon.cpp

示例8: generate

void Sample_VolumeTex::generate()
{
    /* Evaluate julia fractal for each point */
    Julia julia(global_real, global_imag, global_theta);
    const float scale = 2.5;
    const float vcut = 29.0f;
    const float vscale = 1.0f/vcut;

    HardwarePixelBufferSharedPtr buffer = ptex->getBuffer(0, 0);
    Ogre::StringStream d;
    d << "HardwarePixelBuffer " << buffer->getWidth() << " " << buffer->getHeight() << " " << buffer->getDepth();
    LogManager::getSingleton().logMessage(d.str());

    buffer->lock(HardwareBuffer::HBL_NORMAL);
    const PixelBox &pb = buffer->getCurrentLock();
    d.str("");
    d << "PixelBox " << pb.getWidth() << " " << pb.getHeight() << " " << pb.getDepth() << " " << pb.rowPitch << " " << pb.slicePitch << " " << pb.data << " " << PixelUtil::getFormatName(pb.format);
    LogManager::getSingleton().logMessage(d.str());

    Ogre::uint32 *pbptr = static_cast<Ogre::uint32*>(pb.data);
    for(size_t z=pb.front; z<pb.back; z++)
    {
        for(size_t y=pb.top; y<pb.bottom; y++)
        {
            for(size_t x=pb.left; x<pb.right; x++)
            {
                if(z==pb.front || z==(pb.back-1) || y==pb.top|| y==(pb.bottom-1) ||
                        x==pb.left || x==(pb.right-1))
                {
                    // On border, must be zero
                    pbptr[x] = 0;
                }
                else
                {
                    float val = julia.eval(((float)x/pb.getWidth()-0.5f) * scale,
                                           ((float)y/pb.getHeight()-0.5f) * scale,
                                           ((float)z/pb.getDepth()-0.5f) * scale);
                    if(val > vcut)
                        val = vcut;

                    PixelUtil::packColour((float)x/pb.getWidth(), (float)y/pb.getHeight(), (float)z/pb.getDepth(), (1.0f-(val*vscale))*0.7f, PF_A8R8G8B8, &pbptr[x]);

                }
            }
            pbptr += pb.rowPitch;
        }
        pbptr += pb.getSliceSkip();
    }
    buffer->unlock();
}
开发者ID:OGRECave,项目名称:ogre,代码行数:50,代码来源:VolumeTex.cpp

示例9: 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();
}
开发者ID:TheLonetrucker,项目名称:rigs-of-rods,代码行数:15,代码来源:WriteTextToTexture.cpp

示例10: 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;
}
开发者ID:prettyv,项目名称:rauschabstand,代码行数:44,代码来源:Visuals.cpp

示例11: GetLodMaterial

/*	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


//.........这里部分代码省略.........
开发者ID:angeld29,项目名称:mm_mapview2,代码行数:101,代码来源:lodtexture.cpp

示例12: 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;
}
开发者ID:guozanhua,项目名称:OgreKit,代码行数:42,代码来源:gkOgreCompositorHelper.cpp

示例13: 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();
}
开发者ID:team-vigir,项目名称:vigir_ocs_common,代码行数:20,代码来源:overlay_utils.cpp

示例14: update

void WebView::update()
{
#ifdef HAVE_AWESOMIUM
	if(maxUpdatePS)
		if(timer.getMilliseconds() - lastUpdateTime < 1000 / maxUpdatePS)
			return;

	updateFade();

	if(usingMask)
		baseTexUnit->setAlphaOperation(LBX_SOURCE1, LBS_MANUAL, LBS_CURRENT, fadeValue * opacity);
	else if(isWebViewTransparent)
		baseTexUnit->setAlphaOperation(LBX_BLEND_TEXTURE_ALPHA, LBS_MANUAL, LBS_TEXTURE, fadeValue * opacity);
	else
		baseTexUnit->setAlphaOperation(LBX_SOURCE1, LBS_MANUAL, LBS_CURRENT, fadeValue * opacity);

	if(!webView->isDirty())
		return;

	TexturePtr texture = TextureManager::getSingleton().getByName(viewName + "Texture");

	HardwarePixelBufferSharedPtr pixelBuffer = texture->getBuffer();
	pixelBuffer->lock(HardwareBuffer::HBL_DISCARD);
	const PixelBox& pixelBox = pixelBuffer->getCurrentLock();

	uint8* destBuffer = static_cast<uint8*>(pixelBox.data);

	webView->render(destBuffer, (int)texPitch, (int)texDepth);

	if(isWebViewTransparent && !usingMask && ignoringTrans)
	{
		for(int row = 0; row < texHeight; row++)
			for(int col = 0; col < texWidth; col++)
				alphaCache[row * alphaCachePitch + col] = destBuffer[row * texPitch + col * 4 + 3];
	}

	pixelBuffer->unlock();

	lastUpdateTime = timer.getMilliseconds();
#endif
}
开发者ID:danx0r,项目名称:sirikata,代码行数:41,代码来源:WebView.cpp

示例15: convertIplToTexture

void StandByState::convertIplToTexture(IplImage* img,TexturePtr texture)
{
    HardwarePixelBufferSharedPtr pixelBuffer = texture->getBuffer();//Get the Pixel Buffer for Texture
    pixelBuffer->lock(HardwareBuffer::HBL_DISCARD);						//Lock the buffer
    const PixelBox& pixelBox = pixelBuffer->getCurrentLock();			//Get the pixel box for data pointer
    unsigned char* pDest = static_cast<unsigned char*>(pixelBox.data);
    unsigned char* videoPtr=(unsigned char*)(img->imageData);		//Get the pointer to the video frame

    for (int r=0; r<videoHeight; r++)
    {
        for(int c=0; c<videoWidth; c++)
        {
            for (int p=0; p<pix_size; p++)
                *(pDest++)=*(videoPtr++);//Copy the data
            if(pix_size==3)			//Ogre uses 4 bytes per pixel, so add an additional pass if video is RGB
                pDest++;
        }
        pDest+=empty_byte;			//If there are empty bytes at the end of the rows, add them to go to the correct location
        videoPtr+=empty_byte;
    }
    pixelBuffer->unlock();//Unlock the pixel buffer

}
开发者ID:umutgultepe,项目名称:KotonWindow,代码行数:23,代码来源:StandByState.cpp


注:本文中的HardwarePixelBufferSharedPtr::lock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。