How to create such texture?

Problems building or running the engine, queries about how to use features etc.
Post Reply
apapaxionga
Kobold
Posts: 28
Joined: Thu Jun 30, 2011 8:17 am

How to create such texture?

Post by apapaxionga »

i want to create a 2x2 2D texture, which pixel format is PF_R8G8B8A8.

I want the texture like the fellowing 2D texture:
|-----|------|
|Red|Blue |
|-------------|
|Green|White |
|----------------|
how can i create it?

My code is here,but the pixel color is not correct. Why?

Code: Select all

Ogre::TexturePtr tPtr=TextureManager::getSingleton().createManual("EdgeTable",ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
			TEX_TYPE_2D,2,2,0,PF_R8G8B8A8 );
		HardwarePixelBufferSharedPtr pixelBuffer=tPtr->getBuffer();
		pixelBuffer->lock(HardwareBuffer::HBL_NORMAL);
		const PixelBox& pixelBox = pixelBuffer->getCurrentLock();
		uint8* pDest = static_cast<uint8*>(pixelBox.data);
        
		

		*pDest++=255;   //R
		*pDest++=0;   //G
		*pDest++=0;      //B
		*pDest++=255;    //A


		*pDest++=0;   //R
		*pDest++=255;   //G
		*pDest++=0;      //B
		*pDest++=255;    //A

		*pDest++=0;   //R
		*pDest++=0;   //G
		*pDest++=255      //B
		*pDest++=0;    //A

		*pDest++=255;   //R
		*pDest++=255;   //G
		*pDest++=255;      //B
		*pDest++=255;    //A

pixelBuffer->unlock();
User avatar
johnhpus
Platinum Sponsor
Platinum Sponsor
Posts: 1186
Joined: Sat Apr 17, 2004 2:49 am
x 3

Re: How to create such texture?

Post by johnhpus »

What does your resulting texture look like?
Post Reply