PDA

View Full Version : How Create Texture From 8Bit BMP?



ncn213
11-18-2009, 11:20 AM
Hi all,

I load a 24Bit bmp image with glTexImage2D and gluBuildmipmap2D withiot any problem.

But I want that my Image have less size with same resolution, then I save my image in 8Bit bmp format and my image have 1/3 size, I load it in memory but have problem in create texture from it.
I couldn't use this with glu, and with gl I only use it with glTexImage2D(..,GL_R3_G3_B2,..,GL_RED..) and I only could see my image in red or green or blue color.

can you tell me how can i load my 8bit bmp?

overlay
11-18-2009, 12:20 PM
A 8-bit BMP image uses indexed color. What you are seeing right now (only red or green or blue) is probably the index. There is no support for indexed texture in OpenGL. Yes, the FAQ talks about GL_EXT_paletted_texture but it probably does not exist in 2009 (al least not on my nVidia Quadro FX 3600M)

Is the size of your image really an issue? Is this an issue for the RAM or the VRAM?

If you want to save memory on the VRAM, load your 24-bit image into a compressed texture format: GL_COMPRESSED_RGB. Just use glTexImage2D with format GL_COMPRESSED_RGB instead of GL_RGB. OpenGL will compress the image on the fly for you.

It actually has the benefit of rendering faster than non-compressed textures.

(don't use glCompressedTexImage2D(), this function is made for images already compressed in RAM in a known format)

ncn213
11-21-2009, 05:24 AM
Thanks overlay,
My Image size is very large,9k*9k. I don't want to resize my image.
I convert my bmp to dxt1 (.dds) and try to load it ddsviewr but it couldn't open it and say that is larger from your texture memory.
My texMem is 4K.
I need a method that have better performance.
What's your Suggestion?

kroneml
11-21-2009, 08:41 AM
As far as I know, 8192x8192 is the largest possible texture dimension - larger textures are not allowed. Are you actually able to use larger textures?

Yann LE PETITCORPS
11-21-2009, 03:09 PM
You can perhaps tile your 9k*9k into smallest 1024*1024 or 256*256 blocs for example.

This can be really more fast because of very smallest caching usage of the data too


@+
Yannoo

Yann LE PETITCORPS
11-21-2009, 03:13 PM
Cf. make a surface of 9x9 patchs of 1024x1024 pixels is certainly more "hardware friendly" that the use of an big 9k*9k pixels image that the hardware can certainly not handle.

@+
Yannoo

Yann LE PETITCORPS
11-21-2009, 03:23 PM
Or you can make your texture in realtime and only store the data in a definition that is "raisonnable" for to display it on the screen (I don't think that you have a 9x*9k display screen ...)

@+
Yannoo

Yann LE PETITCORPS
11-21-2009, 03:27 PM
Something like does mipmapping but before the texture use

@+
Yannoo

ncn213
11-22-2009, 01:06 AM
Hi Yann LE PETITCORPS

Yes I couldn't load texture biger than 8K*8k pixel.
I change my imageto 8K*8k, but it is slow.
If i want to make 512*512 pixel block of image, do you think that it works better, assume that in runtime i should load some block and in any time i should have more than one block in memory.

Is there a good algorithm for load image block at run time?

ncn213
11-22-2009, 01:18 AM
Hi Yann LE PETITCORPS

Yes I couldn't load texture biger than 8K*8k pixel.
I change my imageto 8K*8k, but it is slow.
If i want to make 512*512 pixel block of image, do you think that it works better, assume that in runtime i should load some block and in any time i should have more than one block in memory.

Is there a good algorithm for load image block at run time?

ncn213
11-22-2009, 01:18 AM
Hi Yann LE PETITCORPS

Yes I couldn't load texture biger than 8K*8k pixel.
I change my imageto 8K*8k, but it is slow.
If i want to make 512*512 pixel block of image, do you think that it works better, assume that in runtime i should load some block and in any time i should have more than one block in memory.

Is there a good algorithm for load image block at run time?

Yann LE PETITCORPS
11-22-2009, 04:31 AM
Hi,

I'm 99% certain that this can be better :)

You can divide your world into 512x512 blocs and only create 2 or 3 textures in real time that you map to the only 2 or 3 blocs that are visible on the display for example (you can compute what blocs are visible by a fustrum test by example).


@+
Yannoo

Yann LE PETITCORPS
11-22-2009, 04:34 AM
Google is ours friend :)

http://www.crownandcutlass.com/features/technicaldetails/frustum.html


@+
Yannoo