manually created texture!

Problems building or running the engine, queries about how to use features etc.
User avatar
eugen
OGRE Expert User
OGRE Expert User
Posts: 1422
Joined: Sat May 22, 2004 5:28 am
Location: Bucharest
x 8

manually created texture!

Post by eugen »

why is that when i try to manually create a texture and load an image on it i get a pixel format not specified error!
here is the code:

Code: Select all

			Texture* text = mRoot->getTextureManager()->createManual("texture" + StringConverter::toString(i), TEX_TYPE_2D, 512, 512, 0, PF_A8R8G8B8, TU_DEFAULT);
			PixelFormat pf = text->getFormat();
after this, the format is not set! i get a PF_UNKNOWN...might be cause the fact the texture is not really loaded/created?

i try next:

Code: Select all

			Image img;
			uchar *pImage = new uchar[512 * 512 * 4];
			img.loadDynamicImage(pImage, 512, 512, PF_A8R8G8B8);
			text->loadImage(img);
here i get an error of pixel format not specified...the load image tries to create the texture but it couldnt find the right pixel format

the ogre code is here:

Code: Select all

	void D3D9Texture::_createNormTex()
	{
		// we must have those defined here
		assert(mSrcWidth > 0 || mSrcHeight > 0);

		// determine wich D3D9 pixel format we'll use
		HRESULT hr;
		D3DFORMAT d3dPF = (mUsage == TU_RENDERTARGET) ? mBBPixelFormat : this->_chooseD3DFormat();

the _chooseD3DFormat() raise an error since the mFinalBpp is not set.
I suppose i miss a step in the texture initialisation or smth!

my goal is to create a blank texture!
any ideas?!
User avatar
eugen
OGRE Expert User
OGRE Expert User
Posts: 1422
Joined: Sat May 22, 2004 5:28 am
Location: Bucharest
x 8

Post by eugen »

i have solved the problem in another way:

Code: Select all

Texture *tex = TextureManager::getSingletonPtr()->loadImage("texture" + StringConverter::toString(i), img);
but i really like to know what went wrong in that case!