Page 1 of 1

Get desired texture format

Posted: Tue Nov 04, 2014 9:02 am
by Pellaeon
Hi,

I have an application which shows camera images as background in the ogre window. Therefore, I create a texture manually and fill it in every frame with the data from teh camera.
Atm I copy pixelwise. To speed up my application I want to do a memcopy. Therefore, I get the pixel format from the camera and set it as parameter in TextureManager::getSingleton().createManual. My problem: I say I want to have R8G8B8 or B8G8R8 but the method always creates X8R8G8B8. That's annoying. How can I get a texture in the format I want?

Best regards

Pellaeon

Re: Get desired texture format

Posted: Tue Nov 04, 2014 9:38 am
by Kojack
Most modern gpus don't support non power of two 3 byte texture formats like RGB888 or BGR888. Only 1, 2, 4, 8 or 16 byte formats are supported. So ogre has to pad the format out to ARGB8888 or XRGB8888 otherwise the hardware can't handle it.
I don't know about AMD, but at least on Nvidia that's the case. You can see all the available texture formats using the Direct X caps viewer.

The usage flags affect it too. For example, on my Geforce 680, ARGB4444 is a valid format for standard textures, but invalid for render targets.

Re: Get desired texture format

Posted: Tue Nov 04, 2014 1:19 pm
by Pellaeon
I have a nvidia graphics card. And it supports e.g. D3DFMT_R8G8B8 (see attachement).
So this should NOT be the problem. :(

Best regards

Marco

Re: Get desired texture format

Posted: Tue Nov 04, 2014 2:28 pm
by Kojack
That's the Reference section, that's for software emulation using the reference driver (supports every theoretical directx thing at poor speed). The actual hardware supported modes are in the HAL section.

Re: Get desired texture format

Posted: Tue Nov 04, 2014 3:43 pm
by Pellaeon
Hm ok. Now, I tried to load the camera stream via an image to have an implicit conversion of the texture format

Code: Select all

Image img;
img.loadDynamicImage((unsigned char*)(imageBuffer), imageWidth, imageHeight, 1, format, false);
m_videoTexture->loadImage(img);
But my screen is always black. What is wrong with my code?


Best regards

Pellaeon