PDA

View Full Version : Rectangular Textures, automatically loading every bmp in a given folder



04-01-2002, 02:45 PM
I'm writing a little gallery, which is supposed to load in every bmp file in a specified folder. I don't know how to get those filenames and how to load the textures then, can anybody help me out?

Because not all images are square, I need to have rectangular textures. I read in some other tutorial that mipmapping does not require a square bmp-file, so I build Mipmaps but draw the textures linear filtered. This works fine, but the images can't be bigger than 400 pixels in any dimension, and the width has to be an even number.
If the image is larger than 400 pixels in one dimension, or the width is an uneven number, the texture is stretched somewhat funny onto the quad.
Does anybody know how I can create Textures with more than 400*400 pixels and why the width has to be an even number?
Thanks in advance!

Elixer
04-01-2002, 06:53 PM
Width has to be power of 2. Ie, in your case 512, (or 256)...

For what your doing, you need a directory walker, then throw up a quad with the texture in question, and you have the poor mans slide show. http://www.opengl.org/discussion_boards/ubb/smile.gif

nexusone
04-01-2002, 07:02 PM
Here is one hint....
You map your image to a quad with the same hight to width ratio.

800 x 600 is about a 1 x 1.2 ratio
(0,0) top left
*******
* *
* *
*******
(1.0, 1.2) bottom right

The only limit to a texture map is that it has to be a power of two, just adjust to loaded picture to make it fit.


Originally posted by ToolOfEvil:
I'm writing a little gallery, which is supposed to load in every bmp file in a specified folder. I don't know how to get those filenames and how to load the textures then, can anybody help me out?

Because not all images are square, I need to have rectangular textures. I read in some other tutorial that mipmapping does not require a square bmp-file, so I build Mipmaps but draw the textures linear filtered. This works fine, but the images can't be bigger than 400 pixels in any dimension, and the width has to be an even number.
If the image is larger than 400 pixels in one dimension, or the width is an uneven number, the texture is stretched somewhat funny onto the quad.
Does anybody know how I can create Textures with more than 400*400 pixels and why the width has to be an even number?
Thanks in advance!

04-02-2002, 04:49 AM
Ok, thanks, I'll give it a try.
But how can I automatically load in every bmp? When I intialise OpenGL, the program is supposed to look for bmp files in the data\ folder, then build a texture of it and give it a number. I do not have the slightest idea how to get that done!

Bob
04-02-2002, 05:06 AM
I read in some other tutorial that mipmapping does not require a square bmp-file

A texture, both mipmapped and non-mipmapped, does not have to be a square. However, the sizes must be a power of two. That means a texture can have a size of, for example, 128x256. Mipmaps are no exception to any square or power of two rule. gluBuild2DMipmaps will rescale the image if needed, but the actual dimensions of the texture once uploaded is always (and always has to be) a power of two.

nexusone
04-02-2002, 05:24 AM
I don't have the code handy and loading files is really not an opengl question.

You need to go out to a C programming site, look for file handeling. File loading and handeling is basic C stuff, so learning a little more about how to program will be very helpful to you in programming opengl.

1. You open a directory, read in the list of files in that directory.
2. Then you sort your list for supported file formats.
3. Then load the images of the supported format.


Originally posted by ToolOfEvil:
Ok, thanks, I'll give it a try.
But how can I automatically load in every bmp? When I intialise OpenGL, the program is supposed to look for bmp files in the data\ folder, then build a texture of it and give it a number. I do not have the slightest idea how to get that done!