Get desired texture format

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
Pellaeon
Halfling
Posts: 97
Joined: Thu Apr 28, 2011 12:23 pm
x 3

Get desired texture format

Post by Pellaeon » Tue Nov 04, 2014 9:02 am

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
0 x

User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7147
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 17

Re: Get desired texture format

Post by Kojack » Tue Nov 04, 2014 9:38 am

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.
0 x

Pellaeon
Halfling
Posts: 97
Joined: Thu Apr 28, 2011 12:23 pm
x 3

Re: Get desired texture format

Post by Pellaeon » Tue Nov 04, 2014 1:19 pm

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
Attachments
Screen.jpg
0 x

User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7147
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 17

Re: Get desired texture format

Post by Kojack » Tue Nov 04, 2014 2:28 pm

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.
0 x

Pellaeon
Halfling
Posts: 97
Joined: Thu Apr 28, 2011 12:23 pm
x 3

Re: Get desired texture format

Post by Pellaeon » Tue Nov 04, 2014 3:43 pm

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
0 x

Post Reply